diff --git a/Code/IO/otbImageFileReader.txx b/Code/IO/otbImageFileReader.txx
index 63e3b23c7f4adea132115c4f4eda5cf422e2f944..9cbd13ed2f87accd140f5343c2ab20264abdc497 100644
--- a/Code/IO/otbImageFileReader.txx
+++ b/Code/IO/otbImageFileReader.txx
@@ -356,7 +356,8 @@ ImageFileReader<TOutputImage>
   else
   {
     otbMsgDevMacro( <<"OSSIM Open Image SUCCESS ! ");
-    hasMetaData = handler->getImageGeometry(geom_kwl);
+//     hasMetaData = handler->getImageGeometry(geom_kwl);
+    hasMetaData = handler->getImageGeometry()->getProjection()->saveState(geom_kwl);
   }
   // Free memory
   delete handler;
@@ -388,7 +389,7 @@ ImageFileReader<TOutputImage>
   {
     otbMsgDevMacro( <<"OSSIM MetaData present ! ");
     otbMsgDevMacro( << geom_kwl);
-  
+
 
     // Update otb Keywordlist
     ImageKeywordlist otb_kwl;
diff --git a/Code/IO/otbImageFileWriter.txx b/Code/IO/otbImageFileWriter.txx
index 0f60fca7a0cd943d6679ef7887111eb2774e8aac..e327b79cbcbb0cbeb7bda824d75acc829143f281 100644
--- a/Code/IO/otbImageFileWriter.txx
+++ b/Code/IO/otbImageFileWriter.txx
@@ -101,15 +101,18 @@ ImageFileWriter<TInputImage>
     otbMsgDevMacro(<<"Exporting keywordlist ...");
     ossimImageHandlerRegistry::instance()->addFactory(ossimImageHandlerSarFactory::instance());
     ossimImageHandler* handler = ossimImageHandlerRegistry::instance()->open(ossimFilename(this->GetFileName()));
-  
+
     if(!handler)
       {
       otbMsgDevMacro(<<"OSSIM Open Image FAILED !");
       }
     else
       {
-      handler->setImageGeometry(geom_kwl);
-      handler->saveImageGeometry();
+        //FIXME find out exactly what we are trying to do here
+        //there is no meaning to blindly save the kwl if we didn't update it in the pipeline
+//       handler->setImageGeometry(geom_kwl);
+//       handler->getImageGeometry()->getProjection()->loadState(geom_kwl);
+//       handler->saveImageGeometry();
       handler->close();
       }
     }
diff --git a/Code/IO/otbStreamingImageFileWriter.txx b/Code/IO/otbStreamingImageFileWriter.txx
index 67a7d13883453d4163b5b39b0f95cb75d1ec648f..19042052afc7f4cd189334e63bf4b65e4759a15d 100644
--- a/Code/IO/otbStreamingImageFileWriter.txx
+++ b/Code/IO/otbStreamingImageFileWriter.txx
@@ -531,11 +531,11 @@ StreamingImageFileWriter<TInputImage>
       this->GetOutput(idx)->DataHasBeenGenerated();
     }
   }
-  
+
   // Write the image keyword list if any
   ossimKeywordlist geom_kwl;
   ImageKeywordlist otb_kwl;
-  
+
   itk::MetaDataDictionary dict = this->GetInput()->GetMetaDataDictionary();
   itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, otb_kwl);
   otb_kwl.convertToOSSIMKeywordlist(geom_kwl);
@@ -545,15 +545,19 @@ StreamingImageFileWriter<TInputImage>
     otbMsgDevMacro(<<"Exporting keywordlist ...");
     ossimImageHandlerRegistry::instance()->addFactory(ossimImageHandlerSarFactory::instance());
     ossimImageHandler* handler = ossimImageHandlerRegistry::instance()->open(ossimFilename(this->GetFileName()));
-  
+
     if(!handler)
       {
       otbMsgDevMacro(<<"OSSIM Open Image FAILED !");
       }
     else
       {
-      handler->setImageGeometry(geom_kwl);
-      handler->saveImageGeometry();
+        //FIXME find out exactly what we are trying to do here
+        //there is no meaning to blindly save the kwl if we didn't update it in the pipeline
+//       handler->setImageGeometry(geom_kwl);
+//       handler->getImageGeometry()->getProjection()->loadState(geom_kwl);
+//
+//       handler->saveImageGeometry();
       handler->close();
       }
     }
diff --git a/Code/Projections/otbMapProjection.h b/Code/Projections/otbMapProjection.h
index 947ec3179c9820b182b222735bd79213f178d13a..b1f0b35ad91c64b2f479e457aa0f4f008231df63 100644
--- a/Code/Projections/otbMapProjection.h
+++ b/Code/Projections/otbMapProjection.h
@@ -72,7 +72,8 @@ public :
   typedef itk::SmartPointer<const Self>             ConstPointer;
 
   typedef typename Superclass::ScalarType           ScalarType;
-  typedef TOssimMapProjection        OssimMapProjectionType;
+  typedef TOssimMapProjection                       OssimMapProjectionType;
+  typedef ossimRefPtr<OssimMapProjectionType>       OssimMapProjectionPointerType;
   typedef itk::Point<ScalarType,NInputDimensions >  InputPointType;
   typedef itk::Point<ScalarType,NOutputDimensions > OutputPointType;
 
@@ -135,7 +136,7 @@ public :
 protected:
   MapProjection();
   virtual ~MapProjection();
-  OssimMapProjectionType* m_MapProjection;
+  OssimMapProjectionPointerType m_MapProjection;
   std::string m_ProjectionRefWkt;
   virtual void InstanciateProjection();
 
diff --git a/Code/Projections/otbMapProjection.txx b/Code/Projections/otbMapProjection.txx
index 77f545adc2e255519746afcd8ec1699def1e948f..2ed7d49ad98e4f5f8a1009caacc2b89fd9cf5cfc 100644
--- a/Code/Projections/otbMapProjection.txx
+++ b/Code/Projections/otbMapProjection.txx
@@ -7,7 +7,7 @@
 
 
   Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
-See OTBCopyright.txt for details.
+  See OTBCopyright.txt for details.
 
 
      This software is distributed WITHOUT ANY WARRANTY; without even
@@ -40,10 +40,7 @@ template<class TOssimMapProjection, InverseOrForwardTransformationEnum Transform
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::~MapProjection()
 {
-  if (m_MapProjection != NULL)
-  {
-    delete m_MapProjection;
-  }
+  m_MapProjection = NULL;
 }
 
 
@@ -52,7 +49,7 @@ const TOssimMapProjection*
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetMapProjection () const
 {
-  return this->m_MapProjection;
+  return this->m_MapProjection.get();
 }
 
 template<class TOssimMapProjection, InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
@@ -60,7 +57,7 @@ TOssimMapProjection*
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetMapProjection ()
 {
-  return this->m_MapProjection;
+  return this->m_MapProjection.release();
 }
 
 template<class TOssimMapProjection, InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
@@ -78,7 +75,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetEllipsoid()
 {
   ossimEllipsoid ellipsoid;
-  this->GetMapProjection()->setEllipsoid(ellipsoid);
+  m_MapProjection->setEllipsoid(ellipsoid);
 }
 
 /// Method to set the projection ellipsoid by copy
@@ -86,7 +83,7 @@ template<class TOssimMapProjection, InverseOrForwardTransformationEnum Transform
 void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::SetEllipsoid(const ossimEllipsoid &ellipsoid)
 {
-  this->GetMapProjection()->setEllipsoid(ellipsoid);
+  m_MapProjection->setEllipsoid(ellipsoid);
 }
 
 ///// Method to set the projection ellipsoid by knowing its code
@@ -95,7 +92,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetEllipsoid(std::string code)
 {
   const ossimEllipsoid ellipsoid = *(ossimEllipsoidFactory::instance()->create(ossimString(code)));
-  this->GetMapProjection()->setEllipsoid(ellipsoid);
+  m_MapProjection->setEllipsoid(ellipsoid);
 }
 
 ///// Method to set the projection ellipsoid by knowing its axis
@@ -104,7 +101,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetEllipsoid(const double &major_axis, const double &minor_axis)
 {
   ossimEllipsoid ellipsoid(major_axis,minor_axis);
-  this->GetMapProjection()->setEllipsoid(ellipsoid);
+  m_MapProjection->setEllipsoid(ellipsoid);
 }
 
 template<class TOssimMapProjection, InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
@@ -125,9 +122,9 @@ MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOu
 
     //map projection
     ossimGpt ossimGPoint;
-    ossimGPoint=this->GetMapProjection()->inverse(ossimDPoint);
+    ossimGPoint=m_MapProjection->inverse(ossimDPoint);
     ossimGPoint.changeDatum(ossimDatumFactory::instance()->wgs84() );
-//     otbGenericMsgDebugMacro(<< "Inverse : " << std::endl << this->GetMapProjection()->print(std::cout));
+//     otbGenericMsgDebugMacro(<< "Inverse : " << std::endl << m_MapProjection->print(std::cout));
 
     outputPoint[0]=ossimGPoint.lon;
     outputPoint[1]=ossimGPoint.lat;
@@ -142,7 +139,7 @@ MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOu
 
     //map projection
     ossimDpt ossimDPoint;
-    ossimDPoint=this->GetMapProjection()->forward(ossimGPoint);
+    ossimDPoint=m_MapProjection->forward(ossimGPoint);
 //     otbGenericMsgDebugMacro(<< "Forward : ========================= " << std::endl << m_MapProjection->print(std::cout));
     outputPoint[0]=ossimDPoint.x;
     outputPoint[1]=ossimDPoint.y;
@@ -169,7 +166,7 @@ typename MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimens
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::Origin()
 {
-  ossimGpt ossimOrigin=this->GetMapProjection()->origin();
+  ossimGpt ossimOrigin=m_MapProjection->origin();
   InputPointType otbOrigin;
   otbOrigin[0]= ossimOrigin.lat;
   otbOrigin[1]= ossimOrigin.lon;
@@ -183,7 +180,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetFalseNorthing() const
 {
-  double falseNorthing=this->GetMapProjection()->getFalseNorthing();
+  double falseNorthing=m_MapProjection->getFalseNorthing();
 
   return falseNorthing;
 }
@@ -194,7 +191,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetFalseEasting() const
 {
-  double falseEasting=this->GetMapProjection()->getFalseEasting();
+  double falseEasting=m_MapProjection->getFalseEasting();
 
   return falseEasting;
 }
@@ -205,7 +202,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetStandardParallel1() const
 {
-  double standardParallel1=this->GetMapProjection()->getStandardParallel1();
+  double standardParallel1=m_MapProjection->getStandardParallel1();
 
   return standardParallel1;
 }
@@ -216,7 +213,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetStandardParallel2() const
 {
-  double standardParallel2=this->GetMapProjection()->getStandardParallel2();
+  double standardParallel2=m_MapProjection->getStandardParallel2();
 
   return standardParallel2;
 }
@@ -228,7 +225,7 @@ MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOu
 ::GetProjectionName() const
 {
   std::string projectionName;
-  projectionName=this->GetMapProjection()->getProjectionName();
+  projectionName=m_MapProjection->getProjectionName();
 
   return projectionName;
 }
@@ -239,7 +236,7 @@ bool
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::IsGeographic() const
 {
-  return (this->GetMapProjection()->isGeographic());
+  return (m_MapProjection->isGeographic());
 }
 
 ///\return the major axis of the ellipsoid
@@ -248,7 +245,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetA() const
 {
-  double majorAxis=this->GetMapProjection()->getA();
+  double majorAxis=m_MapProjection->getA();
 
   return majorAxis;
 }
@@ -259,7 +256,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetB() const
 {
-  double minorAxis=this->GetMapProjection()->getB();
+  double minorAxis=m_MapProjection->getB();
 
   return minorAxis;
 }
@@ -270,7 +267,7 @@ double
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetF() const
 {
-  double flattening=this->GetMapProjection()->getF();
+  double flattening=m_MapProjection->getF();
 
   return flattening;
 }
@@ -281,7 +278,7 @@ typename MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimens
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetMetersPerPixel() const
 {
-  ossimDpt ossimMetersPerPixels=this->GetMapProjection()->getMetersPerPixel();
+  ossimDpt ossimMetersPerPixels=m_MapProjection->getMetersPerPixel();
   OutputPointType metersPerPixels;
 
   metersPerPixels[0]=ossimMetersPerPixels.x;
@@ -296,7 +293,7 @@ typename MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimens
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::GetDecimalDegreesPerPixel() const
 {
-  ossimDpt ossimDecimalDegreesPerPixels=this->GetMapProjection()->getDecimalDegreesPerPixel();
+  ossimDpt ossimDecimalDegreesPerPixels=m_MapProjection->getDecimalDegreesPerPixel();
   OutputPointType DecimalDegreesPerPixels;
 
   DecimalDegreesPerPixels[0]=ossimDecimalDegreesPerPixels.x;
@@ -310,7 +307,7 @@ template<class TOssimMapProjection, InverseOrForwardTransformationEnum Transform
 void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::SetAB(double a, double b)
 {
-  this->GetMapProjection()->setAB(a,b);
+  m_MapProjection->setAB(a,b);
 }
 
 ///Set the origin
@@ -319,10 +316,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetOrigin(const InputPointType &origin)
 {
   ossimGpt ossimOrigin(origin[1], origin[0]);
-  this->GetMapProjection()->setOrigin(ossimOrigin);
-  //TODO: 29-02-2008 Emmanuel: when ossim version > 1.7.2 only
-  // SetOrigin required (remove SetDatum)
-  this->GetMapProjection()->setDatum(ossimOrigin.datum());
+  m_MapProjection->setOrigin(ossimOrigin);
 }
 
 ///Set the origin in a given datum
@@ -331,8 +325,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetOrigin(const InputPointType &origin, std::string datumCode)
 {
   ossimGpt ossimOrigin(origin[1], origin[0], 0, ossimDatumFactory::instance()->create(datumCode));
-  this->GetMapProjection()->setOrigin(ossimOrigin);
-  this->GetMapProjection()->setDatum(ossimOrigin.datum());
+  m_MapProjection->setOrigin(ossimOrigin);
 }
 
 ///Set the map resolution in meters
@@ -341,7 +334,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetMetersPerPixel(const OutputPointType &point)
 {
   ossimDpt ossimDPoint(point[0], point[1]);
-  this->GetMapProjection()->setMetersPerPixel(ossimDPoint);
+  m_MapProjection->setMetersPerPixel(ossimDPoint);
 }
 
 ///Set the map resolution in degree
@@ -350,7 +343,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 ::SetDecimalDegreesPerPixel(const OutputPointType &point)
 {
   ossimDpt ossimDPoint(point[0], point[1]);
-  this->GetMapProjection()->setDecimalDegreesPerPixel(ossimDPoint);
+  m_MapProjection->setDecimalDegreesPerPixel(ossimDPoint);
 }
 
 ///\return an approximation of the resolution in degree
@@ -360,7 +353,7 @@ void MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions
 {
   ossimDpt ossimMetersPerPixel(metersPerPixel[0], metersPerPixel[1]);
   ossimGpt ossimGround(ground[1],ground[0]);
-  this->GetMapProjection()->computeDegreesPerPixel(ossimGround,ossimMetersPerPixel,deltaLat,deltaLon);
+  m_MapProjection->computeDegreesPerPixel(ossimGround,ossimMetersPerPixel,deltaLat,deltaLon);
 }
 
 ///\return an approximation of the resolution in meters
@@ -372,7 +365,7 @@ MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOu
   //Correction
   ossimGpt ossimCenter(center[1],center[0]);
   ossimDpt ossimMetersPerPixel;
-  this->GetMapProjection()->computeMetersPerPixel(ossimCenter,deltaDegreesPerPixelLat, deltaDegreesPerPixelLon,ossimMetersPerPixel);
+  m_MapProjection->computeMetersPerPixel(ossimCenter,deltaDegreesPerPixelLat, deltaDegreesPerPixelLon,ossimMetersPerPixel);
   metersPerPixel[0]=ossimMetersPerPixel.x;
   metersPerPixel[1]=ossimMetersPerPixel.y;
 }
@@ -384,7 +377,7 @@ MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOu
 ::ComputeMetersPerPixel(double deltaDegreesPerPixelLat, double deltaDegreesPerPixelLon, OutputPointType &metersPerPixel)
 {
   ossimDpt ossimMetersPerPixel;
-  this->GetMapProjection()->computeMetersPerPixel(this->GetMapProjection()->origin(),deltaDegreesPerPixelLat, deltaDegreesPerPixelLon,ossimMetersPerPixel);
+  m_MapProjection->computeMetersPerPixel(m_MapProjection->origin(),deltaDegreesPerPixelLat, deltaDegreesPerPixelLon,ossimMetersPerPixel);
   metersPerPixel[0]=ossimMetersPerPixel.x;
   metersPerPixel[1]=ossimMetersPerPixel.y;
 }
@@ -395,7 +388,7 @@ MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOu
 ::GetWkt() const
 {
   ossimKeywordlist kwl;
-  this->GetMapProjection()->saveState(kwl);
+  m_MapProjection->saveState(kwl);
   ossimOgcWktTranslator wktTranslator;
   std::string wkt;
   wkt = wktTranslator.fromOssimKwl(kwl);
@@ -416,7 +409,7 @@ void
 MapProjection<TOssimMapProjection, Transform, TScalarType, NInputDimensions, NOutputDimensions>
 ::PrintMap() const
 {
-  std::cout << this->GetMapProjection()->print(std::cout);
+  std::cout << m_MapProjection->print(std::cout);
 }
 
 
diff --git a/Testing/Code/Projections/otbCreateProjectionWithOSSIM.cxx b/Testing/Code/Projections/otbCreateProjectionWithOSSIM.cxx
index 724941a13e972518a8299b919e727a3138d3042f..8d765bb4244ff08f2bbb7bc4afe11db029184be4 100644
--- a/Testing/Code/Projections/otbCreateProjectionWithOSSIM.cxx
+++ b/Testing/Code/Projections/otbCreateProjectionWithOSSIM.cxx
@@ -75,7 +75,7 @@ int otbCreateProjectionWithOSSIM( int argc, char* argv[] )
 
   ossimKeywordlist geom;
   otbGenericMsgDebugMacro(<< "Read ossim Keywordlist..." );
-  handler->getImageGeometry(geom);
+  handler->getImageGeometry()->getProjection()->saveState(geom);
   ossimGpt ossimGPoint(0,0);
   ossimDpt ossimDPoint;
   otbGenericMsgDebugMacro(<< "Creating projection..." );
diff --git a/Testing/Code/Projections/otbSensorModel.cxx b/Testing/Code/Projections/otbSensorModel.cxx
index be69def92c43055335372618432fd641b9c2d1bf..91526c615d8eaa9ddd3d20da2eff39e220238e46 100644
--- a/Testing/Code/Projections/otbSensorModel.cxx
+++ b/Testing/Code/Projections/otbSensorModel.cxx
@@ -62,10 +62,10 @@ int otbSensorModel( int argc, char* argv[] )
   forwardSensorModel->SetAverageElevation(16.19688987731934);
 
   itk::Point<double,2> imagePoint;
-//   imagePoint[0]=10;
-//   imagePoint[1]=10;
-  imagePoint[0]=3069;
-  imagePoint[1]=1218;
+  imagePoint[0]=10;
+  imagePoint[1]=10;
+//   imagePoint[0]=3069;
+//   imagePoint[1]=1218;
 
   itk::Point<double,2> geoPoint;
   geoPoint = forwardSensorModel->TransformPoint(imagePoint);
diff --git a/Testing/Utilities/ossimIntegrationTest.cxx b/Testing/Utilities/ossimIntegrationTest.cxx
index c4d5920edbfc9fab518c89e2f864989aae83ec19..96dcb1aa20a27fd11788047e36e0d7903a6c69a7 100644
--- a/Testing/Utilities/ossimIntegrationTest.cxx
+++ b/Testing/Utilities/ossimIntegrationTest.cxx
@@ -89,8 +89,8 @@ int ossimIntegrationTest(int argc, char* argv[])
       }
 
       ossimKeywordlist geom;
-      handler->getImageGeometry(geom);
-
+//       handler->getImageGeometry(geom);
+      handler->getImageGeometry()->getProjection()->saveState(geom);
       // grab a projection if it exists
       //
       ossimProjection* inputProjection = ossimProjectionFactoryRegistry::instance()->createProjection(geom);
@@ -123,9 +123,10 @@ int ossimIntegrationTest(int argc, char* argv[])
       // I pass true in to tell the renderer that it owns the
       // projection and will be responsible for deleting
       //
-      renderer->setView(newUtmView(centerGround,
-                                   inputProjection->getMetersPerPixel()),
-                        true);
+      //FIXME commented out after ossim update. to update.
+//       renderer->setView(newUtmView(centerGround,
+//                                    inputProjection->getMetersPerPixel()),
+//                         true);
 
       // connect the renderer to the handler
       renderer->connectMyInputTo(handler);
diff --git a/Testing/Utilities/ossimKeywordlistTest.cxx b/Testing/Utilities/ossimKeywordlistTest.cxx
index 9c1a25ad02bb03cb88b37294d39eb12d81a15423..e60882a947c58e1c2c640aa2cf9992c13124015e 100644
--- a/Testing/Utilities/ossimKeywordlistTest.cxx
+++ b/Testing/Utilities/ossimKeywordlistTest.cxx
@@ -47,7 +47,7 @@ int ossimKeywordlistTest(int argc, char* argv[])
         }
 
         ossimKeywordlist geom;
-        handler->getImageGeometry(geom);
+        handler->getImageGeometry()->getProjection()->saveState(geom);
         ofstream file;
         file.open(argv[2]);
         file << " keywordlist:"<<std::endl<<geom<<std::endl;
diff --git a/Testing/Utilities/ossimRadarSatSupport.cxx b/Testing/Utilities/ossimRadarSatSupport.cxx
index 7000fd693e1fc6284b1c80032ea6537850c2a347..6573d25ff9a730805a6ce456d992ae595bb7853e 100644
--- a/Testing/Utilities/ossimRadarSatSupport.cxx
+++ b/Testing/Utilities/ossimRadarSatSupport.cxx
@@ -79,7 +79,7 @@ int ossimRadarSatSupport( int argc, char* argv[] )
 		 */
         ossimKeywordlist geom;
         std::cout<<"Read ossim Keywordlist...";
-		  if  (! handler->getImageGeometry(geom)) {
+		  if  (! handler->getImageGeometry()->getProjection()->saveState(geom)) {
 				std::cout << "Bad metadata parsing "<< std::endl;
 				return EXIT_FAILURE;
 		  }
diff --git a/Utilities/otbossim/CMakeLists.txt b/Utilities/otbossim/CMakeLists.txt
index 25058871a93a369488d1d47aa25ef0d07cfd0c47..4764d625f5bb91b6cdff97c54cdeb66fea88df7a 100644
--- a/Utilities/otbossim/CMakeLists.txt
+++ b/Utilities/otbossim/CMakeLists.txt
@@ -2,7 +2,7 @@ PROJECT(otbossim)
 
 SET(OSSIM_MAJOR_VERSION_NUMBER "1")
 SET(OSSIM_MINOR_VERSION_NUMBER "7")
-SET(OSSIM_PATCH_VERSION_NUMBER "16")
+SET(OSSIM_PATCH_VERSION_NUMBER "20")
 SET(OSSIM_RELEASE_NUMBER "?")
 SET(OSSIM_VERSION "${OSSIM_MAJOR_VERSION_NUMBER}-${OSSIM_MINOR_VERSION_NUMBER}-${OSSIM_PATCH_VERSION_NUMBER}" )
 
@@ -50,7 +50,9 @@ IF(NOT OTB_DISABLE_UTILITIES_COMPILATION)
   # Removing sources not in use any more (switched to ossim plugins)
   REMOVE(ossim_imaging_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossim/imaging/ErsSar/*")
   REMOVE(ossim_imaging_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossim/imaging/RadarSat2/*")
+  REMOVE(ossim_imaging_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossim/imaging/ossimRadarSat2TileSource.cpp")
   REMOVE(ossim_imaging_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossim/imaging/TerraSar/*")
+  REMOVE(ossim_imaging_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossim/imaging/ossimTerraSarTileSource.cpp")
 
   # Adjust the compiler flags to avoid problems with ossim code.
   IF(CMAKE_COMPILER_IS_GNUCXX)
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dBilinearTransform.h b/Utilities/otbossim/include/ossim/base/ossim2dBilinearTransform.h
new file mode 100644
index 0000000000000000000000000000000000000000..f23d8ea4c46b7c5e630e3f0b996f869bfdeef5dc
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossim2dBilinearTransform.h
@@ -0,0 +1,205 @@
+#ifndef ossim2dBilinearTransform_HEADER
+#define ossim2dBilinearTransform_HEADER
+#include <ossim/base/ossim2dTo2dTransform.h>
+#include <algorithm>
+/**
+ * ossim2dBilinearTransform allows one to specify a set of input points and output points
+ * and will fit a bilinear transform to those points.  Function of the form is solved for each  
+ * output dimension.
+ *
+ * z(x,y) = a + b*x + c*y + d*x*y
+ *
+ * We use the ossimLeastSquareBilin solver to solve for the coefficients.
+ *
+ */
+class OSSIM_DLL ossim2dBilinearTransform : public ossim2dTo2dTransform
+{
+public: 
+   /**
+    * Initialize to the identity
+    */
+   ossim2dBilinearTransform();
+   
+   /**
+    * Initialize the transform that best fits the input and output arrays.  
+    * If the input and output are well dispersed and are 4 points it should fit
+    * exactly.  Both arrays should be of equal number of points
+    *
+    * @param input the list of input points
+    * @param output the list of output points to transform the input to
+    * @param arraySize the number of points for the arrays.
+    */
+   ossim2dBilinearTransform(const ossimDpt* input,
+                            const ossimDpt* output, 
+                            ossim_uint32 arraySize)
+   {
+      setFromPoints(input, output, arraySize);
+   }
+   
+   /**
+    * Mapping 4 corners to an output 4 corners.
+    *
+    */
+   ossim2dBilinearTransform(const ossimDpt& in1, const ossimDpt& in2, const ossimDpt& in3, const ossimDpt& in4,
+                            const ossimDpt& out1, const ossimDpt& out2, const ossimDpt& out3, const ossimDpt& out4)
+   {
+      setFromPoints(in1, in2, in3, in4, out1, out2, out3, out4);
+   }
+   
+   /**
+    * Copy constructor
+    */
+   ossim2dBilinearTransform(const ossim2dBilinearTransform& src);
+   
+   /**
+    * Duplication method that duplicates this object
+    */
+   virtual ossimObject* dup()const{return new ossim2dBilinearTransform(*this);}
+   
+   /**
+    * Overloaded operator equal that allows for assignment.
+    *
+    * @param src the src data to copy into this object.  It will call the base classes
+    * equal operator.
+    */
+   const ossim2dBilinearTransform& operator =(const ossim2dBilinearTransform& src)
+   {
+      if(this == &src) return *this;
+      
+      ossim2dTo2dTransform::operator =(*this); // call base classes equal operator
+      std::copy(src.m_coefficientsXTerm, src.m_coefficientsXTerm+4, m_coefficientsXTerm);
+      std::copy(src.m_coefficientsYTerm, src.m_coefficientsYTerm+4, m_coefficientsYTerm);
+      std::copy(src.m_inverseCoefficientsXTerm, src.m_inverseCoefficientsXTerm+4, m_inverseCoefficientsXTerm);
+      std::copy(src.m_inverseCoefficientsYTerm, src.m_inverseCoefficientsYTerm+4, m_inverseCoefficientsYTerm);
+      
+      return *this;
+   }
+   
+   /**
+    * Mapping 4 corners to an output 4 corners.  Will use the ossimLeastSquareBilin class to solve 
+    * the bilinear coefficients that maps the given input points to the output points.
+    */
+   void setFromPoints(const ossimDpt& in1, const ossimDpt& in2, const ossimDpt& in3, const ossimDpt& in4,
+                      const ossimDpt& out1, const ossimDpt& out2, const ossimDpt& out3, const ossimDpt& out4);
+
+   /**
+    * Initialize the transform that best fits the input and output arrays.  
+    * If the input and output are well dispersed and are 4 points it should fit
+    * exactly.  Both arrays should be of equal number of points
+    *
+    * @param input the list of input points
+    * @param output the list of output points to transform the input to
+    * @param arraySize the number of points for the arrays.
+    */
+   void setFromPoints(const ossimDpt* input,
+                      const ossimDpt* output, 
+                      ossim_uint32 arraySize);
+ 
+   /**
+    * forward transform will transform an input point to the output.  
+    */
+   virtual void forward(const ossimDpt& input,
+                        ossimDpt& output) const
+   {
+      output.x = (m_coefficientsXTerm[0] + 
+                  m_coefficientsXTerm[1]*input.x + 
+                  m_coefficientsXTerm[2]*input.y + 
+                  m_coefficientsXTerm[3]*input.x*input.y);
+      output.y = (m_coefficientsYTerm[0] + 
+                  m_coefficientsYTerm[1]*input.x + 
+                  m_coefficientsYTerm[2]*input.y + 
+                  m_coefficientsYTerm[3]*input.x*input.y);
+   }
+   
+   /**
+    * forward transform will transform an input point to the output and modify the passed in point
+    * to the new value
+    */
+   virtual void forward(ossimDpt&  modify_this) const
+   {
+      double saveX = modify_this.x;
+      modify_this.x = (m_coefficientsXTerm[0] + 
+                       m_coefficientsXTerm[1]*modify_this.x + 
+                       m_coefficientsXTerm[2]*modify_this.y + 
+                       m_coefficientsXTerm[3]*modify_this.x*modify_this.y);
+      modify_this.y = (m_coefficientsYTerm[0] + 
+                       m_coefficientsYTerm[1]*saveX + 
+                       m_coefficientsYTerm[2]*modify_this.y + 
+                       m_coefficientsYTerm[3]*saveX*modify_this.y);
+   }
+   
+   /**
+    * Inverts the point back to the original input value.
+    */
+   virtual void inverse(const ossimDpt& input,
+                        ossimDpt&       output) const
+   {
+      output.x = (m_inverseCoefficientsXTerm[0] + 
+                  m_inverseCoefficientsXTerm[1]*input.x + 
+                  m_inverseCoefficientsXTerm[2]*input.y + 
+                  m_inverseCoefficientsXTerm[3]*input.x*input.y);
+      output.y = (m_inverseCoefficientsYTerm[0] + 
+                  m_inverseCoefficientsYTerm[1]*input.x + 
+                  m_inverseCoefficientsYTerm[2]*input.y + 
+                  m_inverseCoefficientsYTerm[3]*input.x*input.y);
+   }
+   
+   /**
+    * Inverts the point back to the original input value and modifies the passed in point
+    * to the new value.
+    */
+   virtual void inverse(ossimDpt&  modify_this) const
+   {
+      double saveX = modify_this.x;
+      modify_this.x = (m_inverseCoefficientsXTerm[0] + 
+                       m_inverseCoefficientsXTerm[1]*modify_this.x + 
+                       m_inverseCoefficientsXTerm[2]*modify_this.y + 
+                       m_inverseCoefficientsXTerm[3]*modify_this.x*modify_this.y);
+      modify_this.y = (m_inverseCoefficientsYTerm[0] + 
+                       m_inverseCoefficientsYTerm[1]*saveX + 
+                       m_inverseCoefficientsYTerm[2]*modify_this.y + 
+                       m_inverseCoefficientsYTerm[3]*saveX*modify_this.y);
+   }
+   
+   /**
+    * Saves the state of this object.
+    */
+   virtual bool saveState(ossimKeywordlist& kwl,
+                          const char* prefix = 0)const;
+   
+   /**
+    * loads the state of this object from a keywordlist.
+    */
+   virtual bool loadState(const ossimKeywordlist& kwl,
+                          const char* prefix = 0);
+   
+   /**
+    * prints the contents of this object.  Will also cal the base classes
+    * print method.
+    */
+   virtual std::ostream& print(std::ostream& out) const
+   {
+      ossim2dTo2dTransform::print(out);
+      out << "xTerm: " << m_coefficientsXTerm[0] << ", " << m_coefficientsXTerm[1] << ", "
+          << m_coefficientsXTerm[2] << ", " << m_coefficientsXTerm[3] << "\n";
+      out << "yTerm: " << m_coefficientsYTerm[0] << ", " << m_coefficientsYTerm[1] << ", "
+          << m_coefficientsYTerm[2] << ", " << m_coefficientsYTerm[3] << "\n";
+      
+      out << "xInverseTerm: " << m_inverseCoefficientsXTerm[0] << ", " << m_inverseCoefficientsXTerm[1] << ", "
+          << m_inverseCoefficientsXTerm[2] << ", " << m_inverseCoefficientsXTerm[3] << "\n";
+      out << "yInverseTerm: " << m_inverseCoefficientsYTerm[0] << ", " << m_inverseCoefficientsYTerm[1] << ", "
+          << m_inverseCoefficientsYTerm[2] << ", " << m_inverseCoefficientsYTerm[3] << "\n";
+      
+      return out;
+   }
+   
+protected:
+   ossim_float64 m_coefficientsXTerm[4]; // constant, linear x, linear y, cross xy
+   ossim_float64 m_coefficientsYTerm[4]; // constant, linear x, linear y, cross xy
+
+   ossim_float64 m_inverseCoefficientsXTerm[4]; // constant, linear x, linear y, cross xy
+   ossim_float64 m_inverseCoefficientsYTerm[4]; // constant, linear x, linear y, cross xy
+   TYPE_DATA;   
+};
+
+#endif
\ No newline at end of file
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dTo2dIdentityTransform.h b/Utilities/otbossim/include/ossim/base/ossim2dTo2dIdentityTransform.h
new file mode 100644
index 0000000000000000000000000000000000000000..07787aa84b4fe46d0abf61fb7519d16491f355b4
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossim2dTo2dIdentityTransform.h
@@ -0,0 +1,68 @@
+//*******************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description:  Contains class definition for ossim2dTo2dIdentityTransform.
+// 
+//*******************************************************************
+//  $Id$
+#ifndef ossim2dTo2dIdentityTransform_HEADER
+#define ossim2dTo2dIdentityTransform_HEADER
+#include "ossim2dTo2dTransform.h"
+/**
+ * This is the identity transform and just passes the input to the output.
+ */
+class OSSIM_DLL ossim2dTo2dIdentityTransform : public ossim2dTo2dTransform
+{
+public:
+   /**
+    * forward transform just passes the point to the output.
+    */
+   virtual void forward(const ossimDpt& input,
+                        ossimDpt& output) const
+   {
+      output = input;
+   }
+   
+   /**
+    * forward transform nothing is modified on the input point.
+    */
+   virtual void forward(ossimDpt&  modify_this) const
+   {
+      // do nothing this is identity
+   }
+   
+   /**
+    * inverse transform just passes the point to the output.
+    */
+   virtual void inverse(const ossimDpt& input,
+                        ossimDpt&       output) const
+   {
+      output = input;
+   }
+   
+   /**
+    * inverse transform nothing is modified on the input point.
+    */
+   virtual void inverse(ossimDpt&  modify_this) const
+   {
+      // do nothing this is identity
+   }
+   
+   /**
+    * Pass equality to the parent
+    */
+   virtual const ossim2dTo2dIdentityTransform& operator=(
+                                                 const ossim2dTo2dIdentityTransform& rhs)
+   {
+      ossim2dTo2dTransform::operator =(rhs);
+      
+      return *this;
+   }
+   
+protected:
+   TYPE_DATA
+};
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dTo2dShiftTransform.h b/Utilities/otbossim/include/ossim/base/ossim2dTo2dShiftTransform.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c74694f4f41e8d3e0fe60543432bb71d38d4f7a
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossim2dTo2dShiftTransform.h
@@ -0,0 +1,126 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+//----------------------------------------------------------------------------
+// $Id$
+#ifndef ossim2dTo2dShiftTransform_HEADER
+#define ossim2dTo2dShiftTransform_HEADER
+#include <ossim/base/ossim2dTo2dTransform.h>
+
+class OSSIM_DLL ossim2dTo2dShiftTransform : public ossim2dTo2dTransform
+{
+public:
+   /**
+    * Constructor to initialize the shift transform
+    */
+   ossim2dTo2dShiftTransform(const ossimDpt& shift = ossimDpt(0.0,0.0))
+   :ossim2dTo2dTransform(),
+   m_shift(shift)
+   {}
+   
+   /**
+    * Copy constructor
+    */
+   ossim2dTo2dShiftTransform(const ossim2dTo2dShiftTransform& src)
+   :ossim2dTo2dTransform(src),
+   m_shift(src.m_shift)
+   {}
+   
+   /**
+    * Duplication method that duplicates this object
+    */
+   virtual ossimObject* dup()const{return new ossim2dTo2dShiftTransform(*this);}
+   
+   /**
+    * operator = allows one to copy the contents of the class through a common = 
+    * operator.  The = is passed to the derived class.
+    */
+   const ossim2dTo2dShiftTransform& operator =(const ossim2dTo2dShiftTransform& src)
+   {
+      if(this == &src) return *this;
+      
+      ossim2dTo2dTransform::operator =(*this); // call base classes equal operator
+      m_shift = src.m_shift;
+      
+      return *this;
+   }
+   
+   /**
+    * Apply the shift to the input.
+    *
+    * @param input The value to shift.
+    * @param output the shifted value.
+    */
+   virtual void forward(const ossimDpt& input,
+                        ossimDpt& output) const
+   {
+      output = input + m_shift;
+   }
+   /**
+    * Apply the shift to the input and put the result in the same variable
+    *
+    * @param modify_this The value to shift.  The result is placed back into this value.
+    */
+   virtual void forward(ossimDpt&  modify_this) const
+   {
+      modify_this.x += m_shift.x;
+      modify_this.y += m_shift.y;
+   }
+
+   /**
+    * Negate the shift to the input and put the result in output.
+    *
+    * @param input The value to apply the negated shift.
+    * @param output the shifted value.
+    */
+   virtual void inverse(const ossimDpt& input,
+                        ossimDpt& output) const
+   {
+      output = input - m_shift;
+   }
+   
+   /**
+    * Negate the shift operation and put the result in the same variable
+    *
+    * @param modify_this The value to shift.  The result is placed back into this value.
+    */
+   virtual void inverse(ossimDpt&  modify_this) const
+   {
+      modify_this.x -= m_shift.x;
+      modify_this.y -= m_shift.y;
+   }
+   /**
+    * Saves the state of this object.
+    */
+   virtual bool saveState(ossimKeywordlist& kwl,
+                          const char* prefix = 0)const;
+   
+   /**
+    * loads the state of this object from a keywordlist.
+    */
+   virtual bool loadState(const ossimKeywordlist& kwl,
+                          const char* prefix = 0);
+   
+   /**
+    * Print the contents of the class and pass to the derived class.
+    */
+   virtual std::ostream& print(std::ostream& out) const
+   {
+      ossim2dTo2dTransform::print(out);
+      
+      out << "shift: " << m_shift;
+      
+      return out;
+   }
+   
+protected:
+   virtual ~ossim2dTo2dShiftTransform(){}
+   
+   ossimDpt m_shift;
+   
+TYPE_DATA;
+};
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransform.h b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransform.h
index 0a644ac95b915b5a0143743ccef0563702d142e5..33e1ae92bee7677f5f69fb182c2088b34ee829f4 100644
--- a/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransform.h
+++ b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransform.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossim2dTo2dTransform.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossim2dTo2dTransform.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossim2dTo2dTransform_HEADER
 #define ossim2dTo2dTransform_HEADER
 #include <ossim/base/ossimObject.h>
@@ -27,18 +27,21 @@ public:
 
    virtual void inverse(ossimDpt&  modify_this) const;
       
+   virtual const ossim2dTo2dTransform& operator=(
+      const ossim2dTo2dTransform& rhs);
+   
    /*!
     * Used by the inverse iterator.  This will give it a good initial value
     * that is within the input transforms
     */
    virtual ossimDpt getOrigin() const;
 
-   virtual std::ostream& print(std::ostream& out) const = 0;
+   virtual std::ostream& print(std::ostream& out) const;
    
-   bool saveState(ossimKeywordlist& kwl,
+   virtual bool saveState(ossimKeywordlist& kwl,
                    const char* prefix = 0)const;
    
-   bool loadState(const ossimKeywordlist& kwl,
+   virtual bool loadState(const ossimKeywordlist& kwl,
                   const char* prefix = 0);
    
    void setConvergenceThreshold(const double& new_threshold);
@@ -49,8 +52,7 @@ public:
 
 protected:
    ossim2dTo2dTransform();
-   void operator =(const ossim2dTo2dTransform& rhs);
-
+   virtual ~ossim2dTo2dTransform(){}
    double theConvergenceThreshold;
    int    theMaxIterations;
 
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformFactory.h b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformFactory.h
new file mode 100644
index 0000000000000000000000000000000000000000..86944435f913d5136bd58a19fca72043cc42d552
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformFactory.h
@@ -0,0 +1,44 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossim2dTo2dTransformFactory.
+//
+//**************************************************************************************************
+// $Id$
+#ifndef ossim2dTo2dTransformFactory_HEADER
+#define ossim2dTo2dTransformFactory_HEADER
+#include <ossim/base/ossim2dTo2dTransformFactoryBase.h>
+
+class ossim2dTo2dTransform;
+class OSSIM_DLL ossim2dTo2dTransformFactory : public ossim2dTo2dTransformFactoryBase
+{
+public:
+   ossim2dTo2dTransformFactory(){}
+   static ossim2dTo2dTransformFactory* instance();
+   
+   /**
+    * Take a transform type name.
+    */
+   virtual ossim2dTo2dTransform* createTransform(const ossimString& name)const;
+   
+   /**
+    * Take a keywordlist.
+    */
+   virtual ossim2dTo2dTransform* createTransform(const ossimKeywordlist& kwl,
+                                                 const char* prefix)const;
+   
+   /*!
+    * This should return the type name of all objects in all factories.
+    * This is the name used to construct the objects dynamially and this
+    * name must be unique.
+    */
+   virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
+  
+protected:
+   static ossim2dTo2dTransformFactory* m_instance;
+};
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformFactoryBase.h b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformFactoryBase.h
new file mode 100644
index 0000000000000000000000000000000000000000..24a8d517d770192ac7aaac941879e30cd99a3b5a
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformFactoryBase.h
@@ -0,0 +1,49 @@
+#ifndef ossim2dTo2dTransformFactoryBase_HEADER
+#define ossim2dTo2dTransformFactoryBase_HEADER
+#include <ossim/base/ossimObjectFactory.h>
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossim2dTo2dTransformFactoryBase.
+//
+//**************************************************************************************************
+// $Id$
+#include <ossim/base/ossim2dTo2dTransform.h>
+
+class OSSIM_DLL ossim2dTo2dTransformFactoryBase : public ossimObjectFactory
+{
+public:
+   
+   /**
+    * Creates an object given a type name.
+    */
+   virtual ossimObject* createObject(const ossimString& typeName)const
+   {
+      return createTransform(typeName);
+   }
+   
+   /**
+    * Creates and object given a keyword list.
+    */
+   virtual ossimObject* createObject(const ossimKeywordlist& kwl,
+                                     const char* prefix=0)const
+   {
+      return createTransform(kwl, prefix);
+   }
+   
+   /**
+    * Take a transform type name.
+    */
+   virtual ossim2dTo2dTransform* createTransform(const ossimString& name)const=0;
+   
+   /**
+    * Take a keywordlist.
+    */
+   virtual ossim2dTo2dTransform* createTransform(const ossimKeywordlist& kwl,
+                                                 const char* prefix)const=0;
+protected:
+};
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformRegistry.h b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformRegistry.h
new file mode 100644
index 0000000000000000000000000000000000000000..9bf06de8568165cbd57c7edf07e5c570948ec79d
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossim2dTo2dTransformRegistry.h
@@ -0,0 +1,84 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossim2dTo2dTransformRegistry.
+//
+//**************************************************************************************************
+// $Id$
+#ifndef ossim2dTo2dTransformRegistry_HEADER
+#define ossim2dTo2dTransformRegistry_HEADER
+#include <ossim/base/ossimObjectFactory.h>
+#include <ossim/base/ossimRtti.h>
+#include <ossim/base/ossim2dTo2dTransformFactoryBase.h>
+#include <ossim/base/ossim2dTo2dTransform.h>
+#include <vector>
+#include <ossim/base/ossimFactoryListInterface.h>
+
+class OSSIM_DLL ossim2dTo2dTransformRegistry : public ossimObjectFactory,
+                                               public ossimFactoryListInterface<ossim2dTo2dTransformFactoryBase,
+                                                                                ossim2dTo2dTransform>
+{
+public:
+   virtual ~ossim2dTo2dTransformRegistry(){}
+   static ossim2dTo2dTransformRegistry* instance();
+   
+   /*!
+    * Creates an object given a type name.
+    */
+   virtual ossimObject* createObject(const ossimString& typeName)const
+   {
+      return createObjectFromRegistry(typeName);
+   }
+   
+   /*!
+    * Creates and object given a keyword list.
+    */
+   virtual ossimObject* createObject(const ossimKeywordlist& kwl,
+                                     const char* prefix=0)const
+   {
+      return createObjectFromRegistry(kwl, prefix);
+   }
+   /*!
+    * Creates an object given a type name.
+    */
+   virtual ossim2dTo2dTransform* createTransform(const ossimString& typeName)const
+   {
+      return createNativeObjectFromRegistry(typeName);
+   }
+   
+   /*!
+    * Creates and object given a keyword list.
+    */
+   virtual ossim2dTo2dTransform* createTransform(const ossimKeywordlist& kwl,
+                                                 const char* prefix=0)const
+   {
+      return createNativeObjectFromRegistry(kwl, prefix);
+   }
+   
+   /*!
+    * This should return the type name of all objects in all factories.
+    * This is the name used to construct the objects dynamially and this
+    * name must be unique.
+    */
+   virtual void getTypeNameList(std::vector<ossimString>& typeList)const
+   {
+      getAllTypeNamesFromRegistry(typeList);
+   }
+   
+protected:
+   ossim2dTo2dTransformRegistry()
+   :ossimObjectFactory()
+   {}
+   
+   ossim2dTo2dTransformRegistry( const ossim2dTo2dTransformRegistry& rhs )
+   :ossimObjectFactory(rhs)
+   {}
+   void operator =(const ossim2dTo2dTransformRegistry&){}
+   static ossim2dTo2dTransformRegistry* m_instance;
+   
+   TYPE_DATA
+};
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossimActiveEdgeTable.h b/Utilities/otbossim/include/ossim/base/ossimActiveEdgeTable.h
index f7fe36300846b4ff4818f94590f298622ca9f655..699d4ebd28e1d9aed22ff74fe38be2db96fe15ad 100644
--- a/Utilities/otbossim/include/ossim/base/ossimActiveEdgeTable.h
+++ b/Utilities/otbossim/include/ossim/base/ossimActiveEdgeTable.h
@@ -5,12 +5,13 @@
 // AUTHOR: Garrett Potts
 //
 //*****************************************************************************
-//  $Id: ossimActiveEdgeTable.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimActiveEdgeTable.h 14799 2009-06-30 08:54:44Z dburken $
 #include <iostream>
 #include <vector>
 #include <list>
 #include <ossim/base/ossimIrect.h>
-class OSSIMDLLEXPORT ossimPolygon;
+
+class ossimPolygon;
 
 
 class OSSIMDLLEXPORT ossimActiveEdgeTableNode
diff --git a/Utilities/otbossim/include/ossim/base/ossimAffineTransform.h b/Utilities/otbossim/include/ossim/base/ossimAffineTransform.h
index e2f980089c7436c52fa7251ab15aa42ff7124b2c..eeff36a9920a2ad2992bbfd9440dbdaf2f81bad1 100644
--- a/Utilities/otbossim/include/ossim/base/ossimAffineTransform.h
+++ b/Utilities/otbossim/include/ossim/base/ossimAffineTransform.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks.com)
 //
 //*************************************************************************
-// $Id: ossimAffineTransform.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimAffineTransform.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAffineTransform_HEADER
 #define ossimAffineTransform_HEADER
@@ -17,7 +17,20 @@ class OSSIMDLLEXPORT ossimAffineTransform : public ossim2dTo2dTransform
 {
 public:
    ossimAffineTransform();
+   ossimAffineTransform(const ossimAffineTransform& src);
 
+   /**
+    * @brief assignment operator=
+    * @param rhs The data to assign from.
+    * @param A reference to this object.
+    */
+   virtual const ossimAffineTransform& operator=(
+      const ossimAffineTransform& rhs);
+   
+   virtual ossimObject* dup()const
+   {
+      return new ossimAffineTransform(*this);
+   }
    virtual void forward(const ossimDpt& input,
                         ossimDpt& output)const;
    virtual void inverse(const ossimDpt& input,
@@ -81,15 +94,14 @@ public:
       
 protected:
    void computeMatrix();
-   
-   NEWMAT::Matrix theForwardXform;
-   NEWMAT::Matrix theInverseXform;
 
    ossimDpt       theScale;
    double         theRotation;
    ossimDpt       theTranslation;
    bool           theAffineEnabledFlag;
 
+   NEWMAT::Matrix theForwardXform;
+   NEWMAT::Matrix theInverseXform;
 TYPE_DATA      
 };
 
diff --git a/Utilities/otbossim/include/ossim/base/ossimCmyVector.h b/Utilities/otbossim/include/ossim/base/ossimCmyVector.h
index d2764a02fb4d7d7d57f7f44e77c5afe1f2632649..72c684fb8680d8941afd5d2cfb9d751bd38a4252 100644
--- a/Utilities/otbossim/include/ossim/base/ossimCmyVector.h
+++ b/Utilities/otbossim/include/ossim/base/ossimCmyVector.h
@@ -6,14 +6,14 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimCmyVector.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimCmyVector.h 14789 2009-06-29 16:48:14Z dburken $
 #include <iostream>
 #include <ossim/base/ossimConstants.h>
 
-class OSSIMDLLEXPORT ossimJpegYCbCrVector;
-class OSSIMDLLEXPORT ossimHsiVector;
-class OSSIMDLLEXPORT ossimHsvVector;
-class OSSIMDLLEXPORT ossimRgbVector;
+class ossimJpegYCbCrVector;
+class ossimHsiVector;
+class ossimHsvVector;
+class ossimRgbVector;
 
 class OSSIMDLLEXPORT ossimCmyVector
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimColorProperty.h b/Utilities/otbossim/include/ossim/base/ossimColorProperty.h
index ab7a7998b9c4ee73502facfb19756daa79cf8fdd..f3b459d2c47f312640dc9be8a10aa22861525652 100644
--- a/Utilities/otbossim/include/ossim/base/ossimColorProperty.h
+++ b/Utilities/otbossim/include/ossim/base/ossimColorProperty.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimColorProperty.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimColorProperty.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimColorProperty_HEADER
 #define ossimColorProperty_HEADER
 #include <ossim/base/ossimProperty.h>
@@ -18,7 +18,6 @@ public:
    ossimColorProperty(const ossimString& name=ossimString(""),
                       const ossimRgbVector& value = ossimRgbVector(0,0,0));
    ossimColorProperty(const ossimColorProperty& rhs);
-   virtual ~ossimColorProperty();
    virtual ossimObject* dup()const;
    virtual const ossimProperty& assign(const ossimProperty& rhs);
    virtual bool setValue(const ossimString& value);
@@ -32,6 +31,7 @@ public:
    void setGreen(ossim_uint8 r);
    void setBlue(ossim_uint8 r);
 protected:
+   virtual ~ossimColorProperty();
    ossimRgbVector theValue;
 
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/base/ossimCommon.h b/Utilities/otbossim/include/ossim/base/ossimCommon.h
index 92c2ec519deeb79efa7256fa5636179254975f37..7512bf82b0d02d5938419a3dfbb2e5ca42800d1c 100644
--- a/Utilities/otbossim/include/ossim/base/ossimCommon.h
+++ b/Utilities/otbossim/include/ossim/base/ossimCommon.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// LICENSE: See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts, with some additions and modifciations by
 // Patrick Melody
@@ -8,7 +10,7 @@
 // Description: Common file for utility functions.
 //
 //*************************************************************************
-// $Id: ossimCommon.h 12910 2008-05-28 11:09:09Z gpotts $
+// $Id: ossimCommon.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimCommon_HEADER
 #define ossimCommon_HEADER
 
@@ -20,10 +22,13 @@
 #define ossimSTATIC_CHECK(expr,msg)  
 
 #include <cmath>
+#include <istream>
 #include <string>
 #include <vector>
 #include <ossim/base/ossimConstants.h>
 class ossimIpt;
+class ossimDpt;
+class ossimString;
 namespace NEWMAT
 {
    class Matrix;
@@ -31,6 +36,8 @@ namespace NEWMAT
 
 namespace ossim
 {
+   OSSIM_DLL std::istream& skipws(std::istream& in);
+   OSSIM_DLL bool isWhiteSpace(int c);
     template<class T>
 /*     inline bool almostEqual(T x, T y, T tolerence = std::numeric_limits<T>::epsilon()) */
 /*         // are x and y within tolerance distance of each other? */
@@ -49,6 +56,7 @@ namespace ossim
 	// is x in the open interval (a,b)?
 	{ return x > a && x < b; }
 
+   
     /**
      * isnan Test for floating point Not A Number (NAN) value.
      * This should be used test for nan.
@@ -124,7 +132,16 @@ namespace ossim
      * DO NOT USE operator==.  Like "if (myDoubleValue == ossim::nan())"
      */
     inline double nan() { return nanValue.bits.floatname; }
-    
+
+   template <class T>
+   inline T abs(const T& value)
+   {
+      if(value < 0)
+      {
+         return -value;
+      }
+      return value;
+   }
     template <class S, class T> 
     inline T lerp(S x, T begin, T end)
 	// linear interpolation from begin to end by x
@@ -381,11 +398,34 @@ namespace ossim
     OSSIM_DLL ossimByteOrder byteOrder();
         // test endianness of current machine 
 
+    // values for various scalar types
     OSSIM_DLL double defaultMin(ossimScalarType scalarType);
     OSSIM_DLL double defaultMax(ossimScalarType scalarType);
     OSSIM_DLL double defaultNull(ossimScalarType scalarType);
     OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType);
-        // values for various scalar types
+    
+    /** @brief @return true if scalar type is signed, false if not. */
+    OSSIM_DLL bool isSigned(ossimScalarType scalarType);
+
+    /**
+     * @brief Get actual bits per pixel for a given scalar type.
+     * 
+     * This is bits used.  (OSSIM_USHORT11 = 11)
+     * 
+     * @returns The actual bits per pixel.  This will return 0 if the
+     * input connection is not hooked up or there is an unhandled scalar type.
+     */
+    OSSIM_DLL ossim_uint32 getActualBitsPerPixel(ossimScalarType scalarType);
+    
+    /**
+     * @brief Get bits per pixel for a given scalar type.
+     * 
+     * This the total bits per pixel.  (OSSIM_USHORT11 = 16)
+     * 
+     * @returns The bits per pixel.  This will return 0 if the
+     * input connection is not hooked up or there is an unhandled scalar type.
+     */
+    OSSIM_DLL ossim_uint32 getBitsPerPixel(ossimScalarType scalarType);  
         
     OSSIM_DLL void defaultTileSize(ossimIpt& tileSize);
 
@@ -405,6 +445,25 @@ namespace ossim
                                    const char* whitespace,
                                    const char* quotes,
                                    std::vector<std::string>& tokens, bool& unbalancedQuotes);
+   /**
+    * Will take a vector of ossimDpt and convert to a string list separated by spaces
+    * For example: 
+    *      (45,34) (12,34)
+    */
+   OSSIM_DLL void toStringList(ossimString& resultStringOfPoints,
+                               const std::vector<ossimDpt>& pointList);
+   OSSIM_DLL void toStringList(ossimString& resultStringOfPoints,
+                               const std::vector<ossimIpt>& pointList);
+   
+   /**
+    * Will take a string list separated by spaces and convert to a vector of ossimDpts.  It will not clear
+    * the passed in list but will append all points found.
+    */
+   OSSIM_DLL void toVector(std::vector<ossimDpt>& result,
+                           const ossimString& stringOfPoints);
+   OSSIM_DLL void toVector(std::vector<ossimIpt>& result,
+                           const ossimString& stringOfPoints);
+   
         // lex str into tokens starting at position start using whitespace  
 	//    chars as delimiters and quotes[0] and quotes[1] as the opening
 	//    and closing quotation chars (for quoting tokens containing whitespace).
diff --git a/Utilities/otbossim/include/ossim/base/ossimConnectableContainer.h b/Utilities/otbossim/include/ossim/base/ossimConnectableContainer.h
index 3362fa731b5493f248f08c20c81af2c44bc5fa54..18650d241be5e426820f1fa7006ab13909931631 100644
--- a/Utilities/otbossim/include/ossim/base/ossimConnectableContainer.h
+++ b/Utilities/otbossim/include/ossim/base/ossimConnectableContainer.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimConnectableContainer.h 13017 2008-06-10 16:09:17Z dburken $
+// $Id: ossimConnectableContainer.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimConnectableContainer_HEADER
 #define ossimConnectableContainer_HEADER
@@ -25,10 +25,9 @@ class OSSIMDLLEXPORT ossimConnectableContainer : public ossimConnectableObject,
 {
 public:
    typedef std::map<ossim_int64,
-      ossimConnectableObject*> connectablObjectMapType;
+      ossimRefPtr<ossimConnectableObject> > connectablObjectMapType;
    
    ossimConnectableContainer(ossimConnectableObject* owner=0);
-   virtual ~ossimConnectableContainer();
 
    virtual ossimObject* getObject();
    
@@ -56,9 +55,9 @@ public:
     * Example: passing STATIC_TYPE_INFO(ossimImageRenderer) as an argument will
     *          look for all ossimImageRenderer's and return the list.
     */
-   virtual std::vector<ossimConnectableObject*> findAllObjectsOfType(const RTTItypeid& typeInfo,
+   virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid& typeInfo,
                                                             bool recurse=true);
-   virtual std::vector<ossimConnectableObject*> findAllObjectsOfType(const ossimString& className,
+   virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const ossimString& className,
                                                             bool recurse=true);
 
    /*!
@@ -142,6 +141,7 @@ public:
 //                                ossimConnectableObject* start);
      
 protected:
+   virtual ~ossimConnectableContainer();
    ossimConnectableContainer(const ossimConnectableContainer& rhs);
 
    void removeAllListeners();
diff --git a/Utilities/otbossim/include/ossim/base/ossimConnectableContainerInterface.h b/Utilities/otbossim/include/ossim/base/ossimConnectableContainerInterface.h
index 5e8e7f2241ed485d74a363a56287dd89847e85ac..1bac25231840078a97b5f1e4180ca86854d7be77 100644
--- a/Utilities/otbossim/include/ossim/base/ossimConnectableContainerInterface.h
+++ b/Utilities/otbossim/include/ossim/base/ossimConnectableContainerInterface.h
@@ -8,18 +8,17 @@
 // Description: A brief description of the contents of the file.
 //
 //*************************************************************************
-// $Id: ossimConnectableContainerInterface.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimConnectableContainerInterface.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimConnectableContainerInterface_HEADER
 #define ossimConnectableContainerInterface_HEADER
 
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimRtti.h>
 #include <ossim/base/ossimId.h>
+#include <ossim/base/ossimConnectableObject.h>
 #include <vector>
 
-class OSSIMDLLEXPORT ossimObject;
-class OSSIMDLLEXPORT ossimConnectableObject;
-class OSSIMDLLEXPORT ossimString;
+class ossimString;
 
 class OSSIMDLLEXPORT ossimConnectableContainerInterface
 {
@@ -36,11 +35,11 @@ public:
     * Example: passing STATIC_TYPE_INFO(ossimImageRenderer) as an argument will
     *          look for all ossimImageRenderer's and return the list.
     */
-   virtual std::vector<ossimConnectableObject*> findAllObjectsOfType(const RTTItypeid& typeInfo,
-                                                                     bool recurse=true)=0;
-   virtual std::vector<ossimConnectableObject*> findAllObjectsOfType(const ossimString& className,
-                                                                     bool recurse=true)=0;
-
+   virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid& typeInfo,
+                                                                              bool recurse=true)=0;
+   virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const ossimString& className,
+                                                                              bool recurse=true)=0;
+   
    /*!
     * Will find the firt object of the past in type.  Use the RTTI type info.An optional
     * recurse flag will say if there is another container then recurse it to
diff --git a/Utilities/otbossim/include/ossim/base/ossimConnectableObject.h b/Utilities/otbossim/include/ossim/base/ossimConnectableObject.h
index a4bed9e81d6032aa55ad30b1d51089ac64d0acf6..83f0def6f968e07f6bcd41d22d5d54ef3c34d19d 100644
--- a/Utilities/otbossim/include/ossim/base/ossimConnectableObject.h
+++ b/Utilities/otbossim/include/ossim/base/ossimConnectableObject.h
@@ -11,7 +11,7 @@
 // all connectable objects.
 //
 //*************************************************************************
-// $Id: ossimConnectableObject.h 12645 2008-04-09 21:02:33Z dburken $
+// $Id: ossimConnectableObject.h 15798 2009-10-23 19:15:20Z gpotts $
 
 #ifndef ossimConnectableObject_HEADER
 #define ossimConnectableObject_HEADER
@@ -23,6 +23,7 @@
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimListenerManager.h>
 #include <ossim/base/ossimPropertyInterface.h>
+#include <ossim/base/ossimRefPtr.h>
 
 /**
  * This class is the base of all connectable objects.  It will manage
@@ -38,6 +39,7 @@ class  OSSIMDLLEXPORT  ossimConnectableObject : public ossimObject,
                                                 public ossimPropertyInterface
 {
 public:
+   typedef std::vector<ossimRefPtr<ossimConnectableObject> > ConnectableObjectList;
    enum ossimConnectableObjectDirectionType
    {
       CONNECTABLE_DIRECTION_NONE   = 0,
@@ -55,7 +57,6 @@ public:
                           bool outputListIsFixedFlag=true);
 
    virtual ~ossimConnectableObject();
-
    /**
     * All connectable objects will have id's.  This allows us to
     * set the id of this object.
@@ -192,9 +193,9 @@ public:
     * Will disconnect the object at the given input index and generate
     * a connection event.
     */
-   virtual ossimConnectableObject* disconnectMyInput(ossim_int32 inputIndex,
-						     bool disconnectOutputFlag=true,
-						     bool createEventFlag = true);
+   virtual ossimRefPtr<ossimConnectableObject> disconnectMyInput(ossim_int32 inputIndex,
+                                                                 bool disconnectOutputFlag=true,
+                                                                 bool createEventFlag = true);
   
   /**
    * Finds the index of the passed in input and calls
@@ -207,7 +208,7 @@ public:
     *
     */
    virtual void disconnectMyInputs(
-      std::vector<ossimConnectableObject*>& inputList,
+      ConnectableObjectList& inputList,
       bool disconnectOutputFlag=true,
       bool createEventFlag=true);
    
@@ -218,9 +219,9 @@ public:
     * says do you want this method to disconnect the output pointer to
     * this object.
     */
-   virtual ossimConnectableObject* disconnectMyOutput(ossim_int32 outputIndex,
-						      bool disconnectInputFlag=true,
-						      bool createEventFlag = true);
+   virtual ossimRefPtr<ossimConnectableObject> disconnectMyOutput(ossim_int32 outputIndex,
+                                                                  bool disconnectInputFlag=true,
+                                                                  bool createEventFlag = true);
   
    /**
     * Will disconnect the output object.  It will get the index of
@@ -231,7 +232,7 @@ public:
                                    bool createEventFlag=true);
 
    virtual void disconnectMyOutputs(
-      std::vector<ossimConnectableObject*>& outputList,
+      ConnectableObjectList& outputList,
       bool disconnectOutputFlag=true,
       bool createEventFlag=true);
    
@@ -263,7 +264,7 @@ public:
                                         bool createEventFlag=true);
    
    virtual bool connectMyInputTo(
-      std::vector<ossimConnectableObject*>& inputList,
+      ConnectableObjectList& inputList,
       bool makeOutputConnection=true,
       bool createEventFlag = true);   
 
@@ -280,7 +281,7 @@ public:
                                          bool createEventFlag=true);
    
    virtual bool connectMyOutputTo(
-      std::vector<ossimConnectableObject*>& outputList,
+      ConnectableObjectList& outputList,
       bool makeInputConnection=true,
       bool createEventFlag=true);
    
@@ -290,7 +291,7 @@ public:
     * added.
     */
    virtual bool connectInputList(
-      std::vector<ossimConnectableObject*>& inputList);
+      ConnectableObjectList& inputList);
    
    /**
     * Will disconnect itself from all outputs and reset to the passed in
@@ -298,7 +299,7 @@ public:
     * added.
     */
    virtual bool connectOutputList(
-      std::vector<ossimConnectableObject*>& outputList);
+      ConnectableObjectList& outputList);
    
    /**
     * Returns the number of input objects.
@@ -369,43 +370,43 @@ public:
     */
    virtual void setNumberOfOutputs(ossim_int32 numberOfInputs);
    
-   const std::vector<ossimConnectableObject*>& getInputList()const
+   const ConnectableObjectList& getInputList()const
       {
          return theInputObjectList;
       }
-   const std::vector<ossimConnectableObject*>& getOutputList()const
+   const ConnectableObjectList& getOutputList()const
       {
          return theOutputObjectList;
       }
-   std::vector<ossimConnectableObject*>& getInputList()
+   ConnectableObjectList& getInputList()
       {
          return theInputObjectList;
       }
-   std::vector<ossimConnectableObject*>& getOutputList()
+   ConnectableObjectList& getOutputList()
       {
          return theOutputObjectList;
       }
 
    virtual void findAllInputsOfType(
-      std::vector<ossimConnectableObject*>& result,
+      ConnectableObjectList& result,
       const RTTItypeid& typeInfo,
       bool propagateToInputs=true,
       bool recurseChildren=false);
 
    virtual void findAllInputsOfType(
-      std::vector<ossimConnectableObject*>& result,
+      ConnectableObjectList& result,
       const ossimString& className,
       bool propagateToInputs=true,
       bool recurseChildren=false);
    
    virtual void findAllOutputsOfType(
-      std::vector<ossimConnectableObject*>& result,
+      ConnectableObjectList& result,
       const ossimString& className,
       bool propagateToOutputs=true,
       bool recurseChildren=false);
    
    virtual void findAllOutputsOfType(
-      std::vector<ossimConnectableObject*>& result,
+      ConnectableObjectList& result,
       const RTTItypeid& typeInfo,
       bool propagateToOutputs=true,
       bool recurseChildren=false);
@@ -482,6 +483,7 @@ public:
    bool moveInputToBottom(const ossimId& id);
     
 protected:
+   
    ossimId      theId;
    ossimString  theDescription;
    ossimObject* theOwner;
@@ -499,12 +501,12 @@ protected:
    /**
     * Holds a list of input objects.
     */
-   std::vector<ossimConnectableObject*>     theInputObjectList;
+   ConnectableObjectList     theInputObjectList;
    
    /**
     * Holds a list of output objects.
     */
-   std::vector<ossimConnectableObject*>     theOutputObjectList;
+   ConnectableObjectList     theOutputObjectList;
 
 private:
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/base/ossimConnectionEvent.h b/Utilities/otbossim/include/ossim/base/ossimConnectionEvent.h
index 7bfd45b9dca4e395e37057bcec21a9d656f58f35..d86471c3db83db4eaff84b4c048d97bc1bab17d5 100644
--- a/Utilities/otbossim/include/ossim/base/ossimConnectionEvent.h
+++ b/Utilities/otbossim/include/ossim/base/ossimConnectionEvent.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 // 
 //*************************************************************************
-// $Id: ossimConnectionEvent.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimConnectionEvent.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimConnectionEvent_HEADER
 #define ossimConnectionEvent_HEADER
 
@@ -34,8 +34,8 @@ public:
 
    ossimConnectionEvent(ossimObject* object,
                         long id,
-                        const std::vector<ossimConnectableObject*>& newList,
-                        const std::vector<ossimConnectableObject*>& oldList,
+                        const ossimConnectableObject::ConnectableObjectList& newList,
+                        const ossimConnectableObject::ConnectableObjectList& oldList,
                         ossimConnectionDirectionType whichDirection);
 
    ossimConnectionEvent(ossimObject* object,
@@ -56,9 +56,9 @@ public:
    
    virtual ossim_uint32 getNumberOfOldObjects()const;
    
-   virtual ossimConnectableObject* getOldObject(ossim_uint32 i=0)const;
+   virtual ossimConnectableObject* getOldObject(ossim_uint32 i=0);
 
-   virtual ossimConnectableObject* getNewObject(ossim_uint32 i=0)const;
+   virtual ossimConnectableObject* getNewObject(ossim_uint32 i=0);
 
    virtual bool isDisconnect()const;
    
@@ -69,8 +69,8 @@ public:
    virtual bool isOutputDirection()const;
    
 protected:
-   std::vector<ossimConnectableObject*> theNewObjectList;
-   std::vector<ossimConnectableObject*> theOldObjectList;
+   ossimConnectableObject::ConnectableObjectList theNewObjectList;
+   ossimConnectableObject::ConnectableObjectList theOldObjectList;
    ossimConnectionDirectionType         theDirectionType;
 
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowFactoryBase.h b/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowFactoryBase.h
index 87e5e676529bc9a971c4138d69762c3bada3c95a..70317131495637090bb48ca7507b276745c58a70 100644
--- a/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowFactoryBase.h
+++ b/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowFactoryBase.h
@@ -6,12 +6,12 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimCustomEditorWindowFactoryBase.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimCustomEditorWindowFactoryBase.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimCustomEditorWindowFactoryBase_HEADER
 #define ossimCustomEditorWindowFactoryBase_HEADER
 #include <ossim/base/ossimObjectFactory.h>
 
-class OSSIMDLLEXPORT ossimCustomEditorWindow;
+class ossimCustomEditorWindow;
 
 class OSSIMDLLEXPORT ossimCustomEditorWindowFactoryBase : public ossimObjectFactory
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowRegistry.h b/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowRegistry.h
index 59a654015fec2ed8faff54305ea4e4bffe5042c9..85a2242e1132ee3d19faf439442e312c6ed6f811 100644
--- a/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowRegistry.h
+++ b/Utilities/otbossim/include/ossim/base/ossimCustomEditorWindowRegistry.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimCustomEditorWindowRegistry.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimCustomEditorWindowRegistry.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimCustomEditorWindowRegistry_HEADER
 #define ossimCustomEditorWindowRegistry_HEADER
 #include <ossim/base/ossimObject.h>
@@ -14,7 +14,7 @@
 #include <ossim/base/ossimCustomEditorWindowFactoryBase.h>
 
 #include <vector>
-class OSSIMDLLEXPORT ossimCustomEditorWindowFactoryBase;
+class ossimCustomEditorWindowFactoryBase;
 
 class OSSIMDLLEXPORT ossimCustomEditorWindowRegistry : public ossimCustomEditorWindowFactoryBase
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimDataObject.h b/Utilities/otbossim/include/ossim/base/ossimDataObject.h
index eb5b986fef3387b26912009c64a32fb019da5438..b1cd6299680fad14e888a3486e996b7da906c8e8 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDataObject.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDataObject.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimDataObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimDataObject.h 15798 2009-10-23 19:15:20Z gpotts $
 
 #ifndef ossimDataObject_HEADER
 #define ossimDataObject_HEADER
@@ -17,7 +17,7 @@
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimDpt3d.h>
 
-class OSSIMDLLEXPORT ossimSource;
+class ossimSource;
 
 class OSSIMDLLEXPORT ossimDataObject : public ossimObject
 {
@@ -26,10 +26,10 @@ public:
                    ossimDataObjectStatus status=OSSIM_STATUS_UNKNOWN);
    
    ossimDataObject(const ossimDataObject& rhs);
-
    virtual ~ossimDataObject();
 
 
+
    virtual ossim_uint32 getHashId()const=0;
    
    /**
diff --git a/Utilities/otbossim/include/ossim/base/ossimDate.h b/Utilities/otbossim/include/ossim/base/ossimDate.h
index 4e5c23861c91618befe7ef365d525d814049b9c0..60c89638c7d7f17b33b49766d369f4b75c3f527b 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDate.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDate.h
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimDate.h 14478 2009-05-08 18:24:22Z dburken $
+// $Id: ossimDate.h 14902 2009-07-17 11:26:20Z gpotts $
 #ifndef ossimDate_HEADER
 #define ossimDate_HEADER
 #include <ctime>
@@ -40,6 +40,7 @@ public:
    
    int isValid (void) const;             // Test for validity
    
+   void now();
    int compare (ossimLocalTm const & t) const;      // Compare times
    int compare (std::time_t const tt) const;       // Compare times
    
@@ -65,51 +66,51 @@ public:
       ossimLocalTmFormatSepChar       = (int)0x4000,// Separate fields datech
       ossimLocalTmFormatSepSpace      = (int)0x8000,  // Separate fields space
       ossimLocalTmFormatInternational = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatMonText|ossimLocalTmFormatPadMon|
-                                                ossimLocalTmFormatSepSpace),
+                                              ossimLocalTmFormatSepSpace),
       ossimLocalTmFormatIntlShort     = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatMonText|ossimLocalTmFormatPadMon|
-                                                ossimLocalTmFormatSepSpace|ossimLocalTmFormatYearShort),
+                                              ossimLocalTmFormatSepSpace|ossimLocalTmFormatYearShort),
       ossimLocalTmFormatUsa           = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatMonFirst|ossimLocalTmFormatPadDMY|
-                                                ossimLocalTmFormatZeroDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatSepChar),
+                                              ossimLocalTmFormatZeroDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatSepChar),
       ossimLocalTmFormatEnglish       = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatPadDMY|
-                                                ossimLocalTmFormatZeroDMY|ossimLocalTmFormatSepChar),
+                                              ossimLocalTmFormatZeroDMY|ossimLocalTmFormatSepChar),
       ossimLocalTmFormatJapanese      = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatYearFirst|ossimLocalTmFormatPadDMY|
-                                                ossimLocalTmFormatZeroDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatMonFirst|
-                                                ossimLocalTmFormatSepChar),
+                                              ossimLocalTmFormatZeroDMY|ossimLocalTmFormatYearShort|ossimLocalTmFormatMonFirst|
+                                              ossimLocalTmFormatSepChar),
       ossimLocalTmFormatFull          = (int)(ossimLocalTmFormatDMY|ossimLocalTmFormatDayOfWeek|ossimLocalTmFormatMonText|
-                                                ossimLocalTmFormatSepSpace)
+                                              ossimLocalTmFormatSepSpace)
    };
    
    enum ossimTimeFormat  // Time format (nb: time zones not implemented)
-      {
-         ossimTimeFormatSecs          = (int)0x0001,         // Print seconds
-         ossimTimeFormatZeroSecs      = (int)0x0002,     // Zero fill seconds
-         ossimTimeFormatPadSecs       = (int)0x0004,      // Pad seconds to 2
-         ossimTimeFormatSecsAll       = (int)0x0007,
-         ossimTimeFormatTimeZone      = (int)0x0008,        // Print timezone
-         ossimTimeFormatMins          = (int)0x0010,         // Print minutes
-         ossimTimeFormatZeroMins      = (int)0x0020,     // Zero fill minutes
-         ossimTimeFormatPadMins       = (int)0x0040,      // Pad minutes to 2
-         ossimTimeFormatMinsAll       = (int)0x0070,
-         ossimTimeFormatTZNumeric     = (int)0x0080,      // Print numeric TZ
-         ossimTimeFormatHour          = (int)0x0100,            // Print hour
-         ossimTimeFormatZeroHour      = (int)0x0200,        // Zero fill hour
-         ossimTimeFormatPadHour       = (int)0x0400,  // Pad hour to 2 digits
-         ossimTimeFormatHourAll       = (int)0x0700,
-         ossimTimeFormat24hour        = (int)0x0800,          // 24hour clock
-         ossimTimeFormatSepChar       = (int)0x1000, // Separate field timech
-         ossimTimeFormatSepSpace      = (int)0x2000, // Separate fields space
-         ossimTimeFormatSepAbbrev     = (int)0x4000,     // Add abbreviations
-         ossimTimeFormatAmPm          = (int)0x8000,       // Add 'am' or 'pm'
-         ossimTimeFormatInternational = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormatSecsAll|
-                                              ossimTimeFormat24hour|ossimTimeFormatSepChar),
-         ossimTimeFormatShortTime     = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormat24hour|
-                                              ossimTimeFormatSepChar),
-         ossimTimeFormatClockTime     = (int)(ossimTimeFormatHour|ossimTimeFormatPadHour|ossimTimeFormatMinsAll|
-                                              ossimTimeFormatAmPm|ossimTimeFormatSepChar),
-         ossimTimeFormatLongTime      = (int)(ossimTimeFormatHour|ossimTimeFormatPadHour|ossimTimeFormatMinsAll|
-                                              ossimTimeFormatSecsAll|ossimTimeFormatSepAbbrev|ossimTimeFormatSepSpace),
-         ossimTimeFormatMillitary     = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormat24hour)
-      };
+   {
+      ossimTimeFormatSecs          = (int)0x0001,         // Print seconds
+      ossimTimeFormatZeroSecs      = (int)0x0002,     // Zero fill seconds
+      ossimTimeFormatPadSecs       = (int)0x0004,      // Pad seconds to 2
+      ossimTimeFormatSecsAll       = (int)0x0007,
+      ossimTimeFormatTimeZone      = (int)0x0008,        // Print timezone
+      ossimTimeFormatMins          = (int)0x0010,         // Print minutes
+      ossimTimeFormatZeroMins      = (int)0x0020,     // Zero fill minutes
+      ossimTimeFormatPadMins       = (int)0x0040,      // Pad minutes to 2
+      ossimTimeFormatMinsAll       = (int)0x0070,
+      ossimTimeFormatTZNumeric     = (int)0x0080,      // Print numeric TZ
+      ossimTimeFormatHour          = (int)0x0100,            // Print hour
+      ossimTimeFormatZeroHour      = (int)0x0200,        // Zero fill hour
+      ossimTimeFormatPadHour       = (int)0x0400,  // Pad hour to 2 digits
+      ossimTimeFormatHourAll       = (int)0x0700,
+      ossimTimeFormat24hour        = (int)0x0800,          // 24hour clock
+      ossimTimeFormatSepChar       = (int)0x1000, // Separate field timech
+      ossimTimeFormatSepSpace      = (int)0x2000, // Separate fields space
+      ossimTimeFormatSepAbbrev     = (int)0x4000,     // Add abbreviations
+      ossimTimeFormatAmPm          = (int)0x8000,       // Add 'am' or 'pm'
+      ossimTimeFormatInternational = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormatSecsAll|
+                                           ossimTimeFormat24hour|ossimTimeFormatSepChar),
+      ossimTimeFormatShortTime     = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormat24hour|
+                                           ossimTimeFormatSepChar),
+      ossimTimeFormatClockTime     = (int)(ossimTimeFormatHour|ossimTimeFormatPadHour|ossimTimeFormatMinsAll|
+                                           ossimTimeFormatAmPm|ossimTimeFormatSepChar),
+      ossimTimeFormatLongTime      = (int)(ossimTimeFormatHour|ossimTimeFormatPadHour|ossimTimeFormatMinsAll|
+                                           ossimTimeFormatSecsAll|ossimTimeFormatSepAbbrev|ossimTimeFormatSepSpace),
+      ossimTimeFormatMillitary     = (int)(ossimTimeFormatHourAll|ossimTimeFormatMinsAll|ossimTimeFormat24hour)
+   };
    
    
    static char timech;    // Character used for time separator
@@ -123,7 +124,7 @@ public:
                        int tf =timefmt) const;
    std::ostream& printTime(std::ostream & os, int f =timefmt) const;
    std::ostream& printDate(std::ostream & os, int f =datefmt) const;
-
+   
    /**
     * @brief method to dump all the data members.  This is the tm struct +
     * the theFractionalSecond from this class.
@@ -136,57 +137,57 @@ public:
     * @return stream.
     */
    std::ostream& dump(std::ostream& os) const;
-
-
-    int getYear()const;
-
-    int getShortYear()const;
-    
-    /*!
-     * This is one based i.e. values are returned between 1-12
-     */
-    int getMonth()const;
-    
-    /*!
-     * returns the day 1-31
-     */
-    int getDay()const;
-    double getJulian()const;
-    double getModifiedJulian()const;
-
-    ossimLocalTm& setDay(int day);
+   
+   
+   int getYear()const;
+   
+   int getShortYear()const;
+   
+   /*!
+    * This is one based i.e. values are returned between 1-12
+    */
+   int getMonth()const;
+   
+   /*!
+    * returns the day 1-31
+    */
+   int getDay()const;
+   double getJulian()const;
+   double getModifiedJulian()const;
+   
+   ossimLocalTm& setDay(int day);
    /*!
     * The month is a number bewteen 1 and 12.  We will shift it to the internal
     * representation
     */
-    ossimLocalTm& setMonth(int month);
-    ossimLocalTm& setYear(int year);
-    ossimLocalTm& setDateFromJulian(double jd);
-    ossimLocalTm& setDateFromModifiedJulian(double mjd);
-
-    void setFractionalDay(double fractionalDay);
-    static void extractHmsFromFractionalDay(double fractionalDay,
-                                            int &h,
-                                            int &m,
-                                            int &s,
-                                            double& fractionalSecond);
-    int getHour()const;
-    int getMin()const;
-    int getSec()const;
-    double getFractionalSecond()const;
-    ossimLocalTm& setHour(int h);
-    ossimLocalTm& setMin(int m);
+   ossimLocalTm& setMonth(int month);
+   ossimLocalTm& setYear(int year);
+   ossimLocalTm& setDateFromJulian(double jd);
+   ossimLocalTm& setDateFromModifiedJulian(double mjd);
+   
+   void setFractionalDay(double fractionalDay);
+   static void extractHmsFromFractionalDay(double fractionalDay,
+                                           int &h,
+                                           int &m,
+                                           int &s,
+                                           double& fractionalSecond);
+   int getHour()const;
+   int getMin()const;
+   int getSec()const;
+   double getFractionalSecond()const;
+   ossimLocalTm& setHour(int h);
+   ossimLocalTm& setMin(int m);
    ossimLocalTm& setSec(int s);
    ossimLocalTm& setFloatSec(double s);
-    ossimLocalTm& setFractionalSecond(double fractS);
-
-    /**
-     * getTicks() will call getEpoc.  This is te number of microseconds passed
-     * since (00:00:00 UTC, January 1, 1970)
-     */ 
-    time_t getTicks()const;
-    time_t getEpoc()const;
-    
+   ossimLocalTm& setFractionalSecond(double fractS);
+   
+   /**
+    * getTicks() will call getEpoc.  This is te number of microseconds passed
+    * since (00:00:00 UTC, January 1, 1970)
+    */ 
+   time_t getTicks()const;
+   time_t getEpoc()const;
+   
    void addSeconds(ossim_float64 n);
    void addMinutes(ossim_float64 n);
    void addHours(ossim_float64 n);
@@ -196,22 +197,24 @@ public:
    ossim_float64 deltaInMinutes(const ossimLocalTm& d)const;
    ossim_float64 delatInHours(const ossimLocalTm& d)const;
    ossim_float64 deltaInDays(const ossimLocalTm& d)const;
-    /**
-     * Will not adjust for timezone.  The passed in value is based on seconds.
-     */ 
-    void setTimeNoAdjustmentGivenEpoc(time_t ticks);
-
-    /**
-     * Will adjust for timezone. The passed in value is based on seconds.
-     */ 
-    void setTimeGivenEpoc(time_t ticks);
-    
+   
+   ossimLocalTm convertToGmt()const;
+   /**
+    * Will not adjust for timezone.  The passed in value is based on seconds.
+    */ 
+   void setTimeNoAdjustmentGivenEpoc(time_t ticks);
+   
+   /**
+    * Will adjust for timezone. The passed in value is based on seconds.
+    */ 
+   void setTimeGivenEpoc(time_t ticks);
+   
    bool setIso8601(const std::string& timeString, bool shiftToGmtOffsetZero=false);
    
-    ossimRefPtr<ossimXmlNode> saveXml()const;
-    bool loadXml(ossimRefPtr<ossimXmlNode> dateNode);
-    
- protected:
+   ossimRefPtr<ossimXmlNode> saveXml()const;
+   bool loadXml(ossimRefPtr<ossimXmlNode> dateNode);
+   
+protected:
    // Time suffix
    void tSfx(std::ostream & os, int fmt, char ch) const;
    // Time field formatters
@@ -224,7 +227,7 @@ public:
    void pDate(std::ostream & os, int fmt) const;
    void pMonth(std::ostream & os, int fmt) const;
    void pYear(std::ostream & os, int fmt) const;
-
+   
    double theFractionalSecond;
 };
 
diff --git a/Utilities/otbossim/include/ossim/base/ossimDblGrid.h b/Utilities/otbossim/include/ossim/base/ossimDblGrid.h
index 6fdb3891615266408ed51e0df825986efe7fd6d4..99160b5dce8cc6cfe5f3e2f7628d8b05bcfded98 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDblGrid.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDblGrid.h
@@ -24,7 +24,7 @@
 //   spacing are specified to the constructor.
 //
 //*****************************************************************************
-//  $Id: ossimDblGrid.h 11428 2007-07-27 18:44:18Z gpotts $
+//  $Id: ossimDblGrid.h 14799 2009-06-30 08:54:44Z dburken $
 
 #ifndef ossimDblGrid_HEADER
 #define ossimDblGrid_HEADER
@@ -33,7 +33,7 @@
 #include <ossim/base/ossimIpt.h>
 #include <ossim/base/ossimCommon.h>
 
-class OSSIMDLLEXPORT ossimDrect;
+class ossimDrect;
 
 /*!****************************************************************************
  *
diff --git a/Utilities/otbossim/include/ossim/base/ossimDirectory.h b/Utilities/otbossim/include/ossim/base/ossimDirectory.h
index 0ddc48f3245a83eb90a80d8abc68b77c29de745b..32a1ae34f45049ff965d1d2949202315e1a6d522 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDirectory.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDirectory.h
@@ -10,7 +10,7 @@
 // Description: 
 //
 //*************************************************************************
-// $Id: ossimDirectory.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimDirectory.h 14776 2009-06-25 14:34:06Z dburken $
 #ifndef ossimDirectory_HEADER
 #define ossimDirectory_HEADER
 
@@ -67,6 +67,28 @@ public:
    void setFlags(int flags) { theFlags = flags; };
    bool fileMatched(ossimFilename &filename) const;
 #endif    
+
+   // ESH 07/2008, Trac #234: OSSIM is case sensitive 
+   // when using worldfile templates during ingest
+   /*!
+    * Case insensitive search for files with the same name but 
+    * with letters that have different case than the input name. 
+    *
+    * On Windows there can only be one match, but the case can be 
+    * different than the input name. On UNIX there can be multiple 
+    * matches.
+    *
+    * If the bExcludeExactMatch input parameter is set to false, 
+    * the original input name will be included in the 'result'
+    * vector if it is found in the directory. Otherwise (the default),
+    * the input name is excluded from the 'result' vector even if it
+    * is found in the directory.
+    *
+    * Returns true if a name has been added to the result vector.
+    */
+   bool findCaseInsensitiveEquivalents( const ossimFilename &filename, 
+                                        std::vector<ossimFilename>& result,
+                                        bool bExcludeExactMatch = true );
    
    // TODO using scandir() when available later, emulating it otherwise
    
diff --git a/Utilities/otbossim/include/ossim/base/ossimDms.h b/Utilities/otbossim/include/ossim/base/ossimDms.h
index 789e673d96c067f3ea03cc5402de0ea6eca4389c..4b5b8e2c8bfa2f4035c3ba2e40d137a6e04ef7c6 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDms.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDms.h
@@ -8,7 +8,7 @@
 //
 // Contains class definition for Degrees Minutes Seconds (ossimDms)
 //*******************************************************************
-//  $Id: ossimDms.h 12952 2008-06-01 16:23:19Z dburken $
+//  $Id: ossimDms.h 15249 2009-08-25 13:12:11Z gpotts $
 #ifndef ossimDms_HEADER
 #define ossimDms_HEADER
 // #include <iostream>
@@ -78,7 +78,7 @@ public:
     * "45 5 6"  will assume degrees minutes seconds
     * "45"      will assume degrees.
     * "-45"
-    * "4e5W"
+    * "45W"
     *
     * @return true on success, false if unhandled characters are found.
     */
diff --git a/Utilities/otbossim/include/ossim/base/ossimDpt.h b/Utilities/otbossim/include/ossim/base/ossimDpt.h
index 49525f7c9cc6e5c67229726a00e901bd687a0485..bfa6be81d1ea5f76bef8a0faeefcdb0e416e0d03 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDpt.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDpt.h
@@ -10,7 +10,7 @@
 // Used to represent an double point containing an x and y data member.
 // 
 //*******************************************************************
-//  $Id: ossimDpt.h 11398 2007-07-26 13:29:58Z dburken $
+//  $Id: ossimDpt.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimDpt_HEADER
 #define ossimDpt_HEADER
 
@@ -21,10 +21,10 @@
 #include <ossim/base/ossimString.h>
 
 // Forward class declarations.
-class OSSIMDLLEXPORT ossimIpt;
-class OSSIMDLLEXPORT ossimFpt;
-class OSSIMDLLEXPORT ossimDpt3d;
-class OSSIMDLLEXPORT ossimGpt;
+class ossimIpt;
+class ossimFpt;
+class ossimDpt3d;
+class ossimGpt;
 
 class OSSIMDLLEXPORT ossimDpt
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimDrect.h b/Utilities/otbossim/include/ossim/base/ossimDrect.h
index 62856fc33db48a2254c6a29b99f60ad41921543e..99b2a4891604da5e632e39fe98b1ee81a47e3e01 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDrect.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDrect.h
@@ -13,7 +13,7 @@
 // Container class for four double points representing a rectangle.
 // 
 //*******************************************************************
-//  $Id: ossimDrect.h 14218 2009-04-03 13:00:21Z gpotts $
+//  $Id: ossimDrect.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimDrect_HEADER
 #define ossimDrect_HEADER
@@ -42,8 +42,8 @@
 //***
 // Forward class declarations.
 //***
-class OSSIMDLLEXPORT ossimIrect;
-class OSSIMDLLEXPORT ossimPolygon;
+class ossimIrect;
+class ossimPolygon;
 
 //*******************************************************************
 // CLASS:  ossimDrect
diff --git a/Utilities/otbossim/include/ossim/base/ossimDuration.h b/Utilities/otbossim/include/ossim/base/ossimDuration.h
new file mode 100644
index 0000000000000000000000000000000000000000..c61921b111b6470befa1d4fdd4f13e5a68ada14c
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossimDuration.h
@@ -0,0 +1,166 @@
+//*******************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author: Garrett Potts
+//
+//*************************************************************************
+// $Id$
+#ifndef ossimDuration_HEADER
+#define ossimDuration_HEADER
+#include <ossim/base/ossimString.h>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimReferenced.h>
+#include <iostream>
+
+class OSSIM_DLL ossimDuration
+{
+public:
+   /**
+    * This will take an iso8601 encoded duration string and parse out
+    * the individual values
+    */
+   ossimDuration(const ossimString& iso8601Duration = ossimString(""));
+   
+   
+   /**
+    * zero out all fields
+    */
+   void clearFields();
+   
+   /**
+    * This will take an iso8601 encoded duration stream and parse out
+    * the individual values it will stop when a blank character or whitespace is found
+    */
+   bool readIso8601Encoding(std::istream& in);
+   
+   /**
+    * This will take an iso8601 encoded duration stream and parse out
+    * the individual values it will stop when a blank character or whitespace is found
+    */
+   bool setByIso8601DurationString(const ossimString& iso8601Duration);
+   
+   /**
+    * Will take the field values and encode into a iso8601 string format.
+    * Note, anything that is 0 will not be output.
+    *
+    */
+   void toIso8601DurationString(ossimString& result);
+   
+   /**
+    * this will not use the months field or the years field but will use all other
+    * fields to calculate a total value in seconds.  We can not determine leap years
+    * and how many days are in a month so those are omitted and so this serves as
+    * a utility method to just calculate the total seconds if you give a duration string
+    * that contains only one or all or any of the following: weeks, days, minutes, hours,
+    * and/or seconds.
+    *
+    * If the sign is set to negative it will return a negative value.
+    */
+   ossim_float64 toSeconds()const;
+   
+   void setSign(ossim_int32 value)
+   {
+      theSign = ((value < 0)?-1:1);
+   }
+   /**
+    * returns the sign.  Should be either -1 or 1 for the return
+    */
+   ossim_int32 sign()const
+   {
+      return theSign;
+   }
+   void setYears(ossim_uint64 value)
+   {
+      theYears = value;
+   }
+   ossim_int64 years()const
+   {
+      return theYears;
+   }
+   void setMonths(ossim_uint64 value)
+   {
+      theMonths = value;
+   }
+   ossim_int64 months()const
+   {
+      return theMonths;
+   }
+   void setWeeks(ossim_uint64 value)
+   {
+      theWeeks = value;
+   }
+   ossim_int64 weeks()const
+   {
+      return theWeeks;
+   }
+   void setDays(ossim_uint64 value)
+   {
+      theDays = value;
+   }
+   ossim_int64 days()const
+   {
+      return theDays;
+   }
+   void setHours(ossim_uint64 value)
+   {
+      theHours = value;
+   }
+   ossim_int64 hours()const
+   {
+      return theHours;
+   }
+   void setMinutes(ossim_uint64 value)
+   {
+      theMinutes = value;
+   }
+   ossim_int64 minutes()const
+   {
+      return theMinutes;
+   }
+   void setSeconds(ossim_float64 value)
+   {
+      theSeconds = value;
+   }
+   ossim_float64 seconds()const
+   {
+      return theSeconds;
+   }
+   
+   /**
+    * Sets all values in one call
+    */
+   void setAll(ossim_int32 signValue,
+               ossim_uint64 yearsValue,
+               ossim_uint64 monthsValue,
+               ossim_uint64 weeksValue,
+               ossim_uint64 daysValue,
+               ossim_uint64 hoursValue,
+               ossim_uint64 minutesValue,
+               ossim_float64 secondsValue)
+   {
+      theSign    = ((signValue < 0)?-1:1);
+      theYears   = yearsValue;
+      theMonths  = monthsValue;
+      theWeeks   = weeksValue;
+      theDays    = daysValue;
+      theHours   = hoursValue;
+      theMinutes = minutesValue;
+      theSeconds = secondsValue;
+   }
+               
+   
+protected:
+   ossim_int32 theSign; // indicates -1 for negative and anything else is positive
+   ossim_int64 theYears; // number of years
+   ossim_int64 theMonths; // number of months
+   ossim_int64 theWeeks; // number of months
+   ossim_int64 theDays;   // number of days
+   ossim_int64 theHours;  // number of hours
+   ossim_int64 theMinutes; // number of minutes
+   ossim_float64 theSeconds; // umber of Seconds
+};
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossimEllipsoid.h b/Utilities/otbossim/include/ossim/base/ossimEllipsoid.h
index 30499f7939d24fd294eeead0451a46e2a3a3b855..e3d02e19c9684a881b8daf3a530c4b90b271b96c 100644
--- a/Utilities/otbossim/include/ossim/base/ossimEllipsoid.h
+++ b/Utilities/otbossim/include/ossim/base/ossimEllipsoid.h
@@ -22,11 +22,11 @@
 #include <ossim/base/ossimString.h>
 #include <ossim/matrix/newmat.h>
 
-class OSSIMDLLEXPORT ossimEcefRay;
-class OSSIMDLLEXPORT ossimEcefPoint;
-class OSSIMDLLEXPORT ossimEcefVector;
-class OSSIMDLLEXPORT ossimMatrix4x4;
-class OSSIMDLLEXPORT ossimKeywordlist;
+class ossimEcefRay;
+class ossimEcefPoint;
+class ossimEcefVector;
+class ossimMatrix4x4;
+class ossimKeywordlist;
 
 /*!****************************************************************************
  *
diff --git a/Utilities/otbossim/include/ossim/base/ossimErrorCodes.h b/Utilities/otbossim/include/ossim/base/ossimErrorCodes.h
index 24da3e9ccada61cb98487214b980ac63b428dbfa..566ccc6a6b417c70b3c8eeb50ab8aaf742a73506 100644
--- a/Utilities/otbossim/include/ossim/base/ossimErrorCodes.h
+++ b/Utilities/otbossim/include/ossim/base/ossimErrorCodes.h
@@ -10,14 +10,14 @@
 // from code to string and string to code.
 //
 //*************************************************************************
-// $Id: ossimErrorCodes.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimErrorCodes.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimErrorCodes_HEADER
 #define ossimErrorCodes_HEADER
 
 #include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimString.h>
 
-class OSSIMDLLEXPORT ossimString;
 
 /*!
  *  class ossimErrorCodes
diff --git a/Utilities/otbossim/include/ossim/base/ossimFactoryBaseTemplate.h b/Utilities/otbossim/include/ossim/base/ossimFactoryBaseTemplate.h
index 6e8234b8e4f6571367fe958c23123eb006c069c5..1347a6cf8819dfc1e7ca33e579f9a5371881f380 100644
--- a/Utilities/otbossim/include/ossim/base/ossimFactoryBaseTemplate.h
+++ b/Utilities/otbossim/include/ossim/base/ossimFactoryBaseTemplate.h
@@ -12,15 +12,15 @@
 //              Initial coding.
 //<
 //*****************************************************************************
-//  $Id: ossimFactoryBaseTemplate.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimFactoryBaseTemplate.h 14799 2009-06-30 08:54:44Z dburken $
 
 #ifndef ossimFactory_HEADER
 #define ossimFactory_HEADER
 #include <ossim/base/ossimConstants.h>
 #include <list>
-using namespace std;
-class OSSIMDLLEXPORT ossimKeywordlist;
-class OSSIMDLLEXPORT ossimString;
+
+class ossimKeywordlist;
+class ossimString;
 
 /*!****************************************************************************
  *
@@ -78,7 +78,7 @@ public:
     * PURE VIRTUAL METHOD: getList()
     * Returns name list of all products represented by this factory:
     */
-   virtual list<ossimString> getList() const = 0;
+   virtual std::list<ossimString> getList() const = 0;
 
    /*!
     * METHOD: registerFactory()
@@ -104,7 +104,7 @@ protected:
    /*!
     * Member contains list of sub-factories associated with this factory:
     */
-   list<ossimFactoryBase<Product>*> theRegistry;
+   std::list<ossimFactoryBase<Product>*> theRegistry;
    
 };
 
diff --git a/Utilities/otbossim/include/ossim/base/ossimFactoryListInterface.h b/Utilities/otbossim/include/ossim/base/ossimFactoryListInterface.h
new file mode 100644
index 0000000000000000000000000000000000000000..35783d42dedf18d6874ed465362dacedb85377c6
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/base/ossimFactoryListInterface.h
@@ -0,0 +1,252 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossimFactoryListInterface.
+//
+//**************************************************************************************************
+// $Id$
+#ifndef ossimFactoryListInterface_HEADER
+#define ossimFactoryListInterface_HEADER
+#include <OpenThreads/ReentrantMutex>
+#include <OpenThreads/ScopedLock>
+#include <vector>
+#include <ossim/base/ossimRefPtr.h>
+
+/**
+ * The is a factory list interface that allows registries to be accessed in a common way.  
+ */
+template <class T, class NativeType>
+class ossimFactoryListInterface
+   {
+   public:
+      typedef std::vector<T*> FactoryListType;
+      ossimFactoryListInterface(){}
+      
+      /**
+       * This is for backward compatability and calls registerFactory for simple adds.
+       */
+      void addFactory(T* factory)
+      {
+         registerFactory(factory);
+      }
+      
+      /**
+       * Public access method to determine if a factory is already registered to this
+       * list
+       */
+      bool isFactoryRegistered(T* factory)const
+      {
+         if(!factory) return false;
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         
+         return findFactory(factory);
+      }
+      
+      /**
+       * Will register a factory to the factory list.  Will append the passed in factory if not
+       * already registered to the list.
+       */
+      void registerFactory(T* factory)
+      {
+         if(!factory) return;
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         if(!findFactory(factory))
+         {
+            m_factoryList.push_back(factory);
+         }
+      }
+      /**
+       * Will remove the factory from the registry.
+       */
+      void unregisterFactory(T* factory)
+      {
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         ossim_uint32 idx = 0;
+         for(idx = 0; idx < m_factoryList.size(); ++idx)
+         {
+            if(factory == m_factoryList[idx])
+            {
+               m_factoryList.erase(m_factoryList.begin() + idx);
+               return;
+            }
+         }
+      }
+      
+      /**
+       * Will remove all factories from the registry.
+       */
+      void unregisterAllFactories()
+      {
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         m_factoryList.clear();
+      }
+      
+      /**
+       * Inserts the factory to the front of the list.
+       */
+      void registerFactoryToFront(T* factory)
+      {
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         if(!findFactory(factory))
+         {
+            m_factoryList.insert(m_factoryList.begin(), factory);
+         }
+      }
+      
+      /**
+       * Will insert the factory before the beforeThisFactory.  If not found
+       * it will do a simple append.
+       */
+      void registerFactoryBefore(T* factory, T* beforeThisFactory)
+      {
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         if(!findFactory(factory))
+         {
+            ossim_uint32 idx = 0;
+            for(idx = 0; idx < m_factoryList.size(); ++idx)
+            {
+               if(beforeThisFactory == m_factoryList[idx])
+               {
+                  m_factoryList.insert(m_factoryList.begin() + idx, factory);
+                  return;
+               }
+            }
+            m_factoryList.push_back(factory);
+         }
+      }
+      
+      /**
+       *
+       * Will add all object types the factories can allocate.  Typically a list of classnames are returned
+       *
+       */
+      void getAllTypeNamesFromRegistry(std::vector<ossimString>& typeList)const;
+      
+      /**
+       * This is the base object return for all objects in the system.  This is used for 
+       * backward compatability.
+       */
+      ossimObject* createObjectFromRegistry(const ossimString& typeName)const;
+      
+      /**
+       * This is the base object return for all objects in the system.  This is used for 
+       * backward compatability.
+       */
+      ossimObject* createObjectFromRegistry(const ossimKeywordlist& kwl,
+                                            const char* prefix=0)const;
+
+      /**
+       * This is a helper method that calls the createObject and makes sure that the
+       * returned object is of the NativeType base type this registry supports.
+       */
+      NativeType* createNativeObjectFromRegistry(const ossimString& typeName)const;
+      
+      /**
+       * This is a helper method that calls the createObject and makes sure that the
+       * returned object is of the NativeType base type this registry supports.
+       *
+       * @param kwl is a state keywordlist allowing one to instantiate an object 
+       *        defined by a set of name value pairs.  It will use the type 
+       *        keyword to create an object of the defined type and then load the 
+       *        state.
+       */
+      NativeType* createNativeObjectFromRegistry(const ossimKeywordlist& kwl,
+                                                 const char* prefix=0)const;
+   protected:
+      /**
+       * Utility to find a factory in the list
+       */
+      bool findFactory(T* factory)const
+      {
+         if(!factory) return false;
+         ossim_uint32 idx = 0;
+         for(;idx < m_factoryList.size();++idx)
+         {
+            if(m_factoryList[idx] == factory)
+            {
+               return true;
+            }
+         }
+         
+         return false;
+      }
+      mutable OpenThreads::ReentrantMutex m_factoryListMutex;
+      FactoryListType m_factoryList;
+   };
+
+template <class T, class NativeType>
+void ossimFactoryListInterface<T, NativeType>::getAllTypeNamesFromRegistry(std::vector<ossimString>& typeList)const
+{
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   ossim_uint32 idx = 0;
+   for(; idx<m_factoryList.size(); ++idx)
+   {
+      m_factoryList[idx]->getTypeNameList(typeList);
+   }
+}
+template <class T, class NativeType>
+ossimObject* ossimFactoryListInterface<T, NativeType>::createObjectFromRegistry(const ossimString& typeName)const
+{
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   ossimObject* result = 0;
+   ossim_uint32 idx = 0;
+   for(;((idx<m_factoryList.size())&&!result); ++idx)
+   {
+      result = m_factoryList[idx]->createObject(typeName);
+   }
+   return result;
+}
+
+template <class T, class NativeType>
+ossimObject* ossimFactoryListInterface<T, NativeType>::createObjectFromRegistry(const ossimKeywordlist& kwl,
+                                                                                const char* prefix)const
+{
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   ossimObject* result = 0;
+   ossim_uint32 idx = 0;
+   for(;((idx<m_factoryList.size())&&!result); ++idx)
+   {
+      result = m_factoryList[idx]->createObject(kwl, prefix);
+   }
+   return result;
+}
+
+template <class T, class NativeType>
+NativeType* ossimFactoryListInterface<T, NativeType>::createNativeObjectFromRegistry(const ossimString& typeName)const
+{
+   NativeType* result = 0;
+   ossimRefPtr<ossimObject> tempObject = createObjectFromRegistry(typeName);
+   if(tempObject.valid())
+   {
+      result = dynamic_cast<NativeType*>(tempObject.get());
+      if(result)
+      {
+         tempObject.release();
+      }
+   }
+   
+   return result;
+}
+
+template <class T, class NativeType>
+NativeType* ossimFactoryListInterface<T, NativeType>::createNativeObjectFromRegistry(const ossimKeywordlist& kwl,
+                                                                                     const char* prefix)const
+{
+   NativeType* result = 0;
+   ossimRefPtr<ossimObject> tempObject = createObjectFromRegistry(kwl, prefix);
+   if(tempObject.valid())
+   {
+      result = dynamic_cast<NativeType*>(tempObject.get());
+      if(result)
+      {
+         tempObject.release();
+      }
+   }
+   
+   return result;
+}
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/base/ossimFilename.h b/Utilities/otbossim/include/ossim/base/ossimFilename.h
index a8023f1bd3fc190f7a8b91093e660f4c59ea29dc..12c7155b9061e28deaeecec20838ef1838467f11 100644
--- a/Utilities/otbossim/include/ossim/base/ossimFilename.h
+++ b/Utilities/otbossim/include/ossim/base/ossimFilename.h
@@ -9,7 +9,7 @@
 // Description: This class provides manipulation of filenames.
 //
 //*************************************************************************
-// $Id: ossimFilename.h 14233 2009-04-07 01:16:26Z dburken $
+// $Id: ossimFilename.h 14886 2009-07-15 15:40:50Z gpotts $
 
 #ifndef ossimFilename_HEADER
 #define ossimFilename_HEADER
@@ -229,6 +229,8 @@ public:
     */
    bool needsExpansion() const;
    
+   protected:
+	   void convertToNative();
    /*!
     * since windows uses \ for path separation
     * and unix / we need to be consistent.
diff --git a/Utilities/otbossim/include/ossim/base/ossimFpt.h b/Utilities/otbossim/include/ossim/base/ossimFpt.h
index 947a0eeb99213f34bcd818862c3fc1c2819382c0..b85456d6d32a1711362b71f6a277826527750d4f 100644
--- a/Utilities/otbossim/include/ossim/base/ossimFpt.h
+++ b/Utilities/otbossim/include/ossim/base/ossimFpt.h
@@ -9,7 +9,7 @@
 // Contains class declaration for fpt.
 // Used to represent a two dimensional point containing data members x and y.
 //*******************************************************************
-//  $Id: ossimFpt.h 11398 2007-07-26 13:29:58Z dburken $
+//  $Id: ossimFpt.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimFpt_HEADER
 #define ossimFpt_HEADER
@@ -17,8 +17,8 @@
 #include <ossim/base/ossimCommon.h>
 
 // Forward class declarations.
-class OSSIMDLLEXPORT ossimIpt;
-class OSSIMDLLEXPORT ossimDpt;
+class ossimIpt;
+class ossimDpt;
 
 
 class OSSIMDLLEXPORT ossimFpt
diff --git a/Utilities/otbossim/include/ossim/base/ossimGeoid.h b/Utilities/otbossim/include/ossim/base/ossimGeoid.h
index 40e1a41ddb5fb27ea0aac9b56a0f2a310f26d41d..0beef8d8db3fbd9a9de3ba63f307a5ae6c1abb38 100644
--- a/Utilities/otbossim/include/ossim/base/ossimGeoid.h
+++ b/Utilities/otbossim/include/ossim/base/ossimGeoid.h
@@ -19,8 +19,8 @@
 #include <ossim/base/ossimObject.h>
 #include <ossim/base/ossimErrorStatusInterface.h>
 
-class OSSIMDLLEXPORT ossimGpt;
-class OSSIMDLLEXPORT ossimFilename;
+class ossimGpt;
+class ossimFilename;
 
 class OSSIMDLLEXPORT ossimGeoid : public ossimObject,
 				  public ossimErrorStatusInterface
diff --git a/Utilities/otbossim/include/ossim/base/ossimGeoidEgm96.h b/Utilities/otbossim/include/ossim/base/ossimGeoidEgm96.h
index 530768f8aff9067d81b75b01edca008137ff94a2..3d6bd87dab0d8c35cfea8197d20864d04e28eec1 100644
--- a/Utilities/otbossim/include/ossim/base/ossimGeoidEgm96.h
+++ b/Utilities/otbossim/include/ossim/base/ossimGeoidEgm96.h
@@ -10,7 +10,7 @@
 // "Earth Gravity Model 1996".
 //
 //*******************************************************************
-//  $Id: ossimGeoidEgm96.h 11496 2007-08-06 09:18:28Z dburken $
+//  $Id: ossimGeoidEgm96.h 14799 2009-06-30 08:54:44Z dburken $
 
 #ifndef ossimGeoidEgm96_HEADER
 #define ossimGeoidEgm96_HEADER
@@ -25,7 +25,7 @@
 #define GEOID_LAT_ERROR             0x0008
 #define GEOID_LON_ERROR             0x0010
 
-class OSSIMDLLEXPORT ossimGpt;
+class ossimGpt;
 
 class OSSIMDLLEXPORT ossimGeoidEgm96 : public ossimGeoid
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimHsvVector.h b/Utilities/otbossim/include/ossim/base/ossimHsvVector.h
index cc34a7d89abdef6af33f0ac4d34137eb4ac7d636..773a517b66c1aa2c83ce893654ae2e32f86738c5 100644
--- a/Utilities/otbossim/include/ossim/base/ossimHsvVector.h
+++ b/Utilities/otbossim/include/ossim/base/ossimHsvVector.h
@@ -6,13 +6,14 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimHsvVector.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimHsvVector.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimHsvVector_HEADER
 #define ossimHsvVector_HEADER
 #include <iostream>
 using namespace std;
 #include <ossim/base/ossimConstants.h>
-class OSSIMDLLEXPORT ossimRgbVector;
+
+class ossimRgbVector;
 
 class OSSIMDLLEXPORT ossimHsvVector
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimImageAoiListener.h b/Utilities/otbossim/include/ossim/base/ossimImageAoiListener.h
index bf778c59f22e05ab435c410945b19d34c58b1aa2..ddf71d2a2335e841bd69dccbbac3d76fb0f87b72 100644
--- a/Utilities/otbossim/include/ossim/base/ossimImageAoiListener.h
+++ b/Utilities/otbossim/include/ossim/base/ossimImageAoiListener.h
@@ -5,13 +5,13 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageAoiListener.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimImageAoiListener.h 14799 2009-06-30 08:54:44Z dburken $
 #ifndef ossimImageAoiListener_HEADER
 #define ossimImageAoiListener_HEADER
 #include <ossim/base/ossimListener.h>
 
-class OSSIMDLLEXPORT ossimImageRectangleEvent;
-class OSSIMDLLEXPORT ossimImagePolygonEvent;
+class ossimImageRectangleEvent;
+class ossimImagePolygonEvent;
 
 class OSSIMDLLEXPORT ossimImageAoiListener : public ossimListener
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimIpt.h b/Utilities/otbossim/include/ossim/base/ossimIpt.h
index bbb7e6ebb758bbb0f534f678fe61b72460a7a643..096221fa2c5a5191d2b5b9fdb8b9d59a6780cd86 100644
--- a/Utilities/otbossim/include/ossim/base/ossimIpt.h
+++ b/Utilities/otbossim/include/ossim/base/ossimIpt.h
@@ -10,7 +10,7 @@
 // Used to represent an interger point containing an x and y data member.
 // 
 //*******************************************************************
-//  $Id: ossimIpt.h 11414 2007-07-27 15:10:00Z dburken $
+//  $Id: ossimIpt.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimIpt_HEADER
 #define ossimIpt_HEADER
@@ -21,9 +21,9 @@
 #include <ossim/base/ossimDpt.h>
 
 // Forward class declarations.
-class OSSIMDLLEXPORT ossimFpt;
-class OSSIMDLLEXPORT ossimDpt3d;
-class OSSIMDLLEXPORT ossimString;
+class ossimFpt;
+class ossimDpt3d;
+class ossimString;
 
 class OSSIMDLLEXPORT ossimIpt
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimIrect.h b/Utilities/otbossim/include/ossim/base/ossimIrect.h
index 12634d3e1d24eddd6c10062349f8be9fd838f29f..d57a28fc8208e2f8caff7d57ec37d8f5df7f6c0d 100644
--- a/Utilities/otbossim/include/ossim/base/ossimIrect.h
+++ b/Utilities/otbossim/include/ossim/base/ossimIrect.h
@@ -10,7 +10,7 @@
 // Container class for four integer points representing a rectangle.
 //
 //*******************************************************************
-//  $Id: ossimIrect.h 14217 2009-04-03 12:59:37Z gpotts $
+//  $Id: ossimIrect.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimIrect_HEADER
 #define ossimIrect_HEADER 1
@@ -38,8 +38,8 @@
 //***
 // Forward class declarations.
 //***
-class OSSIMDLLEXPORT ossimDrect;
-class OSSIMDLLEXPORT ossimKeywordlist;
+class ossimDrect;
+class ossimKeywordlist;
 
 //*******************************************************************
 // CLASS:  ossimIrect
diff --git a/Utilities/otbossim/include/ossim/base/ossimJpegYCbCrVector.h b/Utilities/otbossim/include/ossim/base/ossimJpegYCbCrVector.h
index 44533658fb9c7c2f2301f6a57bbea86c8075431b..e3b3670db31a5742197a76d6a0746d9f587815f2 100644
--- a/Utilities/otbossim/include/ossim/base/ossimJpegYCbCrVector.h
+++ b/Utilities/otbossim/include/ossim/base/ossimJpegYCbCrVector.h
@@ -6,14 +6,14 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimJpegYCbCrVector.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimJpegYCbCrVector.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimJpegYCbCrVector_HEADER
 #define ossimJpegYCbCrVector_HEADER
 #include <iostream>
 using namespace std;
 #include <ossim/base/ossimConstants.h>
 
-class OSSIMDLLEXPORT ossimRgbVector;
+class ossimRgbVector;
 
 class OSSIMDLLEXPORT ossimJpegYCbCrVector
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimKeywordNames.h b/Utilities/otbossim/include/ossim/base/ossimKeywordNames.h
index e1595f0d53ab578b615ac41cee71535100484a60..9095ef5bf52a4872c795305c69b3bc47857ad58c 100644
--- a/Utilities/otbossim/include/ossim/base/ossimKeywordNames.h
+++ b/Utilities/otbossim/include/ossim/base/ossimKeywordNames.h
@@ -8,7 +8,7 @@
 // Description: Common file for global Keywors.
 //
 //*************************************************************************
-// $Id: ossimKeywordNames.h 11731 2007-09-17 13:48:57Z gpotts $
+// $Id: ossimKeywordNames.h 15464 2009-09-23 19:30:35Z okramer $
 
 #ifndef ossimKeywordNames_HEADER
 #define ossimKeywordNames_HEADER
@@ -77,6 +77,7 @@ public:
    static const char* HORIZONTAL_SIZE_KW;
    static const char* ID_KW;
    static const char* IMAGE_FILE_KW;
+   static const char* IMAGE_ID_KW;
    static const char* IMAGE_MODEL_TRANSFORM_MATRIX_KW;
    static const char* IMAGE_MODEL_TRANSFORM_UNIT_KW;
    static const char* IMAGE_PATH_KW;
@@ -138,6 +139,11 @@ public:
    static const char* QUALITY_KW;
    static const char* RADIOMETRY_KW;
    static const char* REDUCED_RES_LEVEL_KW;
+   static const char* REF_GPT_LAT_KW;
+   static const char* REF_GPT_LON_KW;
+   static const char* REF_GPT_HGT_KW;
+   static const char* REF_IPT_LINE_KW;
+   static const char* REF_IPT_SAMP_KW;
    static const char* ROTATION_KW;
    static const char* SCALAR_TYPE_KW;
    static const char* SCALE_PER_PIXEL_X_KW;
@@ -147,6 +153,7 @@ public:
    static const char* SCALE_Y_KW;
    static const char* SCALE_FACTOR_X_KW;
    static const char* SCALE_FACTOR_Y_KW;
+   static const char* SENSOR_ID_KW;
    static const char* STD_PARALLEL_1_KW;
    static const char* STD_PARALLEL_2_KW;
    static const char* THICKNESS_KW;
diff --git a/Utilities/otbossim/include/ossim/base/ossimKeywordlist.h b/Utilities/otbossim/include/ossim/base/ossimKeywordlist.h
index b0ad111e58d76b792e335a0a965c52fb52df86a0..7273dbd4ca875f4b0a04e504b2d1fedc8ea15f9e 100644
--- a/Utilities/otbossim/include/ossim/base/ossimKeywordlist.h
+++ b/Utilities/otbossim/include/ossim/base/ossimKeywordlist.h
@@ -8,7 +8,7 @@
 // Description: This class provides capabilities for keywordlists.
 //
 //********************************************************************
-// $Id: ossimKeywordlist.h 13015 2008-06-10 16:04:52Z dburken $
+// $Id: ossimKeywordlist.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimKeywordlist_HEADER
 #define ossimKeywordlist_HEADER
@@ -25,8 +25,7 @@
 
 static const char DEFAULT_DELIMITER = ':';
 
-class OSSIMDLLEXPORT ossimFilename;
-class OSSIMDLLEXPORT ossimString;
+class ossimFilename;
 
 
 class OSSIMDLLEXPORT ossimKeywordlist : public ossimErrorStatusInterface,
@@ -163,9 +162,7 @@ public:
    void add(const char*   key,
             ossim_float32 value,
             bool          overwrite    = true,
-            int           precision    = 8,
-            bool          trimZeroFlag = false,
-            bool          scientific   = false);
+            int           precision    = 8);
 
    /**
     * @param key Key for key-value pair.
@@ -185,9 +182,7 @@ public:
             const char*   key,
             ossim_float32 value,
             bool          overwrite    = true,
-            int           precision    = 8,
-            bool          trimZeroFlag = false,
-            bool          scientific   = false);
+            int           precision    = 8);
 
    /**
     * @param key Key for key-value pair.
@@ -206,9 +201,7 @@ public:
    void add(const char*   key,
             ossim_float64 value,
             bool          overwrite    = true,
-            int           precision    = 15,
-            bool          trimZeroFlag = false,
-            bool          scientific   = false);
+            int           precision    = 15);
 
    /**
     * @param key Key for key-value pair.
@@ -228,9 +221,7 @@ public:
             const char*   key,
             ossim_float64 value,
             bool          overwrite    = true,
-            int           precision    = 15,
-            bool          trimZeroFlag = false,
-            bool          scientific   = false);
+            int           precision    = 15);
 
    /*!
     *  find methods
diff --git a/Utilities/otbossim/include/ossim/base/ossimListener.h b/Utilities/otbossim/include/ossim/base/ossimListener.h
index 34bbe76cd07cc7d90d4561a5b07e82dd4e80ee50..041b2848e38e3ee31402121c5b3a1bd5b9323b46 100644
--- a/Utilities/otbossim/include/ossim/base/ossimListener.h
+++ b/Utilities/otbossim/include/ossim/base/ossimListener.h
@@ -8,12 +8,12 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimListener.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimListener.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimListener_HEADER
 #define ossimListener_HEADER
 #include <ossim/base/ossimObject.h>
 
-class OSSIMDLLEXPORT ossimEvent;
+class ossimEvent;
 
 /*!
  * Base class for all listners.  Listners nned to derive from this
diff --git a/Utilities/otbossim/include/ossim/base/ossimListenerManager.h b/Utilities/otbossim/include/ossim/base/ossimListenerManager.h
index f0286a761b0f48b8da0bf3d9df1d043826582f59..15558a0b9998ebc0bfb5b14a1b6359d2f8ce11df 100644
--- a/Utilities/otbossim/include/ossim/base/ossimListenerManager.h
+++ b/Utilities/otbossim/include/ossim/base/ossimListenerManager.h
@@ -7,15 +7,15 @@
 //
 //
 //*************************************************************************
-// $Id: ossimListenerManager.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimListenerManager.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimListenerManager_HEADER
 #define ossimListenerManager_HEADER
 #include <ossim/base/ossimConstants.h>
 #include <list>
 #include <ossim/base/ossimRtti.h>
 
-class OSSIMDLLEXPORT ossimListener;
-class OSSIMDLLEXPORT ossimEvent;
+class ossimListener;
+class ossimEvent;
 
 class OSSIMDLLEXPORT ossimListenerManager
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimLookUpTable.h b/Utilities/otbossim/include/ossim/base/ossimLookUpTable.h
index c6d415b1ff67178064f9a7632170e5d2f0908c4c..2a8400f10e71d177b315f1b93206ddd99b497f99 100644
--- a/Utilities/otbossim/include/ossim/base/ossimLookUpTable.h
+++ b/Utilities/otbossim/include/ossim/base/ossimLookUpTable.h
@@ -11,7 +11,7 @@
 //
 // Contains class declaration for LookUpTable. 
 //*******************************************************************
-//  $Id: ossimLookUpTable.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimLookUpTable.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimLookUpTable_HEADER
 #define ossimLookUpTable_HEADER
@@ -22,7 +22,7 @@
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimKeyword.h>
 
-class OSSIMDLLEXPORT ossimKeywordlist;
+class ossimKeywordlist;
 
 //*******************************************************************
 // CLASS:  LookUpTable
diff --git a/Utilities/otbossim/include/ossim/base/ossimMatrix3x3.h b/Utilities/otbossim/include/ossim/base/ossimMatrix3x3.h
index 9c5d7be6ac271615c870f00c505210dce8ebc214..f5ac9031190b373e105b15137e2e8ed9b74e74ba 100644
--- a/Utilities/otbossim/include/ossim/base/ossimMatrix3x3.h
+++ b/Utilities/otbossim/include/ossim/base/ossimMatrix3x3.h
@@ -9,7 +9,7 @@
 // Helper class for using NEWMAT::Matrix's.
 //
 //*******************************************************************
-//  $Id: ossimMatrix3x3.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimMatrix3x3.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimMatrix3x3_HEADER
 #define ossimMatrix3x3_HEADER
@@ -20,7 +20,7 @@
 #include <ossim/matrix/newmatio.h>
 #include <ossim/base/ossimConstants.h>
 
-class OSSIMDLLEXPORT ossimColumnVector3d;
+class ossimColumnVector3d;
 
 class OSSIMDLLEXPORT ossimMatrix3x3
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimMultiBandHistogram.h b/Utilities/otbossim/include/ossim/base/ossimMultiBandHistogram.h
index 945222254d8adb41936e036539e23d4a88c110cc..2e9adf5535a56432385a30a2f7918cff47495c99 100644
--- a/Utilities/otbossim/include/ossim/base/ossimMultiBandHistogram.h
+++ b/Utilities/otbossim/include/ossim/base/ossimMultiBandHistogram.h
@@ -7,7 +7,7 @@
 // Description: 
 //
 //*******************************************************************
-//  $Id: ossimMultiBandHistogram.h 11724 2007-09-13 19:28:07Z gpotts $
+//  $Id: ossimMultiBandHistogram.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMultiBandHistogram_HEADER
 #define ossimMultiBandHistogram_HEADER
 #include <vector>
@@ -16,8 +16,8 @@
 #include <ossim/base/ossimXmlNode.h>
 #include <ossim/base/ossimReferenced.h>
 
-class OSSIMDLLEXPORT ossimHistogram;
-class OSSIMDLLEXPORT ossimKeywordlist;
+class ossimHistogram;
+class ossimKeywordlist;
 
 class OSSIMDLLEXPORT ossimMultiBandHistogram : public ossimReferenced
 {
@@ -28,7 +28,6 @@ public:
                            long numberOfBuckets,
                            float minValue,
                            float maxValue);
-   virtual ~ossimMultiBandHistogram();
 
    void create(long numberOfBands,
                long numberOfBuckets,
@@ -57,6 +56,7 @@ public:
    virtual bool loadState(const ossimRefPtr<ossimXmlNode> xmlNode);
    
 protected:
+   virtual ~ossimMultiBandHistogram();
    class  ossimProprietaryHeaderInformation
    {
    public:
diff --git a/Utilities/otbossim/include/ossim/base/ossimMultiResLevelHistogram.h b/Utilities/otbossim/include/ossim/base/ossimMultiResLevelHistogram.h
index 41481c634290ec33170d6e7c558161d01795f20c..c333c02ca5c17f8328ad6ab45ffbd96b85324a0f 100644
--- a/Utilities/otbossim/include/ossim/base/ossimMultiResLevelHistogram.h
+++ b/Utilities/otbossim/include/ossim/base/ossimMultiResLevelHistogram.h
@@ -7,7 +7,7 @@
 // Description: 
 //
 //*******************************************************************
-//  $Id: ossimMultiResLevelHistogram.h 11721 2007-09-13 13:19:34Z gpotts $
+//  $Id: ossimMultiResLevelHistogram.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMultiResLevelHistogram_HEADER
 #define ossimMultiResLevelHistogram_HEADER
 #include <vector>
@@ -25,7 +25,6 @@ public:
    ossimMultiResLevelHistogram(ossim_uint32 numberOfResLevels);
    ossimMultiResLevelHistogram(const ossimMultiResLevelHistogram& rhs);
    
-   virtual ~ossimMultiResLevelHistogram();
 
    ossimRefPtr<ossimHistogram> getHistogram(ossim_uint32 band,
                                             ossim_uint32 resLevel=0);
@@ -69,7 +68,8 @@ public:
                           const char* prefix=0)const;
    
 protected:
-   class  ossimProprietaryHeaderInformation
+   virtual ~ossimMultiResLevelHistogram();
+  class  ossimProprietaryHeaderInformation
    {
    public:
       ossimProprietaryHeaderInformation(){clear();}
diff --git a/Utilities/otbossim/include/ossim/base/ossimNBandLutDataObject.h b/Utilities/otbossim/include/ossim/base/ossimNBandLutDataObject.h
index bc706c44f4ee02050129755ca678b0ce0b561da8..2bb77d6db7b56626f0d7e25f4a5040842a2f000e 100644
--- a/Utilities/otbossim/include/ossim/base/ossimNBandLutDataObject.h
+++ b/Utilities/otbossim/include/ossim/base/ossimNBandLutDataObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimNBandLutDataObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNBandLutDataObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNBandLutDataObject_HEADER
 #define ossimNBandLutDataObject_HEADER
 #include <ossim/base/ossimObject.h>
@@ -270,7 +270,10 @@ public:
                            ossimScalarType bandScalarType = OSSIM_UINT8,
                            ossim_int32 nullPixelIndex=-1);
    ossimNBandLutDataObject(const ossimNBandLutDataObject& lut);
-   virtual ~ossimNBandLutDataObject();
+   ossimObject* dup()const
+   {
+      return new ossimNBandLutDataObject(*this);
+   }
    void create(ossim_uint32 numberOfEntries,
                ossim_uint32 numberOfBands=3);
    const LUT_ENTRY_TYPE* operator[](ossim_uint32 idx)const
@@ -444,6 +447,8 @@ public:
     */ 
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
 protected:
+   virtual ~ossimNBandLutDataObject();
+
    LUT_ENTRY_TYPE *theLut;
    ossim_uint32    theNumberOfEntries;
    ossim_uint32    theNumberOfBands;
diff --git a/Utilities/otbossim/include/ossim/base/ossimNotify.h b/Utilities/otbossim/include/ossim/base/ossimNotify.h
index 9f2fd5af195fdf555bdfdc9f718a0bce08af5a09..f214052ddef274e00415e35578592748b1f5ebf3 100644
--- a/Utilities/otbossim/include/ossim/base/ossimNotify.h
+++ b/Utilities/otbossim/include/ossim/base/ossimNotify.h
@@ -7,7 +7,7 @@
 //
 // Contains class declaration for ossimNotify
 //-------------------------------------------------------------------
-//  $Id: ossimNotify.h 9370 2006-08-02 22:02:58Z dburken $
+//  $Id: ossimNotify.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimNotify_HEADER
 #define ossimNotify_HEADER
 #include <iostream>
@@ -22,7 +22,7 @@ extern "C"
   * Notification level enumeration.  This specifies the
   * level of the mesage being written.
   */
-OSSIMDLLEXPORT enum ossimNotifyLevel
+enum ossimNotifyLevel
 {
    ossimNotifyLevel_ALWAYS = 0,
    ossimNotifyLevel_FATAL  = 1,
@@ -36,7 +36,7 @@ OSSIMDLLEXPORT enum ossimNotifyLevel
  * Flags to allow the user to turn off certain notification levels
  * 
  */
-OSSIMDLLEXPORT enum ossimNotifyFlags
+enum ossimNotifyFlags
 {
    ossimNotifyFlags_NONE   = 0,
    ossimNotifyFlags_FATAL  = 1,
diff --git a/Utilities/otbossim/include/ossim/base/ossimObject.h b/Utilities/otbossim/include/ossim/base/ossimObject.h
index f38264f54b1feaed0a06ae8dfa8175f1ecfcba12..95b3e1fd8048f85bdb789bfa319c1ff127d230dc 100644
--- a/Utilities/otbossim/include/ossim/base/ossimObject.h
+++ b/Utilities/otbossim/include/ossim/base/ossimObject.h
@@ -8,7 +8,7 @@
 // Description: Base class for ossim objects.
 //
 //*************************************************************************
-// $Id: ossimObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimObject.h 15798 2009-10-23 19:15:20Z gpotts $
 
 #ifndef ossimObject_HEADER
 #define ossimObject_HEADER
diff --git a/Utilities/otbossim/include/ossim/base/ossimObjectDestructingEvent.h b/Utilities/otbossim/include/ossim/base/ossimObjectDestructingEvent.h
index 75258d850d4ffb47b6bbe609f2a4c32da80da3ba..a14aa1ee5ca920ec4af5c160ab70b35d6fe8dc60 100644
--- a/Utilities/otbossim/include/ossim/base/ossimObjectDestructingEvent.h
+++ b/Utilities/otbossim/include/ossim/base/ossimObjectDestructingEvent.h
@@ -4,7 +4,8 @@
 #include <ossim/base/ossimEvent.h>
 #include <ossim/base/ossimEventIds.h>
 
-class OSSIMDLLEXPORT ossimObject;
+class ossimObject;
+
 class OSSIMDLLEXPORT ossimObjectDestructingEvent : public ossimEvent
 {
 public:
diff --git a/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h b/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h
index ffd14323e16dc26e39f040d9d4160a936e03d446..803eae1955e5c908c07d2961ac9a17871782f9d5 100644
--- a/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h
@@ -6,43 +6,42 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimObjectFactoryRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
+// $Id: ossimObjectFactoryRegistry.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimObjectFactoryRegistry_HEADER
 #define ossimObjectFactoryRegistry_HEADER
 #include <vector>
 
 #include <ossim/base/ossimObject.h>
+#include <ossim/base/ossimObjectFactory.h>
+#include <ossim/base/ossimFactoryListInterface.h>
 
-class OSSIMDLLEXPORT ossimObjectFactory;
-class OSSIMDLLEXPORT ossimKeywordlist;
-class OSSIMDLLEXPORT ossimString;
-
-class OSSIMDLLEXPORT ossimObjectFactoryRegistry : public ossimObject
+class ossimKeywordlist;
+class ossimString;
+class OSSIMDLLEXPORT ossimObjectFactoryRegistry : public ossimObject,
+                                                  public ossimFactoryListInterface<ossimObjectFactory, ossimObject>
 {
 public:
    virtual ~ossimObjectFactoryRegistry();
    static ossimObjectFactoryRegistry* instance();
-   /*!
-    * Should use the registerFactory to add a factory to the list.
-    * This method will call registerFactory.
-    */
-   bool                addFactory(ossimObjectFactory* factory);
-
-   /*!
-    * Registers a factory to the list.
-    */
-   bool                registerFactory(ossimObjectFactory* factory);
-   void                unregisterFactory(ossimObjectFactory* factory);
    
-   virtual ossimObject* createObject(const ossimString& name)const;
+   virtual ossimObject* createObject(const ossimString& name)const
+   {
+      return createObjectFromRegistry(name);
+   }
    virtual ossimObject* createObject(const ossimKeywordlist& kwl,
-                                     const char* prefix=0)const;
+                                     const char* prefix=0)const
+   {
+      return createObjectFromRegistry(kwl, prefix);
+   }
    
    /*!
     * Returns a type list of all objects that can be instantiated
     * through the createObjectMethods above.
     */
-   virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
+   virtual void getTypeNameList(std::vector<ossimString>& typeList)const
+   {
+      getAllTypeNamesFromRegistry(typeList);
+   }
 
    /*!
     * returns a list of objects that are of the passed in
@@ -61,9 +60,9 @@ protected:
    ossimObjectFactoryRegistry(const ossimObjectFactoryRegistry&):ossimObject(){}//hide
    void operator =(const ossimObjectFactoryRegistry&){}//hide
    
-   std::vector<ossimObjectFactory*>   theFactoryList;
+//   std::vector<ossimObjectFactory*>   theFactoryList;
 
-   ossimObjectFactory* findFactory(ossimObjectFactory* factory)const;
+//   ossimObjectFactory* findFactory(ossimObjectFactory* factory)const;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/base/ossimPolyLine.h b/Utilities/otbossim/include/ossim/base/ossimPolyLine.h
index a1c6c1742123c9e77a6e493aeac08e69f134b042..18d0dab285eb4943edc2d11b886be8fab355cb3e 100644
--- a/Utilities/otbossim/include/ossim/base/ossimPolyLine.h
+++ b/Utilities/otbossim/include/ossim/base/ossimPolyLine.h
@@ -11,7 +11,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimPolyLine.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimPolyLine.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimPolyLine_HEADER
 #define ossimPolyLine_HEADER
@@ -23,8 +23,8 @@ using namespace std;
 #include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimIrect.h>
 #include <ossim/base/ossimString.h>
-class OSSIMDLLEXPORT ossimLine;
-class OSSIMDLLEXPORT ossimPolygon;
+class ossimLine;
+class ossimPolygon;
 
 /*!****************************************************************************
  *
diff --git a/Utilities/otbossim/include/ossim/base/ossimPolygon.h b/Utilities/otbossim/include/ossim/base/ossimPolygon.h
index e733e18564055217a1dadf2d676d935410532e4e..a51f781baa00bfcc9cdd556a1033450f284a8eeb 100644
--- a/Utilities/otbossim/include/ossim/base/ossimPolygon.h
+++ b/Utilities/otbossim/include/ossim/base/ossimPolygon.h
@@ -16,7 +16,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimPolygon.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimPolygon.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimPolygon_HEADER
 #define ossimPolygon_HEADER
@@ -28,7 +28,7 @@ using namespace std;
 #include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimIrect.h>
 
-class OSSIMDLLEXPORT ossimLine;
+class ossimLine;
 
 /******************************************************************************
  *
diff --git a/Utilities/otbossim/include/ossim/base/ossimProcessInterface.h b/Utilities/otbossim/include/ossim/base/ossimProcessInterface.h
index cc677648e0eda77afc9f9149ccffc5b099666801..288441b508369c9aded19b19c78634b3749b075b 100644
--- a/Utilities/otbossim/include/ossim/base/ossimProcessInterface.h
+++ b/Utilities/otbossim/include/ossim/base/ossimProcessInterface.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimProcessInterface.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimProcessInterface.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimProcessInterface_HEADER
 #define ossimProcessInterface_HEADER
 #include <iosfwd>
@@ -15,8 +15,8 @@
 #include <ossim/base/ossimProcessProgressEvent.h>
 #include <ossim/base/ossimListenerManager.h>
 
-class OSSIMDLLEXPORT ossimObject;
-class OSSIMDLLEXPORT ossimListenerManager;
+class ossimObject;
+class ossimListenerManager;
 
 class OSSIMDLLEXPORT ossimProcessInterface
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimProcessListener.h b/Utilities/otbossim/include/ossim/base/ossimProcessListener.h
index 5eb5126ed5b946c2928d0170859247793165dc2a..c32504cb5d36a1fc7f9592558f1347482fc74c98 100644
--- a/Utilities/otbossim/include/ossim/base/ossimProcessListener.h
+++ b/Utilities/otbossim/include/ossim/base/ossimProcessListener.h
@@ -7,12 +7,13 @@
 //
 // Author: Garrett Potts
 //
-// $Id: ossimProcessListener.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimProcessListener.h 14799 2009-06-30 08:54:44Z dburken $
 //----------------------------------------------------------------------------
 #ifndef ossimProcessListener_HEADER
 #define ossimProcessListener_HEADER
 #include <ossim/base/ossimListener.h>
-class OSSIMDLLEXPORT ossimProcessProgressEvent;
+
+class ossimProcessProgressEvent;
 
 class OSSIMDLLEXPORT ossimProcessListener : public ossimListener
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimProperty.h b/Utilities/otbossim/include/ossim/base/ossimProperty.h
index 2192fedd2b4c365da11a01566aff1d64e3868c75..3278be5ea67502871f5da9338f8607a0c90ab4b7 100644
--- a/Utilities/otbossim/include/ossim/base/ossimProperty.h
+++ b/Utilities/otbossim/include/ossim/base/ossimProperty.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimProperty.h 10174 2007-01-03 18:24:31Z gpotts $
+// $Id: ossimProperty.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimProperty_HEADER
 #define ossimProperty_HEADER
 #include <ossim/base/ossimObject.h>
@@ -29,7 +29,6 @@ public:
    };
    ossimProperty(const ossimString& name=ossimString(""));
    ossimProperty(const ossimProperty& rhs);
-   virtual ~ossimProperty();
    
    const  ossimProperty& operator = (const ossimProperty& rhs);
    virtual const ossimProperty& assign(const ossimProperty& rhs);
@@ -70,6 +69,7 @@ public:
    virtual ossimRefPtr<ossimXmlNode> toXml()const;
    
 protected:
+   virtual ~ossimProperty();
    ossimString             theName;
    ossimString             theDescription;
    bool                    theReadOnlyFlag;
diff --git a/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceFactory.h b/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceFactory.h
index 0ba0243bb4a3f2d785a14218a57ab5b506247139..1a2939e44e9a39d616e11c6a86399e9a3f3c826a 100644
--- a/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceFactory.h
+++ b/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceFactory.h
@@ -6,15 +6,15 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimPropertyInterfaceFactory.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimPropertyInterfaceFactory.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimPropertyInterfaceFactory_HEADER
 #define ossimPropertyInterfaceFactory_HEADER
 
 
 #include <ossim/base/ossimRtti.h>
 #include <ossim/base/ossimObjectFactory.h>
-class OSSIMDLLEXPORT ossimObject;
-class OSSIMDLLEXPORT ossimPropertyInterface;
+class ossimObject;
+class ossimPropertyInterface;
 
 class OSSIMDLLEXPORT ossimPropertyInterfaceFactory : public ossimObjectFactory
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceRegistry.h b/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceRegistry.h
index 1d0b7d76bd09b0caca2f652f395ff9acc1e540b5..a899d0fc09581bd82a009104380c89e4cdbb0163 100644
--- a/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceRegistry.h
+++ b/Utilities/otbossim/include/ossim/base/ossimPropertyInterfaceRegistry.h
@@ -2,8 +2,8 @@
 #define ossimPropertyInterfaceRegistry_HEADER
 #include <ossim/base/ossimObjectFactory.h>
 
-class OSSIMDLLEXPORT ossimPropertyInterfaceFactory;
-class OSSIMDLLEXPORT ossimPropertyInterface;
+class ossimPropertyInterfaceFactory;
+class ossimPropertyInterface;
 
 #include <ossim/base/ossimRtti.h>
 
@@ -39,7 +39,6 @@ public:
    
    bool addFactory( ossimPropertyInterfaceFactory* factory );
    bool registerFactory(ossimPropertyInterfaceFactory* factory);
-
 protected:
    ossimPropertyInterfaceRegistry()
       :ossimObjectFactory()
diff --git a/Utilities/otbossim/include/ossim/base/ossimQuadTreeWarp.h b/Utilities/otbossim/include/ossim/base/ossimQuadTreeWarp.h
index 876973b4a21f9815b0a0d35b1a1dbf3657b68600..b16397b7aa490ed03c88bce7cd6c9a4659600d06 100644
--- a/Utilities/otbossim/include/ossim/base/ossimQuadTreeWarp.h
+++ b/Utilities/otbossim/include/ossim/base/ossimQuadTreeWarp.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimQuadTreeWarp.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimQuadTreeWarp.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimQuadTreeWarp_HEADER
 #define ossimQuadTreeWarp_HEADER
 
@@ -19,7 +19,7 @@
 #include <vector>
 #include <iosfwd>
 
-class OSSIMDLLEXPORT ossimQuadTreeWarpNode;
+class ossimQuadTreeWarpNode;
 
 class OSSIMDLLEXPORT ossimQuadTreeWarpVertex
 {
@@ -122,7 +122,6 @@ public:
 
    virtual ossimObject* dup()const;
 
-   virtual ~ossimQuadTreeWarp();
    
    virtual ossimDpt getOrigin()const;
 
@@ -248,6 +247,7 @@ public:
    
       
 protected:
+   virtual ~ossimQuadTreeWarp();
    bool                             theWarpEnabledFlag;
    ossimQuadTreeWarpNode*           theTree;
    std::vector<ossimQuadTreeWarpVertex*> theVertexList;
diff --git a/Utilities/otbossim/include/ossim/base/ossimRectilinearDataObject.h b/Utilities/otbossim/include/ossim/base/ossimRectilinearDataObject.h
index 9ac215db579e129408b828f799bbc47370f2a807..7e6a98441372925dbfcb18d518f2df254347a1c3 100644
--- a/Utilities/otbossim/include/ossim/base/ossimRectilinearDataObject.h
+++ b/Utilities/otbossim/include/ossim/base/ossimRectilinearDataObject.h
@@ -1,11 +1,13 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRectilinearDataObject.h 9252 2006-07-14 14:06:13Z dburken $
+// $Id: ossimRectilinearDataObject.h 15798 2009-10-23 19:15:20Z gpotts $
 #ifndef ossimRectilinearDataObject_HEADER
 #define ossimRectilinearDataObject_HEADER
 #include <ossim/base/ossimDataObject.h>
@@ -13,6 +15,10 @@
 class OSSIMDLLEXPORT ossimRectilinearDataObject : public ossimDataObject
 {
 public:
+
+   /** default constructor */
+   ossimRectilinearDataObject();
+
    ossimRectilinearDataObject(const ossimRectilinearDataObject&rhs);
       
    ossimRectilinearDataObject(ossim_uint32 numberOfSpatialComponents,
@@ -62,8 +68,8 @@ public:
                               ossimScalarType   scalarType=OSSIM_SCALAR_UNKNOWN,
                               ossimDataObjectStatus status=OSSIM_NULL);
    
-   virtual ~ossimRectilinearDataObject();
 
+   virtual ~ossimRectilinearDataObject();
    /**
     * How many components make up this data object.  For
     * example:  If this were an RGB image data object then
@@ -121,12 +127,19 @@ public:
 
    virtual std::ostream& print(std::ostream& out) const;
 
+   /**
+    * @brief assignment operator=
+    * @param rhs The data to assign from.
+    * @param A reference to this object.
+    */
+   virtual const ossimRectilinearDataObject& operator=(
+      const ossimRectilinearDataObject& rhs);
+
 protected:
-   ossim_uint32             theNumberOfDataComponents;
-   ossim_uint32             theNumberOfSpatialComponents;
-   ossimScalarType          theScalarType;
-   std::vector<ossim_uint8> theDataBuffer;
-   ossim_uint32*            theSpatialExtents;
+   ossim_uint32              theNumberOfDataComponents;
+   ossimScalarType           theScalarType;
+   std::vector<ossim_uint8>  theDataBuffer;
+   std::vector<ossim_uint32> theSpatialExtents;
    
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/base/ossimRefPtr.h b/Utilities/otbossim/include/ossim/base/ossimRefPtr.h
index f821b0afacb8b97ad201d252cb99f876f795e2cf..4269b60c15e4ea4a1062c96f0767fc2804b3957e 100644
--- a/Utilities/otbossim/include/ossim/base/ossimRefPtr.h
+++ b/Utilities/otbossim/include/ossim/base/ossimRefPtr.h
@@ -13,17 +13,17 @@ template<class T> class ossimRefPtr
  public:
    typedef T element_type;
    
-   ossimRefPtr() :thePtr(0) {}
-   ossimRefPtr(T* t):thePtr(t)              { if (thePtr) thePtr->ref(); }
-   ossimRefPtr(const ossimRefPtr& rp):thePtr(rp.thePtr)  { if (thePtr) thePtr->ref(); }
-   ~ossimRefPtr()                           { if (thePtr) thePtr->unref(); thePtr=0; }
+   ossimRefPtr() :m_ptr(0) {}
+   ossimRefPtr(T* t):m_ptr(t)              { if (m_ptr) m_ptr->ref(); }
+   ossimRefPtr(const ossimRefPtr& rp):m_ptr(rp.m_ptr)  { if (m_ptr) m_ptr->ref(); }
+   ~ossimRefPtr()                           { if (m_ptr) m_ptr->unref(); m_ptr=0; }
    
    inline ossimRefPtr& operator = (const ossimRefPtr& rp)
       {
-         if (thePtr==rp.thePtr) return *this;
-         T* tmpPtr = thePtr;
-         thePtr = rp.thePtr;
-         if (thePtr) thePtr->ref();
+         if (m_ptr==rp.m_ptr) return *this;
+         T* tmpPtr = m_ptr;
+         m_ptr = rp.m_ptr;
+         if (m_ptr) m_ptr->ref();
          // unref second to prevent any deletion of any object which might
          // be referenced by the other object. i.e rp is child of the
          // original _ptr.
@@ -33,45 +33,44 @@ template<class T> class ossimRefPtr
    
    inline ossimRefPtr& operator = (T* ptr)
       {
-         if (thePtr==ptr) return *this;
-         T* tmpPtr = thePtr;
-         thePtr = ptr;
-         if (thePtr) thePtr->ref();
+         if (m_ptr==ptr) return *this;
+         T* tmpPtr = m_ptr;
+         m_ptr = ptr;
+         if (m_ptr) m_ptr->ref();
          // unref second to prevent any deletion of any object which might
          // be referenced by the other object. i.e rp is child of the
-         // original thePtr.
+         // original m_ptr.
          if (tmpPtr) tmpPtr->unref();
          return *this;
       }
    
    // comparison operators for ossimRefPtr.
-   inline bool operator == (const ossimRefPtr& rp) const { return (thePtr==rp.thePtr); }
-   inline bool operator != (const ossimRefPtr& rp) const { return (thePtr!=rp.thePtr); }
-   inline bool operator < (const ossimRefPtr& rp) const { return (thePtr<rp.thePtr); }
-   inline bool operator > (const ossimRefPtr& rp) const { return (thePtr>rp.thePtr); }
+   inline bool operator == (const ossimRefPtr& rp) const { return (m_ptr==rp.m_ptr); }
+   inline bool operator != (const ossimRefPtr& rp) const { return (m_ptr!=rp.m_ptr); }
+   inline bool operator < (const ossimRefPtr& rp) const { return (m_ptr<rp.m_ptr); }
+   inline bool operator > (const ossimRefPtr& rp) const { return (m_ptr>rp.m_ptr); }
    
    // comparion operator for const T*.
-   inline bool operator == (const T* ptr) const { return (thePtr==ptr); }
-   inline bool operator != (const T* ptr) const { return (thePtr!=ptr); }
-   inline bool operator < (const T* ptr) const { return (thePtr<ptr); }
-   inline bool operator > (const T* ptr) const { return (thePtr>ptr); }
+   inline bool operator == (const T* ptr) const { return (m_ptr==ptr); }
+   inline bool operator != (const T* ptr) const { return (m_ptr!=ptr); }
+   inline bool operator < (const T* ptr) const { return (m_ptr<ptr); }
+   inline bool operator > (const T* ptr) const { return (m_ptr>ptr); }
    
+   inline T& operator*()  { return *m_ptr; }
    
-   inline T& operator*()  { return *thePtr; }
+   inline const T& operator*() const { return *m_ptr; }
    
-   inline const T& operator*() const { return *thePtr; }
+   inline T* operator->() { return m_ptr; }
    
-   inline T* operator->() { return thePtr; }
+   inline const T* operator->() const   { return m_ptr; }
    
-   inline const T* operator->() const   { return thePtr; }
+   inline bool operator!() const	{ return m_ptr==0L; }
    
-   inline bool operator!() const	{ return thePtr==0L; }
+   inline bool valid() const	{ return m_ptr!=0L; }
    
-   inline bool valid() const	{ return thePtr!=0L; }
+   inline T* get() { return m_ptr; }
    
-   inline T* get() { return thePtr; }
-   
-   inline const T* get() const { return thePtr; }
+   inline const T* get() const { return m_ptr; }
    
    /** take control over the object pointed to by ref_ptr, unreference but do not delete even if ref count goes to 0,
     * return the pointer to the object.
@@ -79,10 +78,10 @@ template<class T> class ossimRefPtr
     * only use when absolutely required.*/
    inline T* take() { return release();}
    
-   inline T* release() { T* tmp=thePtr; if (thePtr) thePtr->unref_nodelete(); thePtr=0; return tmp;}
+   inline T* release() { T* tmp=m_ptr; if (m_ptr) m_ptr->unref_nodelete(); m_ptr=0; return tmp;}
    
  private:
-   T* thePtr;
+   T* m_ptr;
 };
 
 #endif
diff --git a/Utilities/otbossim/include/ossim/base/ossimRgbLutDataObject.h b/Utilities/otbossim/include/ossim/base/ossimRgbLutDataObject.h
index 3aac638a3de7145a182d7f81fe5dd354898c281c..c9c7a57c9e4bf467cbe6267112abc19191b8be58 100644
--- a/Utilities/otbossim/include/ossim/base/ossimRgbLutDataObject.h
+++ b/Utilities/otbossim/include/ossim/base/ossimRgbLutDataObject.h
@@ -6,13 +6,14 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbLutDataObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbLutDataObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbLutDataObject_HEADER
 #define ossimRgbLutDataObject_HEADER
 #include <ossim/base/ossimRgbVector.h>
 #include <ossim/base/ossimObject.h>
 #include <iosfwd>
-class OSSIMDLLEXPORT ossimKeywordlist;
+
+class ossimKeywordlist;
 
 class OSSIMDLLEXPORT ossimRgbLutDataObject : public ossimObject
 {
@@ -24,7 +25,10 @@ public:
     */
    ossimRgbLutDataObject(unsigned long numberOfEntries=0);
    ossimRgbLutDataObject(const ossimRgbLutDataObject& lut);
-   virtual ~ossimRgbLutDataObject();
+   virtual ossimObject* dup()const
+   {
+      return new ossimRgbLutDataObject(*this);
+   }
    const ossimRgbVector& operator[](unsigned int index)const
       {
          return index<theNumberOfEntries?theLut[index]:theLut[theNumberOfEntries-1];
@@ -76,6 +80,8 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
 protected:
+   virtual ~ossimRgbLutDataObject();
+
    ossimRgbVector *theLut;
    ossim_uint32 theNumberOfEntries;
 
diff --git a/Utilities/otbossim/include/ossim/base/ossimRgbVector.h b/Utilities/otbossim/include/ossim/base/ossimRgbVector.h
index d0e889f0bb040a205654c7a877b7ec8109ab8e9c..8852887611206c609dc48c74478b2dd9dcfd9414 100644
--- a/Utilities/otbossim/include/ossim/base/ossimRgbVector.h
+++ b/Utilities/otbossim/include/ossim/base/ossimRgbVector.h
@@ -6,17 +6,17 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimRgbVector.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimRgbVector.h 14789 2009-06-29 16:48:14Z dburken $
 #ifndef ossimRgbVector_HEADER
 #define ossimRgbVector_HEADER
 #include <iostream>
 using namespace std;
 #include <ossim/base/ossimConstants.h>
 
-class OSSIMDLLEXPORT ossimJpegYCbCrVector;
-class OSSIMDLLEXPORT ossimHsiVector;
-class OSSIMDLLEXPORT ossimHsvVector;
-class OSSIMDLLEXPORT ossimCmyVector;
+class ossimJpegYCbCrVector;
+class ossimHsiVector;
+class ossimHsvVector;
+class ossimCmyVector;
 
 class OSSIMDLLEXPORT ossimRgbVector
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimRtti.h b/Utilities/otbossim/include/ossim/base/ossimRtti.h
index 50f898ccebf0212128cca169a9a9c6841869b3d0..452b08cf6fafb263f48b75b0f077a9f7d9609f18 100644
--- a/Utilities/otbossim/include/ossim/base/ossimRtti.h
+++ b/Utilities/otbossim/include/ossim/base/ossimRtti.h
@@ -118,7 +118,7 @@
 #include <ossim/base/ossimConstants.h>
 /////////////////////////////////////////////////////////////
 
-class OSSIMDLLEXPORT RTTITypeinfo;
+class RTTITypeinfo;
 
 class OSSIMDLLEXPORT RTTItypeid	
 		{							// Main class for RTTI interface.
diff --git a/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h b/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h
index ad4cd63629667f96e39c99ede252ccfe22130d30..e1b904733ed6a8c9f57927152bb4d1ef9a399305 100644
--- a/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h
+++ b/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h
@@ -9,12 +9,13 @@
 // SevenParamDatum. This is a base class for all
 // seven param datums.
 //*******************************************************************
-//  $Id: ossimSevenParamDatum.h 13560 2008-09-10 11:42:57Z gpotts $
+//  $Id: ossimSevenParamDatum.h 14789 2009-06-29 16:48:14Z dburken $
 
 #ifndef ossimSevenParamDatum_HEADER
 #define ossimSevenParamDatum_HEADER
 #include <ossim/base/ossimDatum.h>
-class OSSIMDLLEXPORT ossimEllipsoid;
+
+class ossimEllipsoid;
 
 class OSSIM_DLL ossimSevenParamDatum : public ossimDatum
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimSource.h b/Utilities/otbossim/include/ossim/base/ossimSource.h
index a982302b0343c22a874709a73d786966c6e01e7d..830885c9c9e897c9436258585f3d5fb524ee0855 100644
--- a/Utilities/otbossim/include/ossim/base/ossimSource.h
+++ b/Utilities/otbossim/include/ossim/base/ossimSource.h
@@ -8,7 +8,7 @@
 // ossimConnectableObject since all source's should be connectable
 //
 //*************************************************************************
-// $Id: ossimSource.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimSource.h 15798 2009-10-23 19:15:20Z gpotts $
 
 #ifndef ossimSource_HEADER
 #define ossimSource_HEADER
@@ -17,7 +17,7 @@
 #include <ossim/base/ossimErrorStatusInterface.h>
 #include <ossim/base/ossimConstants.h>
 
-class OSSIMDLLEXPORT ossimDataObject;
+class ossimDataObject;
 
 class OSSIMDLLEXPORT ossimSource : public ossimConnectableObject,
 				   public ossimErrorStatusInterface
@@ -29,9 +29,8 @@ public:
                ossim_uint32 outputListSize,
                bool inputListIsFixedFlag=true,
                bool outputListIsFixedFlag=true);
-   
    virtual ~ossimSource();
-
+   
    virtual bool isSourceEnabled()const;
    virtual void enableSource();
    virtual void disableSource();
diff --git a/Utilities/otbossim/include/ossim/base/ossimString.h b/Utilities/otbossim/include/ossim/base/ossimString.h
index 0695a6b654c9c9b7cc60c2ef80699d71cd81e5e6..f59fa02f703f6f369341d917db2ab080d9f6cdeb 100644
--- a/Utilities/otbossim/include/ossim/base/ossimString.h
+++ b/Utilities/otbossim/include/ossim/base/ossimString.h
@@ -1,13 +1,15 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts
 // 
 // Description: This class extends the stl's string class.
 //
 //********************************************************************
-// $Id: ossimString.h 13586 2008-09-17 01:35:25Z gpotts $
+// $Id: ossimString.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimString_HEADER
 #define ossimString_HEADER 1
 
@@ -275,6 +277,12 @@ public:
    static bool          toBool(const ossimString& aString);
    int                  toInt()const;
    static int           toInt(const ossimString& aString);
+   
+   ossim_int16          toInt16()const;
+   static ossim_int16   toInt16(const ossimString& aString);
+   ossim_uint16         toUInt16()const;
+   static ossim_uint16  toUInt16(const ossimString& aString);
+
    ossim_int32          toInt32()const;
    static ossim_int32   toInt32(const ossimString& aString);
    ossim_uint32         toUInt32()const;
@@ -326,9 +334,7 @@ public:
     * "e-10" will not be trimmed to "e-1".
     */
    static ossimString toString(ossim_float32 aValue,
-                               int  precision    = 8,
-                               bool trimZeroFlag = false,
-                               bool scientific   = false );
+                               int  precision    = 8 );
    
    /**
     * @param aValue Value to convert to string.
@@ -345,9 +351,7 @@ public:
     * "e-10" will not be trimmed to "e-1".
     */
    static ossimString toString(ossim_float64 aValue,
-                               int  precision    = 15,
-                               bool trimZeroFlag = false,
-                               bool scientific   = false);
+                               int  precision    = 15);
 
    static ossimString stripLeading(const ossimString &value,
                                    char characterToStrip);
@@ -398,7 +402,7 @@ public:
    ossimString urlEncode()const;
    /**
     * If OSSIM_ID_ENABLED returns the OSSIM_ID which currently is the
-    * expanded cvs $Id: ossimString.h 13586 2008-09-17 01:35:25Z gpotts $ macro; else, an empty string.
+    * expanded cvs $Id: ossimString.h 15766 2009-10-20 12:37:09Z gpotts $ macro; else, an empty string.
     */
    ossimString getOssimId() const;
 };
diff --git a/Utilities/otbossim/include/ossim/base/ossimTDpt.h b/Utilities/otbossim/include/ossim/base/ossimTDpt.h
index f8baa2aa53b3cdb647c8a7ab1610149bb4df3fbf..d78729144f53954b7b36f644778a1e7351a9290e 100644
--- a/Utilities/otbossim/include/ossim/base/ossimTDpt.h
+++ b/Utilities/otbossim/include/ossim/base/ossimTDpt.h
@@ -10,10 +10,10 @@
 #include <ossim/base/ossimDpt.h>
 
 // Forward class declarations.
-class OSSIMDLLEXPORT ossimIpt;
-class OSSIMDLLEXPORT ossimFpt;
-class OSSIMDLLEXPORT ossimDpt3d;
-class OSSIMDLLEXPORT ossimGpt;
+class ossimIpt;
+class ossimFpt;
+class ossimDpt3d;
+class ossimGpt;
 
 class OSSIMDLLEXPORT ossimTDpt : public ossimDpt
 {
diff --git a/Utilities/otbossim/include/ossim/base/ossimTieGpt.h b/Utilities/otbossim/include/ossim/base/ossimTieGpt.h
index 5842d499092be02c95edbf8dbef306324265fd4c..fdd51e465668882cd9ac282670ef34a342cb2b64 100644
--- a/Utilities/otbossim/include/ossim/base/ossimTieGpt.h
+++ b/Utilities/otbossim/include/ossim/base/ossimTieGpt.h
@@ -6,7 +6,7 @@
 #include <ossim/base/ossimGpt.h>
 #include <ossim/base/ossimReferenced.h>
 
-class OSSIMDLLEXPORT ossimDpt;
+class ossimDpt;
 
 /**
  * storage class for tie point between ground and image
diff --git a/Utilities/otbossim/include/ossim/base/ossimTieGptSet.h b/Utilities/otbossim/include/ossim/base/ossimTieGptSet.h
index 1ec8989caa7c96137db2e33b5e4f21bc0db81901..8626f935caaea0a9e2d415d5168e6e23e730384e 100644
--- a/Utilities/otbossim/include/ossim/base/ossimTieGptSet.h
+++ b/Utilities/otbossim/include/ossim/base/ossimTieGptSet.h
@@ -8,7 +8,7 @@
 #include <ossim/base/ossimFilename.h>
 #include <ossim/matrix/newmat.h>
 
-class OSSIMDLLEXPORT ossimDpt;
+class ossimDpt;
 
 /**
  * storage class for a set of geographic tie points, between master and slave images
diff --git a/Utilities/otbossim/include/ossim/base/ossimViewController.h b/Utilities/otbossim/include/ossim/base/ossimViewController.h
index 7542cb74feae1f139cc4e97da25bc08097faf76a..4e4d7200b233b7b6f419f0396377080d2051c573 100644
--- a/Utilities/otbossim/include/ossim/base/ossimViewController.h
+++ b/Utilities/otbossim/include/ossim/base/ossimViewController.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks)
 //
 //*************************************************************************
-// $Id: ossimViewController.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimViewController.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimViewController_HEADER
 #define ossimViewController_HEADER
 #include <ossim/base/ossimSource.h>
@@ -43,7 +43,7 @@ public:
                                     const ossimConnectableObject* obj)const;
    virtual const ossimObject* findFirstViewOfType(RTTItypeid typeId)const;
 protected:
-   ossimObject* theView;
+   ossimRefPtr<ossimObject> theView;
    
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/base/ossimViewInterface.h b/Utilities/otbossim/include/ossim/base/ossimViewInterface.h
index 4fda10a8aee0ca22096daaa89c207abe5bd17fa4..3f1743d8845cfcecdec8a43ca6408a70c62f8838 100644
--- a/Utilities/otbossim/include/ossim/base/ossimViewInterface.h
+++ b/Utilities/otbossim/include/ossim/base/ossimViewInterface.h
@@ -5,12 +5,12 @@
 // Author: Garrett Potts (gpotts@imagelinks)
 //
 //*************************************************************************
-// $Id: ossimViewInterface.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimViewInterface.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimViewInterface_HEADER
 #define ossimViewInterface_HEADER
 #include <ossim/base/ossimRtti.h>
 
-class OSSIMDLLEXPORT ossimObject;
+class ossimObject;
 
 class OSSIMDLLEXPORT ossimViewInterface
 {
@@ -21,7 +21,7 @@ public:
 
    /*!
     * The derived classes should overrid this method and
-    * return true or fals whether it was able to cast the
+    * return true or false whether it was able to cast the
     * past in view to a view that it can interface to.
     * So if you are a projective view you might
     * cast to an ossimProjection.  The ownsTheView specifies
@@ -30,7 +30,7 @@ public:
     * need to re-allocate the pointer or just delete its old
     * pointer and set it to the passed in pointer.
     */
-   virtual bool setView(ossimObject* baseObject, bool ownsTheView = false)=0;
+   virtual bool setView(ossimObject* baseObject)=0;
    virtual ossimObject* getView()=0;
    virtual const ossimObject* getView()const=0;
    virtual void refreshView();
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimDtedFactory.h b/Utilities/otbossim/include/ossim/elevation/ossimDtedFactory.h
index c61f5c8b41b1dd8b0dd1204375cc8886375c3fc3..62e47c934c9efd723136a7aca09bc9d3494fb9a3 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimDtedFactory.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimDtedFactory.h
@@ -12,7 +12,7 @@
 // Class declaration for ossimDtedFactory.
 // This is the base class interface for elevation cell factories.
 //*****************************************************************************
-// $Id: ossimDtedFactory.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimDtedFactory.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimDtedFactory_HEADER
 #define ossimDtedFactory_HEADER
 
@@ -26,11 +26,11 @@ public:
    ossimDtedFactory();
    ossimDtedFactory(const ossimFilename& dir);
       
-   virtual ~ossimDtedFactory();
 
    virtual ossimElevSource* getNewElevSource(const ossimGpt& gpt) const;
    virtual void createIndex();
 protected:
+   virtual ~ossimDtedFactory();
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimDtedHandler.h b/Utilities/otbossim/include/ossim/elevation/ossimDtedHandler.h
index 398d7551c9cb40a713bb28f5c4561e8d1b5609c0..2bbb21a7260c8962331ab7c4059d1b7609648a5e 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimDtedHandler.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimDtedHandler.h
@@ -16,7 +16,7 @@
 //              Derived from ossimElevCellHandler.
 //<
 //*****************************************************************************
-// $Id: ossimDtedHandler.h 14296 2009-04-14 17:25:00Z gpotts $
+// $Id: ossimDtedHandler.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimDtedHandler_HEADER
 #define ossimDtedHandler_HEADER
@@ -34,7 +34,6 @@ class OSSIM_DLL ossimDtedHandler : public ossimElevCellHandler
 public:
    ossimDtedHandler(const ossimFilename& dted_file, bool memoryMapFlag=false);
    
-   virtual ~ossimDtedHandler();
 
    enum
    {
@@ -83,8 +82,9 @@ public:
 
    virtual void setMemoryMapFlag(bool flag);
    
-private:
-   // Disallow operator= and copy constrution...
+protected:
+   virtual ~ossimDtedHandler();
+  // Disallow operator= and copy constrution...
    const ossimDtedHandler& operator=(const ossimDtedHandler& rhs);
    ossimDtedHandler(const ossimDtedHandler&);
 
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandler.h b/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandler.h
index e6a60847aeecaf7a9d14397fae682a8d35fe05d6..7f13f9db82734b203081c57be83faa6cf7063db8 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandler.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandler.h
@@ -13,7 +13,7 @@
 //              Initial coding.
 //<
 //*****************************************************************************
-// $Id: ossimElevCellHandler.h 11317 2007-07-17 20:39:10Z dburken $
+// $Id: ossimElevCellHandler.h 15766 2009-10-20 12:37:09Z gpotts $
 
 
 #ifndef ossimElevCellHandler_HEADER
@@ -41,7 +41,6 @@ public:
    ossimElevCellHandler (const char* elev_filename);
    ossimElevCellHandler (const ossimElevCellHandler& src);
 
-   virtual ~ossimElevCellHandler();
 
    const ossimElevCellHandler& operator=(const ossimElevCellHandler& rhs);
    virtual ossimFilename getFilename() const;
@@ -85,6 +84,7 @@ public:
       
 protected:
    ossimElevCellHandler ();
+   virtual ~ossimElevCellHandler();
    
    /**
     * Virtual method for reading 
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandlerFactory.h b/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandlerFactory.h
index 424c355dcaf1cc9783b13d0d378b68c98addb3b5..762ba9509f39d87464d5410333f5aa49804cd00b 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandlerFactory.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimElevCellHandlerFactory.h
@@ -16,6 +16,7 @@
 #ifndef ossimElevCellHandlerFactory_HEADER
 #define ossimElevCellHandlerFactory_HEADER
 
+#include <list>
 #include <ossim/base/ossimFactoryBaseTemplate.h>
 
 class ossimElevCellHandler;
@@ -36,7 +37,7 @@ class ossimElevCellHandlerFactory :
    virtual ossimElevCellHandler* create(const ossimKeywordlist& kwl,
                                         const char* prefix) const;
    
-   virtual list<ossimString> getList() const;
+   virtual std::list<ossimString> getList() const;
    
  protected:
    ossimElevCellHandlerFactory();
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimElevSource.h b/Utilities/otbossim/include/ossim/elevation/ossimElevSource.h
index 8112943a97aba0cddc507c66b6f7a1618c6c38f7..df6c5fa3abcfb18177ecdd53d49a4b84259f5044 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimElevSource.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimElevSource.h
@@ -10,7 +10,7 @@
 //   all objects providing height information given horizontal ground position.
 //
 //*****************************************************************************
-// $Id: ossimElevSource.h 14297 2009-04-14 17:25:31Z gpotts $
+// $Id: ossimElevSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimElevSource_HEADER
 #define ossimElevSource_HEADER
@@ -32,7 +32,6 @@ class OSSIM_DLL ossimElevSource : public ossimSource
 {
 public:
 
-   virtual ~ossimElevSource();
 
    virtual const ossimElevSource& operator = (const ossimElevSource& src);
    /**
@@ -150,6 +149,7 @@ public:
 
 
 protected:
+   virtual ~ossimElevSource();
    /**
     * Constructors/Destructors:
     */
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimSrtmHandler.h b/Utilities/otbossim/include/ossim/elevation/ossimSrtmHandler.h
index 2ab11b7c425fcee29211dc61adf8302927778c08..b25c500c4a4c11f6471d7137eb0adede9a325196 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimSrtmHandler.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimSrtmHandler.h
@@ -9,7 +9,7 @@
 // Shuttle Radar Topography Mission (SRTM) elevation source.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimSrtmHandler.h 14298 2009-04-14 17:26:03Z gpotts $
+// $Id: ossimSrtmHandler.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimSrtmHandler_HEADER
 #define ossimSrtmHandler_HEADER
 
@@ -31,8 +31,6 @@ public:
    /** Constructor that takes a file name. */
    ossimSrtmHandler(const ossimFilename& srtmFile);
 
-   /** destructor */
-   virtual ~ossimSrtmHandler();
 
    enum
    {
@@ -73,7 +71,9 @@ public:
     */
    virtual void close();
    
-private:
+protected:
+   /** destructor */
+   virtual ~ossimSrtmHandler();
    // Disallow operator= and copy constrution...
    const ossimSrtmHandler& operator=(const ossimSrtmHandler& rhs);
    ossimSrtmHandler(const ossimSrtmHandler&);
diff --git a/Utilities/otbossim/include/ossim/font/ossimFont.h b/Utilities/otbossim/include/ossim/font/ossimFont.h
index 04f55607c29314528dd0f25bb0eab545918eea0f..4030becf26f957fd397667c3c5d5d86db42d5a67 100644
--- a/Utilities/otbossim/include/ossim/font/ossimFont.h
+++ b/Utilities/otbossim/include/ossim/font/ossimFont.h
@@ -6,7 +6,7 @@
 // Description: 
 // 
 //********************************************************************
-// $Id: ossimFont.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimFont.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFont_HEADER
 #define ossimFont_HEADER
 #include <ossim/base/ossimIpt.h>
@@ -86,8 +86,6 @@ public:
          theLocalOrigin            = rhs.theLocalOrigin;
          theAffineTransform        = rhs.theAffineTransform;
       }
-   virtual ~ossimFont()
-      {}
    virtual ossimObject* dup()const=0;
 
    /*!
@@ -289,6 +287,8 @@ public:
       }
 
 protected:
+   virtual ~ossimFont()
+   {}
    ossimString theStringToRasterize;
    ossimString theFamilyName;
    ossimString theStyleName;
diff --git a/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h b/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h
index 59b02701b1facc35115000eb12a0d08368f4c11d..95c95969db7db8c6f37e2bd544372a02cb789b71 100644
--- a/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h
@@ -6,13 +6,15 @@
 // Description: 
 // 
 //********************************************************************
-// $Id: ossimFontFactoryRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
+// $Id: ossimFontFactoryRegistry.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFontFactoryRegistry_HEADER
 #define ossimFontFactoryRegistry_HEADER
 #include <vector>
 #include <ossim/base/ossimFontInformation.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/font/ossimFontFactoryBase.h>
+#include <ossim/font/ossimFont.h>
+#include <ossim/base/ossimRefPtr.h>
 
 
 class OSSIMDLLEXPORT ossimFontFactoryRegistry
@@ -52,7 +54,7 @@ public:
    ossimFont* getDefaultFont()const;
    
 protected:
-   mutable ossimFont* theDefaultFont;
+   mutable ossimRefPtr<ossimFont> theDefaultFont;
 
    //static ossimFontFactoryRegistry* theInstance;
 
diff --git a/Utilities/otbossim/include/ossim/font/ossimFreeTypeFont.h b/Utilities/otbossim/include/ossim/font/ossimFreeTypeFont.h
index cafb3e0804f3cffab2a5d8ff85908eacb2288c0f..c207a1c0425d15388563e487098f37a59b343fe2 100644
--- a/Utilities/otbossim/include/ossim/font/ossimFreeTypeFont.h
+++ b/Utilities/otbossim/include/ossim/font/ossimFreeTypeFont.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 // 
 //********************************************************************
-// $Id: ossimFreeTypeFont.h 9105 2006-06-14 01:45:40Z gpotts $
+// $Id: ossimFreeTypeFont.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFreeTypeFont_HEADER
 #define ossimFreeTypeFont_HEADER
 
@@ -41,7 +41,6 @@ public:
       {
          return new ossimFreeTypeFont(*this);
       }
-   virtual ~ossimFreeTypeFont();
 
    virtual const ossim_uint8* getBuf()const
       {
@@ -146,8 +145,9 @@ public:
   {
     return theFontFace;
   }
-private:
-   
+protected:
+   virtual ~ossimFreeTypeFont();
+
    FT_Face       theFontFace;
    FT_Library    theLibrary;
    FT_Matrix     theMatrix;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossim3x3ConvolutionFilter.h b/Utilities/otbossim/include/ossim/imaging/ossim3x3ConvolutionFilter.h
index 5a9c596e56adc5bb282f24f3663d814735ad9e13..63637ba1aed3812282f0071f190415625a6572fc 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossim3x3ConvolutionFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossim3x3ConvolutionFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossim3x3ConvolutionFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossim3x3ConvolutionFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossim3x3ConvolutionFilter_HEADER
 #define ossim3x3ConvolutionFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossim3x3ConvolutionFilter : public ossimImageSourceFilter
 {
 public:
    ossim3x3ConvolutionFilter(ossimObject* owner=NULL);
-   virtual ~ossim3x3ConvolutionFilter();
 
    virtual ossimString getShortName()const{return ossimString("3x3 Convolution");}
    virtual ossimString getLongName()const{return ossimString("Convolves the input image with a 3x3 kernel");}
@@ -48,6 +47,7 @@ public:
                           const char* prefix = 0)const;
    
 protected:
+   virtual ~ossim3x3ConvolutionFilter();
 
    /**
     * Allocates theTile.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAOD.h b/Utilities/otbossim/include/ossim/imaging/ossimAOD.h
index 738a08b0257860fc32d21921ea386b2ffc94d88f..074c5554ad0aa8a8be789b0fcd1fc5b46ebc5a63 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAOD.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAOD.h
@@ -13,7 +13,7 @@
 // correction.
 //
 //*************************************************************************
-// $Id: ossimAOD.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAOD.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAOD_HEADER
 #define ossimAOD_HEADER
 
@@ -27,7 +27,6 @@ public:
    ossimAOD(ossimImageSource* inputSource);
    ossimAOD(ossimObject* owner, ossimImageSource* inputSource);
 
-   virtual ~ossimAOD();
 
    virtual ossimString getShortName() const;
 
@@ -49,6 +48,7 @@ public:
    static void writeTemplate(ostream& os);
 
 protected:
+   virtual ~ossimAOD();
 
    void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAdrgTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimAdrgTileSource.h
index 1eabb01b8dc4b83fc1a53a59186d232c63afa7f7..f730c3d07df741de54c292870b92bf474bff0846 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAdrgTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAdrgTileSource.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Ken Melero
 // 
@@ -8,7 +10,7 @@
 //              ADRG file.
 //
 //********************************************************************
-// $Id: ossimAdrgTileSource.h 12988 2008-06-04 16:49:43Z gpotts $
+// $Id: ossimAdrgTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAdrgTileSource_HEADER
 #define ossimAdrgTileSource_HEADER
@@ -41,11 +43,10 @@ public:
    };
       
    ossimAdrgTileSource();
-   virtual ~ossimAdrgTileSource();
 
    virtual ossimString getShortName()const;
    virtual ossimString getLongName()const;
-   virtual ossimString className()const;
+   virtual ossimString getClassName()const;
 
    /**
     *  @return Returns true on success, false on error.
@@ -64,7 +65,20 @@ public:
     */
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
-   
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);   
+
    /**
     *  Returns the number of bands in the image.
     *  Satisfies pure virtual requirement from ImageHandler class.
@@ -106,12 +120,9 @@ public:
                           const char* prefix=0);
    
    /**
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
+    *  Returns the image geometry object associated with this tile source or NULL if non defined.
     */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   virtual ossimImageGeometry* getImageGeometry();
    
    /**
     * Returns the output pixel type of the tile source.
@@ -160,7 +171,8 @@ public:
     */
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
-private:
+protected:
+   virtual ~ossimAdrgTileSource();
    
    /**
     *  Adjust point to even 128 boundary.  Assumes 0,0 origin.
@@ -171,12 +183,13 @@ private:
     *  Returns true on success, false on error.
     */
    bool fillBuffer(const ossimIrect& tile_rect,
-                   const ossimIrect& clip_rect);
+                   const ossimIrect& clip_rect,
+                   ossimImageData* tile);
    
-   ossimRefPtr<ossimImageData>  theTile;
-   ossim_uint8*                 theTileBuffer;
-   std::ifstream                theFileStr;
-   ossimAdrgHeader*             theAdrgHeader;
+   ossimRefPtr<ossimImageData>  m_Tile;
+   ossim_uint8*                 m_TileBuffer;
+   std::ifstream                m_FileStr;
+   ossimAdrgHeader*             m_AdrgHeader;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationEllipseObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationEllipseObject.h
index 3f7acac9378336512659b6ae2a234b7d6568bd2a..de8d519c38cf53d2ed2ccbcbfbcdf8d705cf5d9e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationEllipseObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationEllipseObject.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationEllipseObject.h 11360 2007-07-23 20:49:37Z dburken $
+// $Id: ossimAnnotationEllipseObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationEllipseObject_HEADER
 #define ossimAnnotationEllipseObject_HEADER
 
@@ -26,7 +26,6 @@ public:
 
    virtual ossimObject* dup()const;
 
-   virtual ~ossimAnnotationEllipseObject();
 
    virtual void applyScale(double x, double y);
 
@@ -88,6 +87,7 @@ public:
                           const char* prefix=0);
    
 protected:
+   virtual ~ossimAnnotationEllipseObject();
    ossimDpt      theCenter;
    ossimDpt      theWidthHeight;
    ossim_float64 theAzimuthInDegrees;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationFontObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationFontObject.h
index f705d98d32ab345c71fc0ce879f6673eec7040fe..c55faeed93b1753cf7d3c15a208e62793357835f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationFontObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationFontObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationFontObject.h 13967 2009-01-14 16:32:01Z gpotts $
+// $Id: ossimAnnotationFontObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationFontObject_HEADER
 #define ossimAnnotationFontObject_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
@@ -42,7 +42,6 @@ public:
    ossimAnnotationFontObject(const ossimAnnotationFontObject& rhs);
                              
    
-   virtual ~ossimAnnotationFontObject();
 
    virtual ossimObject* dup()const;
 
@@ -55,8 +54,7 @@ public:
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
    virtual bool intersects(const ossimDrect& rect)const;
    virtual bool isPointWithin(const ossimDpt& imagePoint)const;
-   virtual void setFont(ossimFont* font,
-                        bool ownsFontFlag=true);
+   virtual void setFont(ossimFont* font);
    virtual void setCenterPosition(const ossimIpt& position);
    virtual void setUpperLeftPosition(const ossimIpt& position);
    virtual void setPointSize(const ossimIpt& size);
@@ -67,8 +65,8 @@ public:
    virtual void applyScale(double x, double y);
                            
 protected:
-   mutable ossimFont*   theFont;
-   bool                 theOwnsFontFlag;
+   virtual ~ossimAnnotationFontObject();
+   mutable ossimRefPtr<ossimFont>   theFont;
    ossimIpt             thePosition;
    ossimString          theString;
    ossimIpt             thePixelSize;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationGdBitmapFont.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationGdBitmapFont.h
index 7b53a5c37c7f630473bc9995b3a817a38145c0dc..b2c28728e7b1ef3f1490258e5e9d47600f42102d 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationGdBitmapFont.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationGdBitmapFont.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimAnnotationGdBitmapFont.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimAnnotationGdBitmapFont.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationGdBitmapFont_HEADER
 #define ossimAnnotationGdBitmapFont_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
@@ -30,7 +30,6 @@ public:
                                unsigned char b = 255,
                                long thickness = 1);
    ossimAnnotationGdBitmapFont(const ossimAnnotationGdBitmapFont& rhs);
-   virtual ~ossimAnnotationGdBitmapFont();
 
    virtual ossimObject* dup()const
       {
@@ -109,6 +108,7 @@ public:
    virtual bool isPointWithin(const ossimDpt& imagePoint)const;
    
 protected:
+   virtual ~ossimAnnotationGdBitmapFont();
    ossimGdFontPtr theFontPtr;
    ossimString    theText;
    ossimDrect     theBoundingRect;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiEllipseObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiEllipseObject.h
index 6cb0dc8b98e9d8845e2ff7dc18ce5bf858488c2e..cc9217d9b7bf4451bee92295106a6630cf69a9b6 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiEllipseObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiEllipseObject.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationMultiEllipseObject.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimAnnotationMultiEllipseObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationMultiEllipseObject_HEADER
 #define ossimAnnotationMultiEllipseObject_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
@@ -33,7 +33,6 @@ public:
 
    ossimObject* dup()const;
 
-   virtual ~ossimAnnotationMultiEllipseObject();
 
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
    virtual void applyScale(double x, double y);
@@ -57,6 +56,7 @@ public:
    const ossimDpt& operator[](int i)const;
    
 protected:
+   virtual ~ossimAnnotationMultiEllipseObject();
    std::vector<ossimDpt>  thePointList;
    ossimDpt               theWidthHeight;
    bool                   theFillFlag;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyLineObject.h
index 4871aa5de73a7c632bf1950ac930e3b13910d86d..547b643582fcda2c504f7fa435b1317b3806ad7b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyLineObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyLineObject.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimAnnotationMultiPolyLineObject.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimAnnotationMultiPolyLineObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationMultiPolyLineObject_HEADER
 #define ossimAnnotationMultiPolyLineObject_HEADER
 
@@ -28,7 +28,6 @@ public:
 
    virtual ossimObject* dup()const;
 
-   virtual ~ossimAnnotationMultiPolyLineObject();
    virtual void applyScale(double x,
                            double y);
    virtual void draw(ossimRgbImage& anImage)const;
@@ -47,6 +46,7 @@ public:
    const std::vector<ossimPolyLine>& getMultiPolyLine()const;
    std::vector<ossimPolyLine>& getMultiPolyLine();
 protected:
+   virtual ~ossimAnnotationMultiPolyLineObject();
    vector<ossimPolyLine> theMultiPolyLine;
    ossimDrect           theBoundingRect;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyObject.h
index 8275a273ad05e4fb8adf5b1e7920203303a77eea..86afe536363027303d72884f53009705613c9e70 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationMultiPolyObject.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimAnnotationMultiPolyObject.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimAnnotationMultiPolyObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationMultiPolyObject_HEADER
 #define ossimAnnotationMultiPolyObject_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
@@ -35,7 +35,6 @@ public:
       {
          return new ossimAnnotationMultiPolyObject(*this);
       }
-   virtual ~ossimAnnotationMultiPolyObject();
    virtual void applyScale(double x,
                            double y);
    virtual void draw(ossimRgbImage& anImage)const;
@@ -73,6 +72,7 @@ public:
          theFillEnabled = flag;
       }
 protected:
+   virtual ~ossimAnnotationMultiPolyObject();
    vector<ossimPolygon> theMultiPolygon;
    ossimDrect           theBoundingRect;
    bool                 theFillEnabled;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationObject.h
index cea358b93922fb5b374e1a71a48eff0159969513..a0a42cc080b4a33dc6d1d0f71a5f60f05a24f793 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAnnotationObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationObject_HEADER
 #define ossimAnnotationObject_HEADER
 #include <iostream>
@@ -25,7 +25,6 @@ public:
                          ossim_uint8 g=255,
                          ossim_uint8 b=255,
                          ossim_uint8 thickness=1);
-   virtual ~ossimAnnotationObject();
    virtual void applyScale(double x,
                            double y)=0;
    virtual void applyScale(const ossimDpt& scale);
@@ -90,6 +89,7 @@ public:
   static void restIdCounter();
 
 protected:
+   virtual ~ossimAnnotationObject();
    ossim_uint8 theRed;
    ossim_uint8 theGreen;
    ossim_uint8 theBlue;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationPolyObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationPolyObject.h
index 959d7596c906412c15c07939c522b5b1f06adc11..77b8503101ae7c5032614abeb8698361cc162a09 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationPolyObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationPolyObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationPolyObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAnnotationPolyObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationPolyObject_HEADER
 #define ossimAnnotationPolyObject_HEADER
 
@@ -34,7 +34,6 @@ public:
 
    ossimObject* dup()const;
 
-   virtual ~ossimAnnotationPolyObject();
 
    virtual void applyScale(double x, double y);
 
@@ -70,7 +69,8 @@ public:
    virtual void setFillFlag(bool flag);
 
 protected:
-   ossimPolygon thePolygon;
+   virtual ~ossimAnnotationPolyObject();
+  ossimPolygon thePolygon;
    ossimDrect   theBoundingRect;
    bool         theFillEnabled;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h
index 8598101bb167b47bdc61d62e1b18e991c863da6e..ae6060a761e73988f6bd897acd023aeea1996da4 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h
@@ -17,7 +17,7 @@
 //    the fourth band will not be drawn to.
 //
 //*************************************************************************
-// $Id: ossimAnnotationSource.h 13330 2008-07-28 18:04:40Z dburken $
+// $Id: ossimAnnotationSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAnnotationSource_HEADER
 #define ossimAnnotationSource_HEADER
 
@@ -26,13 +26,14 @@
 #include <ossim/base/ossimIrect.h>
 #include <ossim/base/ossimDrect.h>
 #include <ossim/imaging/ossimRgbImage.h>
+#include <ossim/imaging/ossimAnnotationObject.h>
 
-class ossimAnnotationObject;
 class ossimKeywordlist;
 
 class OSSIMDLLEXPORT ossimAnnotationSource : public ossimImageSourceFilter
 {
 public:
+   typedef std::vector<ossimRefPtr<ossimAnnotationObject> > AnnotationObjectListType;
    ossimAnnotationSource(ossimImageSource* inputSource=0);
    virtual ~ossimAnnotationSource();
 
@@ -93,16 +94,16 @@ public:
     * Calls the isPointWithin all Annotation
     * Objects.  Note:  Do not delete these objects.
     */
-   std::vector<ossimAnnotationObject*> pickObjects(const ossimDpt& imagePoint);
+   AnnotationObjectListType pickObjects(const ossimDpt& imagePoint);
 
    /*!
     * Note: do not delete the objects returned.
     */
-   std::vector<ossimAnnotationObject*> pickObjects(const ossimDrect& imageRect);
+   AnnotationObjectListType pickObjects(const ossimDrect& imageRect);
 
-   const std::vector<ossimAnnotationObject*>& getObjectList()const;
+   const AnnotationObjectListType& getObjectList()const;
 
-   std::vector<ossimAnnotationObject*>& getObjectList();
+   AnnotationObjectListType& getObjectList();
 
    /*!
      Clears theAnnotationObjectList vector.  All elements are deleted.
@@ -145,7 +146,7 @@ protected:
     * These will be all your primitives in
     * Example: lines, circles, text ...
     */
-   std::vector<ossimAnnotationObject*> theAnnotationObjectList;   
+   AnnotationObjectListType theAnnotationObjectList;   
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAppTileCache.h b/Utilities/otbossim/include/ossim/imaging/ossimAppTileCache.h
index 1755b4594d37531a325fc337c00d3d5b3bc19465..382ffe0568a91e826db9ce276e07a530ce8090ae 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAppTileCache.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAppTileCache.h
@@ -10,7 +10,7 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimAppTileCache.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAppTileCache.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAppTileCache_HEADER
 #define ossimAppTileCache_HEADER
 #include <map>
@@ -19,6 +19,7 @@ using namespace std;
 
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimDpt3d.h>
+#include <ossim/base/ossimRefPtr.h>
 // class ossimTile;
 class ossimTileCache;
 class ossimDataObject;
@@ -59,16 +60,16 @@ public:
     * Will remove a tile completly from the cache.  The
     * returned tile is no longer owned by the cache.
     */
-   ossimDataObject* removeTile(ossimAppCacheId id,
-                              const ossimDpt3d &origin,
-                              unsigned long resLevel);
+   ossimRefPtr<ossimDataObject> removeTile(ossimAppCacheId id,
+                                           const ossimDpt3d &origin,
+                                           unsigned long resLevel);
    /*!
     * Will insert a tile into the cache.
     */
-   ossimDataObject* insert(ossimAppCacheId id,
-                          const ossimDpt3d &origin,
-                          const ossimDataObject* data,
-                          ossim_uint32 resLevel=0);
+   ossimRefPtr<ossimDataObject> insert(ossimAppCacheId id,
+                                       const ossimDpt3d &origin,
+                                       const ossimDataObject* data,
+                                       ossim_uint32 resLevel=0);
    
    /*!
     * This will delete the specified cache. The LRU queue will
@@ -133,7 +134,7 @@ protected:
     * and return it to the caller. This is used by the insert
     * when the max cache size is exceeded.
     */
-   ossimDataObject* removeTile();
+   ossimRefPtr<ossimDataObject> removeTile();
 
 
    static ossimAppTileCache *theInstance;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAtCorrGridRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimAtCorrGridRemapper.h
index 067f2cf1443a9c11be57d44e30794ee3bb3ca126..b9e49478153bd11a727ef08053a29cc560745da0 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAtCorrGridRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAtCorrGridRemapper.h
@@ -5,7 +5,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimAtCorrGridRemapper.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimAtCorrGridRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAtCorrGridRemapper_HEADER
 #define ossimAtCorrGridRemapper_HEADER
 #include <ossim/imaging/ossimAtCorrRemapper.h>
@@ -61,7 +61,6 @@ public:
                            ossimImageSource* inputSource =  NULL,
                            const ossimString& sensorType = "");
    
-   virtual ~ossimAtCorrGridRemapper();
 
 
    void setGridRect(const ossimIrect& rect)
@@ -120,7 +119,8 @@ public:
                           const char* prefix=0)const;
 
 protected:
-   ossimIrect theGridBounds;
+   virtual ~ossimAtCorrGridRemapper();
+  ossimIrect theGridBounds;
    ossimIpt   theUlGridBound;
    ossimIpt   theGridSize;
    std::vector< std::vector< std::vector<double> > >theAGrid;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAtCorrRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimAtCorrRemapper.h
index 71f9b86b267ee2ce20eda89e75cc82d4cc5375e6..be043a096f57990b21279e063740eee96acf4b0b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAtCorrRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAtCorrRemapper.h
@@ -13,7 +13,7 @@
 // Converts Lsat to Surface Reflectance values
 //
 //*************************************************************************
-// $Id: ossimAtCorrRemapper.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAtCorrRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAtCorrRemapper_HEADER
 #define ossimAtCorrRemapper_HEADER
 
@@ -27,7 +27,6 @@ public:
                        ossimImageSource* inputSource =  NULL,
                        const ossimString& sensorType = "");
 
-   virtual ~ossimAtCorrRemapper();
 
    virtual ossimString getShortName() const;
 
@@ -57,6 +56,7 @@ public:
    void setSensorType(const ossimString& sensorType);
 
 protected:
+   virtual ~ossimAtCorrRemapper();
 
    /*!
     * Method to set unset the enable flag.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAtbController.h b/Utilities/otbossim/include/ossim/imaging/ossimAtbController.h
index 57cb4c08d185d0027e37fd634a734197129e001a..c9a465d96047ecfc37ee081cc3d38ad55d4f45cc 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAtbController.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAtbController.h
@@ -11,7 +11,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAtbController.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimAtbController.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAtbController_HEADER
 #define ossimAtbController_HEADER
@@ -135,9 +135,9 @@ protected:
    void initializeRemappers();
 
    ossimDrect                       theBoundingRect;
-   ossimConnectableContainer*       theContainer;
+   ossimRefPtr<ossimConnectableContainer>       theContainer;
    ossimGridRemapEngine*            theGridRemapEngine;
-   std::vector<ossimAtbMatchPoint*> theMatchPoints;
+   std::vector<ossimRefPtr<ossimAtbMatchPoint> > theMatchPoints;
    ossimIpt                         theGridSpacing;
 
    TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAtbMatchPoint.h b/Utilities/otbossim/include/ossim/imaging/ossimAtbMatchPoint.h
index 7d742abe268fb0e295833e1191896008a860c91f..ba69ca282bf332f6f145b4984670a3f5dbd7dd15 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAtbMatchPoint.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAtbMatchPoint.h
@@ -12,12 +12,13 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAtbMatchPoint.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimAtbMatchPoint.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAtbMatchPoint_HEADER
 #define ossimAtbMatchPoint_HEADER
 
 #include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimReferenced.h>
 #include <vector>
 using namespace std;
 
@@ -30,7 +31,7 @@ class ossimGridRemapSource;
  * CLASS:  ossimAtbMatchPoint
  *
  *****************************************************************************/
-class ossimAtbMatchPoint
+class ossimAtbMatchPoint : public ossimReferenced
 {
 public:
    ossimAtbMatchPoint()
@@ -40,7 +41,6 @@ public:
                       ossimGridRemapEngine* engine)
       : theViewPoint(view_point), theGridRemapEngine(engine) {}
 
-   ~ossimAtbMatchPoint();
    
    /*!
     * Returns the point in view coordinates associated with this object.
@@ -79,7 +79,9 @@ public:
 
 //   friend ostream& operator << (ostream& os);
 
-private:
+protected:
+   virtual ~ossimAtbMatchPoint();
+   
    ossimDpt                     theViewPoint;
    vector<ossimAtbPointSource*> thePointSourceList; 
    ossimGridRemapEngine*        theGridRemapEngine;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAtbPointSource.h b/Utilities/otbossim/include/ossim/imaging/ossimAtbPointSource.h
index b35eed37c1595fbf4319233fda594ce9e771201a..a19e5af0e8c40753f47c2603c813307103f99e18 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAtbPointSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAtbPointSource.h
@@ -12,12 +12,14 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAtbPointSource.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimAtbPointSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAtbPointSource_HEADER
 #define ossimAtbPointSource_HEADER
 
 #include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimReferenced.h>
+#include <ossim/base/ossimRefPtr.h>
 
 class ossimImageSource;
 class ossimImageData;
@@ -29,14 +31,13 @@ class ossimGridRemapEngine;
  * CLASS: ossimAtbPointSource 
  *
  *****************************************************************************/
-class ossimAtbPointSource
+class ossimAtbPointSource : public ossimReferenced
 {
 public:
    ossimAtbPointSource();
    ossimAtbPointSource(ossimGridRemapSource* remap_source,
                        const ossimDpt&       view_point);
 
-   ~ossimAtbPointSource();
 
    /*!
     * Sets the pointer of the source of pixels used to compute the stats.
@@ -46,7 +47,7 @@ public:
    /*!
     * Returns the reference to the remapper feeding this source.
     */
-   ossimGridRemapSource* getRemapSource() { return theRemapSource; }
+   ossimGridRemapSource* getRemapSource() { return theRemapSource.get(); }
 
    /*!
     * Sets the view coordinates corresponding to this point.
@@ -80,11 +81,14 @@ public:
     */
    void setGridRemapEngine(ossimGridRemapEngine* engine)
       { theGridRemapEngine = engine; }
-   
+protected:
+   virtual ~ossimAtbPointSource();
+
 private:
-   ossimGridRemapSource* theRemapSource;
+   
+   ossimRefPtr<ossimGridRemapSource> theRemapSource;
    ossimDpt              theViewPoint;
-   ossimGridRemapEngine* theGridRemapEngine;
+   ossimRefPtr<ossimGridRemapEngine> theGridRemapEngine;
    int                   theKernelSize;
    bool                  theViewPointIsValid;
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBandAverageFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimBandAverageFilter.h
index 938b064cc15432a49b6ba22801d57a7a4ca6d114..2ebf11fbd3b06bab8d727fdd47be86c28f804c2f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBandAverageFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBandAverageFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBandAverageFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBandAverageFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBandAverageFilter_HEADER
 #define ossimBandAverageFilter_HEADER
 #include <vector>
@@ -27,7 +27,6 @@ public:
    ossimBandAverageFilter();
    ossimBandAverageFilter(ossimImageSource* input,
                           const std::vector<double>& weights);
-   virtual ~ossimBandAverageFilter();
 
    /**
     * The data object argument is deprecated and should not be used.
@@ -93,7 +92,9 @@ public:
                           const char* prefix=0)const;
 
 protected:
-   ossimRefPtr<ossimImageData> theTile;
+   virtual ~ossimBandAverageFilter();
+   
+  ossimRefPtr<ossimImageData> theTile;
    std::vector<double>         theWeights;
 
    void checkWeights();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBandClipFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimBandClipFilter.h
index bba772334634c35ab1b8101494ed9ed49911276d..f925082a641ea6df2a6f53e685c29d1cac038f93 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBandClipFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBandClipFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBandClipFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBandClipFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBandClipFilter_HEADER
 #define ossimBandClipFilter_HEADER
 #include <vector>
@@ -43,7 +43,6 @@ public:
                         double maxPix,
                         ossimBandClipType clipType=ossimBandClipType_NONE);
 
-   virtual ~ossimBandClipFilter();
 
    void setClipType(ossimBandClipType clipType);
 
@@ -73,6 +72,7 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix = NULL)const;
 protected:
+   virtual ~ossimBandClipFilter();
 
    void runClip();
    void runClamp();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBandMergeSource.h b/Utilities/otbossim/include/ossim/imaging/ossimBandMergeSource.h
index 2cca87176ec3c08c99b3d3a8f2db37552518464f..cc74f308dac14330945e8bb6569934077bf0f758 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBandMergeSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBandMergeSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBandMergeSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBandMergeSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBandMergeSource_HEADER
 #define ossimBandMergeSource_HEADER
 #include <ossim/imaging/ossimImageCombiner.h>
@@ -20,8 +20,7 @@ class OSSIM_DLL ossimBandMergeSource : public ossimImageCombiner
 {
 public:
    ossimBandMergeSource();
-   ossimBandMergeSource(vector<ossimImageSource*>& inputSources);
-   virtual ~ossimBandMergeSource();
+   ossimBandMergeSource(ossimConnectableObject::ConnectableObjectList& inputSources);
    
    /**
     * This will merge all the bands from the input source list
@@ -49,6 +48,7 @@ public:
    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
    
 protected:
+   virtual ~ossimBandMergeSource();
    /** Performs allocation of "theTile". */
    void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBandSelector.h b/Utilities/otbossim/include/ossim/imaging/ossimBandSelector.h
index b0cb8d8caa551a54481d4db8499768df078f24eb..cbc5e62ff17cf47bc45ba6a8a8d7cc89f0819db3 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBandSelector.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBandSelector.h
@@ -8,7 +8,7 @@
 // Description:  Contains class declaration for ossimBandSelector.
 // 
 //*******************************************************************
-//  $Id: ossimBandSelector.h 13486 2008-08-22 17:07:13Z gpotts $
+//  $Id: ossimBandSelector.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBandSelector_HEADER
 #define ossimBandSelector_HEADER
 
@@ -30,7 +30,6 @@ public:
    };
    ossimBandSelector();
    
-   virtual ~ossimBandSelector();
    
    virtual ossimString getLongName()  const;
    virtual ossimString getShortName() const;
@@ -98,7 +97,8 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;						  
 						  
    
-private:
+protected:
+   virtual ~ossimBandSelector();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBlendMosaic.h b/Utilities/otbossim/include/ossim/imaging/ossimBlendMosaic.h
index 9ae21d7c157581d71e21f2c81c31c70364a9e7f2..f9a7bbe63dfa289a61ef2def5615a0e25c11cb42 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBlendMosaic.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBlendMosaic.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBlendMosaic.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBlendMosaic.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBlendMosaic_HEADER
 #define ossimBlendMosaic_HEADER
 #include <ossim/imaging/ossimImageMosaic.h>
@@ -17,8 +17,7 @@ class OSSIMDLLEXPORT ossimBlendMosaic : public ossimImageMosaic
 {
 public:
    ossimBlendMosaic();
-   ossimBlendMosaic(vector<ossimImageSource*>& inputSources);
-   virtual ~ossimBlendMosaic();
+   ossimBlendMosaic(ossimConnectableObject::ConnectableObjectList& inputSources);
    virtual void initialize();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
@@ -55,6 +54,7 @@ public:
    void findMinMax(double& minValue, double& maxValue)const;
    
 protected:
+   virtual ~ossimBlendMosaic();
    vector<double>              theWeights;
    ossimRefPtr<ossimImageData> theNormResult;
    /**
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBrightnessContrastSource.h b/Utilities/otbossim/include/ossim/imaging/ossimBrightnessContrastSource.h
index c156b6b88747bf2cea3830628aa2bd354a01e053..afb94542c6b2b3000e3b448bc0080a83d4c51df8 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBrightnessContrastSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBrightnessContrastSource.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 // 
 //*************************************************************************
-// $Id: ossimBrightnessContrastSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBrightnessContrastSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBrightnessContrastSource_HEADER
 #define ossimBrightnessContrastSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -22,7 +22,6 @@ public:
     */
    ossimBrightnessContrastSource();
 
-   virtual ~ossimBrightnessContrastSource();
 
    /**
     * Will apply the algorithm:
@@ -99,6 +98,7 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
 protected:
+   virtual ~ossimBrightnessContrastSource();
 
    /**
     * Called to initialize tiles by first get tile when theTile or theNormTile
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBrightnessMatch.h b/Utilities/otbossim/include/ossim/imaging/ossimBrightnessMatch.h
index 54837d5189f587b392edab3f2d521c6a60bcf59e..3708f844b37b3de8e1c682b3ba34732df45ff194 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBrightnessMatch.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBrightnessMatch.h
@@ -10,7 +10,7 @@
 // Description: A brief description of the contents of the file.
 //
 //*************************************************************************
-// $Id: ossimBrightnessMatch.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBrightnessMatch.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBrightnessMatch_HEADER
 #define ossimBrightnessMatch_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -22,7 +22,6 @@ public:
    ossimBrightnessMatch();
 
 
-   virtual ~ossimBrightnessMatch();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
@@ -41,6 +40,8 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
 protected:
+   virtual ~ossimBrightnessMatch();
+   
    double          theTargetBrightness;
    double          theInputBrightness;
    ossimRefPtr<ossimImageData> theNormTile;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBumpShadeTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimBumpShadeTileSource.h
index 7180a8a503d45c6ed9c64eef4abab17264bf53ca..cc8e4e9d04a21b4a0cce794f71e28f62e9f0ea34 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimBumpShadeTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimBumpShadeTileSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBumpShadeTileSource.h 13382 2008-08-04 18:53:26Z gpotts $
+// $Id: ossimBumpShadeTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBumpShadeTileSource_HEADER
 #define ossimBumpShadeTileSource_HEADER
 #include <ossim/imaging/ossimImageCombiner.h>
@@ -104,7 +104,6 @@ public:
     */
    ossimBumpShadeTileSource(ossimImageSource* colorSource,
                             ossimImageSource* bumpMapSource);
-   virtual ~ossimBumpShadeTileSource();
       
    ossimString getShortName()const;
    ossimString getLongName()const;
@@ -239,6 +238,7 @@ public:
    /* ------------------ PROPERTY INTERFACE END ------------------- */
    
 protected:
+   virtual ~ossimBumpShadeTileSource();
    void allocate();
    /**
     * The result of the illumination equation is stored in
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimCacheTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimCacheTileSource.h
index ab8e2ee65cc970fe9a60aa9a2bf9e89220403e67..1001ee9c0b8a477eb3d73b49940aa44a541ccf83 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimCacheTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimCacheTileSource.h
@@ -7,7 +7,7 @@
 // Description:  ossimCacheTileSource
 // 
 //*******************************************************************
-//  $Id: ossimCacheTileSource.h 12623 2008-04-07 14:10:08Z gpotts $
+//  $Id: ossimCacheTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimCacheTileSource_HEADER
 #define ossimCacheTileSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -24,7 +24,6 @@ public:
     */
    ossimCacheTileSource();
    // ossimCacheTileSource(ossimImageSource* inputSource);
-   virtual ~ossimCacheTileSource();
 
    virtual ossimString getLongName()  const;
    virtual ossimString getShortName() const;
@@ -58,6 +57,7 @@ public:
    
 
 protected:
+   virtual ~ossimCacheTileSource();
 
    void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimCastTileSourceFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimCastTileSourceFilter.h
index 7326be5d31c28b0c7373ce70b2c57a28f63cab24..198101034f7855082885ef977936b7ef43693fce 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimCastTileSourceFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimCastTileSourceFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimCastTileSourceFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimCastTileSourceFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimCastTileSourceFilter_HEADER
 #define ossimCastTileSourceFilter_HEADER
 
@@ -19,7 +19,6 @@ class OSSIMDLLEXPORT ossimCastTileSourceFilter : public ossimImageSourceFilter
 public:
    ossimCastTileSourceFilter(ossimImageSource* inputSource=NULL,
 			     ossimScalarType scalarType=OSSIM_UCHAR);
-   virtual ~ossimCastTileSourceFilter();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
    virtual void initialize();
@@ -69,6 +68,7 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
      
 protected:
+   virtual ~ossimCastTileSourceFilter();
 
    void allocate(const ossimRefPtr<ossimImageData> inputTile);
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimCcfTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimCcfTileSource.h
index 20d84f9cc070df271212af07e7626c0d94d0db1e..789384e19fbafd7515955fac0595fdf82b0998a8 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimCcfTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimCcfTileSource.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
 // License:  LGPL
 //
@@ -18,13 +17,12 @@
 // would make the chunk 24 x 8 chips.
 //
 //*******************************************************************
-//  $Id: ossimCcfTileSource.h 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimCcfTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimCcfTileSource_HEADER
 #define ossimCcfTileSource_HEADER
 
 #include <fstream>
-using namespace std;
 
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimCcfHead.h>
@@ -36,11 +34,10 @@ class OSSIM_DLL ossimCcfTileSource : public ossimImageHandler
 public:
 
    ossimCcfTileSource();
-   virtual ~ossimCcfTileSource();
    
    virtual ossimString getShortName()const;
    virtual ossimString getLongName()const;
-   virtual ossimString className()const;
+   virtual ossimString getClassName()const;
 
    /**
     *  @return Returns true on success, false on error.
@@ -56,6 +53,20 @@ public:
    
    virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
+
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
    
     /**
      *  Returns the number of bands in the image.
@@ -68,13 +79,15 @@ public:
      *  Returns the number of lines in the image.
      *  Satisfies pure virtual from ImageHandler class.
      */
-   virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level = 0) const;
+   virtual ossim_uint32 getNumberOfLines(
+      ossim_uint32 reduced_res_level = 0) const;
    
    /**
     *  Returns the number of samples in the image.  
     *  Satisfies pure virtual from ImageHandler class.
     */
-   virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level = 0) const;
+   virtual ossim_uint32 getNumberOfSamples(
+      ossim_uint32 reduced_res_level = 0) const;
 
    /**
     *  Returns the number of reduced resolution data sets (rrds).
@@ -87,7 +100,8 @@ public:
     *  Returns the zero based image rectangle for the reduced resolution data
     *  set (rrds) passed in.  Note that rrds 0 is the highest resolution rrds.
     */
-   virtual ossimIrect getImageRectangle(ossim_uint32 reduced_res_level = 0) const;
+   virtual ossimIrect getImageRectangle(
+      ossim_uint32 reduced_res_level = 0) const;
    
    /**
     *  Set the output band list.  Use to set the number and order of output
@@ -147,7 +161,8 @@ public:
     * @param name The name of the property to get.
     * @return Returns property matching "name".
     */
-   virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
+   virtual ossimRefPtr<ossimProperty> getProperty(
+      const ossimString& name)const;
    
    /**
     * @brief Gets a list of property names available.
@@ -156,7 +171,8 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 	
    
-private:
+protected:
+   virtual ~ossimCcfTileSource();
 
    void initVerticesFromHeader();
    
@@ -170,7 +186,8 @@ private:
    bool fillBuffer(const  ossimIrect& tile_rect,
                    const  ossimIrect& clip_rect,
                    const  ossimIrect& image_rect,
-                   ossim_uint32 reduced_res_level);
+                   ossim_uint32 reduced_res_level,
+                   ossimImageData* tile);
 
    /**
     *  Returns true on success, false on error.
@@ -178,15 +195,17 @@ private:
    bool fillUshortBuffer(const  ossimIrect& tile_rect,
                          const  ossimIrect& clip_rect,
                          const  ossimIrect& image_rect,
-                         ossim_uint32 reduced_res_level);
-
+                         ossim_uint32 reduced_res_level,
+                         ossimImageData* tile);
+   
    /**
     *  Returns true on success, false on error.
     */
    bool fillUcharBuffer(const  ossimIrect& tile_rect,
                         const  ossimIrect& clip_rect,
                         const  ossimIrect& image_rect,
-                        ossim_uint32 reduced_res_level);
+                        ossim_uint32 reduced_res_level,
+                        ossimImageData* tile);
 
    /**
     *  Adjust point to even 256 boundary.  Assumes 0,0 origin.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimCibCadrgTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimCibCadrgTileSource.h
index dfb78e6c910c91ee04b9d56b4ba5c5519fde8df3..168dc824141d7d416f27b838dbcc0bf7287709b0 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimCibCadrgTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimCibCadrgTileSource.h
@@ -9,7 +9,7 @@
 //              CADRG file.
 //
 //-----------------------------------------------------------------------
-//$Id: ossimCibCadrgTileSource.h 12990 2008-06-04 19:14:34Z gpotts $
+//$Id: ossimCibCadrgTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimCibCadrgTileSource_HEADER
 #define ossimCibCadrgTileSource_HEADER 1
 #include <ossim/imaging/ossimImageHandler.h>
@@ -56,13 +56,6 @@ public:
     */
    ossimCibCadrgTileSource();
 
-   /**
-    * Destructor.
-    *
-    * Will return allocated memory back to the heap.
-    */
-   virtual ~ossimCibCadrgTileSource();
-
    /**
     * This method is defined in the base class ossimObject.
     * This class overrides the default implementation
@@ -102,6 +95,20 @@ public:
    virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& rect,
                                                ossim_uint32 resLevel = 0);
 
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
+
    /**
     *  Satisfies pure virtual requirement from ImageHandler class.
     *
@@ -201,10 +208,10 @@ public:
                           const char* prefix=0);
    
    /**
-    *  Populates the keyword list with image geometry information.  This
+    *  Populates the geometry object with image geometry information.  This
     *  method is used to relay projection/model information to users.
     *  Returns true if geometry info is present, false if not.
-    *  Keywords supported by this object are:
+    *  Keywords supported by this class are:
     *  @verbatim
     *  datum:    // datum code>   // Datum code
     *  ul_lat:   // upper left latitude
@@ -229,15 +236,9 @@ public:
     *  type:              // class name of the object for factory driven reconstruction
     *  map_scale:         // Map scale of the image
     *  @endverbatim
-    *  @see ossimImageSource for further code example on using the geometry
-    *       information in kwl.
-    *  @param kwl Keywordlist to populate the image geometry with.
-    *  @param prefix A unique prefix to prepend to the keywords.
-    *    
-    *  @return True if image geometry is present and false otherwise.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+    *  @see ossimImageSource for further code example on using the geometry.
+    */
+   virtual ossimImageGeometry* getImageGeometry();
    
    /**
     * This method allows you to query the scalar type of the output data.
@@ -383,7 +384,14 @@ public:
    
 
 protected:
-
+   /**
+    * Destructor.
+    *
+    * Will return allocated memory back to the heap.
+    */
+   virtual ~ossimCibCadrgTileSource();
+   
+   
 	void updatePropertiesToFirstValidFrame();
    /**
     * Sets the entry to be renderer.  The entry within the table
@@ -471,7 +479,8 @@ protected:
     * @param framesInvolved All intersecting frames used to render the region.
     */
    void fillTile(const ossimIrect& tileRect,
-                 const vector<ossimFrameEntryData>& framesInvolved);
+                 const vector<ossimFrameEntryData>& framesInvolved,
+                 ossimImageData* tile);
 
    /**
     * Will uncompress the CIB file using a VQ decompression algorithm.
@@ -482,7 +491,8 @@ protected:
     */
    void fillSubTileCib(const ossimRpfFrame& aFrame,
                        const ossimIrect& tileRect,
-                       const ossimFrameEntryData& frameEntryData);
+                       const ossimFrameEntryData& frameEntryData,
+                       ossimImageData* tile);
    
    /**
     * Will uncompress the CADRG file using a VQ decompression algorithm.
@@ -493,7 +503,8 @@ protected:
     */
    void fillSubTileCadrg(const ossimRpfFrame& aFrame,
                          const ossimIrect& tileRect,
-                         const ossimFrameEntryData& frameEntryData);
+                         const ossimFrameEntryData& frameEntryData,
+                         ossimImageData* tile);
    
    /**
     * Will allocate an internal buffer for the given product.  If the product is
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimColorNormalizedFusion.h b/Utilities/otbossim/include/ossim/imaging/ossimColorNormalizedFusion.h
index f9f2157fa4cace2c0eb93fea4db927a93edacb7c..d9f52a19f50cbccf7a2558dd8c8180bf9ec4d73f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimColorNormalizedFusion.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimColorNormalizedFusion.h
@@ -10,7 +10,7 @@
 // Description: Color normalized fusion
 //
 //*************************************************************************
-// $Id: ossimColorNormalizedFusion.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimColorNormalizedFusion.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimColorNormalizedFusion_HEADER
 #define ossimColorNormalizedFusion_HEADER
 #include <ossim/imaging/ossimFusionCombiner.h>
@@ -21,11 +21,11 @@ public:
 
    ossimColorNormalizedFusion();
    ossimColorNormalizedFusion(ossimObject* owner);
-   virtual ~ossimColorNormalizedFusion();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
 
 protected:
+   virtual ~ossimColorNormalizedFusion();
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimConvolutionFilter1D.h b/Utilities/otbossim/include/ossim/imaging/ossimConvolutionFilter1D.h
index f7831fb1f3952d993ce9b0323a44066167b7da8b..3a7f74192b792ddcd60bc9004dbc6353ffd49d5f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimConvolutionFilter1D.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimConvolutionFilter1D.h
@@ -8,7 +8,7 @@
 //
 // efficient for gradients & separable convolution kernels (like gaussian)
 //*******************************************************************
-// $Id: ossimConvolutionFilter1D.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimConvolutionFilter1D.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimConvolutionFilter1D_HEADER
 #define ossimConvolutionFilter1D_HEADER
@@ -36,7 +36,6 @@ public:
    * own class methods
    */
    ossimConvolutionFilter1D(ossimObject* owner=NULL);
-   virtual ~ossimConvolutionFilter1D();
 
    virtual inline const std::vector<ossim_float64>& getKernel()const { return theKernel; }
    virtual void setKernel(const std::vector<ossim_float64>& aKernel);
@@ -72,6 +71,7 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,const char* prefix = 0)const;
    
 protected:
+   virtual ~ossimConvolutionFilter1D();
 
    /**
     * Allocates theTile.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimConvolutionSource.h b/Utilities/otbossim/include/ossim/imaging/ossimConvolutionSource.h
index 298faa4ad42b3e48d590496f6fb18a37b9d19946..c7def30d5232bbe9f14e914c88e1660f68b463a5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimConvolutionSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimConvolutionSource.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimConvolutionSource.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimConvolutionSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimConvolutionSource_HEADER
 #define ossimConvolutionSource_HEADER
 #include <vector>
@@ -29,7 +29,6 @@ public:
                           const NEWMAT::Matrix& convolutionMatix);
    ossimConvolutionSource(ossimImageSource* inputSource,
                           const vector<NEWMAT::Matrix>& convolutionList);
-   virtual ~ossimConvolutionSource();
    
    virtual void setConvolution(const double* kernel, int nrows, int ncols, bool doWeightedAverage=false);
    virtual void setConvolution(const NEWMAT::Matrix& convolutionMatrix, bool doWeightedAverage=false);
@@ -49,14 +48,15 @@ public:
    virtual void initialize();
    
 protected:
+   virtual ~ossimConvolutionSource();
 
    void allocate();
    
    ossimRefPtr<ossimImageData> theTile;
-   long                        theMaxKernelWidth;
-   long                        theMaxKernelHeight;
+   ossim_int32                 theMaxKernelWidth;
+   ossim_int32                 theMaxKernelHeight;
    
-   vector<ossimDiscreteConvolutionKernel*> theConvolutionKernelList;
+   std::vector<ossimDiscreteConvolutionKernel* > theConvolutionKernelList;
    virtual void setKernelInformation();
    virtual void deleteConvolutionList();
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimDoqqTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimDoqqTileSource.h
index f66879ba72dfc81531647e07ae483d084960db09..dc5cd0cfb8ba05ed0b19033443122c8e9c3ca0cc 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimDoqqTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimDoqqTileSource.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimDoqqTileSource.h 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimDoqqTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimDoqqTileSource_HEADER
 #define ossimDoqqTileSource_HEADER
 #include <ossim/imaging/ossimGeneralRasterTileSource.h>
@@ -18,7 +18,6 @@ class OSSIM_DLL ossimDoqqTileSource: public ossimGeneralRasterTileSource
 {
 public:
    ossimDoqqTileSource();
-   virtual ~ossimDoqqTileSource();
    
    ossimString getShortName()const;
    ossimString getLongName()const;
@@ -26,8 +25,10 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix = NULL);
    
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   //! Returns the image geometry object associated with this tile source or NULL if non defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   virtual ossimImageGeometry* getImageGeometry();
+
    bool open(const ossimFilename& filename);
    bool open(const ossimGeneralRasterInfo& info);
 
@@ -47,6 +48,7 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 	
 protected:
+   virtual ~ossimDoqqTileSource();
   ossimRefPtr<ossimDoqq>   theHeaderInformation;
   ossimString  theAcqDate;
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimDtedTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimDtedTileSource.h
index dc73504b03146e7f85f92b7d5973f7843286f6b5..6bfda37f02e5aab33d92e9ce1ad05c896dfd5059 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimDtedTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimDtedTileSource.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2001 ImageLinks Inc. 
 //
 // License:  LGPL
 //
@@ -14,13 +13,12 @@
 // handler for DTED files.
 //
 //********************************************************************
-// $Id: ossimDtedTileSource.h 14137 2009-03-25 20:23:05Z dburken $
+// $Id: ossimDtedTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimDtedTileSource_HEADER
 #define ossimDtedTileSource_HEADER
 
 #include <fstream>
-using namespace std;
 
 #include <ossim/imaging/ossimImageHandler.h>
 
@@ -31,7 +29,6 @@ class OSSIM_DLL ossimDtedTileSource : public ossimImageHandler
 public:
       
    ossimDtedTileSource();
-   virtual ~ossimDtedTileSource();
 
    enum
    {
@@ -43,7 +40,7 @@ public:
    
    virtual ossimString getShortName()const;
    virtual ossimString getLongName()const;
-   virtual ossimString className()const;
+   virtual ossimString getClassName()const;
 
    /**
     *  Returns true if "theImageFile" can be opened and is a valid adrg file.
@@ -53,6 +50,20 @@ public:
    virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& tile_rect,
                                                ossim_uint32 resLevel=0);
    
+  /**
+   * Method to get a tile.   
+   *
+   * @param result The tile to stuff.  Note The requested rectangle in full
+   * image space and bands should be set in the result tile prior to
+   * passing.  It will be an error if:
+   * result.getNumberOfBands() != this->getNumberOfOutputBands()
+   *
+   * @return true on success false on error.  If return is false, result
+   *  is undefined so caller should handle appropriately with makeBlank or
+   * whatever.
+   */
+  virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
+  
    /**
     *  Returns the number of bands in the image.
     *  Satisfies pure virtual requirement from ImageHandler class.
@@ -100,13 +111,9 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
    
-   /**
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   //! Returns the image geometry object associated with this tile source or NULL if not defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   virtual ossimImageGeometry* getImageGeometry();
    
    /**
     * Returns the output pixel type of the tile source.
@@ -163,7 +170,9 @@ public:
    virtual void getPropertyNames(
       std::vector<ossimString>& propertyNames)const;
    
-private:
+protected:
+   virtual ~ossimDtedTileSource();
+
    // Disallow operator= and copy constrution...
    const ossimDtedTileSource& operator=(const  ossimDtedTileSource& rhs);
    ossimDtedTileSource(const ossimDtedTileSource&);
@@ -177,13 +186,14 @@ private:
     *  Returns true on success, false on error.
     */
    bool fillBuffer(const ossimIrect& tile_rect,
-                   const ossimIrect& clip_rect);
+                   const ossimIrect& clip_rect,
+                   ossimImageData* tile);
 
    void gatherStatistics();
    ossim_sint16 convertSignedMagnitude(ossim_uint16& s) const;
    
    ossimRefPtr<ossimImageData> theTile;
-   mutable ifstream           theFileStr;
+   mutable std::ifstream      theFileStr;
    ossim_uint32               theTileWidth;
    ossim_uint32               theTileHeight;   
    ossim_uint32               theNumberOfLines;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimERSFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimERSFileWriter.h
index c521f305a570b6006e6dadb45e6c05d847b196ae..ac6e6bd174d4d80ca433b0505751d2061f227a09 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimERSFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimERSFileWriter.h
@@ -10,7 +10,7 @@
 // writing an ERS header file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimERSFileWriter.h 10317 2007-01-19 18:11:58Z dburken $
+// $Id: ossimERSFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimERSFileWriter_H
 #define ossimERSFileWriter_H
 
@@ -30,8 +30,6 @@ public:
    /** default constructor */
    ossimERSFileWriter();
 
-   /** virtual destructor */
-   virtual ~ossimERSFileWriter();
 
    /**
     * Initializes the state of the writer.  Users should use this to set
@@ -63,7 +61,9 @@ public:
     */
    virtual bool hasMetadataType(const ossimString& metadataType)const;   
    
-private:
+protected:
+   /** virtual destructor */
+   virtual ~ossimERSFileWriter();
    
    virtual bool writeFile();
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimERSTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimERSTileSource.h
index b5dc6d4ff0aacc2ab751261d222a43ac778b0036..114c07cb94fabf8c4a679b89d0859dde71b4f1ab 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimERSTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimERSTileSource.h
@@ -12,7 +12,7 @@
 // Contains class definition for the class "ossimERSTileSource".
 //
 //*******************************************************************
-//  $Id: ossimERSTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimERSTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimERSTileSource_HEADER
 #define ossimERSTileSource_HEADER
@@ -28,7 +28,6 @@ public:
 
    ossimERSTileSource(const ossimKeywordlist& kwl, const char* prefix=0);
    
-   virtual ~ossimERSTileSource();
 
    virtual ossimString getShortName() const;
    virtual ossimString getLongName() const;
@@ -36,17 +35,15 @@ public:
 
    virtual bool open(const ossimFilename& filename);
   
-  /*!
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
-
+   //! Returns the image geometry object associated with this tile source or NULL if not defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   virtual ossimImageGeometry* getImageGeometry();
 
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix = NULL);
+protected:
+   virtual ~ossimERSTileSource();
+
 private:
 
    void openHeader(const ossimFilename& file);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimEastingNorthingCutter.h b/Utilities/otbossim/include/ossim/imaging/ossimEastingNorthingCutter.h
index 90784a75f90794bccd653667c616f67a83c5ece2..ce302d3abe49a7a76e5dbacfb77efe8baab69789 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimEastingNorthingCutter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimEastingNorthingCutter.h
@@ -11,7 +11,6 @@ public:
    ossimEastingNorthingCutter(ossimObject* owner,
                               ossimImageSource* inputSource=NULL);
    ossimEastingNorthingCutter(ossimImageSource* inputSource=NULL);
-   virtual ~ossimEastingNorthingCutter();
    
    void setEastingNorthingRectangle(const ossimDpt& ul,
                                     const ossimDpt& lr);
@@ -23,8 +22,7 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
    
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
+   virtual bool setView(ossimObject* baseObject);
 
    virtual ossimObject* getView();
    virtual const ossimObject* getView()const;
@@ -32,10 +30,11 @@ public:
    virtual void initialize();
    
 protected:
+   virtual ~ossimEastingNorthingCutter();
    ossimDpt theUlEastingNorthing;
    ossimDpt theLrEastingNorthing;
    
-   ossimProjection* theViewProjection;
+   ossimRefPtr<ossimProjection> theViewProjection;
 
 
    void transformVertices();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimElevImageSource.h b/Utilities/otbossim/include/ossim/imaging/ossimElevImageSource.h
index d0913a0111911041404020789504c49b6c5df732..2cd5ccc651276d04ff9248b755b0cdf09cdc912c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimElevImageSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimElevImageSource.h
@@ -11,7 +11,7 @@
 // manager.
 //
 //********************************************************************
-// $Id: ossimElevImageSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimElevImageSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimElevImageSource_HEADER
 #define ossimElevImageSource_HEADER
@@ -38,7 +38,6 @@ public:
                         const ossimKeywordlist& kwl,
                         const char* prefix=0);
    
-   virtual ~ossimElevImageSource();
 
    /*!
     *  Returns a pointer to a tile given an origin representing the upper left
@@ -131,6 +130,7 @@ public:
    virtual void setMaxPixelValue(ossim_float64 max_pix);
    
 protected:
+   virtual ~ossimElevImageSource();
 
    ossimElevSource*            theElevManager;
    ossimRefPtr<ossimImageData> theTile;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimEnviHeaderFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimEnviHeaderFileWriter.h
index 678867518be11a5666af0f4b7fd2af15c7feea8c..b5c599c4b1ec02fc8c8fe31bfdbedfc4a44e3bee 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimEnviHeaderFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimEnviHeaderFileWriter.h
@@ -13,7 +13,7 @@
 // writing an ENVI (The Environment for Visualizing Images) header file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimEnviHeaderFileWriter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimEnviHeaderFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimEnviHeaderFileWriter_H
 #define ossimEnviHeaderFileWriter_H
@@ -33,8 +33,6 @@ public:
    /** default constructor */
    ossimEnviHeaderFileWriter();
 
-   /** virtual destructor */
-   virtual ~ossimEnviHeaderFileWriter();
 
    /**
     * Initializes the state of the writer.  Users should use this to set
@@ -65,7 +63,10 @@ public:
     * @return true if "metadataType" is supported by writer.
     */
    virtual bool hasMetadataType(const ossimString& metadataType)const;   
-   
+protected:
+   /** virtual destructor */
+   virtual ~ossimEnviHeaderFileWriter();
+
 private:
    
    virtual bool writeFile();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimEquationCombiner.h b/Utilities/otbossim/include/ossim/imaging/ossimEquationCombiner.h
index 950eb99338c3d1da1a95450fbdbd722d840a03ce..054def5647af2ed338928b9ace282252530dbd31 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimEquationCombiner.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimEquationCombiner.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimEquationCombiner.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimEquationCombiner.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimEquationCombiner_HEADER
 #define ossimEquationCombiner_HEADER
 #include <ossim/imaging/ossimImageCombiner.h>
@@ -163,7 +163,6 @@ class OSSIMDLLEXPORT ossimEquationCombiner : public ossimImageCombiner
 {
 public:
    ossimEquationCombiner();
-   virtual ~ossimEquationCombiner();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -237,12 +236,15 @@ protected:
       ossimEquDataType d;
    };
 
+   virtual ~ossimEquationCombiner();
+   
+   
    ossimScalarType             theOutputScalarType;
    ossimString                 theEquation;
    mutable ossimEquTokenizer  *theLexer;
    ossimRefPtr<ossimImageData> theTile;
-   ossimCastTileSourceFilter  *theCastFilter;
-   ossimCastTileSourceFilter  *theCastOutputFilter;
+   ossimRefPtr<ossimCastTileSourceFilter>  theCastFilter;
+   ossimRefPtr<ossimCastTileSourceFilter> theCastOutputFilter;
    
    mutable int                theCurrentId;
    mutable std::stack<ossimEquValue> theValueStack;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFeatherMosaic.h b/Utilities/otbossim/include/ossim/imaging/ossimFeatherMosaic.h
index c299cfa9d7b3b7d5fa97f8f4705c0703d9c519dc..b0fff9a974e0ac4457f3c38ff271ace86d97010f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimFeatherMosaic.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimFeatherMosaic.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimFeatherMosaic.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimFeatherMosaic.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFeatherMosaic_HEADER
 #define ossimFeatherMosaic_HEADER
 #include <vector>
@@ -25,13 +25,13 @@ class OSSIMDLLEXPORT ossimFeatherMosaic : public ossimImageMosaic
 {
 public:
    ossimFeatherMosaic();
-   ossimFeatherMosaic(vector<ossimImageSource*>& inputSources);
-   virtual ~ossimFeatherMosaic();
+   ossimFeatherMosaic(ossimConnectableObject::ConnectableObjectList& inputSources);
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                    ossim_uint32 resLevel=0);
    virtual void initialize();
        
 protected:
+   virtual ~ossimFeatherMosaic();
    /**
     * This is only visible by this class and will remain here
     * unless we want to move it later.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFftFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimFftFilter.h
index 3e8e1e0a73420b9c0ba62c0b7cbebc2d8bef5935..49b6f0e61cb5062817cf2ab726050dab915efcdd 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimFftFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimFftFilter.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimFftFilter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimFftFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFftFilter_HEADER
 #define ossimFftFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -27,7 +27,6 @@ public:
    ossimFftFilter(ossimImageSource* inputSource);
    ossimFftFilter(ossimObject* owner,
                   ossimImageSource* inputSource);
-   virtual ~ossimFftFilter();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                    ossim_uint32 resLevel=0);
    virtual void initialize();
@@ -60,9 +59,10 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix = 0)const;
 protected:
+   virtual ~ossimFftFilter();
    ossimRefPtr<ossimImageData> theTile;
    ossimFftFilterDirectionType theDirectionType;
-   ossimScalarRemapper*        theScalarRemapper;
+   ossimRefPtr<ossimScalarRemapper>        theScalarRemapper;
    template <class T>
    void runFft(T dummy,
                ossimRefPtr<ossimImageData>& input,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFgdcFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimFgdcFileWriter.h
index 7140bddbc85928be77587bc81c50c7c9d8b667fa..5df2704bcd10cbe248749509d26a7df9eb54cc5a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimFgdcFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimFgdcFileWriter.h
@@ -11,7 +11,7 @@
 // Committe (FGDC) format.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimFgdcFileWriter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimFgdcFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFgdcFileWriter_HEADER
 #define ossimFgdcFileWriter_HEADER
 
@@ -30,8 +30,6 @@ public:
    /** constructor */
    ossimFgdcFileWriter();
 
-   /** destructor */
-   virtual ~ossimFgdcFileWriter();
    
    /**
     * Method to load the state from a keyword list.
@@ -108,6 +106,8 @@ public:
    bool writeTemplate(const ossimFilename& file) const;
 
 protected:
+   /** destructor */
+   virtual ~ossimFgdcFileWriter();
 
    /**
     * Writes file to disk.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFixedTileCache.h b/Utilities/otbossim/include/ossim/imaging/ossimFixedTileCache.h
index 1be27120e1c02ab91d8a9f70f8bffe41ca066630..8816ab7e54e15c0dd65e3e1a2c735b8ac730282f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimFixedTileCache.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimFixedTileCache.h
@@ -10,7 +10,7 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimFixedTileCache.h 13485 2008-08-22 17:06:20Z gpotts $
+// $Id: ossimFixedTileCache.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFixedTileCache_HEADER
 #define ossimFixedTileCache_HEADER
 #include <map>
@@ -64,7 +64,6 @@ class ossimFixedTileCache : public ossimReferenced
 {
 public:
    ossimFixedTileCache();
-   virtual ~ossimFixedTileCache();
    virtual void setRect(const ossimIrect& rect);
    virtual void setRect(const ossimIrect& rect,
                         const ossimIpt& tileSize);
@@ -128,6 +127,7 @@ public:
    virtual ossim_int32 computeId(const ossimIpt& tileOrigin)const;
    virtual void setTileSize(const ossimIpt& tileSize);
 protected:
+   virtual ~ossimFixedTileCache();
    OpenThreads::ReentrantMutex theMutex;
    ossimIrect   theTileBoundaryRect;
    ossimIpt     theTileSize;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFusionCombiner.h b/Utilities/otbossim/include/ossim/imaging/ossimFusionCombiner.h
index 32e72b31f0c0206fd735dc9bbd26b5975179ab68..d08aff4bda5c95843374cae8a8d3eb51f28ea363 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimFusionCombiner.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimFusionCombiner.h
@@ -12,7 +12,7 @@
 //              the intensity source.
 //
 //*************************************************************************
-// $Id: ossimFusionCombiner.h 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimFusionCombiner.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimFusionCombiner_HEADER
 #define ossimFusionCombiner_HEADER
 
@@ -23,7 +23,6 @@ class OSSIMDLLEXPORT ossimFusionCombiner : public ossimImageCombiner
 public:
   ossimFusionCombiner();
   ossimFusionCombiner(ossimObject* owner);
-  virtual ~ossimFusionCombiner();   
   virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const;
   bool canConnectMyInputTo(ossim_int32 inputIndex,
 			   const ossimConnectableObject* object)const;
@@ -31,6 +30,7 @@ public:
    
   virtual void initialize();
 protected:
+   virtual ~ossimFusionCombiner();   
   ossimRefPtr<ossimImageData> theTile;
   ossimRefPtr<ossimImageData> theNormTile;
   ossimRefPtr<ossimImageData> theNormIntensity;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGammaRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimGammaRemapper.h
index dca5392eb5c85ec5ffbbf5380c19b5548e7e5440..95b6a9672f2f209594a8ad16d58aaf8d6ac0e81f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGammaRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGammaRemapper.h
@@ -12,7 +12,7 @@
 // Gamma remapper.
 //
 //*************************************************************************
-// $Id: ossimGammaRemapper.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGammaRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGammaRemapper_HEADER
 #define ossimGammaRemapper_HEADER
 
@@ -26,7 +26,6 @@ public:
    ossimGammaRemapper(ossimImageSource* inputSource);
    ossimGammaRemapper(ossimObject* owner, ossimImageSource* inputSource);
 
-   virtual ~ossimGammaRemapper();
 
    virtual ossimString getShortName()const;
 
@@ -51,6 +50,7 @@ public:
    virtual void enableSource();
    
 protected:
+   virtual ~ossimGammaRemapper();
 
    /*!
     * Method to set unset the enable flag.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterTileSource.h
index 9e8ab459b417c2293cdf2eee5eddda4b3020109c..043361e5bb23bb959d0f10a43b1391551947ffff 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterTileSource.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
 // License:  LGPL
 //
@@ -13,15 +12,12 @@
 // ossimGeneralRasterTileSource is derived from ImageHandler which is
 // derived from ossimTileSource.
 //*******************************************************************
-//  $Id: ossimGeneralRasterTileSource.h 11181 2007-06-07 19:57:14Z dburken $
+//  $Id: ossimGeneralRasterTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimGeneralRasterTileSource_HEADER
 #define ossimGeneralRasterTileSource_HEADER
 
-  // #include <fstream>
 #include <ossim/base/ossimIoStream.h>
-  //using namespace std;
-
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimGeneralRasterInfo.h>
 
@@ -33,11 +29,9 @@ public:
 
    ossimGeneralRasterTileSource();
 
-   virtual ~ossimGeneralRasterTileSource();
-
    virtual ossimString getShortName()const;
    virtual ossimString getLongName()const;
-   virtual ossimString className()const;
+   virtual ossimString getClassName()const;
    
    /**
     *  Returns a pointer to a tile given an origin representing the upper
@@ -46,11 +40,25 @@ public:
     */
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tile_rect,
                                                ossim_uint32 resLevel=0);
+
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);   
    
-    /**
-     *  Returns the number of bands in the image.
-     *  Satisfies pure virtual from ImageHandler class.
-     */
+   /**
+    *  Returns the number of bands in the image.
+    *  Satisfies pure virtual from ImageHandler class.
+    */
    virtual ossim_uint32 getNumberOfInputBands() const;
    
    /**
@@ -120,29 +128,30 @@ public:
    virtual ossim_uint32 getImageTileHeight() const;   
    
    bool isValidRLevel(ossim_uint32 reduced_res_level) const;
-  
+   
    virtual void close();
    virtual bool isOpen() const;
    virtual bool open();
    virtual bool open(const ossimGeneralRasterInfo& info);
-
+   
    /**
     * Override base getXXXXPixValue methods since the null/min/max can be set
     * to something different.  Currently returns the same value for all bands.
     */
-    virtual double getNullPixelValue(ossim_uint32 band=0)const;
-    virtual double getMinPixelValue(ossim_uint32 band=0)const;
-    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
-
+   virtual double getNullPixelValue(ossim_uint32 band=0)const;
+   virtual double getMinPixelValue(ossim_uint32 band=0)const;
+   virtual double getMaxPixelValue(ossim_uint32 band=0)const;
+   
 protected:
+   virtual ~ossimGeneralRasterTileSource();
    /**
     *  Methods return true on succes false on error.
     */
-   virtual bool fillBuffer(const ossimIpt& origin);
-   virtual bool fillBIP(const ossimIpt& origin);
-   virtual bool fillBIL(const ossimIpt& origin);
-   virtual bool fillBSQ(const ossimIpt& origin);
-   virtual bool fillBsqMultiFile(const ossimIpt& origin);
+   virtual bool fillBuffer(const ossimIpt& origin, const ossimIpt& size);
+   virtual bool fillBIP(const ossimIpt& origin, const ossimIpt& size); 
+   virtual bool fillBIL(const ossimIpt& origin, const ossimIpt& size);
+   virtual bool fillBSQ(const ossimIpt& origin, const ossimIpt& size);
+   virtual bool fillBsqMultiFile(const ossimIpt& origin, const ossimIpt& size);
 
    virtual bool initializeHandler();
    virtual void checkBuffer(const ossimIrect& rect);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterWriter.h
index 42e57e5737d7a93417555e780a68df04bf37508b..59f23e88f303ae3bbd750f5767900729a310e7b4 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeneralRasterWriter.h
@@ -10,7 +10,7 @@
 // Contains class declaration for ossimGeneralRasterWriter.
 //
 //*******************************************************************
-//  $Id: ossimGeneralRasterWriter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimGeneralRasterWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimGeneralRasterWriter_HEADER
 #define ossimGeneralRasterWriter_HEADER
@@ -27,7 +27,6 @@ public:
    ossimGeneralRasterWriter();
    ossimGeneralRasterWriter(ossimImageSource* inputSource,
                             const ossimFilename& file=ossimFilename(""));
-   virtual ~ossimGeneralRasterWriter();
 
    /**
     * void getImageTypeList(std::vector<ossimString>& imageTypeList)const
@@ -60,6 +59,8 @@ public:
     */
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
+protected:
+   virtual ~ossimGeneralRasterWriter();
 
 private:
    virtual bool writeFile();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationBitmap.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationBitmap.h
index 117cbfce7c421a57c6ceaf1829ff6366e41c52fd..f32820ecc93470c1f778db7449251b40df8a4a2e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationBitmap.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationBitmap.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationBitmap.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationBitmap.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationBitmap_HEADER
 #define ossimGeoAnnotationBitmap_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -24,8 +24,6 @@ public:
                             unsigned char b = 255);
    
    ossimGeoAnnotationBitmap(const ossimGeoAnnotationBitmap& rhs);
-
-   virtual ~ossimGeoAnnotationBitmap();
    
    virtual ossimObject* dup()const;
 
@@ -38,26 +36,14 @@ public:
    virtual std::ostream& print(std::ostream& out)const;
    virtual void draw(ossimRgbImage& anImage)const;
    virtual void getBoundingRect(ossimDrect& rect)const;
-   virtual void transform(ossimProjection* projection);
+   virtual void transform(ossimImageGeometry* projection);
 
-   /**
-    * @brief Transforms from geographic to image space for a reduced
-    * resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
-   
    virtual void setImageData(ossimRefPtr<ossimImageData>& imageData);
    virtual void computeBoundingRect();
 
 protected:
+   virtual ~ossimGeoAnnotationBitmap();
+   
    ossimGpt                    theCenterPoint;
    ossimDpt                    theProjectedPoint;
    ossimRefPtr<ossimImageData> theImageData;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h
index f484d23044c3c4a5614046ce48015880d00dc8b9..76048a64eeb3a1c66f5cdb8e1fa6f88fa3a605c5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h
@@ -5,12 +5,11 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationEllipseObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationEllipseObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationEllipseObject_HEADER
 #define ossimGeoAnnotationEllipseObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
-
-class ossimAnnotationEllipseObject;
+#include <ossim/imaging/ossimAnnotationEllipseObject.h>
 
 class OSSIMDLLEXPORT ossimGeoAnnotationEllipseObject : public ossimGeoAnnotationObject
 {
@@ -30,7 +29,6 @@ public:
                                    ossim_uint8 b = 255,
                                    ossim_uint8 thickness = 1);
    ossimGeoAnnotationEllipseObject(const ossimGeoAnnotationEllipseObject& rhs);
-   virtual ~ossimGeoAnnotationEllipseObject();
 
    virtual ossimObject* dup()const;
 
@@ -41,21 +39,7 @@ public:
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
    virtual void getBoundingRect(ossimDrect& rect)const;
    virtual void computeBoundingRect();
-   virtual void transform(ossimProjection* projection);
-
-   /**
-    * @brief Transforms from geographic to image space for a reduced
-    * resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
+   virtual void transform(ossimImageGeometry* projection);
 
    /**
     * Saves the current state of this object.
@@ -149,11 +133,12 @@ public:
    virtual void getCenter(ossimGpt& gpt) const;
 
 protected:
+   virtual ~ossimGeoAnnotationEllipseObject();
 
    void getWidthHeightInPixels(ossimDpt& widthHeight,
-                               const ossimProjection* projection) const;
+                               const ossimImageGeometry* projection) const;
    
-   ossimAnnotationEllipseObject* theProjectedEllipse;
+   ossimRefPtr<ossimAnnotationEllipseObject> theProjectedEllipse;
    ossimGpt                      theCenter;
    ossimDpt                      theWidthHeight;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationFontObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationFontObject.h
index 416c830aaf5f8bf5bff63e7f372c59a62c8f9cb3..5bf622bb1f3b0cf8f0315f92051c1933edbd33b7 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationFontObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationFontObject.h
@@ -4,7 +4,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationFontObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationFontObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationFontObject_HEADER
 #define ossimGeoAnnotationFontObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -29,8 +29,6 @@ public:
                                 ossim_uint8 b=255);
    ossimGeoAnnotationFontObject(const ossimGeoAnnotationFontObject& rhs);
    
-   virtual ~ossimGeoAnnotationFontObject();
-   
    virtual ossimObject* dup()const;
 
    ossimAnnotationFontObject* getFontObject();
@@ -51,22 +49,8 @@ public:
                          ossim_uint8 g,
                          ossim_uint8 b);
 
-   virtual void transform(ossimProjection* projection);
+   virtual void transform(ossimImageGeometry* projection);
 
-   /**
-    * @brief Transforms from geographic to image space for a reduced
-    * resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
-   
    virtual void setCenterGround(const ossimGpt& gpt);
    
    virtual void draw(ossimRgbImage& anImage)const;
@@ -131,10 +115,12 @@ public:
                           const char* prefix=0);
    
 protected:
+   virtual ~ossimGeoAnnotationFontObject();
+   
    ossimGpt                   theCenterGround;
-   ossimFont*                 theFont;
+   ossimRefPtr<ossimFont>     theFont;
    ossimFontInformation       theFontInfo;
-   ossimAnnotationFontObject* theAnnotationFontObject;
+   ossimRefPtr<ossimAnnotationFontObject> theAnnotationFontObject;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationGdBitmapFont.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationGdBitmapFont.h
index 0df6ed16fd8c5ef70fda2843e1381c0ab1e59cde..93fbb2cb9dc93688918de0362a3a961f0c9e9cc6 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationGdBitmapFont.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationGdBitmapFont.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationGdBitmapFont.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationGdBitmapFont.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationGdBitmapFont_HEADER
 #define ossimGeoAnnotationGdBitmapFont_HEADER
 
@@ -26,7 +26,6 @@ public:
                                   unsigned char b = 255,
                                   long thickness = 1);
    ossimGeoAnnotationGdBitmapFont(const ossimGeoAnnotationGdBitmapFont& rhs);
-   virtual ~ossimGeoAnnotationGdBitmapFont();
    virtual ossimObject* dup()const;
    virtual void applyScale(double x, double y);
    virtual std::ostream& print(std::ostream& out)const;
@@ -39,27 +38,15 @@ public:
     * Add the projection interface to all
     * geographically defined objects.
     */
-   virtual void transform(ossimProjection* projection);
-
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
+   virtual void transform(ossimImageGeometry* projection);
 
    virtual void setText(const ossimString& text);
    virtual void setFont(ossimGdFontPtr font);
 
 protected:
-   ossimAnnotationGdBitmapFont* theProjectedFont;
+   virtual ~ossimGeoAnnotationGdBitmapFont();
+
+   ossimRefPtr<ossimAnnotationGdBitmapFont> theProjectedFont;
 
    /*!
     * Will be the upper left corner of text;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h
index 615295655a628a8a983de7fe611288f5812a7223..90d383886b06ea3e9f83c415616378fd4a335790 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h
@@ -6,13 +6,13 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationLineObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationLineObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationLineObject_HEADER
 #define ossimGeoAnnotationLineObject_HEADER
 #include <ossim/base/ossimGpt.h>
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
 
-class OSSIMDLLEXPORT ossimAnnotationLineObject;
+class ossimAnnotationLineObject;
 
 class ossimGeoAnnotationLineObject : public ossimGeoAnnotationObject
 {
@@ -24,27 +24,12 @@ public:
                                 unsigned char b=255,
                                 long thickness=1);
    ossimGeoAnnotationLineObject(const ossimGeoAnnotationLineObject& rhs);
-   virtual ~ossimGeoAnnotationLineObject();
 
    virtual ossimObject* dup()const;
 
    virtual void applyScale(double x, double y);
-   virtual void transform(ossimProjection* projection);
-
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
-   
+   virtual void transform(ossimImageGeometry* projection);
+
    virtual std::ostream& print(std::ostream& out)const;
    virtual bool intersects(const ossimDrect& rect)const;
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
@@ -53,6 +38,8 @@ public:
    virtual void computeBoundingRect();
 
 protected:
+   virtual ~ossimGeoAnnotationLineObject();
+   
    ossimAnnotationLineObject* theProjectedLineObject;
    ossimGpt                   theStart;
    ossimGpt                   theEnd;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h
index eb8b25edf338085f44427b3e8e5cb406bdf8bfed..cd3341cd73706ae4aa2290e32fed2029bb40e454 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiEllipseObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationMultiEllipseObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationMultiEllipseObject_HEADER
 #define ossimGeoAnnotationMultiEllipseObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -34,21 +34,7 @@ public:
 
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
 
-   virtual void transform(ossimProjection* projection);
-
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
+   virtual void transform(ossimImageGeometry* projection);
    
    virtual void applyScale(double x, double y);
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h
index cd57191523a432b9f859e4cc3222d5234b8f6dd4..b71ba7ee652b54a7ac22f69b465b56b1c9b459e4 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiPolyLineObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationMultiPolyLineObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationMultiPolyLineObject_HEADER
 #define ossimGeoAnnotationMultiPolyLineObject_HEADER
 
@@ -31,23 +31,8 @@ public:
    ossimGeoAnnotationMultiPolyLineObject(const ossimGeoAnnotationMultiPolyLineObject& rhs);
    virtual ossimObject* dup()const;
 
-   virtual ~ossimGeoAnnotationMultiPolyLineObject();
-   virtual void transform(ossimProjection* projection);
+   virtual void transform(ossimImageGeometry* projection);
 
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
-   
    virtual void applyScale(double x, double y);
    virtual void draw(ossimRgbImage& anImage)const;
    virtual bool intersects(const ossimDrect& rect)const;
@@ -92,10 +77,12 @@ public:
                           const char* prefix=0);
    
 protected:
+   virtual ~ossimGeoAnnotationMultiPolyLineObject();
+   
    std::vector<ossimPolyLine>          theMultiPolyLine;
    ossimDrect                          theBoundingRect;
    const ossimDatum*                   theDatum;
-   ossimAnnotationMultiPolyLineObject* theProjectedPolyLineObject;
+   ossimRefPtr<ossimAnnotationMultiPolyLineObject> theProjectedPolyLineObject;
    
    void allocateProjectedPolyLine();
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyObject.h
index 4b386751a4d5b0887efe192e036e68d6841d0d56..7daf42c12738d5bcd35b3eee347c5e063706bc28 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyObject.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiPolyObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationMultiPolyObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationMultiPolyObject_HEADER
 #define ossimGeoAnnotationMultiPolyObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -28,22 +28,7 @@ public:
    ossimGeoAnnotationMultiPolyObject(const ossimGeoAnnotationMultiPolyObject& rhs);
    virtual ossimObject* dup()const;
 
-   virtual ~ossimGeoAnnotationMultiPolyObject();
-   virtual void transform(ossimProjection* projection);
-
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
+   virtual void transform(ossimImageGeometry* projection);
 
    virtual void applyScale(double x,
                                 double y);
@@ -69,10 +54,12 @@ public:
    std::vector<ossimGeoPolygon>& getMultiPolygon(){return theMultiPolygon;}
    
 protected:
+   virtual ~ossimGeoAnnotationMultiPolyObject();
+
    std::vector<ossimGeoPolygon>    theMultiPolygon;
    ossimDrect                      theBoundingRect;
    bool                            theFillEnabled;
-   ossimAnnotationMultiPolyObject* theProjectedPolyObject;
+   ossimRefPtr<ossimAnnotationMultiPolyObject> theProjectedPolyObject;
    
    void allocateProjectedPolygon();
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h
index 8af66b77408f752f5070cd79b66f0e063269cb3b..58c1614404284faec47f610971d5b7ff4831ac21 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h
@@ -6,13 +6,13 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationObject_HEADER
 #define ossimGeoAnnotationObject_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
 #include <ossim/base/ossimGpt.h>
+#include <ossim/imaging/ossimImageGeometry.h>
 
-class ossimProjection;
 class ossimImageProjectionModel;
 
 class OSSIM_DLL ossimGeoAnnotationObject : public ossimAnnotationObject
@@ -25,27 +25,12 @@ public:
 
    ossimGeoAnnotationObject(const ossimGeoAnnotationObject& rhs);
 
-   virtual ~ossimGeoAnnotationObject();
    
    /*!
     * Add the projection interface to all
     * geographically defined objects.
     */
-   virtual void transform(ossimProjection* projection)=0;
-
-   /**
-    * @brief Pure virtual transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds) = 0;
+   virtual void transform(ossimImageGeometry* projection)=0;
 
    /**
     * Saves the current state of this object.
@@ -60,6 +45,9 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
 
+protected:
+   virtual ~ossimGeoAnnotationObject();
+
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyLineObject.h
index 77e55467fcb7ee3b0912bb5ba56646f37d5e4d82..9e70c82442580c58cbe63d2b1474b726633e7768 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyLineObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyLineObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyLineObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationPolyLineObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationPolyLineObject_HEADER
 #define ossimGeoAnnotationPolyLineObject_HEADER
 #include <ossim/base/ossimGpt.h>
@@ -23,26 +23,11 @@ public:
                                      ossim_uint8 b=255,
                                      ossim_uint8 thickness=1);
    ossimGeoAnnotationPolyLineObject(const ossimGeoAnnotationPolyLineObject& rhs);
-   virtual ~ossimGeoAnnotationPolyLineObject();
    virtual ossimObject* dup()const;
 
    virtual void applyScale(double x, double y);
 
-   virtual void transform(ossimProjection* projection);
-
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);
+   virtual void transform(ossimImageGeometry* projection);
    
    virtual std::ostream& print(std::ostream& out)const;
    virtual void draw(ossimRgbImage& anImage)const;
@@ -70,6 +55,8 @@ public:
    virtual void setThickness(ossim_uint8 thickness);
 
 protected:
+   virtual ~ossimGeoAnnotationPolyLineObject();
+   
    std::vector<ossimGpt>           thePolygon;
    ossimAnnotationMultiLineObject* theProjectedMultiLineObject;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h
index 53245fe0e083b9ca3dd7128406beb4665fa380e2..39e16ace95f321d87698240c7200f509d3d42767 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h
@@ -6,16 +6,15 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyObject.h 13349 2008-07-30 15:34:34Z dburken $
+// $Id: ossimGeoAnnotationPolyObject.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationPolyObject_HEADER
 #define ossimGeoAnnotationPolyObject_HEADER
 
 #include <vector>
-
 #include <ossim/base/ossimGpt.h>
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
-class ossimAnnotationPolyObject;
-
+#include <ossim/imaging/ossimAnnotationPolyObject.h>
+ 
 class OSSIMDLLEXPORT ossimGeoAnnotationPolyObject : public ossimGeoAnnotationObject
 {
 public:
@@ -34,28 +33,13 @@ public:
 
    ossimGeoAnnotationPolyObject(const ossimGeoAnnotationPolyObject& rhs);
 
-   virtual ~ossimGeoAnnotationPolyObject();
 
    virtual ossimObject* dup()const;
 
    virtual void applyScale(double x, double y);
 
-   virtual void transform(ossimProjection* projection);
+   virtual void transform(ossimImageGeometry* projection);
 
-   /**
-    * @brief Transforms from geographic to image space for a
-    * reduced resolution data set (rrds).
-    *
-    * This will transform any world points to line sample; then, convert any
-    * line sample to the correct rrds point.
-    *
-    * @param model The model to use for transformation.
-    *
-    * @param rrds Reduced resolution data set to use.
-    */
-   virtual void transform(const ossimImageProjectionModel& model,
-                          ossim_uint32 rrds);  
-   
    virtual std::ostream& print(std::ostream& out)const;
 
    virtual void draw(ossimRgbImage& anImage)const;
@@ -94,8 +78,10 @@ public:
                           const char* prefix=0);
    
 protected:
+   virtual ~ossimGeoAnnotationPolyObject();
+
    std::vector<ossimGpt>      thePolygon;
-   ossimAnnotationPolyObject* theProjectedPolyObject;
+   ossimRefPtr<ossimAnnotationPolyObject> theProjectedPolyObject;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationSource.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationSource.h
index c01f1b84da85faf3f4d329a4425a345a10d98188..beecf4370f01d9dc379f6c08799246ba7081108c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationSource.h
@@ -6,12 +6,13 @@
 // Author: Garrett Potts
 //
 //*******************************************************************
-// $Id: ossimGeoAnnotationSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoAnnotationSource_HEADER
 #define ossimGeoAnnotationSource_HEADER
 
 #include <iostream>
 #include <ossim/imaging/ossimAnnotationSource.h>
+#include <ossim/imaging/ossimImageGeometry.h>
 #include <ossim/base/ossimViewInterface.h>
 
 class ossimGeoAnnotationObject;
@@ -23,14 +24,13 @@ class OSSIM_DLL ossimGeoAnnotationSource :
 {
 public:
    friend std::ostream& operator <<(std::ostream& out, const ossimGeoAnnotationSource& rhs);
-   ossimGeoAnnotationSource(ossimProjection* projection=NULL,
+   ossimGeoAnnotationSource(ossimImageGeometry* geom=NULL,
                             bool ownsProjectionFlag=false);
 
    ossimGeoAnnotationSource(ossimImageSource* inputSource,
-                            ossimProjection* projection=NULL,
+                            ossimImageGeometry* geom=NULL,
                             bool ownsProjectionFlag=false);
 
-   virtual ~ossimGeoAnnotationSource();
    
    /*!
     * Will add an object to the list.
@@ -39,13 +39,10 @@ public:
     */
    virtual bool addObject(ossimAnnotationObject* anObject);
    virtual void computeBoundingRect();
-   virtual void transformObjects(ossimProjection* projection=0);
-   virtual void setProjection(ossimProjection* projection,
-                              bool ownsProjectionFlag=false);
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
-    virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   virtual void transformObjects(ossimImageGeometry* geom=0);
+   virtual void setGeometry(ossimImageGeometry* projection);
+   virtual bool setView(ossimObject* baseObject);
+   virtual ossimImageGeometry*  getImageGeometry();
   
    virtual ossimObject*       getView();
    virtual const ossimObject* getView()const;
@@ -64,10 +61,9 @@ public:
                           const char* prefix=0);
    
 protected:
-   ossimProjection* theProjection;
-   bool           theOwnsProjectionFlag;
+   virtual ~ossimGeoAnnotationSource();
    
-   void removeProjection();
+   ossimRefPtr<ossimImageGeometry> m_geometry;
    
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoPolyCutter.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoPolyCutter.h
index fb9ffd8cc681db49a60ef1a18b7e773f8ded56ba..be6cb3000915bc7f9e8e118e2b6a38a16926d943 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoPolyCutter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoPolyCutter.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks)
 //
 //*************************************************************************
-// $Id: ossimGeoPolyCutter.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimGeoPolyCutter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimGeoPolyCutter_HEADER
 #define ossimGeoPolyCutter_HEADER
 #include <ossim/imaging/ossimPolyCutter.h>
@@ -90,7 +90,6 @@ class OSSIM_DLL ossimGeoPolyCutter : public ossimPolyCutter,
 {
 public:
    ossimGeoPolyCutter();
-   virtual ~ossimGeoPolyCutter();
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
    
@@ -188,8 +187,7 @@ public:
     * Will set the view to the passed in object.  Once set it will project the
     * ground polygon relative to the passed in view.
     */
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
+   virtual bool setView(ossimObject* baseObject);
 
    /*!
     * \return The current view for this object.
@@ -202,15 +200,12 @@ public:
    virtual const ossimObject* getView()const;
    
 protected:
+   virtual ~ossimGeoPolyCutter();
+   
    /*!
     * The view projection used to project the ground coordinates.
     */
-   ossimProjection* theViewProjection;
-
-   /*!
-    * Specifies whether the view is owned by this object or not.
-    */
-   bool           theOwnsViewFlag;
+   ossimRefPtr<ossimProjection> theViewProjection;
 
    std::vector<ossimGeoPolygon> theGeoPolygonList;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeographicAnnotationGrid.h b/Utilities/otbossim/include/ossim/imaging/ossimGeographicAnnotationGrid.h
index 03dca6ddf72cf08d0ec4d8765b284b70a4d0a993..23489ce3c27352bda5cfb00f30762fbf19d3a96e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeographicAnnotationGrid.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeographicAnnotationGrid.h
@@ -31,7 +31,7 @@ protected:
    /*!
     * Holds the view projection.
     */
-   ossimMapProjection* theViewProjection;
+   ossimRefPtr<ossimMapProjection> theViewProjection;
 
    ossimGrect       theGroundRect;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeomFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimGeomFileWriter.h
index d2ea54bc5d4ddf39e76c4c9b263c90000c994faf..3b273e56ae1e38e01b59605577a7814295c8841c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeomFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeomFileWriter.h
@@ -8,7 +8,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimGeomFileWriter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimGeomFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimGeomFileWriter_H
 #define ossimGeomFileWriter_H
@@ -22,8 +22,6 @@ public:
    /** default constructor */
    ossimGeomFileWriter();
 
-   /** virtual destructor */
-   virtual ~ossimGeomFileWriter();
 
    /**
     * Satisfies pure virtual from ossimMetadataWriter base.
@@ -46,7 +44,9 @@ public:
     */
    virtual bool hasMetadataType(const ossimString& metadataType)const;
 
-private:
+protected:
+   /** virtual destructor */
+   virtual ~ossimGeomFileWriter();
 
    /** Write a geometry file to "theFilename". */
    virtual bool writeFile();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGridRemapEngine.h b/Utilities/otbossim/include/ossim/imaging/ossimGridRemapEngine.h
index 10e1e1b2bdc706963b181d514645315d33d13f48..a2d26c7c5e8600886dbe99b2fb0c611ff661c0c9 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGridRemapEngine.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGridRemapEngine.h
@@ -14,7 +14,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimGridRemapEngine.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimGridRemapEngine.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimGridRemapEngine_HEADER
 #define ossimGridRemapEngine_HEADER
@@ -56,6 +56,7 @@ protected:
       : theNumberOfParams(numParams), theNumberOfBands(numBands) {}
 
    ossimGridRemapEngine() {}
+   virtual ~ossimGridRemapEngine() {}
 
    virtual void computeRemapNode(ossimAtbPointSource*  point_source,
                                  void*                 source_value,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGridRemapSource.h b/Utilities/otbossim/include/ossim/imaging/ossimGridRemapSource.h
index 8bd9e405686794bc337b547865fd77f37db8715e..b3eb06132be76d51f00f3b7db7740ed3101048a4 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGridRemapSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGridRemapSource.h
@@ -16,7 +16,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimGridRemapSource.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimGridRemapSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimGridRemapSource_HEADER
 #define ossimGridRemapSource_HEADER
@@ -46,8 +46,6 @@ public:
    ossimGridRemapSource(ossimImageSource* inputSource,
                         ossimGridRemapEngine* engine);
 
-   virtual ~ossimGridRemapSource();
-
    /*!ossimAtbPointSource
     * Initializes the remap engine. This object implements specific algorithms
     * for interpreting the grids owned by this remapper. It actually performs
@@ -127,6 +125,8 @@ public:
    void setGridFilename(const ossimFilename& grid_filename);
    
 protected:
+   virtual ~ossimGridRemapSource();
+
    /*!
     * Deallocates grid memory.
     */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHistoMatchRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimHistoMatchRemapper.h
index b68dab89b45f72cc104ef8d87a13c6f210e69983..707e092e59d511a0500315811cbcdbdcfd258e2a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHistoMatchRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHistoMatchRemapper.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimHistoMatchRemapper.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimHistoMatchRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHistoMatchRemapper_HEADER
 #define ossimHistoMatchRemapper_HEADER
 #include <vector>
@@ -26,7 +26,6 @@ public:
                            const vector<double>& inputMeanPerBand   = vector<double>(),
                            const vector<double>& inputSigmaPerBand  = vector<double>()
                            );
-   virtual ~ossimHistoMatchRemapper();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
@@ -49,6 +48,8 @@ public:
                           const char* prefix=NULL);
 
 protected:
+   virtual ~ossimHistoMatchRemapper();
+   
    ossimRefPtr<ossimImageData> theBlankTile;
    
    vector<double> theTargetMeanPerBand;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHistogramEqualization.h b/Utilities/otbossim/include/ossim/imaging/ossimHistogramEqualization.h
index f48edc1bc78f40cfe18a42cdcb59cd5eafb70c34..cee88f8ab4dc7fa71d3de662c372490533493d5c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHistogramEqualization.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHistogramEqualization.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimHistogramEqualization.h 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimHistogramEqualization.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHistogramEqualization_HEADER
 #define ossimHistogramEqualization_HEADER
 #include <ossim/imaging/ossimImageSourceHistogramFilter.h>
@@ -22,7 +22,6 @@ public:
    ossimHistogramEqualization(ossimImageSource* inputSource,
                               ossimRefPtr<ossimMultiResLevelHistogram> histogram,
                               bool inverseFlag);
-   virtual ~ossimHistogramEqualization();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
 
@@ -41,6 +40,7 @@ public:
    virtual std::ostream& print(std::ostream& out) const;
 
 protected:
+   virtual ~ossimHistogramEqualization();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHistogramRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimHistogramRemapper.h
index cc350859792d798547a747d63248dd30310ea262..66e75383872cd40ee9b5f2fb96a3ba6ac4d936b2 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHistogramRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHistogramRemapper.h
@@ -28,7 +28,7 @@
 //   but is provided for convenience.
 //   
 //*************************************************************************
-// $Id: ossimHistogramRemapper.h 14075 2009-03-08 22:56:29Z gpotts $
+// $Id: ossimHistogramRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHistogramRemapper_HEADER
 #define ossimHistogramRemapper_HEADER
 
@@ -52,8 +52,6 @@ public:
    /** default constructor */
    ossimHistogramRemapper();
 
-   /** virtual destructor */
-   virtual ~ossimHistogramRemapper();
 
    virtual ossimString getLongName()  const;
    virtual ossimString getShortName() const;
@@ -457,7 +455,19 @@ public:
    virtual ostream& print(ostream& os) const;
 
    friend ostream& operator <<(ostream& os, const ossimHistogramRemapper& hr);
+   /**
+    * Returns the min pixel of the band.
+    */
+   virtual double getMinPixelValue(ossim_uint32 band=0)const;
    
+   /**
+    * Returns the max pixel of the band.
+    */
+   virtual double getMaxPixelValue(ossim_uint32 band=0)const;
+protected:
+   /** virtual destructor */
+   virtual ~ossimHistogramRemapper();
+
 private:
    // Do not allow copy constructor, operator=.
    ossimHistogramRemapper(const ossimHistogramRemapper& hr);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHistogramThreshholdFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimHistogramThreshholdFilter.h
index 6079ffd3f8f7951d8052c9a5c898be7e24018410..9d8121e4a6d4da9266b33f1666f2231dc00d30ac 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHistogramThreshholdFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHistogramThreshholdFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimHistogramThreshholdFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimHistogramThreshholdFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHistogramThreshholdFilter_HEADER
 #define ossimHistogramThreshholdFilter_HEADER
 #include <ossim/imaging/ossimImageSourceHistogramFilter.h>
@@ -21,7 +21,6 @@ public:
                                   double maxValuePercent,
                                   ossimImageSource* inputSource,
                                   ossimMultiResLevelHistogram* histogram);
-   virtual ~ossimHistogramThreshholdFilter();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
    
@@ -38,6 +37,7 @@ public:
                           const char* prefix=0)const;
    
 protected:
+   virtual ~ossimHistogramThreshholdFilter();
    
    double theMinValuePercent;
    double theMaxValuePercent;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHistogramWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimHistogramWriter.h
index 0def612f3ab2635564213cfb7c2e3fda29d268b8..9ceca46f35fc0ef42088096b4f17ff1e6388c8ad 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHistogramWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHistogramWriter.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimHistogramWriter.h 11002 2007-05-22 03:23:10Z dburken $
+// $Id: ossimHistogramWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHistogramWriter_HEADER
 #define ossimHistogramWriter_HEADER
 #include <ossim/base/ossimOutputSource.h>
@@ -36,7 +36,6 @@ public:
    ossimHistogramWriter(ossimImageSource* inputSource=0,
                         ossimObject* owner=0);
 
-   virtual ~ossimHistogramWriter();
    void setAreaOfInterest(const ossimIrect& rect);
 
    virtual ossimObject* getObject();
@@ -86,6 +85,7 @@ public:
    virtual void abort();
    
 protected:
+   virtual ~ossimHistogramWriter();
    virtual void writeHistogram();
    ossimIrect                           theAreaOfInterest;
    ossimFilename                        theFilename;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHsiRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimHsiRemapper.h
index d7dfb96df23914f3c7fbb422497705bcf496d514..cc73a944a662cf2435c9eaf6c38b514840f2c768 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHsiRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHsiRemapper.h
@@ -12,7 +12,7 @@
 // Remapper to adjust hue, saturation and intensity.
 //
 //*************************************************************************
-// $Id: ossimHsiRemapper.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimHsiRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimHsiRemapper_HEADER
 #define ossimHsiRemapper_HEADER
@@ -35,8 +35,6 @@ public:
    
    ossimHsiRemapper();
 
-   virtual ~ossimHsiRemapper();
-
    virtual ossimString getLongName()  const;
    virtual ossimString getShortName() const;
 
@@ -187,6 +185,7 @@ public:
    void resetMagenta();
    
 protected:
+   virtual ~ossimHsiRemapper();
    void   allocate(const ossimIrect& rect);
    void   verifyEnabled();
    double calculateMinNormValue();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHsiToRgbSource.h b/Utilities/otbossim/include/ossim/imaging/ossimHsiToRgbSource.h
index fd2c761024fe2b26159cf119867a3f5773d9b34d..4cdc91e9b0829fb1a323e92d465c0533b9174d34 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHsiToRgbSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHsiToRgbSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimHsiToRgbSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimHsiToRgbSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHsiToRgbSource_HEADER
 #define ossimHsiToRgbSource_HEADER
 
@@ -19,7 +19,6 @@ class ossimHsiToRgbSource : public ossimImageSourceFilter
 public:
    ossimHsiToRgbSource();
    ossimHsiToRgbSource(ossimImageSource* inputSource);
-   virtual ~ossimHsiToRgbSource();
    virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
 
@@ -31,6 +30,7 @@ public:
 
    virtual void initialize();
 protected:
+   virtual ~ossimHsiToRgbSource();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHsvToRgbSource.h b/Utilities/otbossim/include/ossim/imaging/ossimHsvToRgbSource.h
index 0ca1fe1adf3c639f3a7bd505d3ece7916531cae8..92dd14bc525cf4172d47717152a2b158b23b30c0 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimHsvToRgbSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimHsvToRgbSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimHsvToRgbSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimHsvToRgbSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimHsvToRgbSource_HEADER
 #define ossimJpegRgbToYCbCrSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossimHsvToRgbSource : public ossimImageSourceFilter
 public:
    ossimHsvToRgbSource();
    ossimHsvToRgbSource(ossimImageSource* inputSource);
-   virtual ~ossimHsvToRgbSource();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
 
@@ -30,6 +29,7 @@ public:
    virtual void initialize();
 
 protected:
+   virtual ~ossimHsvToRgbSource();
 
    virtual void allocate();
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageChain.h b/Utilities/otbossim/include/ossim/imaging/ossimImageChain.h
index b1922d5d00768e893472e8c2a2b49cc9eaaaa0ea..f80d26458c36834425be221a65184884d4336c9e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageChain.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageChain.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageChain.h 13475 2008-08-22 14:21:54Z gpotts $
+// $Id: ossimImageChain.h 15798 2009-10-23 19:15:20Z gpotts $
 #ifndef ossimImageChain_HEADER
 #define ossimImageChain_HEADER
 #include <vector>
@@ -176,8 +176,7 @@ public:
                                       ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER,
                                       ossim_uint32 resLevel=0)const;
    
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=NULL);
+   virtual ossimImageGeometry* getImageGeometry();
 
    virtual void getDecimationFactor(ossim_uint32 resLevel,
                                     ossimDpt& result) const;
@@ -199,15 +198,14 @@ public:
    virtual void initialize();
    virtual void enableSource();
    virtual void disableSource();
-   vector<ossimConnectableObject*>& getChildren();
    
    bool canConnectMyInputTo(ossim_int32 myInputIndex,
                             const ossimConnectableObject* object)const
       {
          if(theImageChainList.size()&&
-            theImageChainList[theImageChainList.size()-1])
+            theImageChainList[theImageChainList.size()-1].valid())
          {
-            ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject, theImageChainList[theImageChainList.size()-1]);
+            ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject, theImageChainList[theImageChainList.size()-1].get());
             if(obj)
             {
                return obj->canConnectMyInputTo(myInputIndex,
@@ -249,9 +247,9 @@ public:
     * Example: passing STATIC_TYPE_INFO(ossimImageRenderer) as an argument will
     *          look for all ossimImageRenderer's and return the list.
     */
-   virtual std::vector<ossimConnectableObject*> findAllObjectsOfType(const RTTItypeid& typeInfo,
+   virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid& typeInfo,
                                                                      bool recurse=true);
-   virtual std::vector<ossimConnectableObject*> findAllObjectsOfType(const ossimString& className,
+   virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const ossimString& className,
                                                                      bool recurse=true);
 
    /**
@@ -331,12 +329,12 @@ public:
    
 protected:
    friend class ossimImageChainChildListener;
-   /**
+  /**
     * This will hold a sequence of image sources.
     * theFirst one in the list will be the head of the
     * list and the last one is the tail.
     */
-   vector<ossimConnectableObject*> theImageChainList;
+   ossimConnectableObject::ConnectableObjectList theImageChainList;
    
    ossimRefPtr<ossimImageData>     theBlankTile;
    ossimImageChainChildListener*   theChildListener;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageCombiner.h b/Utilities/otbossim/include/ossim/imaging/ossimImageCombiner.h
index 444faaec0cf0f55f7829f5703afd8abe3de2bcee..c4af59534e3ef591bf4dbfc807d49e6f2d34621d 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageCombiner.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageCombiner.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageCombiner.h 10777 2007-04-25 14:49:17Z gpotts $
+// $Id: ossimImageCombiner.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageCombiner_HEADER
 #define ossimImageCombiner_HEADER
 #include <vector>
@@ -29,8 +29,7 @@ public:
                       bool inputListIsFixedFlag,
                       bool outputListIsFixedFlag);
    
-   ossimImageCombiner(const std::vector<ossimImageSource*>& inputSources);
-   virtual ~ossimImageCombiner();   
+   ossimImageCombiner(ossimConnectableObject::ConnectableObjectList& inputSources);
 
    virtual void getDecimationFactor(ossim_uint32 resLevel,
                                     ossimDpt& result) const;
@@ -39,8 +38,7 @@ public:
 
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const;
 
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=NULL);
+   virtual ossimImageGeometry* getImageGeometry();
 
    virtual void initialize();
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=NULL);
@@ -127,6 +125,7 @@ public:
 
    
 protected:
+   virtual ~ossimImageCombiner();   
    void precomputeBounds()const;
 
    ossim_uint32                theLargestNumberOfInputBands;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageData.h b/Utilities/otbossim/include/ossim/imaging/ossimImageData.h
index 442db5e01930dd290b9e16e341879527907b1eca..91481a0c42e930adf27df8d066b19b2bc51e7919 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageData.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageData.h
@@ -6,10 +6,10 @@
 //
 // Author: Garrett Potts
 // 
-// Description: A brief description of the contents of the file.
+// Description: Container class for a tile of image data.
 //
 //*******************************************************************
-// $Id: ossimImageData.h 14530 2009-05-16 23:56:54Z dburken $
+// $Id: ossimImageData.h 15798 2009-10-23 19:15:20Z gpotts $
 #ifndef ossimImageData_HEADER
 #define ossimImageData_HEADER
 
@@ -27,6 +27,24 @@ class OSSIMDLLEXPORT ossimImageData : public ossimRectilinearDataObject
 {
 public:
 
+   /** Definitions for the unloadBand routines. */
+   enum OverwriteBandRule
+   {
+      /*
+       * The COLOR_DISCREPANCY rule directs that the selected band of a pixel
+       * of the destination buffer is to be overwritten if any one of the other 
+       * bands of the same pixel have color values that deviate from the  
+       * color value of the selected band. 
+       */
+      COLOR_DISCREPANCY = 0,
+      
+      /*
+       * The selected band of the destination buffer is to be overwritten 
+       * by the selected band of the source image data (no questions asked).
+       */
+      NULL_RULE = 1
+   };
+
    /** @brief copy constructor */
    ossimImageData(const ossimImageData &rhs);
 
@@ -63,6 +81,14 @@ public:
    /** @brief virtual destructor */
    virtual ~ossimImageData();
 
+   /**
+    * @brief assignment operator=
+    * @param rhs The data to assign from.
+    * @param A reference to this object.
+    */
+   virtual const ossimImageData& operator=(const ossimImageData &rhs);
+
+
    /**
     * @return The width of the data object.
     */
@@ -549,50 +575,140 @@ public:
                               const ossimIrect& src_rect,
                               ossim_uint32 band,
                               bool swap_bytes=false);
-   
-   virtual void unloadTile(void* dest,
-                           const ossimIrect& dest_rect,
-                           ossimInterleaveType il_type) const;
-   
-   virtual void unloadTile(void* dest,
-                           const ossimIrect& dest_rect,
-                           const ossimIrect& clip_rect,
-                           ossimInterleaveType il_type) const;
+
+   /**
+    * This routine is designed for overwriting a selected band of the 
+    * destination buffer 'dest' by an independent selected band of the
+    * source buffer according to a user-selected rule, defined by 
+    * OverwriteBandRule.
+    *
+    * Currently the rules available in OverwriteBandRule are: 
+    *
+    * The COLOR_DISCREPANCY rule directs that the selected band of a pixel
+    * of the destination buffer is to be overwritten if any one of the other 
+    * bands of the same pixel have color values that deviate from the  
+    * color value of the selected band. 
+    *
+    * The NULL_RULE rule directs that the selected band of the 
+    * destination buffer is to be overwritten by the selected band of the 
+    * source image data (no questions asked).
+    *
+    * @note The src object should have at least the same number of bands as 
+    * the 'dest' buffer. 
+    *
+    * Currently this routine is only implemented for il_type set to OSSIM_BSQ.
+    *
+    * @param dest The destination buffer with at least the same number of bands
+    * as the src (this) object.
+    * @param src_band  The 0-based band of the source image data.
+    * @param dest_band The 0-based band of the dest buffer.
+    * @param dest_rect The rectangle of the destination buffer.
+    * @param il_type   The interleave type. Only OSSIM_BSQ available.
+    * @param ow_type   The rule for overwriting the destination buffer.
+    */
+   virtual void unloadBand( void* dest,
+                            ossim_uint32 src_band,
+                            ossim_uint32 dest_band,
+                            const ossimIrect& dest_rect,
+                            ossimInterleaveType il_type=OSSIM_BSQ,
+                            OverwriteBandRule ow_type=NULL_RULE ) const;
+
+   /**
+    * This routine is designed for overwriting a selected band of the 
+    * destination buffer 'dest' by an independent selected band of the
+    * source buffer according to a user-selected rule, defined by 
+    * OverwriteBandRule.
+    *
+    * Currently the rules available in OverwriteBandRule are: 
+    *
+    * The COLOR_DISCREPANCY rule directs that the selected band of a pixel
+    * of the destination buffer is to be overwritten if any one of the other 
+    * bands of the same pixel have color values that deviate from the  
+    * color value of the selected band. 
+    *
+    * The NULL_RULE rule directs that the selected band of the 
+    * destination buffer is to be overwritten by the selected band of the 
+    * source image data (no questions asked).
+    *
+    * Note: The src object should have at least the same number of bands as 
+    * the 'dest' buffer. 
+    *
+    * Currently this routine is only implemented for il_type set to OSSIM_BSQ.
+    *
+    * @param dest The destination buffer with at least the same number of bands
+    * as the src (this) object.
+    * @param src_band  The 0-based band of the source image data.
+    * @param dest_band The 0-based band of the dest buffer.
+    * @param dest_rect The rectangle of the destination buffer.
+    * @param clip_rect Only data within will be copied.
+    * @param il_type   The interleave type. Only OSSIM_BSQ available.
+    * @param ow_type   The rule for overwriting the destination buffer.
+    */
+   virtual void unloadBand( void* dest,
+                            ossim_uint32 src_band,
+                            ossim_uint32 dest_band,
+                            const ossimIrect& dest_rect,
+                            const ossimIrect& clip_rect,
+                            ossimInterleaveType il_type=OSSIM_BSQ,
+                            OverwriteBandRule ow_type=NULL_RULE ) const;
 
    /**
     * @param dest The destination buffer.  It is assumed this is a single band
     * and the size of dest_rect.
     * @param dest_rect The rectangle of the destination buffer.
-    * @param band The band to copy (unload) from the tile.
+    * @param src_band The band to copy (unload) from the tile.
     */
    virtual void unloadBand(void* dest,
                            const ossimIrect& dest_rect,
-                           ossim_uint32 band) const;
+                           ossim_uint32 src_band) const;
 
    /**
     * @param dest The destination buffer.  It is assumed this is a single band
     * and the size of dest_rect.
     * @param dest_rect The rectangle of the destination buffer.
     * param clip_rect Only data within the clip_rect will be copied.
-    * @param band The band to copy (unload) from the tile.
+    * @param src_band The band to copy (unload) from the tile.
     */
    virtual void unloadBand(void* dest,
                            const ossimIrect& dest_rect,
                            const ossimIrect& clip_rect,
-                           ossim_uint32 band) const;
+                           ossim_uint32 src_band) const;
    
+   virtual void unloadTile(void* dest,
+                           const ossimIrect& dest_rect,
+                           ossimInterleaveType il_type ) const;
+
+   virtual void unloadTile(void* dest,
+                           const ossimIrect& dest_rect,
+                           const ossimIrect& clip_rect,
+                           ossimInterleaveType il_type) const;
    
    virtual bool isPointWithin(const ossimIpt& point)const;
    virtual bool isPointWithin(ossim_int32 x,
                               ossim_int32 y)const;
 
    virtual std::ostream& print(std::ostream& out) const;
+
+   /**
+    * @brief Performs linear stretch on tile data from min/max to limits of
+    * scalar type.
+    */
+   virtual void stretchMinMax();
    
 protected:
+
    ossimImageData();
 
    /**
-    * Templated valide method.
+    * @brief Templated stretch method.
+    *
+    * Performs linear stretches on tile data from min/max to limits of
+    * scalar type.
+    */
+   template <class T> void stretchMinMax(T dummyTemplate);
+
+   /**
+    * Templated validate method.
     *
     * @return The status of the ossimImageDataMethod.
     *
@@ -620,40 +736,6 @@ protected:
       ossim_float64 computeAverageBandValue(T dummyTemplate,
                                             ossim_uint32 bandNumber) const;
    
-   /**
-    *  
-    *  Takes normPix, unnormalizes and initializes pixel.
-    *  "band" is used as index to get the min/max/null values.
-    */
-   void getPixFromNorm(ossim_int32& pixel,
-                       ossim_float32  normPix,
-                       ossim_uint32 band) const;
-
-   
-   /**
-    *  Takes normPix, unnormalizes and initializes pixel.
-    *  "band" is used as index to get the min/max/null values.
-    */
-   void getPixFromNorm(ossim_int32& pixel,
-                       ossim_float64 normPix,
-                       ossim_uint32 band) const;
-
-   /**
-    *  Take pixel, normalizes and initializes normPix.
-    *  "band" is used as index to get the min/max/null values.
-    */
-   void getNormFromPix  (ossim_int32  pixel,
-                         ossim_float32& normPix,
-                         ossim_uint32 band) const;
-
-   /**
-    *  Take pixel, normalizes and initializes normPix.
-    *  "band" is used as index to get the min/max/null values.
-    */
-   void getNormFromPix (ossim_int32  pixel,
-                        ossim_float64& normPix,
-                        ossim_uint32 band) const;
-
    void loadTileFromBip(const void* src, const ossimIrect& src_rect);
    void loadTileFromBil(const void* src, const ossimIrect& src_rect);
    void loadTileFromBsq(const void* src, const ossimIrect& src_rect);
@@ -678,6 +760,24 @@ protected:
                         const ossimIrect& dest_rect,
                         const ossimIrect& clip_rect) const;
 
+   /**
+    * Called from public unloadBand() routines that have an 
+    * OverwriteBandRule interface.
+    *
+    * @param dest      The destination buffer.
+    * @param src_band  The 0-based band of the source image data.
+    * @param dest_band The 0-based band of the destination buffer.
+    * @param dest_rect The rectangle of the destination buffer.
+    * @param clip_rect Only data within will be copied.
+    * @param ow_type   The rule for overwriting the destination buffer.
+    */
+   virtual void unloadBandToBsq( void* dest,
+                                 ossim_uint32 src_band,
+                                 ossim_uint32 dest_band,
+                                 const ossimIrect& dest_rect,
+                                 const ossimIrect& clip_rect,
+                                 OverwriteBandRule ow_type=NULL_RULE ) const;
+
    /**
     * Copies entire tile to buf passed in.  Data put in buf is normalized.
     * The "buf" passed to method is assumed to be at least as big as:
@@ -771,27 +871,35 @@ protected:
                                                    const ossimIrect& src_rect,
                                                    const ossimIrect& clip_rect);
    
-   template <class T> void unloadTileToBipTemplate(T, // dummy tmeplate variable
+   template <class T> void unloadTileToBipTemplate(T, // dummy template variable
                                                    void* dest,
                                                    const ossimIrect& dest_rect,
                                                    const ossimIrect& clip_rect) const;
 
-   template <class T> void unloadTileToBilTemplate(T, // dummy tmeplate variable
+   template <class T> void unloadTileToBilTemplate(T, // dummy template variable
                                                    void* dest,
                                                    const ossimIrect& dest_rect,
                                                    const ossimIrect& clip_rect) const;
 
-   template <class T> void unloadTileToBsqTemplate(T, // dummy tmeplate variable
+   template <class T> void unloadTileToBsqTemplate(T, // dummy template variable
                                                    void* dest,
                                                    const ossimIrect& dest_rect,
                                                    const ossimIrect& clip_rect) const;
 
-   template <class T> void unloadBandTemplate(T, // dummy tmeplate variable
+   template <class T> void unloadBandTemplate(T, // dummy template variable
                                               void* dest,
                                               const ossimIrect& dest_rect,
                                               const ossimIrect& clip_rect,
                                               ossim_uint32 band) const;
 
+   template <class T> void unloadBandToBsqTemplate(T, // dummy template variable
+                                                   void* dest,
+                                                   ossim_uint32 src_band,
+                                                   ossim_uint32 dest_band,
+                                                   const ossimIrect& dest_rect,
+                                                   const ossimIrect& clip_rect,
+                                                   OverwriteBandRule ow_type=NULL_RULE) const;
+
    /**
     * @brief initializeDefaults() Resizes and sets min/max/null arrays to
     * number of bands and some default value for scalar type.
@@ -821,12 +929,16 @@ protected:
    
    bool hasSameDimensionsAs(ossimImageData* data)const
    {
-      if(!data) return false;
-      return ((theNumberOfSpatialComponents ==
-               data->theNumberOfSpatialComponents)&
-              (theSpatialExtents[0] == data->theSpatialExtents[0])&&
-              (theSpatialExtents[1] == data->theSpatialExtents[1])&&
-              (theScalarType == data->theScalarType));
+      bool result = false;
+      if(data)
+      {
+         result = ((theSpatialExtents.size() ==
+                    data->theSpatialExtents.size())&&
+                   (theSpatialExtents[0] == data->theSpatialExtents[0])&&
+                   (theSpatialExtents[1] == data->theSpatialExtents[1])&&
+                   (theScalarType == data->theScalarType));
+      }
+      return result;
    }
    
    /**
@@ -845,110 +957,13 @@ protected:
    std::vector<ossim_float64> theMaxPixelValue;
    
    ossimIpt       theOrigin;
-   
+
 private:
-   /**
-    * @note disallow 
-    */
-   const ossimImageData& operator=(const ossimImageData &rhs);
+
    
 TYPE_DATA
 };
 
-inline void ossimImageData::getPixFromNorm(ossim_int32& pixel,
-                                           ossim_float32 normPix,
-                                           ossim_uint32 band) const
-{
-   // If norm pix is 0.0 or negative make if null.
-   ossim_float32 p = theNullPixelValue[band]; 
-   
-   if (normPix > 0.0)
-   {
-      // un-normalize...
-      p = normPix * (theMaxPixelValue[band]-theMinPixelValue[band]+1.0);
-      
-      // handle negative min values.
-      p = p + theMinPixelValue[band] - 1.0;  
-      
-      // Clamp to  max.
-      if (p > theMaxPixelValue[band]) p = theMaxPixelValue[band];
-   
-      //***
-      // If p is less than min, make it min as it wasn't a null before.
-      // Add or subtract 0.5 to p otherwise as it will be cast to an
-      // int for proper rounding.
-      //***
-      p = p > theMinPixelValue[band] ?
-          ( p<0.0 ? p-0.5 : p+0.5 ) :
-          theMinPixelValue[band];
-   }
-
-   // Cast back to an int.
-   pixel = static_cast<ossim_int32>(p);
-}
-
-inline void ossimImageData::getPixFromNorm(ossim_int32& pixel,
-                                           ossim_float64 normPix,
-                                           ossim_uint32 band) const
-{
-   // If norm pix is 0.0 or negative make if null.
-   ossim_float64 p = theNullPixelValue[band]; 
-   
-   if (normPix > 0.0)
-   {
-      // un-normalize...
-      p = normPix * (theMaxPixelValue[band]-theMinPixelValue[band]+1.0);
-      
-      // handle negative min values.
-      p = p + theMinPixelValue[band] - 1.0;  
-      
-      // Clamp to  max.
-      if (p > theMaxPixelValue[band]) p = theMaxPixelValue[band];
-   
-      //***
-      // If p is less than min, make it min as it wasn't a null before.
-      // Add or subtract 0.5 to p otherwise as it will be cast to an
-      // int for proper rounding.
-      //***
-      p = p > theMinPixelValue[band] ?
-          ( p<0.0 ? p-0.5 : p+0.5 ) :
-          theMinPixelValue[band];
-   }
-
-   // Cast back to an int.
-   pixel = static_cast<ossim_int32>(p);
-}
-
-inline void ossimImageData::getNormFromPix(ossim_int32 pixel,
-                                           ossim_float32&  normPix,
-                                           ossim_uint32 band) const
-{
-   if      (pixel == theNullPixelValue[band]) normPix = 0.0;
-   else if (pixel >= theMaxPixelValue[band])  normPix = 1.0;
-
-   //***
-   // Normalize...
-   // Note that this will shift any negatives to positive prior to dividing.
-   //***
-   else normPix = ( (pixel-theMinPixelValue[band]+1) /
-                    (theMaxPixelValue[band] - theMinPixelValue[band] + 1.0) );
-}
-
-inline void ossimImageData::getNormFromPix(ossim_int32  pixel,
-                                           ossim_float64&   normPix,
-                                           ossim_uint32 band) const
-{
-   if      (pixel == theNullPixelValue[band]) normPix = 0.0;
-   else if (pixel >= theMaxPixelValue[band])  normPix = 1.0;
-
-   //***
-   // Normalize...
-   // Note that this will shift any negatives to positive prior to dividing.
-   //***
-   else normPix = ( (pixel-theMinPixelValue[band]+1) /
-                    (theMaxPixelValue[band] - theMinPixelValue[band] + 1.0) );
-}
-
 inline ossimIrect ossimImageData::getImageRectangle() const
 {
    ossimIpt lr(theOrigin.x + getWidth()  - 1,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageDisplayWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageDisplayWriter.h
index 03b2a7446a2a3030dedf2c1e314bdc6d68d81ce6..c6d8e14aa116859cf1f52bc28d7c31774fa1be2b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageDisplayWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageDisplayWriter.h
@@ -8,7 +8,7 @@
 //
 // Contains class declaration for ossimImageWriter
 //*******************************************************************
-//  $Id: ossimImageDisplayWriter.h 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimImageDisplayWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageDisplayWriter_HEADER
 #define ossimImageDisplayWriter_HEADER
 
@@ -25,9 +25,7 @@ class ossimImageDisplayWriter :  public ossimImageWriter,
 
 {
 public:
-   virtual ~ossimImageDisplayWriter(){}
    
-
    bool canConnectMyInputTo(ossim_int32 inputIndex,
                             const ossimConnectableObject* object)const
       {
@@ -65,6 +63,8 @@ public:
    virtual void show()=0;
    
 protected:
+   virtual ~ossimImageDisplayWriter(){}
+   
    ossimImageDisplayWriter(ossimObject* owner=NULL);
    ossimImageDisplayWriter(ossimObject* owner,
                            ossim_uint32 numberOfInputs,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageFileWriter.h
index 90cdb1429c790fcd165cf997454c6158a5553f2a..8acf46467c5b0a9097703f66e4c6cfca10b7a1c5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageFileWriter.h
@@ -8,7 +8,7 @@
 //
 // Contains class declaration for ossimImageWriter
 //*******************************************************************
-//  $Id: ossimImageFileWriter.h 11181 2007-06-07 19:57:14Z dburken $
+//  $Id: ossimImageFileWriter.h 15798 2009-10-23 19:15:20Z gpotts $
 
 #ifndef ossimImageFileWriter_HEADER
 #define ossimImageFileWriter_HEADER
@@ -44,9 +44,9 @@ public:
    ossimImageFileWriter(const ossimFilename& filename = ossimFilename(),
                         ossimImageSource* inputSource=0,
                         ossimObject* owner=0);
-   
    virtual ~ossimImageFileWriter();
    
+   
    virtual ossimObject* getObject();
 
    virtual const ossimObject* getObject()const;
@@ -90,36 +90,36 @@ public:
     * Will write an envi header file.  If "theFilename" is "foo.tif"
     * then this will write out "foo.hdr".
     */
-   virtual bool writeEnviHeaderFile() const;
+   virtual bool writeEnviHeaderFile() ;
 
    /**
     * Will write an ER Mapper header file.  If "theFilename" is "foo.tif"
     * then this will write out "foo.hdr".
     */
-   virtual bool writeErsHeaderFile() const;
+   virtual bool writeErsHeaderFile() ;
 
    /**
     * Will write an external geometry file.  If "theFilename" is "foo.tif"
     * then this will write out "foo.geom".
     */
-   virtual bool writeExternalGeometryFile() const;
+   virtual bool writeExternalGeometryFile() ;
 
    /**
     * Will write an fgdc file.  If "theFilename" is "foo.tif"
     * then this will write out "foo.xml".
     */
-   virtual bool writeFgdcFile() const;
+   virtual bool writeFgdcFile() ;
 
    /**
     * Returns true on success, false on error.
     */
-   virtual bool writeHistogramFile() const;
+   virtual bool writeHistogramFile() ;
 
    /**
     * Will write a jpeg world file.  If "theFilename" is "foo.tif"
     * then this will write out "foo.jpw".
     */
-   virtual bool writeJpegWorldFile() const;
+   virtual bool writeJpegWorldFile() ;
 
    /**
     * Write out an ossim overview file from the source_file.
@@ -141,19 +141,19 @@ public:
     * @return true on success, false on error.
     */
    virtual bool writeOverviewFile(ossim_uint16 tiff_compress_type = 1,
-                                  ossim_int32 jpeg_compress_quality = 75)const;
+                                  ossim_int32 jpeg_compress_quality = 75);
 
    /**
     * Will write a readme file.  If "theFilename" is "foo.tif"
     * then this will write out "foo_readme.txt".
     */
-   virtual bool writeReadmeFile() const;
+   virtual bool writeReadmeFile() ;
 
    /**
     * Will write a readme file.  If "theFilename" is "foo.tif"
     * then this will write out "foo.tfw".
     */
-   virtual bool writeTiffWorldFile() const;
+   virtual bool writeTiffWorldFile() ;
 
    /**
     * Convenience method that calls meta data write methods that are flagged
@@ -172,7 +172,7 @@ public:
     *
     * @return true if all files flagged are written, false if not.
     */
-   virtual bool writeMetaDataFiles() const;
+   virtual bool writeMetaDataFiles() ;
 
    virtual void setAreaOfInterest(const ossimIrect& inputRect);
 
@@ -388,7 +388,7 @@ protected:
     *
     * @return true on success, false on error.
     */
-   bool writeWorldFile(const ossimFilename& file) const;
+   bool writeWorldFile(const ossimFilename& file);
    
    /**
     * Write out the file.
@@ -396,8 +396,8 @@ protected:
     */
    virtual bool writeFile() = 0;
    
-   ossimImageSourceSequencer* theInputConnection;
-   ossimViewController*       theViewController;
+   ossimRefPtr<ossimImageSourceSequencer> theInputConnection;
+   ossimRefPtr<ossimViewController>       theViewController;
    ossimListener*             theProgressListener;
    ossimFilename              theFilename;
    ossimString                theOutputImageType;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageGaussianFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageGaussianFilter.h
index 056f9c705e33e46cce3b157c7ec629208b042b32..cd55cfb4843200689f78fe60b9394f372a45fede 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageGaussianFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageGaussianFilter.h
@@ -4,7 +4,7 @@
 // See LICENSE.txt file in the top level directory for more details.
 // class ossimImageGaussianFilter : tile source
 //*******************************************************************
-// $Id: ossimImageGaussianFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageGaussianFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageGaussianFilter_HEADER
 #define ossimImageGaussianFilter_HEADER
 
@@ -30,7 +30,6 @@ public:
    * own methods
    */
    ossimImageGaussianFilter();
-   virtual ~ossimImageGaussianFilter();
 
    inline ossim_float64 getGaussStd()const { return theGaussStd; }
    void setGaussStd(const ossim_float64& v);
@@ -56,6 +55,7 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,const char* prefix = 0)const;
    
 protected:
+   virtual ~ossimImageGaussianFilter();
   /**
    * protected methods
    */
@@ -71,8 +71,8 @@ protected:
   /**
    * subprocesses
    */
-   ossimConvolutionFilter1D* theHF; //horizontal filter
-   ossimConvolutionFilter1D* theVF; //vertical filter
+   ossimRefPtr<ossimConvolutionFilter1D> theHF; //horizontal filter
+   ossimRefPtr<ossimConvolutionFilter1D> theVF; //vertical filter
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageGeometry.h b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometry.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb80d3b93962b264c0e84767b21225499cacd805
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometry.h
@@ -0,0 +1,218 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  Oscar Kramer (oscarkramer@yahoo.com)
+//
+// Description: Class declaration of ossimImageGeometry.
+//
+//**************************************************************************************************
+// $Id$
+
+#ifndef ossimImageGeometry_HEADER
+#define ossimImageGeometry_HEADER 1
+
+#include <vector>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimObject.h>
+#include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimRtti.h>
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/projection/ossimProjection.h>
+#include <ossim/base/ossim2dTo2dTransform.h>
+
+//**************************************************************************************************
+//! Container class that holds both 2D transform and 3D projection information for an image
+//! Only one instance of this is alive per image. This is  the object that is returned from
+//! a call to ossimImageSource::getImageGeometry()
+//! 
+//! All images in OSSIM have at least a 2D transformation from local (relative to start of file)
+//! to full-image coordinates. Often this transform is an identity transform (does nothing). In 
+//! some cases however, the first pixel in the file does not correspond to the upper-left pixel of
+//! the original, full image. Since the image's sensor model may only apply to full-image pixel 
+//! coordinates, it is necessary to reference the latter when making computing ground point 
+//! location.
+//! 
+//! Additionally, images typically are accompanied by some form of metadata that defines the mapping
+//! from 2D image coordinates to 3D world coordinates. This mapping may be in the form of a map
+//! projection for orthorectified images, or a perspective projection such as a sensor model.
+//! 
+//! This object class maintains both 2D transform and 3D projection information for the associated
+//! image. This object will typically be created and "owned" by the image handler object. Therefore,
+//! only one copy per image will exist at a time.
+//**************************************************************************************************
+class OSSIM_DLL ossimImageGeometry : public ossimObject
+{
+public:
+   //! Default constructor defaults to unity transform with no projection.
+   ossimImageGeometry();
+   
+   //! Copy constructor -- performs a deep copy. This is needed when an imageSource in the chain
+   //! needs to modify the image geometry at that point in the chain. The image geometry to the 
+   //! left of that imageSource must remain unchanged. This constructor permits that imageSource to 
+   //! maintain its own geometry based on the input geometry. All chained objects to the right
+   //! would see this alternate geometry. See ossimScaleFilter for an example of this case.
+   ossimImageGeometry(const ossimImageGeometry& copy_this);
+
+   //! Constructs with projection and transform objects available for referencing. Either pointer
+   //! can be NULL -- the associated mapping would be identity.
+   ossimImageGeometry(ossim2dTo2dTransform* transform, ossimProjection* projection);
+   
+   //! rnToLocal is a utility method that takes a rn resolution image point and maps it to the local
+   //! image point.
+   //!
+   //! @param rnPt Is a point in resolution n.
+   //! @param resolutionLevel Is the resolution of the point rnPt.  a value of 0 is the local image
+   //! @param localPt Is the result of the transform
+   //!
+   void rnToLocal(const ossimDpt& rnPt, ossim_uint32 resolutionLevel, ossimDpt& localPt);
+   
+   //! rnToFull is a utility method that takes a rn resolution image point and maps it to the full
+   //! image point.
+   //!
+   //! @param rnPt Is a point in resolution n.
+   //! @param resolutionLevel Is the resolution of the point rnPt.  a value of 0 is the local image
+   //! @param fullPt Is the result of the transform
+   //!
+   void rnToFull(const ossimDpt& rnPt, ossim_uint32 resolutionLevel, ossimDpt& fullPt);
+
+   //! rnToWorld is a utility method that takes a rn resolution image point and maps it to the 
+   //! world point.
+   //!
+   //! @param rnPt Is a point in resolution n.
+   //! @param resolutionLevel Is the resolution of the point rnPt.  a value of 0 is the local image
+   //! @param wpt Is the result of the transform
+   //!
+   void rnToWorld(const ossimDpt& rnPt, ossim_uint32 resolutionLevel, ossimGpt& wpt);
+   
+   
+   //! worldToRn is a utility method that takes a world point allows one to transform all the way back to
+   //! an rn point.
+   //!
+   //! @param wpt Ground point.
+   //! @param resolutionLevel Is the resolution of the point rnPt.  a value of 0 is the local image
+   //! @param rnPt Is the resoltion point.
+   //!
+   void worldToRn(const ossimGpt& wpt, ossim_uint32 resolutionLevel, ossimDpt& rnPt);
+   
+   //! Exposes the 2D functionality that transforms from local (file) x,y pixel to full-image
+   //! X,Y coordinates
+   void localToFullImage(const ossimDpt& local_pt, ossimDpt& full_pt) const;
+
+   //! Exposes the 2D functionality that transforms from full-image X,Y coordinates to 
+   //! local (file) x,y pixel coordinates
+   void fullToLocalImage(const ossimDpt& full_pt, ossimDpt& local_pt) const;
+
+   //! Exposes the 3D projection from image to world coordinates. The caller should verify that
+   //! a valid projection exists before calling this method. Returns TRUE if a valid ground point
+   //! is available in the ground_pt argument. This method depends on the existence of elevation
+   //! information. If no DEM is available, the results will be incorrect or inaccurate.
+   bool localToWorld(const ossimDpt& local_pt, ossimGpt& world_pt) const;
+
+   //! Exposes the 3D world-to-local image coordinate reverse projection. The caller should verify 
+   //! that a valid projection exists before calling this method. Returns TRUE if a valid image 
+   //! point is available in the local_pt argument.
+   bool worldToLocal(const ossimGpt& world_pt, ossimDpt& local_pt) const;
+
+   //! Sets the transform to be used for local-to-full-image coordinate transformation
+   void setTransform(ossim2dTo2dTransform* transform);
+
+   //! Sets the projection to be used for local-to-world coordinate transformation
+   void setProjection(ossimProjection* projection);
+
+   //! Access methods for transform (may be NULL pointer).
+   const ossim2dTo2dTransform* getTransform() const { return m_transform.get(); }
+   ossim2dTo2dTransform*       getTransform()       { return m_transform.get(); }
+
+   //! Access methods for projection (may be NULL pointer).
+   const ossimProjection* getProjection() const { return m_projection.get(); }
+   ossimProjection*       getProjection()       { return m_projection.get(); }
+
+   //! Returns TRUE if valid projection defined
+   bool hasProjection() const { return m_projection.valid(); }
+   
+   //! Returns TRUE if valid transform defined
+   bool hasTransform() const { return m_transform.valid(); }
+
+   //! Returns TRUE if this geometry is sensitive to elevation
+   bool isAffectedByElevation() const;
+
+   //! Returns the GSD associated with this image in the active projection. Note that this only
+   //! makes sense if there is a projection associated with the image. Returns NaNs if no 
+   //! projection defined.
+   const ossimDpt& getMetersPerPixel() const;
+
+   //! Prints contents to output stream.
+   std::ostream& print(std::ostream& out) const;
+
+   //! Returns TRUE if argument geometry has exactly the same instances for transform and 
+   //! m_projection. This should be expanded to permit different instances of same transforms
+   bool operator==(const ossimImageGeometry& compare_this) const;
+
+   //! Replaces any existing transform and projection with those in the copy_this object
+   const ossimImageGeometry& operator=(const ossimImageGeometry& copy_this);
+
+   //! Returns the decimation factor from R0 for the resolution level specified. For r_index=0, the 
+   //! decimation factor is by definition 1.0. For the non-discrete case, r_index=1 returns a 
+   //! decimation of 0.5. If the vector of discrete decimation factors (m_decimationFactors) is 
+   //! empty, the factor will be computed as f=1/2^n
+   ossimDpt decimationFactor(ossim_uint32 r_index) const;
+
+   /**
+    * @brief Method to get the decimation factor for a given resolution
+    * level.
+    *
+    * If the array of decimations is not initialized by owner, the default is:
+    * r_index=0 is by definition 1.0.
+    * r_index=n Where n is some level the factor will be computed as f=1/2^n.
+    *
+    * @param resLevel Reduced resolution set for requested decimation.
+    *
+    * @param result ossimDpt to initialize with requested decimation.
+    */
+   void decimationFactor(ossim_uint32 r_index, ossimDpt& result) const;
+
+   /**
+    * @brief Gets array of all decimation levels.
+    * @param decimations Array to initialiaze.
+    */
+   void decimationFactors(std::vector<ossimDpt>& decimations) const;
+
+   //! Sets the decimation scheme to a discrete list of decimation factors.
+   void setDiscreteDecimation(const std::vector<ossimDpt>& decimation_list) 
+      { m_decimationFactors = decimation_list; }
+
+   //! @return The number of decimation factors
+   ossim_uint32 getNumberOfDecimations()const
+   {
+      return (ossim_uint32)m_decimationFactors.size();
+   }
+   //! Creates a new instance of ossimImageGeometry with the same transform and projection.
+   //! Overrides base-class version requiring loadState() and saveState() (not implemented yet)
+   virtual ossimObject* dup() const { return new ossimImageGeometry(*this); }
+
+   //! Attempts to initialize a transform and a projection given the KWL. Returns TRUE if no
+   //! error encountered.
+   virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
+
+   //! Saves the transform (if any) and projection (if any) states to the KWL.
+   virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0) const;
+
+protected:
+   //! Hidden destructor prevents unmanaged delete.
+   virtual ~ossimImageGeometry();
+
+   //! When either the projection or the transform changes, this method recomputes the GSD.
+   void computeGsd()const;
+
+   ossimRefPtr<ossim2dTo2dTransform> m_transform;   //!< Maintains local_image-to-full_image transformation 
+   ossimRefPtr<ossimProjection>      m_projection;  //!< Maintains full_image-to-world_space transformation
+   mutable ossimDpt                  m_gsd;         //!< meters per pixel
+   std::vector<ossimDpt>             m_decimationFactors; //!< List of decimation factors for R-levels
+
+   TYPE_DATA
+};
+
+#endif /* #ifndef ossimImageGeometry_HEADER */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryFactory.h b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryFactory.h
new file mode 100644
index 0000000000000000000000000000000000000000..4c2035391474399673e4d8017960dc46c330c8d1
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryFactory.h
@@ -0,0 +1,53 @@
+//*****************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossimImageGeometryFactory.
+//
+//*****************************************************************************
+// $Id$
+#ifndef ossimImageGeometryFactory_HEADER
+#define ossimImageGeometryFactory_HEADER 1
+
+#include <ossim/imaging/ossimImageGeometryFactoryBase.h>
+
+class ossim2dTo2dTransform;
+class ossimNitfTileSource;
+class ossimProjection;
+
+class OSSIM_DLL ossimImageGeometryFactory : public ossimImageGeometryFactoryBase
+{
+public:
+   static ossimImageGeometryFactory* instance();
+   virtual ossimImageGeometry* createGeometry(const ossimString& typeName)const;
+   virtual ossimImageGeometry* createGeometry(const ossimKeywordlist& kwl,
+                                              const char* prefix=0)const;
+   virtual ossimImageGeometry* createGeometry(const ossimFilename& filename,
+                                              ossim_uint32 entryIdx)const;
+   virtual bool extendGeometry(ossimImageHandler* handler)const;
+   
+   virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
+   
+   /**
+    * This is a utility method used by crateGeoemtry that takes an image handler
+    */
+   virtual ossim2dTo2dTransform* createTransform(ossimImageHandler* handler)const;
+
+   /**
+    * @brief Utility method to create a projection from an image handler.
+    * @param handler The image handler to create projection from.
+    * @return Pointer to an ossimProjection on success, null on error.
+    */
+   virtual ossimProjection* createProjection(ossimImageHandler* handler) const;
+   
+protected:
+   ossimImageGeometryFactory();
+
+   virtual ossim2dTo2dTransform* createTransformFromNitf(ossimNitfTileSource* handler)const;
+   
+   static ossimImageGeometryFactory* m_instance;
+};
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryFactoryBase.h b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryFactoryBase.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f732de8ee96ec7be1f823d32eba2adb8824860b
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryFactoryBase.h
@@ -0,0 +1,44 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossimImageGeometryFactoryBase. See .h file for class documentation.
+//
+//**************************************************************************************************
+// $Id$
+#ifndef ossimImageGeometryFactoryBase_HEADER
+#define ossimImageGeometryFactoryBase_HEADER
+#include <ossim/base/ossimBaseObjectFactory.h>
+#include <ossim/imaging/ossimImageGeometry.h>
+
+class ossimImageHandler;
+class OSSIM_DLL ossimImageGeometryFactoryBase : public ossimBaseObjectFactory
+{
+public: 
+   /**
+    * Creates an object given a type name.
+    */
+   virtual ossimObject* createObject(const ossimString& typeName)const
+   {
+      return createGeometry(typeName);
+   }
+   
+   /**
+    * Creates and object given a keyword list.
+    */
+   virtual ossimObject* createObject(const ossimKeywordlist& kwl,
+                                     const char* prefix=0)const
+   {
+      return createGeometry(kwl, prefix);
+   }
+   
+   virtual ossimImageGeometry* createGeometry(const ossimString& typeName)const=0;
+   virtual ossimImageGeometry* createGeometry(const ossimKeywordlist& kwl,
+                                              const char* prefix=0)const=0;
+   virtual ossimImageGeometry* createGeometry(const ossimFilename& filename,
+                                              ossim_uint32 entryIdx)const = 0;
+   virtual bool extendGeometry(ossimImageHandler* handler)const=0;
+};
+#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryRegistry.h b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryRegistry.h
new file mode 100644
index 0000000000000000000000000000000000000000..51bc96136528e42a3e5631280ace43e3fc627a1e
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageGeometryRegistry.h
@@ -0,0 +1,67 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossimImageGeometryRegistry. See .h file for class documentation.
+//
+//**************************************************************************************************
+// $Id$
+#ifndef ossimImageGeometryRegistry_HEADER
+#define ossimImageGeometryRegistry_HEADER
+#include <ossim/base/ossimConstants.h>
+#include <ossim/imaging/ossimImageGeometryFactoryBase.h>
+#include <ossim/imaging/ossimImageGeometry.h>
+#include <ossim/base/ossimFactoryListInterface.h>
+class OSSIM_DLL ossimImageGeometryRegistry : public ossimBaseObjectFactory,
+                                             public ossimFactoryListInterface<ossimImageGeometryFactoryBase,
+                                                                              ossimImageGeometry>
+{
+public:
+   virtual ~ossimImageGeometryRegistry(){m_instance=0;}
+   static ossimImageGeometryRegistry* instance();
+   
+   /*!
+    * Creates an object given a type name.
+    */
+   virtual ossimObject* createObject(const ossimString& typeName)const
+   {
+      return createObjectFromRegistry(typeName);
+   }
+   
+   /*!
+    * Creates and object given a keyword list.
+    */
+   virtual ossimObject* createObject(const ossimKeywordlist& kwl,
+                                     const char* prefix=0)const
+   {
+      return createObjectFromRegistry(kwl, prefix);
+   }
+   
+   virtual bool extendGeometry(ossimImageHandler* handler)const;
+   
+   /*!
+    * This should return the type name of all objects in all factories.
+    * This is the name used to construct the objects dynamially and this
+    * name must be unique.
+    */
+   virtual void getTypeNameList(std::vector<ossimString>& typeList)const
+   {
+      getAllTypeNamesFromRegistry(typeList);
+   }
+   
+protected:
+   ossimImageGeometryRegistry()
+   :ossimBaseObjectFactory()
+   {}
+   
+   ossimImageGeometryRegistry( const ossimImageGeometryRegistry& rhs )
+   :ossimBaseObjectFactory(rhs)
+   {}
+   void operator =(const ossimImageGeometryRegistry&){}
+   static ossimImageGeometryRegistry* m_instance;
+   
+   TYPE_DATA
+};
+#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageHandler.h b/Utilities/otbossim/include/ossim/imaging/ossimImageHandler.h
index c2698bcd08336ea676cde73bcbde2c12eb72795c..e411eb92ddd495329a617e48832576cf6e2077d8 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageHandler.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageHandler.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:   See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts
 // 
@@ -10,7 +12,7 @@
 // derive from.
 //
 //********************************************************************
-// $Id: ossimImageHandler.h 14047 2009-03-03 02:24:10Z gpotts $
+// $Id: ossimImageHandler.h 15798 2009-10-23 19:15:20Z gpotts $
 #ifndef ossimImageHandler_HEADER
 #define ossimImageHandler_HEADER
 
@@ -21,7 +23,6 @@
 #include <ossim/base/ossimIrect.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/imaging/ossimFilterResampler.h>
-class ossimTiffTileSource;
 
 /**
  *  This class defines an abstract Handler which all image handlers(loaders)
@@ -44,12 +45,12 @@ public:
     * Constructor (default):
     */
    ossimImageHandler();
-
    /**
     * Destructor:
     * Derived classes should implement.
     */
    virtual ~ossimImageHandler();
+   
 
    //virtual ossimObject* dup()const;
    /**
@@ -243,21 +244,26 @@ public:
                               bool includeFullResFlag=false);
    
    /**
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *
-    *  @param kwl Keyword list that will be initialized with geometry info.
-    *  Returns true if geometry info is present, false if not.
-    *
-    *  @param prefix The prefix is added to the resulting keyword list
-    *  keywords.  So is you if you pass in a prefix of "image01.", the
-    *  keyword ul_lat will be like:  "image01.ul_lat:  -40.00000"
+    * Returns the image geometry object associated with this tile source or
+    * NULL if non defined.  The geometry contains full-to-local image
+    * transform as well as projection (image-to-world).
     */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   virtual ossimImageGeometry* getImageGeometry();
 
    /**
-    * Sets the image geometry keyword list.
+    * Returns the image geometry object associated with this tile source or
+    * NULL if non defined.  The geometry contains full-to-local image
+    * transform as well as projection (image-to-world).
+    *
+    * This method just looks for external .geom style override only.
+    * If you want to go through a registry then call getImageGeometry().
+    */
+   virtual ossimImageGeometry* getExternalImageGeometry();
+   
+   virtual ossimImageGeometry* getInternalImageGeometry();
+   
+   /**
+    * Sets the image geometry object.
     *
     * @note Callers should note that this will override any existing
     *       geometry.
@@ -265,7 +271,7 @@ public:
     * @note This does not write the geometry to disk, to do so call
     *       one of the saveImageGeometry methods. 
     */
-   virtual void setImageGeometry(const ossimKeywordlist& kwl);
+   virtual void setImageGeometry(ossimImageGeometry* geom);
 
    /**
     * Saves the image geometry to a file that will be made based on the image
@@ -351,22 +357,6 @@ public:
     */
    virtual ossim_uint32 getNumberOfReducedResSets()const;
    
-   /**
-    * @param resLevel Reduced resolution set for requested offset.
-    * 
-    * @return Returns the offset between the relative image rectangle and
-    * the absolute, or full, image rectangle. This is typically (0,0) unless
-    * this is a sub-image.  If a resLevel other than zero is requested the
-    * decimation factor will be applied to offset.  If resLevel is not valid
-    * an the ossimIpt returned will be nan's.
-    */
-   ossimIpt getSubImageOffset(ossim_uint32 resLevel) const;
-
-   /**
-    * Permits initializing this sub-image's offset relative to full image space.
-    */
-   void setSubImageOffset(const ossimIpt& p);
-
    /**
     * Sets the filename
     */
@@ -392,7 +382,13 @@ public:
                           const char* prefix=0);
 
    /**
-    * Determines if the passed in reslution level is valid
+    * @brief Determines if the passed in reslution level is valid.
+    *
+    * If this reader is used as an overview the caller should pass in a
+    * resLevel relative to the full image.
+    * 
+    * @param resLevel zero base resolution level.
+    * @return true on success, false on error.
     */
    virtual bool isValidRLevel(ossim_uint32 resLevel) const;
 
@@ -475,7 +471,7 @@ public:
    virtual double getMinPixelValue(ossim_uint32 band=0)const;
    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
    virtual double getNullPixelValue(ossim_uint32 band=0)const;
-
+   
    /**
     * @return The current entry number.
     *
@@ -483,19 +479,19 @@ public:
     * if of multiple entry image type.
     */
    virtual ossim_uint32 getCurrentEntry()const;
-
+   
    /**
     * @return The number of entries (images) in the image file.
     */
    virtual ossim_uint32 getNumberOfEntries()const;
-
+   
    /**
     * @param entryList This is the list to initialize with entry indexes.
     *
     * @note This implementation returns puts one entry "0" in the list.
     */
    virtual void getEntryList(std::vector<ossim_uint32>& entryList) const;
-
+   
    /**
     * @param entryStringList List to initialize with strings associated with
     * entries.
@@ -508,6 +504,7 @@ public:
       std::vector<ossimString>& entryStringList) const;
    
    ossimFilename getOverviewFile()const;
+
    /**
     * @param entryIdx Entry number to select.
     *
@@ -517,39 +514,68 @@ public:
     * @return true if it was able to set the current entry and false otherwise.
     */
    virtual bool setCurrentEntry(ossim_uint32 entryIdx);
-
+   
    virtual void setProperty(ossimRefPtr<ossimProperty> property);
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
-
+   
    /**
-   * Returns the image file with extension set.
+    * Returns the image file with extension set.
+    *
+    * Examples:
+    * 
+    * - theImageFile          = "foo.hdf"
+    * - The number of entries = 1
+    * - ext parameter         = "geom"
+    * - return of method will = "foo.geom"
+    *
+    * - theImageFile          = "foo.hdf"
+    * - The number of entries = 12
+    * - The current entry     = 3
+    * - ext parameter         = "geom"
+    * - return of method will = "foo_e3.geom"
+    *
+    * @param ext Extension to tack onto file.  Can have or have not ".", it
+    * will be added if "." is not the first character.
+    *
+    * @param set_e0_prefix If true and the number of entries = 1 then
+    * "foo.geom" would come out "foo_e0.geom" instead. Default = false.
+    * 
+    * @return theImageFile with sent extension.
+    */
+   ossimFilename getFilenameWithThisExtension(const ossimString& ext,
+                                              bool set_e0_prefix=false) const;
+   
+   ossim_uint32 getStartingResLevel() const;
+   
+   void setStartingResLevel(ossim_uint32 level);
+   
+protected:
+   
+   
+  // void setStartingResLevel(ossim_uint32 level);
+
+  /**
+   * @brief Method to get an overview tile.  Derived classes should override if
+   * they have built in overviews or something different than the standard
+   * external overview file.  Image handlers can call this method from getTile
+   * in place of inlining code or if derived class needs to override this
+   * method.
    *
-   * Examples:
+   * @param resLevel The resolution level to pull from with resLevel 0 being
+   * full res.
    * 
-   * - theImageFile          = "foo.hdf"
-   * - The number of entries = 1
-   * - ext parameter         = "geom"
-   * - return of method will = "foo.geom"
-   *
-   * - theImageFile          = "foo.hdf"
-   * - The number of entries = 12
-   * - The current entry     = 3
-   * - ext parameter         = "geom"
-   * - return of method will = "foo_e3.geom"
-   *
-   * @param ext Extension to tack onto file.  Can have or have not ".", it will
-   * be added if "." is not the first character.
+   * @param result The tile to stuff. 
+   * passing. 
    *
-   * @param set_e0_prefix If true and the number of entries = 1 then
-   * "foo.geom" would come out "foo_e0.geom" instead. Default = false.
-   * 
-   * @return theImageFile with sent extension.
+   * @return true on success false on error.  Typically this will return false
+   * if resLevel==0 unless the overview has r0.  If return is false, result
+   * is undefined so caller should handle appropriately with makeBlank or
+   * whatever.
    */
-  ossimFilename getFilenameWithThisExtension(const ossimString& ext,
-                                             bool set_e0_prefix=false) const;
-   
-protected:
+  virtual bool getOverviewTile(ossim_uint32 resLevel,
+                               ossimImageData* result);  
+  
    /**
     *  Opens file and attempts to initialize the valid image vertices.
     *  Returns true on success, false on error.
@@ -566,12 +592,17 @@ protected:
 
    ossimFilename        theImageFile;
    ossimFilename        theOverviewFile;
-   ossimTiffTileSource* theOverview;
-   ossimIpt             theSubImageOffset;
+   ossimRefPtr<ossimImageHandler>   theOverview;
    vector<ossimIpt>     theValidImageVertices;
    ossimImageMetaData   theMetaData;
-   ossimKeywordlist     theGeometryKwl;
+   mutable ossimRefPtr<ossimImageGeometry> theGeometry;
    ossimRefPtr<ossimNBandLutDataObject> theLut;
+
+   /**
+    * theStartingResLevel If set to something other than zero(default) this is
+    * indicative that the reader is an overview.
+    */
+   ossim_uint32         theStartingResLevel; // 0 being full or highest res.
    
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerFactory.h b/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerFactory.h
index 6089de50f1ad8b75e1a96a0f40b9b7d6e722a023..09bdf6bdb9fb72cf99d616f541f3dc24202bcd68 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerFactory.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerFactory.h
@@ -8,7 +8,7 @@
 //
 // Contains class declaration for ossimImageHandlerFactoryMaker.
 //*******************************************************************
-//  $Id: ossimImageHandlerFactory.h 10103 2006-12-14 16:12:19Z gpotts $
+//  $Id: ossimImageHandlerFactory.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimImageHandlerFactory_HEADER
 #define ossimImageHandlerFactory_HEADER
@@ -33,7 +33,6 @@ public:
    virtual ossimImageHandler* open(const ossimKeywordlist& kwl,
                                    const char* prefix=0)const;
 
-   
    virtual ossimObject* createObject(const ossimString& typeName)const;
    
    /*!
@@ -49,8 +48,23 @@ public:
     */
    virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
    virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList& extensionList)const;
-  
+
 protected:
+
+   /**
+    * @brief Open method that looks at extension e.g. "tif", "jpg" to select
+    * class to open.
+    *
+    * This is to be called by standard open before just going down the list
+    * of classes the brute force hard way.
+    * 
+    * @param fileName The filename to open.
+    * 
+    * @return Pointer to image handler or null if nothing opened.
+    */
+   virtual ossimImageHandler* openFromExtension(
+      const ossimFilename& fileName) const;
+  
    ossimImageHandlerFactory(){}
    ossimImageHandlerFactory(const ossimImageHandlerFactory&){}
    void operator = (const ossimImageHandlerFactory&){}
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h b/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h
index 1576d69b45046fe7db83df7fa5654e8f3f8fa80e..c4d768375ef634037f0adbf06e926d68729c8bd2 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageHistogramSource.h 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimImageHistogramSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageHistogramSource_HEADER
 #define ossimImageHistogramSource_HEADER
 #include <ossim/base/ossimHistogramSource.h>
@@ -32,8 +32,6 @@ public:
 	};
    ossimImageHistogramSource(ossimObject* owner = 0);
    
-   virtual ~ossimImageHistogramSource();
-
    virtual ossimObject* getObject();
    virtual const ossimObject* getObject()const;
 
@@ -79,9 +77,9 @@ public:
                           const char* prefix=0);
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
-
 	
 protected:
+   virtual ~ossimImageHistogramSource();
 	void getBinInformation(ossim_uint32& numberOfBins,
 								  ossim_float64& minValue,
 								  ossim_float64& maxValue)const;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h b/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h
index ba82afbcd98b7981b0c12cd7a43b613f94dfbb91..3ab9c98f49dc0652f95a62a896db2e67779ab2c0 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h
@@ -37,8 +37,6 @@ public:
    /** @brief default constructor */
    ossimImageModel();
 
-   /** @brief virtual destructor */
-   virtual ~ossimImageModel();
 
    /**
     * @brief Method to initialize class from an image handler.
@@ -172,6 +170,8 @@ public:
  
 
 protected:
+   /** @brief virtual destructor */
+   virtual ~ossimImageModel();
 
    /** Offset from the full image. */
    ossimDpt theSubImageOffset;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageMosaic.h b/Utilities/otbossim/include/ossim/imaging/ossimImageMosaic.h
index c757ccbe13c996847a9b87340f6fa979966099ee..e5afb34e5de912440240add55c811f9b3ac8b280 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageMosaic.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageMosaic.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageMosaic.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageMosaic.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageMosaic_HEADER
 #define ossimImageMosaic_HEADER
 #include <vector>
@@ -27,8 +27,7 @@ class OSSIMDLLEXPORT ossimImageMosaic : public ossimImageCombiner
 {
 public:
    ossimImageMosaic();
-   ossimImageMosaic(const std::vector<ossimImageSource*>& inputSources);
-   virtual ~ossimImageMosaic();
+   ossimImageMosaic(ossimConnectableObject::ConnectableObjectList& inputSources);
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -50,6 +49,7 @@ public:
                           const char* prefix=0);
 
 protected:
+   virtual ~ossimImageMosaic();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageReconstructionFilterRegistry.h b/Utilities/otbossim/include/ossim/imaging/ossimImageReconstructionFilterRegistry.h
index fceeabc77277f334e364dbf3e1b9d9ee70cf9703..8a53b5b1b8e589d3883771e6802a97d2d3443095 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageReconstructionFilterRegistry.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageReconstructionFilterRegistry.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageReconstructionFilterRegistry.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimImageReconstructionFilterRegistry.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageReconstructionFilterRegistry_HEADER
 #define ossimImageReconstructionFilterRegistry_HEADER
 #include <ossim/imaging/ossimImageSourceFactoryBase.h>
@@ -13,7 +13,6 @@
 class ossimImageReconstructionFilterRegistry : public ossimImageSourceFactoryBase
 {
 public:
-   virtual ~ossimImageReconstructionFilterRegistry();
    static ossimImageReconstructionFilterRegistry* instance();
    virtual ossimObject* createObject(const ossimString& name)const;
    virtual ossimObject* createObject(const ossimKeywordlist& kwl,
@@ -25,6 +24,7 @@ public:
    bool findFactory(ossimImageSourceFactoryBase* factory)const;
    
 protected:
+   virtual ~ossimImageReconstructionFilterRegistry();
    ossimImageReconstructionFilterRegistry(); // hide
    ossimImageReconstructionFilterRegistry(const ossimImageReconstructionFilterRegistry&){}//hide
    void operator = (ossimImageReconstructionFilterRegistry&){}// hide
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h b/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h
index 49bd19f514639d2795e5f41c78be0db897f43515..5e247624c1c008e17803d07504343da1045de09b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*******************************************************************
-// $Id: ossimImageRenderer.h 13330 2008-07-28 18:04:40Z dburken $
+// $Id: ossimImageRenderer.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimImageRenderer_HEADER
 #define ossimImageRenderer_HEADER
@@ -29,7 +29,6 @@ public:
    ossimImageRenderer();
    ossimImageRenderer(ossimImageSource* inputSource,
                       ossimImageViewTransform* imageViewTrans = NULL);
-   virtual ~ossimImageRenderer();
 
    virtual ossimString getLongName()  const;
    virtual ossimString getShortName() const;
@@ -49,7 +48,7 @@ public:
    virtual void initialize();
 
    /**
-    * TheResampler will adjust the rect to whatever the view is.  So it
+    * m_Resampler will adjust the rect to whatever the view is.  So it
     * will project the full image rect onto the view and return the upright
     * bounding rect.
     */
@@ -70,29 +69,23 @@ public:
                           const char* prefix=0);
 
    void setImageViewTransform(ossimImageViewTransform* transform);
-   ossimImageViewTransform* getImageViewTransform(){return theImageViewTransform;}
+   ossimImageViewTransform* getImageViewTransform() { return m_ImageViewTransform; }
 
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
-   ossimFilterResampler* getResampler()
-      {
-         return theResampler;
-      }
+   //! Returns instance to the input image geometry. This may be a NULL pointer.
+   //! This is only valid if the IVT is a projection type IVT (IVPT) 
+   virtual ossimImageGeometry* getImageGeometry();
+
+   virtual bool setView(ossimObject* baseObject);
+   ossimFilterResampler* getResampler() { return m_Resampler; }
    virtual ossimObject* getView();
    virtual const ossimObject* getView()const;
 
-   virtual void getDecimationFactor(ossim_uint32 resLevel,
-                                    ossimDpt& result)const;
+   virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt& result)const;
   virtual void getDecimationFactors(vector<ossimDpt>& decimations)const;
   virtual ossim_uint32 getNumberOfDecimationLevels()const;
   
-
-   virtual void setAutoUpdateInputTransformFlag(bool flag)
-      {
-         theAutoUpdateInputTransform = flag;
-      }
+   virtual void setAutoUpdateInputTransformFlag(bool flag){ m_AutoUpdateInputTransform = flag; }
+   
    /**
     * ordering specifies how the vertices should be arranged.
     * valid image vertices is basically the tightly fit convex hull
@@ -117,86 +110,38 @@ public:
    virtual void setProperty(ossimRefPtr<ossimProperty> property);
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
+protected:
+   virtual ~ossimImageRenderer();
 
 private:
    
-
    class ossimRendererSubRectInfo
    {
    public:
-      friend std::ostream& operator <<(std::ostream& out,
-                                       const ossimRendererSubRectInfo& rhs)
-         {
-            return out << "vul:   " << rhs.theVul << endl
-                       << "vur:   " << rhs.theVur << endl
-                       << "vlr:   " << rhs.theVlr << endl
-                       << "vll:   " << rhs.theVll << endl
-                       << "iul:   " << rhs.theIul << endl
-                       << "iur:   " << rhs.theIur << endl
-                       << "ilr:   " << rhs.theIlr << endl
-                       << "ill:   " << rhs.theIll << endl
-                       << "scale: " << rhs.theViewToImageScale << endl;
-               
-         }
-      ossimRendererSubRectInfo()
-         {
-            theVul.makeNan();
-            theVur.makeNan();
-            theVlr.makeNan();
-            theVll.makeNan();
-            theIul.makeNan();
-            theIur.makeNan();
-            theIlr.makeNan();
-            theIll.makeNan();
-            theViewToImageScale.makeNan();
-            theImageToViewScale.makeNan();            
-         }
+      friend std::ostream& operator <<(std::ostream& out, const ossimRendererSubRectInfo& rhs)
+      {
+         return out << "vul:   " << rhs.m_Vul << endl
+            << "vur:   " << rhs.m_Vur << endl
+            << "vlr:   " << rhs.m_Vlr << endl
+            << "vll:   " << rhs.m_Vll << endl
+            << "iul:   " << rhs.m_Iul << endl
+            << "iur:   " << rhs.m_Iur << endl
+            << "ilr:   " << rhs.m_Ilr << endl
+            << "ill:   " << rhs.m_Ill << endl
+            << "scale: " << rhs.m_ViewToImageScale << endl;
+
+      }
+
+      ossimRendererSubRectInfo();
       ossimRendererSubRectInfo(const ossimDpt& vul,
                                const ossimDpt& vur,
                                const ossimDpt& vlr,
-                               const ossimDpt& vll)
-         :theVul(vul),
-          theVur(vur),
-          theVlr(vlr),
-          theVll(vll)
-         {
-            theIul.makeNan();
-            theIur.makeNan();
-            theIlr.makeNan();
-            theIll.makeNan();
-            theViewToImageScale.makeNan();
-            theImageToViewScale.makeNan();            
-         }
+                               const ossimDpt& vll);
          
-      bool imageHasNans()const
-         {
-            return ( theIul.hasNans()||
-                     theIur.hasNans()||
-                     theIlr.hasNans()||
-                     theIll.hasNans());
-         }
-      
-      bool imageIsNan()const
-         {
-            return ( theIul.hasNans()&&
-                     theIur.hasNans()&&
-                     theIlr.hasNans()&&
-                     theIll.hasNans());
-         }
-      bool viewHasNans()const
-      {
-         return ( theVul.hasNans()||
-                  theVur.hasNans()||
-                  theVlr.hasNans()||
-                  theVll.hasNans());
-      }
-      bool viewIsNan()const
-      {
-         return ( theVul.hasNans()&&
-                  theVur.hasNans()&&
-                  theVlr.hasNans()&&
-                  theVll.hasNans());
-      }
+      bool imageHasNans()const;
+      bool imageIsNan()const;
+      bool viewHasNans()const;
+      bool viewIsNan()const;
       void splitView(ossimImageViewTransform* transform,
                      ossimRendererSubRectInfo& ulRect,
                      ossimRendererSubRectInfo& urRect,
@@ -206,89 +151,19 @@ private:
       void transformViewToImage(ossimImageViewTransform* transform);
       void transformImageToView(ossimImageViewTransform* transform);
       
-      void roundToInteger()
-         {
-            theIul = ossimIpt(theIul);
-            theIur = ossimIpt(theIur);
-            theIlr = ossimIpt(theIlr);
-            theIll = ossimIpt(theIll);
-
-            theVul = ossimIpt(theVul);
-            theVur = ossimIpt(theVur);
-            theVlr = ossimIpt(theVlr);
-            theVll = ossimIpt(theVll);
-         }
+      void roundToInteger();
       void stretchImageOut(bool enableRound=false);
-      ossimDrect getViewRect()const
-         {
-            return ossimDrect(theVul,
-                              theVur,
-                              theVlr,
-                              theVll);            
-         }
-      ossimDrect getImageRect()const
-         {
-            return ossimDrect(theIul,
-                              theIur,
-                              theIlr,
-                              theIll);
-         }
-      void roundImageToInteger()
-         {
-            theIul = ossimIpt(theIul);
-            theIur = ossimIpt(theIur);
-            theIlr = ossimIpt(theIlr);
-            theIll = ossimIpt(theIll);
-         }
-      void roundViewToInteger()
-         {
-            theVul = ossimIpt(theVul);
-            theVur = ossimIpt(theVur);
-            theVlr = ossimIpt(theVlr);
-            theVll = ossimIpt(theVll);
-         }
-      bool isViewEqual(const ossimRendererSubRectInfo& infoRect)const
-         {
-            return ( (theVul == infoRect.theVul)&&
-                     (theVur == infoRect.theVur)&&
-                     (theVlr == infoRect.theVlr)&&
-                     (theVll == infoRect.theVll));
-         }
-      bool isViewEqual(const ossimDrect& viewRect)const
-         {
-            return ( (theVul == viewRect.ul())&&
-                     (theVur == viewRect.ur())&&
-                     (theVlr == viewRect.lr())&&
-                     (theVll == viewRect.ll()));
-         }
-      ossimDpt getAbsValueViewToImageScales()const
-         {
-            if(theViewToImageScale.hasNans())
-            {
-               return theImageToViewScale;
-            }
-            return ossimDpt(fabs(theViewToImageScale.x),
-                            fabs(theViewToImageScale.y));
-         }
-      ossimDpt getAbsValueImageToViewScales()const
-         {
-            if(theImageToViewScale.hasNans())
-            {
-               return theImageToViewScale;
-            }
-            
-            return ossimDpt(fabs(theImageToViewScale.x),
-                            fabs(theImageToViewScale.y));
-         }
-      bool isViewAPoint()const
-         {
-            return ((theVul == theVur)&&
-                    (theVul == theVlr)&&
-                    (theVul == theVll));
-         }
+      ossimDrect getViewRect()const;
+      ossimDrect getImageRect()const;
+      void roundImageToInteger();
+      void roundViewToInteger();
+      bool isViewEqual(const ossimRendererSubRectInfo& infoRect)const;
+      bool isViewEqual(const ossimDrect& viewRect)const;
+      ossimDpt getAbsValueViewToImageScales()const;
+      ossimDpt getAbsValueImageToViewScales()const;
+      bool isViewAPoint()const;
       bool isIdentity()const;
-      bool canBilinearInterpolate(ossimImageViewTransform* transform,
-				  double error)const;
+      bool canBilinearInterpolate(ossimImageViewTransform* transform, double error)const;
 
       ossimDpt getParametricCenter(const ossimDpt& ul, const ossimDpt& ur, 
 				    const ossimDpt& lr, const ossimDpt& ll)const;
@@ -305,18 +180,18 @@ private:
 		       ossimDpt& leftMid,
 		       ossimDpt& center)const;
 
-      ossimDpt theIul;
-      ossimDpt theIur;
-      ossimDpt theIlr;
-      ossimDpt theIll;
+      ossimDpt m_Iul;
+      ossimDpt m_Iur;
+      ossimDpt m_Ilr;
+      ossimDpt m_Ill;
 
-      ossimIpt theVul;
-      ossimIpt theVur;
-      ossimIpt theVlr;
-      ossimIpt theVll;
+      ossimIpt m_Vul;
+      ossimIpt m_Vur;
+      ossimIpt m_Vlr;
+      ossimIpt m_Vll;
 
-      ossimDpt theViewToImageScale;
-      ossimDpt theImageToViewScale;
+      ossimDpt m_ViewToImageScale;
+      ossimDpt m_ImageToViewScale;
       
    };
 
@@ -331,10 +206,8 @@ private:
    ossimIrect getBoundingImageRect()const;
 
    
-   /**
-    *this is called on a property event and on input connection changes.
-    */
-   void checkTransform();
+   //! this is called on a property event and on input connection changes.
+   void checkIVT();
 
    void computeRects();
 
@@ -366,10 +239,10 @@ private:
 
    virtual void fireProgressEvent(double percentComplete);
    
-   ossimFilterResampler*       theResampler;
-   ossimRefPtr<ossimImageData> theBlankTile;
-   ossimRefPtr<ossimImageData> theTile;
-   ossimRefPtr<ossimImageData> theTemporaryBuffer;
+   ossimFilterResampler*       m_Resampler;
+   ossimRefPtr<ossimImageData> m_BlankTile;
+   ossimRefPtr<ossimImageData> m_Tile;
+   ossimRefPtr<ossimImageData> m_TemporaryBuffer;
 
    /**
     * This is going to allow us to chain multiple
@@ -380,27 +253,166 @@ private:
     * The default will be r-level 0 request coming
     * from the right.
     */
-   ossim_uint32             theStartingResLevel;
-   ossimImageViewTransform *theImageViewTransform;
-   mutable ossimIrect               theBoundingRect;
-   mutable ossimIrect               theBoundingViewRect;
-
-   /**
-    * Holds a pre-computed input rect.
-    */
-//   ossimIrect                theInputRect;
-
-   /**
-    * Holds a precomputed output rect.
-    */
-//   ossimIrect                theOutputRect;
-
-   ossim_uint32               theMaxRecursionLevel;
-   bool                       theAutoUpdateInputTransform;
-   vector<ossimDpt>           theInputDecimationFactors;
-   ossim_uint32               theMaxLevelsToCompute;
+   ossim_uint32             m_StartingResLevel;
+   ossimImageViewTransform *m_ImageViewTransform;
+   mutable ossimIrect       m_BoundingRect;
+   mutable ossimIrect       m_BoundingViewRect;
+   ossim_uint32             m_MaxRecursionLevel;
+   bool                     m_AutoUpdateInputTransform;
+   vector<ossimDpt>         m_InputDecimationFactors;
+   ossim_uint32             m_MaxLevelsToCompute;
    
 TYPE_DATA
 };
 
+inline ossimImageRenderer::ossimRendererSubRectInfo::ossimRendererSubRectInfo()
+{
+   m_Vul.makeNan();
+   m_Vur.makeNan();
+   m_Vlr.makeNan();
+   m_Vll.makeNan();
+   m_Iul.makeNan();
+   m_Iur.makeNan();
+   m_Ilr.makeNan();
+   m_Ill.makeNan();
+   m_ViewToImageScale.makeNan();
+   m_ImageToViewScale.makeNan();            
+}
+
+inline ossimImageRenderer::ossimRendererSubRectInfo::ossimRendererSubRectInfo(const ossimDpt& vul,
+                         const ossimDpt& vur,
+                         const ossimDpt& vlr,
+                         const ossimDpt& vll)
+                         :m_Vul(vul),
+                         m_Vur(vur),
+                         m_Vlr(vlr),
+                         m_Vll(vll)
+{
+   m_Iul.makeNan();
+   m_Iur.makeNan();
+   m_Ilr.makeNan();
+   m_Ill.makeNan();
+   m_ViewToImageScale.makeNan();
+   m_ImageToViewScale.makeNan();            
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::imageHasNans()const
+{
+   return ( m_Iul.hasNans()||
+      m_Iur.hasNans()||
+      m_Ilr.hasNans()||
+      m_Ill.hasNans());
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::imageIsNan()const
+{
+   return ( m_Iul.hasNans()&&
+      m_Iur.hasNans()&&
+      m_Ilr.hasNans()&&
+      m_Ill.hasNans());
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::viewHasNans()const
+{
+   return ( m_Vul.hasNans()||
+      m_Vur.hasNans()||
+      m_Vlr.hasNans()||
+      m_Vll.hasNans());
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::viewIsNan()const
+{
+   return ( m_Vul.hasNans()&&
+      m_Vur.hasNans()&&
+      m_Vlr.hasNans()&&
+      m_Vll.hasNans());
+}
+
+inline void ossimImageRenderer::ossimRendererSubRectInfo::roundToInteger()
+{
+   m_Iul = ossimIpt(m_Iul);
+   m_Iur = ossimIpt(m_Iur);
+   m_Ilr = ossimIpt(m_Ilr);
+   m_Ill = ossimIpt(m_Ill);
+
+   m_Vul = ossimIpt(m_Vul);
+   m_Vur = ossimIpt(m_Vur);
+   m_Vlr = ossimIpt(m_Vlr);
+   m_Vll = ossimIpt(m_Vll);
+}
+
+inline ossimDrect ossimImageRenderer::ossimRendererSubRectInfo::getViewRect()const
+{
+   return ossimDrect(m_Vul,
+      m_Vur,
+      m_Vlr,
+      m_Vll);            
+}
+
+inline ossimDrect ossimImageRenderer::ossimRendererSubRectInfo::getImageRect()const
+{
+   return ossimDrect(m_Iul,
+      m_Iur,
+      m_Ilr,
+      m_Ill);
+}
+
+inline void ossimImageRenderer::ossimRendererSubRectInfo::roundImageToInteger()
+{
+   m_Iul = ossimIpt(m_Iul);
+   m_Iur = ossimIpt(m_Iur);
+   m_Ilr = ossimIpt(m_Ilr);
+   m_Ill = ossimIpt(m_Ill);
+}
+
+inline void ossimImageRenderer::ossimRendererSubRectInfo::roundViewToInteger()
+{
+   m_Vul = ossimIpt(m_Vul);
+   m_Vur = ossimIpt(m_Vur);
+   m_Vlr = ossimIpt(m_Vlr);
+   m_Vll = ossimIpt(m_Vll);
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::isViewEqual(const ossimRendererSubRectInfo& infoRect)const
+{
+   return ( (m_Vul == infoRect.m_Vul)&&
+      (m_Vur == infoRect.m_Vur)&&
+      (m_Vlr == infoRect.m_Vlr)&&
+      (m_Vll == infoRect.m_Vll));
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::isViewEqual(const ossimDrect& viewRect)const
+{
+   return ( (m_Vul == viewRect.ul())&&
+      (m_Vur == viewRect.ur())&&
+      (m_Vlr == viewRect.lr())&&
+      (m_Vll == viewRect.ll()));
+}
+
+inline ossimDpt ossimImageRenderer::ossimRendererSubRectInfo::getAbsValueViewToImageScales()const
+{
+   if(m_ViewToImageScale.hasNans())
+   {
+      return m_ImageToViewScale;
+   }
+   return ossimDpt(fabs(m_ViewToImageScale.x), fabs(m_ViewToImageScale.y));
+}
+
+inline ossimDpt ossimImageRenderer::ossimRendererSubRectInfo::getAbsValueImageToViewScales()const
+{
+   if(m_ImageToViewScale.hasNans())
+   {
+      return m_ImageToViewScale;
+   }
+
+   return ossimDpt(fabs(m_ImageToViewScale.x), fabs(m_ImageToViewScale.y));
+}
+
+inline bool ossimImageRenderer::ossimRendererSubRectInfo::isViewAPoint()const
+{
+   return ((m_Vul == m_Vur)&&
+      (m_Vul == m_Vlr)&&
+      (m_Vul == m_Vll));
+}
+
 #endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSharpenFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSharpenFilter.h
index 106ac2ffb6c021ed13828461ca2cf05114dba0b4..efbce719384729a6b00f4f5c18b7f21e51323d9b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSharpenFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSharpenFilter.h
@@ -8,33 +8,53 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSharpenFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageSharpenFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageSharpenFilter_HEADER
 #define ossimImageSharpenFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
-
+#include <ossim/imaging/ossimConvolutionSource.h>
 class OSSIMDLLEXPORT ossimImageSharpenFilter : public ossimImageSourceFilter
 {
 public:
    ossimImageSharpenFilter(ossimObject* owner=NULL);
-   virtual ~ossimImageSharpenFilter();
 
    virtual ossimString getShortName()const;
    virtual ossimString getLongName()const;
    
+   ossim_uint32 getWidth()const;
+   ossim_float64 getSigma()const;
+   void setWidthAndSigma(ossim_uint32 w, ossim_float64 sigma);
+   
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
    
    virtual void initialize();
    
+   virtual void connectInputEvent(ossimConnectionEvent &event);
+   virtual void disconnectInputEvent(ossimConnectionEvent &event);
+   
+   virtual void setProperty(ossimRefPtr<ossimProperty> property);
+   virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
+   virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
+   
+   virtual bool loadState(const ossimKeywordlist& kwl,
+                          const char* prefix=0);
+   virtual bool saveState(ossimKeywordlist& kwl,
+                          const char* prefix=0)const;
 protected:
-
-   /**
-    * Called on first getTile, will initialize all data needed.
-    */
-   virtual void allocate();
+   virtual ~ossimImageSharpenFilter();
+   inline double laplacianOfGaussian(double x, double y, double sigma)
+   {
+      double r2 = x*x+y*y;
+      double sigma2 = sigma*sigma;
+      return ((1.0/(M_PI*sigma2*sigma2))*
+              (1.0-r2/(2.0*sigma2))*
+              (exp(-r2/(2.0*sigma2))));
+      
+   }
+   
+   void buildConvolutionMatrix();
    
-   ossimRefPtr<ossimImageData> theTile;
 
    /*!
     * Convolve full means that the input data is full and has
@@ -54,6 +74,9 @@ protected:
                        const ossimRefPtr<ossimImageData>& inputData,
                        ossimRefPtr<ossimImageData>& outputData);
 
+   ossimRefPtr<ossimConvolutionSource> theConvolutionSource;
+   ossim_uint32 theWidth;
+   ossim_float64 theSigma;
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h
index b1728c1fcade73294755e53221d47e33ddfe06f0..9fae56cb4f058c899ac0693351a3d392886caccf 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -8,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSource.h 13329 2008-07-28 18:03:19Z dburken $
+// $Id: ossimImageSource.h 15798 2009-10-23 19:15:20Z gpotts $
 #ifndef ossimImageSource_HEADER
 #define ossimImageSource_HEADER
 
@@ -16,6 +15,7 @@
 #include <ossim/base/ossimSource.h>
 #include <ossim/base/ossimIrect.h>
 #include <ossim/imaging/ossimImageData.h>
+#include <ossim/imaging/ossimImageGeometry.h>
 
 class ossimDpt;
 
@@ -28,7 +28,6 @@ public:
                     ossim_uint32 outputListSize,
                     bool inputListIsFixedFlag=true,
                     bool outputListIsFixedFlag=true);
-
    virtual ~ossimImageSource();
 
    /**
@@ -42,6 +41,22 @@ public:
    */
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
+
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    *
+    * @note Derived classes should override this method to most efficiently
+    * stuff result.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
    
   /**
    * For RTTI support. overrides ossimImageSource
@@ -165,17 +180,14 @@ public:
                                       ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER,
                                       ossim_uint32 resLevel=0)const;
 
-   /**
-    * the default is to find the first input source that is of
-    * type ossimImageSource and return its input geometry.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   //! Returns the image geometry object associated with this tile source or NULL if not defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   //! Default implementation returns the image geometry object associated with the next  
+   //! (left) input source (if any) connected to this source in the chain, or NULL.
+   virtual ossimImageGeometry* getImageGeometry();
 
-   /**
-    * Default method to call input's setImageGeometry.
-    */
-   virtual void setImageGeometry(const ossimKeywordlist& kwl);
+   //! Default implementation sets geometry of the first input to the geometry specified.
+   virtual void setImageGeometry(const ossimImageGeometry* geom);
 
    /**
     * Default method to call input's saveImageGeometry.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFactoryRegistry.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFactoryRegistry.h
index ee3043ea8f5188c3e345f1b4bb2815f0c2fd0acc..b6d1785f65d4b5b5b96ab0446899c982863a33e4 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFactoryRegistry.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSourceFactoryRegistry.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimImageSourceFactoryRegistry.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageSourceFactoryRegistry_HEADER
 #define ossimImageSourceFactoryRegistry_HEADER
 #include <ossim/imaging/ossimImageSourceFactoryBase.h>
@@ -13,8 +13,8 @@
 class OSSIM_DLL ossimImageSourceFactoryRegistry : public ossimImageSourceFactoryBase
 {
 public:
-   virtual ~ossimImageSourceFactoryRegistry();
    static ossimImageSourceFactoryRegistry* instance();
+   virtual ~ossimImageSourceFactoryRegistry();
    virtual ossimObject* createObject(const ossimString& name)const;
    virtual ossimObject* createObject(const ossimKeywordlist& kwl,
                                      const char* prefix=0)const;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFilter.h
index b34e3c3a0aef06ad93c5b9e1135a05114ce020ca..05abcc6c5c41a9c85f465a4c4dd622d18832888a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFilter.h
@@ -10,7 +10,7 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimImageSourceFilter.h 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimImageSourceFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageSourceFilter_HEADER
 #define ossimImageSourceFilter_HEADER
 #include <ossim/imaging/ossimImageSource.h>
@@ -25,7 +25,6 @@ public:
    ossimImageSourceFilter(ossimImageSource* inputSource);
    ossimImageSourceFilter(ossimObject* owner,
                           ossimImageSource* inputSource);
-   virtual ~ossimImageSourceFilter();
 
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const;
    virtual void getDecimationFactor(ossim_uint32 resLevel,
@@ -108,6 +107,7 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
 protected:
+   virtual ~ossimImageSourceFilter();
    ossimImageSource* theInputConnection;
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceHistogramFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceHistogramFilter.h
index fe80dcea7581bc0cf3f2c9619d790c6e21b4f152..b1a0a72c105da7f9f0ddc3e3b234b077a9b15f54 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceHistogramFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceHistogramFilter.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSourceHistogramFilter.h 11740 2007-09-19 12:16:40Z gpotts $
+// $Id: ossimImageSourceHistogramFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageSourceHistogramFilter_HEADER
 #define ossimImageSourceHistogramFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ public:
    ossimImageSourceHistogramFilter();
    ossimImageSourceHistogramFilter(ossimImageSource* inputSource,
                         ossimRefPtr<ossimMultiResLevelHistogram> histogram);
-   virtual ~ossimImageSourceHistogramFilter();
    virtual void setHistogram(ossimRefPtr<ossimMultiResLevelHistogram> histogram);
    virtual bool setHistogram(const ossimFilename& filename);
    virtual const ossimFilename& getHistogramFilename()const;
@@ -39,7 +38,8 @@ public:
    virtual std::ostream& print(std::ostream& out) const;
 
 protected:
-   long                         theCurrentResLevel;
+   virtual ~ossimImageSourceHistogramFilter();
+   ossim_int32                         theCurrentResLevel;
 
 private:
    ossimRefPtr<ossimMultiResLevelHistogram> theHistogram;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceSequencer.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceSequencer.h
index 5b486fde1d80b47bc2f3c2ce932732057c2468c8..d5f6cb2f7adf086a6ae0dc34e1bb8e710845ef31 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceSequencer.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceSequencer.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimImageSourceSequencer.h 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimImageSourceSequencer.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageSourceSequencer_HEADER
 #define ossimImageSourceSequencer_HEADER
 #include <ossim/imaging/ossimImageSource.h>
@@ -25,7 +25,6 @@ public:
    ossimImageSourceSequencer(ossimImageSource* inputSource=NULL,
                              ossimObject* owner=NULL);
 
-   virtual ~ossimImageSourceSequencer();
   /*!
     * This will return the number of tiles within the
     * area of interest.
@@ -135,6 +134,7 @@ public:
    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
    
 protected:
+   virtual ~ossimImageSourceSequencer();
    ossimImageSource*  theInputConnection;
    ossimRefPtr<ossimImageData> theBlankTile;
    /*!
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageStatisticsSource.h b/Utilities/otbossim/include/ossim/imaging/ossimImageStatisticsSource.h
index b96cff6d8af14bed545ceec9fb4fc4c811591e54..92c618ee4df7cf0906bd6850d0bca0ec6802b82d 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageStatisticsSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageStatisticsSource.h
@@ -6,7 +6,6 @@ class OSSIMDLLEXPORT ossimImageStatisticsSource : public ossimSource
 {
 public:
    ossimImageStatisticsSource();
-   virtual ~ossimImageStatisticsSource();
    
    
    virtual void computeStatistics();
@@ -19,6 +18,7 @@ public:
    const std::vector<ossim_float64>& getMax()const;
    
 protected:
+   virtual ~ossimImageStatisticsSource();
    void clearStatistics();
    template <class T>
    void computeStatisticsTemplate(T dummyVariable);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageWriter.h
index 50c22e65b88df0a8db38e394237b0ae1711a6abd..1367465eb8068e7d46d65b10ba582d5b2b3d3b3e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageWriter.h
@@ -9,7 +9,7 @@
 //
 // Contains class declaration for ossimImageWriter
 //*******************************************************************
-//  $Id: ossimImageWriter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageWriter.h 15798 2009-10-23 19:15:20Z gpotts $
 
 #ifndef ossimImageWriter_HEADER
 #define ossimImageWriter_HEADER
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimIndexToRgbLutFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimIndexToRgbLutFilter.h
index b37997438c21519ee1761fcdf17aad8cf5707d4b..218e6f90ee1b873751d81b0c5af8419777d485a8 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimIndexToRgbLutFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimIndexToRgbLutFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimIndexToRgbLutFilter.h 10147 2006-12-21 12:34:02Z gpotts $
+// $Id: ossimIndexToRgbLutFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimIndexToRgbLutFilter_HEADER
 #define ossimIndexToRgbLutFilter_HEADER
 #include <ossim/base/ossimRgbVector.h>
@@ -115,7 +115,6 @@ public:
                            double minValue,
                            double maxValue,
                            ossimIndexToRgbLutFilterInterpolationType interpolationType);
-   virtual ~ossimIndexToRgbLutFilter();
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -173,13 +172,14 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=NULL);
 protected:
+   virtual ~ossimIndexToRgbLutFilter();
 
    /**
     * Called on first getTile, will initialize all data needed.
     */
    void allocate();
    
-   ossimRgbLutDataObject theLut;
+   ossimRefPtr<ossimRgbLutDataObject> theLut;
    double theMinValue;
    double theMaxValue;
    double theMinMaxDeltaLength;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimIntensityAdjustmentFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimIntensityAdjustmentFilter.h
index bde98b39af438eb1747e294f98dd6fc1d097a4ae..6b83809fc0acfa883c8d3d6a8c2faf9fa52b6257 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimIntensityAdjustmentFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimIntensityAdjustmentFilter.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-// $Id: ossimIntensityAdjustmentFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimIntensityAdjustmentFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimIntensityAdjustmentFilter_HEADER
 #define ossimIntensityAdjustmentFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossimIntensityAdjustmentFilter : public ossimImageSourceFilter
 {
 public:
    ossimIntensityAdjustmentFilter();
-   virtual ~ossimIntensityAdjustmentFilter();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
 
@@ -50,6 +49,7 @@ public:
    
    virtual void initialize();
 protected:
+   virtual ~ossimIntensityAdjustmentFilter();
 
    virtual void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h
index 811e32d57dda16b68ce391680b15b608cf9aa306..7360d3643ed68f0a0281346043339e2391347f26 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
 // License:  LGPL
 //
@@ -13,7 +12,7 @@
 // JpegTileSource is derived from ImageHandler which is derived from
 // TileSource.
 //*******************************************************************
-//  $Id: ossimJpegTileSource.h 13054 2008-06-23 13:55:13Z gpotts $
+//  $Id: ossimJpegTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimJpegTileSource_HEADER
 #define ossimJpegTileSource_HEADER
@@ -34,21 +33,34 @@ public:
 
    ossimJpegTileSource(const char* jpeg_file);
 
-   virtual ~ossimJpegTileSource();
 
    virtual ossimString getShortName() const;
    virtual ossimString getLongName()  const;
-   virtual ossimString className()    const;
+   virtual ossimString getClassName()    const;
 
    /**
     *  Returns a pointer to a tile given an origin representing the upper
     *  left corner of the tile to grab from the image.
     *  Satisfies pure virtual from TileSource class.
     */
-   virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& tile_rect,
+   virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
 
-    /**
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
+
+   /**
      *  Returns the number of bands in the image.
      *  Satisfies pure virtual from ImageHandler class.
      */
@@ -146,6 +158,7 @@ public:
     */
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 protected:
+   virtual ~ossimJpegTileSource();
 	class PrivateData;
    /**
     *  Returns true if no errors initializing object.
@@ -166,7 +179,7 @@ protected:
     * @note this method assumes that setImageRectangle has been called on
     * theTile.
     */
-   void fillTile(const ossimIrect& clip_rect);
+   void fillTile(const ossimIrect& clip_rect, ossimImageData* tile);
 
    ossimRefPtr<ossimImageData>  theTile;
    ossimRefPtr<ossimImageData>  theCacheTile;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimJpegWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimJpegWriter.h
index 7f277b81d9ed5732e949e9db2b45df0b2d81d967..a29a6cd50855e4549d0afe4d509be625386d045b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimJpegWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimJpegWriter.h
@@ -9,7 +9,7 @@
 // Contains class definition for JpegWriter.
 //
 //*******************************************************************
-//  $Id: ossimJpegWriter.h 9817 2006-10-30 12:35:40Z dburken $
+//  $Id: ossimJpegWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimJpegWriter_HEADER
 #define ossimJpegWriter_HEADER
 
@@ -27,9 +27,6 @@ public:
    /** default constructor */
    ossimJpegWriter();
 
-   /** virtual destructor */
-   virtual ~ossimJpegWriter();
-
    /**
     * void getImageTypeList(std::vector<ossimString>& imageTypeList)const
     *
@@ -91,6 +88,10 @@ public:
 
    bool hasImageType(const ossimString& imageType) const;
 
+protected:
+   /** virtual destructor */
+   virtual ~ossimJpegWriter();
+   
    
 private:
    virtual bool writeFile();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h b/Utilities/otbossim/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h
index e1b46e6e3398f9c7cbc31e4e16acef074e5598d9..6436eddf8fa8202baabf29ee54cbaa513b091c26 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimJpegYCbCrToRgbSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimJpegYCbCrToRgbSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimJpegYCbCrToRgbSource_HEADER
 #define ossimJpegYCbCrToRgbSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossimJpegYCbCrToRgbSource : public ossimImageSourceFilter
 public:
    ossimJpegYCbCrToRgbSource();
    ossimJpegYCbCrToRgbSource(ossimImageSource* inputSource);
-   virtual ~ossimJpegYCbCrToRgbSource();
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -26,6 +25,7 @@ public:
    virtual void initialize();
        
 protected:
+   virtual ~ossimJpegYCbCrToRgbSource();
 
    virtual void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimLandsatTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimLandsatTileSource.h
index 55e2791f79fdd711b87cb87f7cb9c084f8e14e00..64bc8078ba686ee3dc47231fce2451d47a692747 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimLandsatTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimLandsatTileSource.h
@@ -11,15 +11,14 @@
 // TileSource.
 //
 //*******************************************************************
-//  $Id: ossimLandsatTileSource.h 10751 2007-04-23 16:49:08Z dburken $
+//  $Id: ossimLandsatTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimLandsatTileSource_HEADER
 #define ossimLandsatTileSource_HEADER
 
 #include <ossim/imaging/ossimGeneralRasterTileSource.h>
 #include <ossim/base/ossimDate.h>
-
-class ossimFfL7;
+#include <ossim/support_data/ossimFfL7.h>
 
 class OSSIM_DLL ossimLandsatTileSource : public ossimGeneralRasterTileSource
 {
@@ -29,7 +28,6 @@ public:
    ossimLandsatTileSource(const ossimKeywordlist& kwl,
                            const char* prefix=0);
    
-   virtual ~ossimLandsatTileSource();
 
    virtual ossimString getShortName() const;
    
@@ -56,14 +54,9 @@ public:
    bool isVir()const;
    bool isTm()const;
    
-  /*!
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
-
+   //! Returns the image geometry object associated with this tile source or NULL if non defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   virtual ossimImageGeometry* getImageGeometry();
 
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix = NULL);
@@ -82,10 +75,11 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
 private:
+   virtual ~ossimLandsatTileSource();
 
    void openHeader(const ossimFilename& file);
    
-   ossimFfL7* theFfHdr;
+   ossimRefPtr<ossimFfL7> theFfHdr;
 
    TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimLandsatTopoCorrectionFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimLandsatTopoCorrectionFilter.h
index e6c3d541d911cf632d115570619859530910a812..4426cb16be4d247aff62eb391838c6a786d94817 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimLandsatTopoCorrectionFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimLandsatTopoCorrectionFilter.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimLandsatTopoCorrectionFilter.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimLandsatTopoCorrectionFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimLandsatTopoCorrectionFilter_HEADER
 #define ossimLandsatTopoCorrectionFilter_HEADER
 #include <ossim/base/ossimFilename.h>
@@ -15,7 +15,6 @@ class OSSIM_DLL ossimLandsatTopoCorrectionFilter : public ossimTopographicCorrec
 {
 public:
    ossimLandsatTopoCorrectionFilter();
-   virtual ~ossimLandsatTopoCorrectionFilter();
    ossimLandsatTopoCorrectionFilter(ossimImageSource* colorSource,
                                     ossimImageSource* elevSource,
                                     const ossimFilename& landsatFileName=ossimFilename(""));
@@ -32,6 +31,7 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
 protected:
+   virtual ~ossimLandsatTopoCorrectionFilter();
    ossimFilename theLandsatHeader;
    ossimFilename findLandsatHeader();
 //   virtual void computeC();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimLocalCorrelationFusion.h b/Utilities/otbossim/include/ossim/imaging/ossimLocalCorrelationFusion.h
index 6dcae77be1d4092e95b67f5498b5eb6b253d23eb..64d9eaf53e580c362deee3a8a86fa0c46fd5dcfd 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimLocalCorrelationFusion.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimLocalCorrelationFusion.h
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimLocalCorrelationFusion.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimLocalCorrelationFusion.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimLocalCorrelationFusion_HEADER
 #define ossimLocalCorrelationFusion_HEADER
 #include <ossim/imaging/ossimFusionCombiner.h>
@@ -40,7 +40,6 @@ class OSSIM_DLL ossimLocalCorrelationFusion : public ossimFusionCombiner,
 {
 public:
    ossimLocalCorrelationFusion();
-   virtual ~ossimLocalCorrelationFusion();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
    virtual void initialize();
@@ -62,6 +61,7 @@ public:
                           const char* prefix=0);
    
 protected:
+   virtual ~ossimLocalCorrelationFusion();
    void setFilters();
    bool computeRegression(ossim_float64& slopeResult,
                           const ossimIpt& origin,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMapCompositionSource.h b/Utilities/otbossim/include/ossim/imaging/ossimMapCompositionSource.h
index 4e57b90b6cb19cf3026bfd5ec2c00b7f3629c11d..eae155264f92b93e85cc3b9dd7a75bf81d504eca 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMapCompositionSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMapCompositionSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimMapCompositionSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimMapCompositionSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMapCompositionSource_HEADER
 #define ossimMapCompositionSource_HEADER
 #include <ossim/imaging/ossimAnnotationSource.h>
@@ -32,7 +32,6 @@ public:
    };
 
    ossimMapCompositionSource();
-   virtual ~ossimMapCompositionSource();
    
    virtual ossimScalarType getOutputScalarType() const;
    virtual ossim_uint32    getNumberOfOutputBands() const;
@@ -192,15 +191,11 @@ public:
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
-   virtual bool saveState(ossimKeywordlist& kwl,
-                          const char* prefix=0)const;
-
-   virtual bool loadState(const ossimKeywordlist& kwl,
-                          const char* prefix=0);
-
-
+   virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
+   virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
 
 protected:
+   virtual ~ossimMapCompositionSource();
    ossimIpt            theViewWidthHeight;
    ossimGridLineType   theMeterGridType;
    ossimGridLineType   theGeographicGridType;
@@ -218,7 +213,7 @@ protected:
    // title info
    //
    ossimString          theTitleString;
-   ossimFont*           theTitleFont;
+   ossimRefPtr<ossimFont>           theTitleFont;
    ossimFontInformation theTitleFontInfo;
    ossimRgbVector       theTitleColor;
    
@@ -236,22 +231,22 @@ protected:
    // grid label font
    //
    ossimFontInformation theGeographicTopLabelFontInfo;
-   ossimFont*           theGeographicTopLabelFont;
+   ossimRefPtr<ossimFont>           theGeographicTopLabelFont;
    ossimFontInformation theGeographicBottomLabelFontInfo;
-   ossimFont*           theGeographicBottomLabelFont;
+   ossimRefPtr<ossimFont>           theGeographicBottomLabelFont;
    ossimFontInformation theGeographicLeftLabelFontInfo;
-   ossimFont*           theGeographicLeftLabelFont;
+   ossimRefPtr<ossimFont>           theGeographicLeftLabelFont;
    ossimFontInformation theGeographicRightLabelFontInfo;
-   ossimFont*           theGeographicRightLabelFont;
+   ossimRefPtr<ossimFont>           theGeographicRightLabelFont;
 
    ossimFontInformation theMeterTopLabelFontInfo;
-   ossimFont*           theMeterTopLabelFont;
+   ossimRefPtr<ossimFont>           theMeterTopLabelFont;
    ossimFontInformation theMeterBottomLabelFontInfo;
-   ossimFont*           theMeterBottomLabelFont;
+   ossimRefPtr<ossimFont>           theMeterBottomLabelFont;
    ossimFontInformation theMeterLeftLabelFontInfo;
-   ossimFont*           theMeterLeftLabelFont;
+   ossimRefPtr<ossimFont>           theMeterLeftLabelFont;
    ossimFontInformation theMeterRightLabelFontInfo;
-   ossimFont*           theMeterRightLabelFont;
+   ossimRefPtr<ossimFont>           theMeterRightLabelFont;
    
    // grid label dms format strings
    //
@@ -294,9 +289,7 @@ protected:
    //  tick spacing in meter units
    ossimDpt            theMeterSpacing;
    
-   ossimMapProjection* theInputProjection;
-
-   vector<ossimAnnotationObject*> theFixedAnnotationList;
+   ossimAnnotationSource::AnnotationObjectListType theFixedAnnotationList;
 
    /*!
     * Override base classes drawAnnotations so we can layout
@@ -332,6 +325,10 @@ protected:
    
    ossimIrect getViewingRect()const;
    
+   //! Fetches the input connection's image geometry and verifies that it is a map projection.
+   //! Returns NULL if no valid projection found.
+   const ossimMapProjection* inputMapProjection() const;
+
 // For RTTI
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMaskFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimMaskFilter.h
index 43ffae440bd76086ffe7b1841a0ea782b939d329..f9164c1a5ef7d8259887c1cf959ad548d66b32ec 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMaskFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMaskFilter.h
@@ -10,7 +10,7 @@
 // Description: A brief description of the contents of the file.
 //
 //*************************************************************************
-// $Id: ossimMaskFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimMaskFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef  ossimMaskFilter_HEADER
 #define  ossimMaskFilter_HEADER
 #include <ossim/imaging/ossimImageCombiner.h>
@@ -88,10 +88,6 @@ public:
 		  ossimImageSource* imageSource,
 		  ossimImageSource* maskSource);
 
-   /**
-    * Will delete its owned tile.
-    */
-   virtual ~ossimMaskFilter();
 
    /**
     * Sets the mask type.
@@ -166,6 +162,10 @@ public:
       ossimRefPtr<ossimImageData> maskSourceData);
    
 protected:
+   /**
+    * Will delete its owned tile.
+    */
+   virtual ~ossimMaskFilter();
    
    void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMaxMosaic.h b/Utilities/otbossim/include/ossim/imaging/ossimMaxMosaic.h
index 0b76909c14c1f0e2fac78180cd7c98f7da2de645..af13fd11d2e7f721ef4d0add02622856ae9ecbf9 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMaxMosaic.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMaxMosaic.h
@@ -11,7 +11,7 @@
 //              of all inputs to the top of the mosaic output. 
 //
 //*************************************************************************
-// $Id: ossimMaxMosaic.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimMaxMosaic.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMaxMosaic_HEADER
 #define ossimMaxMosaic_HEADER
 
@@ -29,8 +29,7 @@ class OSSIMDLLEXPORT ossimMaxMosaic : public ossimImageCombiner
 {
 public:
    ossimMaxMosaic();
-   ossimMaxMosaic(const std::vector<ossimImageSource*>& inputSources);
-   virtual ~ossimMaxMosaic();
+   ossimMaxMosaic(ossimConnectableObject::ConnectableObjectList& inputSources);
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -56,7 +55,7 @@ public:
    virtual ossimString getDescription()const;
 
 protected:
-
+   virtual ~ossimMaxMosaic();
    /**
     * Called on first getTile, will initialize all data needed.
     */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMeanMedianFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimMeanMedianFilter.h
index 67ab5055505c3898b36754e0fbf70623697a10a8..9e50e9b90bf44f99242e19e19efddecc9372130a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMeanMedianFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMeanMedianFilter.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimMeanMedianFilter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimMeanMedianFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMeanMedianFilter_HEADER
 #define ossimMeanMedianFilter_HEADER
 
@@ -22,7 +22,7 @@
  * the center pixel is replaced.
  *
  */
-class ossimMeanMedianFilter : public ossimImageSourceFilter
+class OSSIM_DLL ossimMeanMedianFilter : public ossimImageSourceFilter
 {
 public:
 
@@ -48,7 +48,6 @@ public:
    };
 
    ossimMeanMedianFilter(ossimObject* owner=NULL);
-   virtual ~ossimMeanMedianFilter();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
@@ -94,6 +93,7 @@ public:
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const;
 
 protected:
+   virtual ~ossimMeanMedianFilter();
    
    ossimRefPtr<ossimImageData> theTile;
    ossimMeanMedianFilterType   theFilterType;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h b/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h
index 1980ab771e14e62d4d38c159793e302699902ee9..376d87b9af5bf6386cc185d50572779d62c15a8f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h
@@ -55,7 +55,8 @@ public:
 	virtual ossim_uint32 getNumberOfDecimationLevels() const;
    virtual void getDecimationFactor(ossim_uint32 resLevel,
                                     ossimDpt& result) const;
-  
+   virtual void getDecimationFactors(std::vector<ossimDpt>& decimations)const;
+   
 protected:
    ossimRefPtr<ossimImageData> theImage;
    ossimRefPtr<ossimImageData> theResult;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMetadataFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimMetadataFileWriter.h
index a53ef461f6b66f3892abb20af5fd9b220cb04d0a..04d44ec3e545bdcfaaefaece3ae757a4473769c8 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMetadataFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMetadataFileWriter.h
@@ -8,7 +8,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimMetadataFileWriter.h 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimMetadataFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimMetadataFileWriter_H
 #define ossimMetadataFileWriter_H
@@ -55,7 +55,6 @@ class OSSIMDLLEXPORT ossimMetadataFileWriter :
 public:
    ossimMetadataFileWriter();
    
-   virtual ~ossimMetadataFileWriter();
 
    virtual ossimObject*       getObject();
    virtual const ossimObject* getObject() const;
@@ -159,6 +158,7 @@ public:
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 protected:
+   virtual ~ossimMetadataFileWriter();
    /**
     * Write out the file.
     * @return true on success, false on error.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMultiBandHistogramTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimMultiBandHistogramTileSource.h
index 177bd8f9b1f07002f25b41e674ef0ba6a7ac6cf1..1402b395d04d3c0368907284f143183db4a3924c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMultiBandHistogramTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMultiBandHistogramTileSource.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimMultiBandHistogramTileSource.h 11951 2007-10-31 14:34:38Z gpotts $
+// $Id: ossimMultiBandHistogramTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMultiBandHistogramTileSource_HEADER
 #define ossimMultiBandHistogramTileSource_HEADER
 #include <ossim/imaging/ossimImageSourceHistogramFilter.h>
@@ -23,7 +23,6 @@ public:
                                   double maxValuePercent,
                                   ossimImageSource* inputSource,
                                   ossimMultiResLevelHistogram* histogram);
-   virtual ~ossimMultiBandHistogramTileSource();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
 
@@ -83,6 +82,7 @@ public:
                           const char* prefix=0)const;
    
 protected:
+   virtual ~ossimMultiBandHistogramTileSource();
 
    void allocate();
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNBandToIndexFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimNBandToIndexFilter.h
index 91debb32f9cc66c7df381bdfee6980cb030d8452..0ec580d2db323a4ac435f538f6b3cabe2f9788f2 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNBandToIndexFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNBandToIndexFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimNBandToIndexFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNBandToIndexFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNBandToIndexFilter_HEADER
 #define ossimNBandToIndexFilter_HEADER
 #include <ossim/base/ossimNBandLutDataObject.h>
@@ -47,7 +47,6 @@ public:
     * Initializes the min value to 0 and the max value to 4000.
     */
    ossimNBandToIndexFilter();
-   virtual ~ossimNBandToIndexFilter();
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -105,6 +104,7 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
 protected:
+   virtual ~ossimNBandToIndexFilter();
    void allocate();
 
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h b/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h
index 61c098302bef3e0965350e7998ebe1950aaeef74..c26ba01b36673867a09d5b9f2bd943907111e122 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h
@@ -1,7 +1,8 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  Garrett Potts
 //
@@ -12,6 +13,7 @@
 
 #include <iosfwd>
 #include <ossim/imaging/ossimImageFileWriter.h>
+#include <ossim/imaging/ossimNitfWriterBase.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
 #include <ossim/base/ossimRgbLutDataObject.h>
@@ -21,7 +23,7 @@
 
 class ossimProjection;
 
-class OSSIM_DLL ossimNitf20Writer : public ossimImageFileWriter
+class OSSIM_DLL ossimNitf20Writer : public ossimNitfWriterBase
 {
 public:
    ossimNitf20Writer(const ossimFilename& filename=ossimFilename(""),
@@ -54,8 +56,6 @@ public:
     * @note The following names are handled:
     *  file_header
     *  image_header
-    *  enable_rpcb_tag
-    *  enable_blocka_tag
     */
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
@@ -70,12 +70,6 @@ public:
     * @param prefix Usually something like: "object2."
 
     * @return true on success, false on failure.
-    *
-    * Keywords saved by saveState:
-    * 
-    * enable_rpcb_tag: true
-    *
-    * enable_blocka_tag: true
     */
    virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0) const;
 
@@ -88,12 +82,6 @@ public:
     * @param prefix Usually something like: "object2."
 
     * @return true on success, false on failure.
-    *
-    * Keywords picked up by loadState:
-    * 
-    * enable_rpcb_tag: true
-    *
-    * enable_blocka_tag: true
     */
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
 
@@ -117,63 +105,8 @@ protected:
     */
    virtual bool writeBlockBandSequential();
 
-   /**
-    * Populates tags with geometry info from projection.  Will write an
-    * rpcb tag if theEnableRpcbTagFlag if set to true.
-    */
-   void writeGeometry();
-
    void addTags();
-   /**
-    * Sets the complexity level of theFileHeader.
-    *
-    * @param endPosition This should be the end seek position of the file.
-    */
-   void setComplexityLevel(ossim_uint64 endPosition);
-
 
-   /**
-    * Adds the BLOCKA tag.
-    *
-    * @param mapInfo ossimMapProjectionInfo to use to set tag with.
-    *
-    * @note Currently only used with map projected images.
-    */
-   void addBlockaTag(ossimMapProjectionInfo& mapInfo);
-
-   /**
-    * Adds the RPC00B tag.
-    *
-    * @param rect Requested rectangle of image to write.
-    *
-    * @param proj The output projection.
-    */
-   void addRpcbTag(const ossimIrect& rect,
-                   ossimRefPtr<ossimProjection> proj);
-   /**
-    * This is bits used.  (OSSIM_USHORT11 = 11)
-    * 
-    * @returns The actual bits per pixel.  This will return 0 if the
-    * input connection is not hooked up or there is an unhandled scalar type.
-    */
-   ossim_uint32 getActualBitsPerPixel() const;
-
-   /**
-    * This the total bits per pixel.  (OSSIM_USHORT11 = 16)
-    * 
-    * @returns The bits per pixel.  This will return 0 if the
-    * input connection is not hooked up or there is an unhandled scalar type.
-    */
-   ossim_uint32 getBitsPerPixel() const;
-
-   /**
-    * @return Pixel type as a string. Like: "INT", "R", "SI".  .  This will
-    * return an empty string if the input connection is not hooked up or
-    * there is an unhandled scalar type.
-    */
-   ossimString getNitfPixelType() const;   
-
-   
    std::ofstream* theOutputStream;
    
    ossimRefPtr<ossimNitfFileHeaderV2_0>  theFileHeader;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h
index 49b2404b7a443809d9cfc37f0974ebfa0e6d2e8f..551f85b308d4f2eb9bd7299e25be6b1e8215bc31 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
@@ -9,7 +11,7 @@
 // Contains class declaration for NitfTileSource.
 //
 //*******************************************************************
-//  $Id: ossimNitfTileSource.h 13942 2009-01-01 18:58:36Z dburken $
+//  $Id: ossimNitfTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNitfTileSource_HEADER
 #define ossimNitfTileSource_HEADER
 
@@ -58,11 +60,10 @@ public:
 
    ossimNitfTileSource();
    
-   virtual ~ossimNitfTileSource();
    
    virtual ossimString getShortName() const;
    virtual ossimString getLongName()  const;
-   virtual ossimString className()    const;
+   virtual ossimString getClassName() const;
 
    /**
     *  Returns true if the image_file can be opened and is a valid nitf file.
@@ -124,7 +125,7 @@ public:
     */
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
-   
+
    /**
     * Returns the output pixel type of the tile source.
     */
@@ -208,10 +209,12 @@ public:
    virtual double getNullPixelValue(ossim_uint32 band=0)const;
 
    const ossimNitfFileHeader* getFileHeader()const;
+   ossimNitfFileHeader* getFileHeader();
    /**
     * @return The image header for the current entry.
     */
    const ossimNitfImageHeader* getCurrentImageHeader() const;
+   ossimNitfImageHeader* getCurrentImageHeader();
 
    /**
     * @brief Gets the decimation factor.
@@ -235,9 +238,22 @@ public:
     */
    virtual void getDecimationFactor(ossim_uint32 resLevel,
                                     ossimDpt& result) const;
-
+   
+   
+//   virtual ossimImageGeometry* getImageGeometry();
 protected:
+   virtual ~ossimNitfTileSource();
 
+   /**
+    * @brief Initiailizes theDecimationFactors.
+    *
+    * To any derived classes that override this should be called after
+    * completeOpen() so that the overviews are picked up.
+    *
+    * @return true on success false on error.
+    */
+   virtual bool computeDecimationFactors();
+   
    /**
     * @param imageRect The full resolution image rectangle.
     *
@@ -246,29 +262,16 @@ protected:
    void setBoundingRectangle(const ossimIrect& imageRect);
    
    /** Copy constructor, disallow... */
-   ossimNitfTileSource(const ossimNitfTileSource& source);
+   ossimNitfTileSource(const ossimNitfTileSource& obj);
 
    /** Operator=, disallow... */
-   ossimNitfTileSource& operator=(const ossimNitfTileSource& source); 
+   ossimNitfTileSource& operator=(const ossimNitfTileSource& rhs); 
 
    /**
     *  Returns true on success, false on error.
     */
    bool loadTile(const ossimIrect& clipRect);
 
-   /**
-    * @param pt Point to adjust.  This will be modified by the method to fall
-    * on an even block boundary.  Behavior is to snap to the nearest upper
-    * left block corner.
-    *
-    * @param tileHeight Height of one tile in pixels.
-    *s
-    * @param tileWidth Width of one tile in pixels.
-    */
-   void adjustToStartOfBlock(ossimIpt& pt,
-                             ossim_int32 tileHeight,
-                             ossim_int32 tileWidth) const;
-
    /**
     * @return Returns the block number given an origin.
     */
@@ -280,22 +283,17 @@ protected:
    void destroy();
 
    /**
-    * Parses "theImageFile" and initializes all nitf headers.
-    *
+    * @brief Parses "theImageFile" and initializes all nitf headers.
     * @return true on success, false on error.
-    *
-    * @note parseFile() and initialize() are separated  so initialize() can
-    * be called on a entry change to an already open nitf file.
     */
-   bool parseFile();
+   virtual bool parseFile();
 
    /**
-    * Allocates all memory with the exception of headers.
-    *
-    * @note parseFile() and allocate() are separated so allocate() can
-    * be called on a entry change to an already open nitf file.
+    * @brief Allocates everything for current entry.
+    * @return True on success, false on error.
+    * @note allocate is called on a entry change to an already open nitf file.
     */
-   bool allocate();
+   virtual bool allocate();
 
    /**
     * @param hdr Pointer to image header.
@@ -311,7 +309,7 @@ protected:
    /**
     * Initializes the data member "theSwapBytesFlag" from the current entry.
     */
-   void initializeSwapBytesFlag();
+   virtual void initializeSwapBytesFlag();
    
    /**
     * Initializes the data member "theReadMode" from the current entry.
@@ -344,13 +342,6 @@ protected:
     */
    void initializeDecimationFactor();
 
-   /**
-    * Initializes the data "theSubImageOffset" from the current entry.
-    *
-    * @return true on success, false on error.
-    */
-   virtual bool initializeSubImageOffset();
-
    /**
     * Initializes the data members "theImageRect" and "theBlockRect"
     * from the current entry.
@@ -367,7 +358,7 @@ protected:
    /**
     * Initializes the data member "theCacheTileInterLeaveType".
     */
-   void initializeCacheTileInterLeaveType();
+   virtual void initializeCacheTileInterLeaveType();
    
    /**
     * Initializes the cache tile size(width and height).  For block images
@@ -399,7 +390,22 @@ protected:
     * @note x and y are zero based relative to the upper left corner so any
     * sub image offset should be subtracted off.
     */
-   bool loadBlock(ossim_uint32 x, ossim_uint32 y);
+   bool loadBlockFromCache(ossim_uint32 x, ossim_uint32 y,
+                           const ossimIrect& clipRect);
+
+   /**
+    * Loads a block of data to theCacheTile.
+    * 
+    * @param x Starting x position of block to load.
+    *
+    * @param y Starting y position of block to load.
+    *
+    * @return true on success, false on error.
+    *
+    * @note x and y are zero based relative to the upper left corner so any
+    * sub image offset should be subtracted off.
+    */
+   virtual bool loadBlock(ossim_uint32 x, ossim_uint32 y);
 
    /**
     * @param x Horizontal upper left pixel position of the requested block.
@@ -485,7 +491,7 @@ protected:
    ossimRefPtr<ossimImageData>   theTile;
    ossimRefPtr<ossimImageData>   theCacheTile;
    ossimRefPtr<ossimNitfFile>    theNitfFile;
-   vector<ossimRefPtr<ossimNitfImageHeader> > theNitfImageHeader;
+   std::vector<ossimRefPtr<ossimNitfImageHeader> > theNitfImageHeader;
    ReadMode                      theReadMode;
    ossimScalarType               theScalarType;
    bool                          theSwapBytesFlag;
@@ -497,7 +503,7 @@ protected:
    ossim_uint32                  theCurrentEntry;
    ossimIrect                    theImageRect;
    std::ifstream                 theFileStr;   
-   vector<ossim_uint32>          theOutputBandList;
+   std::vector<ossim_uint32>     theOutputBandList;
    ossimIpt                      theCacheSize;
    ossimInterleaveType           theCacheTileInterLeaveType;
    bool                          theCacheEnabledFlag;
@@ -505,8 +511,9 @@ protected:
    ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId;
    bool                          thePackedBitsFlag;
    ossimIrect                    theBlockImageRect;
-   ossim_uint8*                  theCompressedBuf;
+   std::vector<ossim_uint8>      theCompressedBuf;
    ossim_float64                 theDecimationFactor;
+   std::vector<ossimDpt>         theDecimationFactors;
 
    //---
    // Have compressed jpeg blocks of variable length so we must scan and
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNitfWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimNitfWriter.h
index e07829f026454d6931dbee7a475d75eb672d12ec..883ff6bcab8e70a10bca2a7094ee29800d8a55bf 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNitfWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNitfWriter.h
@@ -1,17 +1,18 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimNitfWriter.h 9256 2006-07-14 15:28:19Z dburken $
+//  $Id: ossimNitfWriter.h 15612 2009-10-08 18:54:42Z dburken $
 #ifndef ossimNitfWriter_HEADER
 #define ossimNitfWriter_HEADER
 
 #include <iosfwd>
-#include <ossim/imaging/ossimImageFileWriter.h>
+#include <ossim/imaging/ossimNitfWriterBase.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
 #include <ossim/base/ossimRgbLutDataObject.h>
@@ -21,7 +22,7 @@
 
 class ossimProjection;
 
-class OSSIM_DLL ossimNitfWriter : public ossimImageFileWriter
+class OSSIM_DLL ossimNitfWriter : public ossimNitfWriterBase
 {
 public:
    ossimNitfWriter(const ossimFilename& filename=ossimFilename(""),
@@ -54,8 +55,6 @@ public:
     * @note The following names are handled:
     *  file_header
     *  image_header
-    *  enable_rpcb_tag
-    *  enable_blocka_tag
     */
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
@@ -70,12 +69,6 @@ public:
     * @param prefix Usually something like: "object2."
 
     * @return true on success, false on failure.
-    *
-    * Keywords saved by saveState:
-    * 
-    * enable_rpcb_tag: true
-    *
-    * enable_blocka_tag: true
     */
    virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0) const;
 
@@ -88,12 +81,6 @@ public:
     * @param prefix Usually something like: "object2."
 
     * @return true on success, false on failure.
-    *
-    * Keywords picked up by loadState:
-    * 
-    * enable_rpcb_tag: true
-    *
-    * enable_blocka_tag: true
     */
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
 
@@ -117,78 +104,14 @@ protected:
     */
    virtual bool writeBlockBandSequential();
 
-   /**
-    * Populates tags with geometry info from projection.  Will write an
-    * rpcb tag if theEnableRpcbTagFlag if set to true.
-    */
-   void writeGeometry();
-
-   /**
-    * Sets the complexity level of theFileHeader.
-    *
-    * @param endPosition This should be the end seek position of the file.
-    */
-   void setComplexityLevel(ossim_uint64 endPosition);
-
    /** Currently disabled... */
    // virtual void addStandardTags();
 
-   /**
-    * Adds the BLOCKA tag.
-    *
-    * @param mapInfo ossimMapProjectionInfo to use to set tag with.
-    *
-    * @note Currently only used with map projected images.
-    */
-   void addBlockaTag(ossimMapProjectionInfo& mapInfo);
-
-   /**
-    * Adds the RPC00B tag.
-    *
-    * @param rect Requested rectangle of image to write.
-    *
-    * @param proj The output projection.
-    */
-   void addRpcbTag(const ossimIrect& rect,
-                   ossimRefPtr<ossimProjection> proj);
-
-   /**
-    * This is bits used.  (OSSIM_USHORT11 = 11)
-    * 
-    * @returns The actual bits per pixel.  This will return 0 if the
-    * input connection is not hooked up or there is an unhandled scalar type.
-    */
-   ossim_uint32 getActualBitsPerPixel() const;
-
-   /**
-    * This the total bits per pixel.  (OSSIM_USHORT11 = 16)
-    * 
-    * @returns The bits per pixel.  This will return 0 if the
-    * input connection is not hooked up or there is an unhandled scalar type.
-    */
-   ossim_uint32 getBitsPerPixel() const;
-
-   /**
-    * @return Pixel type as a string. Like: "INT", "R", "SI".  .  This will
-    * return an empty string if the input connection is not hooked up or
-    * there is an unhandled scalar type.
-    */
-   ossimString getNitfPixelType() const;   
-
    std::ofstream* theOutputStream;
    
    ossimRefPtr<ossimNitfFileHeaderV2_1>  theFileHeader;
    ossimRefPtr<ossimNitfImageHeaderV2_1> theImageHeader;
 
-   /** If true user wants to set RPC00B tag. (DEFAULT = false) */
-   bool theEnableRpcbTagFlag;
-
-   /**
-    * If true user wants to set BLOCKA tag. (DEFAULT = true)
-    * Currently only valid for map projected images.
-    */
-   bool theEnableBlockaTagFlag;
-   
 TYPE_DATA   
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNitfWriterBase.h b/Utilities/otbossim/include/ossim/imaging/ossimNitfWriterBase.h
new file mode 100644
index 0000000000000000000000000000000000000000..f9c94253c1c1f64815ecc21e4615de1dbfc5d03a
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNitfWriterBase.h
@@ -0,0 +1,163 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: OSSIM nitf writer base class to hold methods common to
+// all nitf writers.
+//
+//----------------------------------------------------------------------------
+// $Id: ossimKakaduNitfWriter.h 15073 2009-08-13 19:55:34Z dburken $
+#ifndef ossimNitfWriterBase_HEADER
+#define ossimNitfWriterBase_HEADER
+
+#include <ossim/imaging/ossimImageFileWriter.h>
+
+class ossimFilename;
+class ossimImageSourceSequencer;
+class ossimMapProjectionInfo;
+class ossimNitfFileHeaderV2_X;
+class ossimNitfImageHeaderV2_X;
+class ossimProjection;
+
+/**
+ * @brief OSSIM nitf writer base class to hold methods common to
+ * all nitf writers.
+ */
+class ossimNitfWriterBase : public ossimImageFileWriter
+{
+public:
+
+   /** @brief default constructor */
+   ossimNitfWriterBase();
+
+   /**
+    * @brief Constructor that takes filename and input source.
+    * @param filename The output file name.
+    * @param inputSource The input source to write to file.
+    */
+   ossimNitfWriterBase(const ossimFilename& filename,
+                       ossimImageSource* inputSource);
+
+   /* @brief virtual destructor */
+   virtual ~ossimNitfWriterBase();
+
+   /**
+    * @brief Set the properties.
+    * @param property The property to set.
+    */
+   virtual void setProperty(ossimRefPtr<ossimProperty> property);
+
+   /**
+    * @brief Gets a property.
+    * @param The name of the property to get.
+    * @return The property if found.
+    */
+   virtual ossimRefPtr<ossimProperty> getProperty(
+      const ossimString& name)const;
+
+   /**
+    * @param propertyNames Array to populate with property names.
+    *
+    * @note The following names are handled:
+    *  enable_rpcb_tag
+    *  enable_blocka_tag
+    */
+   virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
+ 
+
+   /**
+    * Saves the state of the writer to kwl with prefix then calls
+    * base class ossimImageFileWriter::saveState
+    *
+    * @param kwl Keyword list to save to.
+    *
+    * @param prefix Usually something like: "object2."
+
+    * @return true on success, false on failure.
+    *
+    * Keywords saved by saveState:
+    * 
+    * enable_rpcb_tag: true
+    *
+    * enable_blocka_tag: true
+    */
+   virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0) const;
+
+   /**
+    * Initializes the state of the writer from kwl with prefix then calls
+    * base class ossimImageFileWriter::loadState
+    *
+    * @param kwl Keyword list to initialize from.
+    *
+    * @param prefix Usually something like: "object2."
+
+    * @return true on success, false on failure.
+    *
+    * Keywords picked up by loadState:
+    * 
+    * enable_rpcb_tag: true
+    *
+    * enable_blocka_tag: true
+    */
+   virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
+
+protected:
+
+   /**
+    * @brief Populates tags with geometry info from projection.  Will write an
+    * rpcb tag if theEnableRpcbTagFlag if set to true.
+    * @param hdr The header to write to.
+    * @param seq The input connection or image source.
+    */
+   void writeGeometry(ossimNitfImageHeaderV2_X* hdr,
+                      ossimImageSourceSequencer* seq);
+
+   /**
+    * @brief Adds the BLOCKA tag.
+    *
+    * @param mapInfo ossimMapProjectionInfo to use to set tag with.
+    * @param hdr The header to write to.
+    *
+    * @note Currently only used with map projected images.
+    */
+   void addBlockaTag(ossimMapProjectionInfo& mapInfo,
+                     ossimNitfImageHeaderV2_X* hdr);
+
+   /**
+    * @brief Adds the RPC00B tag.
+    *
+    * @param rect Requested rectangle of image to write.
+    *
+    * @param proj The output projection.
+    */
+   void addRpcbTag(const ossimIrect& rect,
+                   ossimProjection* proj,
+                   ossimNitfImageHeaderV2_X* hdr);
+
+   /**
+    * @brief Sets the complexity level of theFileHeader.
+    *
+    * @param endPosition This should be the end seek position of the file.
+    */
+   void setComplexityLevel(std::streamoff,
+                           ossimNitfFileHeaderV2_X* hdr);
+
+   /** @brief If true user wants to set RPC00B tag. (DEFAULT = false) */
+   bool theEnableRpcbTagFlag;
+   
+   /**
+    * @brief If true user wants to set BLOCKA tag. (DEFAULT = true)
+    * Currently only valid for map projected images.
+    */
+   bool theEnableBlockaTagFlag;
+
+private:
+
+TYPE_DATA
+};
+
+#endif /* #ifndef ossimKakaduNitfVoid Writer_HEADER */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedRemapTable.h b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedRemapTable.h
index 1188735bf8a272950e8c3f5e8059bbb748b87258..88b6e6d5e623fe431b7ef7f7de7f65bec8019e62 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedRemapTable.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedRemapTable.h
@@ -1,15 +1,15 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
-// Author:  David Burken
-//
 // Description:
 //
-// Contains class declaration for  NormalizedRemapTable.  Table for
-// normalizing unsigned 8 bit data.
+// Contains class declaration for base class ossimNormalizedRemapTable.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedRemapTable.h 10456 2007-02-08 14:17:50Z gpotts $
+//  $Id: ossimNormalizedRemapTable.h 15742 2009-10-17 12:59:43Z dburken $
 
 
 #ifndef ossimNormalizedRemapTable_HEADER
@@ -17,38 +17,68 @@
 
 #include <ossim/base/ossimConstants.h>
 
-//*******************************************************************
-// CLASS:  ossimNormalizedRemapTable
-//*******************************************************************
+/**
+ * @class ossimNormalizedRemapTable
+ *
+ * @brief Base class implemetation of normalized remap tables to go to/from
+ * normalized value to pixel value.
+ */
 class OSSIM_DLL ossimNormalizedRemapTable
 {
 public:
+
+   /** default constructor */
    ossimNormalizedRemapTable();
 
-   virtual ~ossimNormalizedRemapTable(){}
+   /** virtual destructor */
+   virtual ~ossimNormalizedRemapTable();
 
-   /*!
-    *  Returns a normalized value (between '0.0' and '1.0') from
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
     *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
     */
-   virtual ossim_float64 normFromPix(ossim_int32 pix) const = 0; 
+   virtual ossim_float64 operator[](ossim_int32 pix) const = 0;
 
-   /*!
-    *  Returns an pixel value as an int from a normalized value.
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
+   virtual ossim_float64 normFromPix(ossim_int32 pix) const = 0;
+
+   /**
+    * @brief Returns an pixel value as an int from a normalized value.
+    *
+    * @return Value between scalar range of remap table.
     */
    virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const = 0;
 
-   /*!
-    *  Returns a normalized value (between '0.0' and '1.0') from a
-    *  pixel value.
+   /**
+    * @brief Pure virtual method to get the number of table entries.
+    * @return The number of entries in a table.
     */
-   virtual ossim_float64 operator[](ossim_int32 pix) const = 0;
-   
+   virtual ossim_int32 getEntries() const = 0;
+
+   /**
+    * @brief Get the value used to normalize and un-normalize table entries.
+    * @return Value used to normalize and un-normalize table entries.
+    */
+   virtual ossim_float64 getNormalizer() const;
+
 private:
+
    // Forbid copy constructor and asignment operator.
    ossimNormalizedRemapTable(const ossimNormalizedRemapTable& source);
    ossimNormalizedRemapTable& operator=(const ossimNormalizedRemapTable&);  
 
  };
 
+inline ossim_float64 ossimNormalizedRemapTable::getNormalizer() const
+{
+   return static_cast<ossim_float64>(getEntries()-1);
+}
+
 #endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedS16RemapTable.h b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedS16RemapTable.h
new file mode 100644
index 0000000000000000000000000000000000000000..2065dadb87a535fc0a74600bd2ecb609acdbd0d6
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedS16RemapTable.h
@@ -0,0 +1,128 @@
+//*******************************************************************
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+// 
+// Description:
+//
+// Contains class declaration for  ossimNormalizedS16RemapTable.  Table for
+// normalizing signed 16 bit data.
+// 
+//*******************************************************************
+//  $Id: ossimNormalizedS16RemapTable.h 10456 2007-02-08 14:17:50Z gpotts $
+
+#ifndef ossimNormalizedS16RemapTable_HEADER
+#define ossimNormalizedS16RemapTable_HEADER
+
+#include <ossim/imaging/ossimNormalizedRemapTable.h>
+#include <ossim/base/ossimCommon.h> /* for round */
+
+/**
+ * @class ossimNormalizedS16RemapTable
+ *
+ * @brief Signed 16 bit normalized remap tables to go to/from
+ * normalized value to pixel value.
+ */
+class OSSIM_DLL ossimNormalizedS16RemapTable : public ossimNormalizedRemapTable
+{
+public:
+   
+   /** @brief default constructor */
+   ossimNormalizedS16RemapTable();
+
+   /** @brief virtual destructor */
+   virtual ~ossimNormalizedS16RemapTable();
+
+   enum
+   {
+      TABLE_ENTRIES  = 65536, // 2^16 32767-(-32768)+1
+      OFFSET_TO_ZERO = 32768  // Gets -32768 to zero.
+   };
+
+   /**
+    * @brief Gets the number of table entries.
+    * @return The number of entries in a table.
+    */
+   virtual ossim_int32 getEntries() const;
+
+   /**
+    * @brief Gets normalized value (between '0.0' and '1.0') from an
+    * int which should in scalar range of a signed 16 bit.
+    * @return Value between 0.0 and 1.0.
+    */
+   virtual ossim_float64 operator[](ossim_int32 pix) const;
+
+   /**
+    * @brief Gets normalized value (between '0.0' and '1.0') from an
+    * int which should in scalar range of a signed 16 bit.
+    * @return Value between 0.0 and 1.0.
+    */
+   virtual ossim_float64 normFromPix(ossim_int32 pix) const;
+
+   /**
+    * @brief Gets pixel value from normalized value.
+    *
+    * Valid returns range is signed 16 bit range or -32768 to 32767.
+    *
+    * @return Value between -32768 to 32767.
+    */
+   virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
+
+private:
+
+   static ossim_float64  theTable[TABLE_ENTRIES];
+   static bool theTableIsInitialized;
+
+};
+
+inline ossim_int32 ossimNormalizedS16RemapTable::getEntries() const
+{
+   return TABLE_ENTRIES;
+}
+
+inline ossim_float64 ossimNormalizedS16RemapTable::operator[](
+   ossim_int32 pix) const
+{
+   ossim_float64 result = 0;
+
+   // Move pix into table range.  This will take -32768 to 0.
+   ossim_int32 p = pix + OFFSET_TO_ZERO;
+
+   result = (p < TABLE_ENTRIES ? ( p >= 0 ? theTable[p] : 0.0) : 1.0);
+
+   return result;
+}
+
+inline ossim_float64 ossimNormalizedS16RemapTable::normFromPix(
+   ossim_int32 pix) const
+{
+   ossim_float64 result = 0;
+
+   // Move pix into table range.  This will take -32768 to 0.
+   ossim_int32 p = pix + OFFSET_TO_ZERO;
+
+   result = (p < TABLE_ENTRIES ? ( p >= 0 ? theTable[p] : 0.0) : 1.0);
+
+   return result;
+}
+
+inline ossim_int32 ossimNormalizedS16RemapTable::pixFromNorm(
+   ossim_float64 normPix) const
+{
+   // Clamp between 0 and 1 on the way in.
+   ossim_float64 p = (normPix<1.0) ? ( (normPix>0.0) ? normPix : 0.0) : 1.0;
+
+   // Un-normalize.
+   p = p * getNormalizer(); // TABLE_ENTRIES - 1;
+
+   //---
+   // Move pixel into sign range then round it.  This will take  65535 to
+   // 32767 which is the max pixel for this scalar type.
+   //---
+   p = ossim::round<ossim_int32>(p - OFFSET_TO_ZERO);
+
+   return static_cast<ossim_int32>(p);
+}
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU11RemapTable.h b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU11RemapTable.h
index 830b2ec71ec7540312fb732c9e4da21c17c3488f..00f9badfcba4e92b76a176272506359155a154f6 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU11RemapTable.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU11RemapTable.h
@@ -1,86 +1,108 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
-// Author:  David Burken
-//
 // Description:
 //
 // Contains class declaration for  ossimNormalizedU11RemapTable.  Table for
 // normalizing unsigned 11 bit data.
 //
 //*******************************************************************
-//  $Id: ossimNormalizedU11RemapTable.h 10456 2007-02-08 14:17:50Z gpotts $
+//  $Id: ossimNormalizedU11RemapTable.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimNormalizedU11RemapTable_HEADER
 #define ossimNormalizedU11RemapTable_HEADER
 
 #include <ossim/imaging/ossimNormalizedRemapTable.h>
+#include <ossim/base/ossimCommon.h> /* for round */
 
+/**
+ * @class ossimNormalizedU11RemapTable
+ *
+ * @brief Eleven bit normalized remap table to go to/from normalized value
+ * to pixel value.
+ */
 class OSSIM_DLL ossimNormalizedU11RemapTable : public ossimNormalizedRemapTable
 {
 public:
+
+   /** @brief default constructor */
    ossimNormalizedU11RemapTable();
+   /** @brief virtual destructor */
+   virtual ~ossimNormalizedU11RemapTable();
 
-   virtual ~ossimNormalizedU11RemapTable(){}
 
    enum
    {
-      TABLE_ENTRIES = 2048
+      TABLE_ENTRIES = 2048 //  2^11
    };
-   
-   virtual ossim_float64 normFromPix(ossim_int32 pix) const;
-      //> Returns a normalized value (between '0.0' and '1.0') from an eight
-      //  bit unsigned char.
-      //<
-   
-   virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
-      //> Returns a pixel value from a normalized value.
-      //  Notes:
-      //  - Valid returns range from '0' to '255' so given a
-      //    value greater than '1.0' method returns '255' and given a
-      //    value less than '0.0' method returns '0.0'.
-      //<
 
+   /**
+    * @brief Gets the number of table entries.
+    * @return The number of entries in a table.
+    */
+   virtual ossim_int32 getEntries() const;
+
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
    virtual ossim_float64 operator[](ossim_int32 pix) const;
-      //> Returns a normalized value (between '0.0' and '1.0') from an eight
-      //  bit unsigned char.
-      //<
-   
+
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
+   virtual ossim_float64 normFromPix(ossim_int32 pix) const;
+
+   /**
+    * @brief Returns an pixel value as an int from a normalized value.
+    *
+    * @return Value between scalar range of remap table.
+    */
+   virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;   
+
 private:
-   // Forbid copy constructor and asignment operator.
-   ossimNormalizedU11RemapTable(const ossimNormalizedU11RemapTable& source){}
-   ossimNormalizedU11RemapTable&
-   operator=(const ossimNormalizedU11RemapTable&);  
 
    static ossim_float64  theTable[TABLE_ENTRIES];
    static bool theTableIsInitialized;
+   
 };
 
-inline ossim_float64 ossimNormalizedU11RemapTable::operator[](ossim_int32 pix) const
+inline ossim_int32 ossimNormalizedU11RemapTable::getEntries() const
+{
+   return TABLE_ENTRIES;
+}
+
+inline ossim_float64 ossimNormalizedU11RemapTable::operator[](
+   ossim_int32 pix) const
 {
-   return (pix < TABLE_ENTRIES ? (pix > 0 ? theTable[pix] : 0.0) : 1.0);  
+   return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);  
 }
 
-inline ossim_float64 ossimNormalizedU11RemapTable::normFromPix(ossim_int32 pix) const
+inline ossim_float64 ossimNormalizedU11RemapTable::normFromPix(
+   ossim_int32 pix) const
 {
-   return (pix < TABLE_ENTRIES ? (pix > 0 ? theTable[pix] : 0.0) : 1.0);
+   return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);
 }
 
-inline ossim_int32 ossimNormalizedU11RemapTable::pixFromNorm(ossim_float64 normPix) const
+inline ossim_int32 ossimNormalizedU11RemapTable::pixFromNorm(
+   ossim_float64 normPix) const
 {
    // un-normalize...
-   ossim_float64 p = normPix * 2047.0;
+   ossim_float64 p = normPix * getNormalizer();
 
-   // Ensure pixel is between 0 and 2047.
-   p = p < 2047.0 ? (p > 0.0 ? p : 0.0) : 2047.0;
+   // Ensure pixel is in range.
+   p = ( (p < TABLE_ENTRIES) ? (p >= 0.0 ? p : 0.0) : getNormalizer());
 
-   //***
-   // If p is between greater than zero and less than one, make it one as it
-   // wasn't a null before.
-   // Add 0.5 to p otherwise as it will be cast to an int for proper rounding.
-   //***
-   p = p > 1.0 ? (p+0.5) : ( !p ? 0.0 : 1.0);
+   // Since going from double to int round...
+   p = ossim::round<ossim_int32>(p);
        
    return static_cast<ossim_int32>(p);
 }
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU16RemapTable.h b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU16RemapTable.h
index 4b06edf68be15d3d93311909ff5bcd81cea8781c..49479efd281e9532e71eb80c6598f280446bf668 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU16RemapTable.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU16RemapTable.h
@@ -1,85 +1,107 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
-// 
-// Author:  David Burken
+// License:  LGPL
 //
+// See LICENSE.txt file in the top level directory for more details.
+// 
 // Description:
 //
 // Contains class declaration for  ossimNormalizedU16RemapTable.  Table for
 // normalizing unsigned 16 bit data.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedU16RemapTable.h 10456 2007-02-08 14:17:50Z gpotts $
+//  $Id: ossimNormalizedU16RemapTable.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimNormalizedU16RemapTable_HEADER
 #define ossimNormalizedU16RemapTable_HEADER
 
 #include <ossim/imaging/ossimNormalizedRemapTable.h>
+#include <ossim/base/ossimCommon.h> /* for round */
 
+/**
+ * @class ossimNormalizedU16RemapTable
+ *
+ * @brief Unsigned 16 bit normalized remap table to go to/from normalized value
+ * to pixel value.
+ */
 class OSSIM_DLL ossimNormalizedU16RemapTable : public ossimNormalizedRemapTable
 {
 public:
-   ossimNormalizedU16RemapTable();
 
-   virtual ~ossimNormalizedU16RemapTable(){}
+   /** @brief default constructor */
+   ossimNormalizedU16RemapTable();
+   /** @brief virtual destructor */
+   virtual ~ossimNormalizedU16RemapTable();
 
    enum
    {
-      TABLE_ENTRIES   = 65536
+      TABLE_ENTRIES   = 65536 // 2^16
    };
+
+   /**
+    * @brief Gets the number of table entries.
+    * @return The number of entries in a table.
+    */
+   virtual ossim_int32 getEntries() const;
    
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
+   virtual ossim_float64 operator[](ossim_int32 pix) const;
+
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
    virtual ossim_float64 normFromPix(ossim_int32 pix) const;
-      //> Returns a normalized value (between '0.0' and '1.0') from an eight
-      //  bit unsigned char.
-      //<
-   
-   virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
-      //> Returns a pixel value from a normalized value.
-      //  Notes:
-      //  - Valid returns range from '0' to '255' so given a
-      //    value greater than '1.0' method returns '255' and given a
-      //    value less than '0.0' method returns '0.0'.
-      //<
 
-   virtual ossim_float64 operator[](ossim_int32 pix) const;
-      //> Returns a normalized value (between '0.0' and '1.0') from an eight
-      //  bit unsigned char.
-      //<
+   /**
+    * @brief Returns an pixel value as an int from a normalized value.
+    *
+    * @return Value between scalar range of remap table.
+    */
+   virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
    
-private:
-   // Forbid copy constructor and asignment operator.
-   ossimNormalizedU16RemapTable(const ossimNormalizedU16RemapTable& source){}
-   ossimNormalizedU16RemapTable&
-   operator=(const ossimNormalizedU16RemapTable&);  
+protected:
 
    static ossim_float64  theTable[TABLE_ENTRIES];
    static bool theTableIsInitialized;
+   
 };
 
-inline ossim_float64 ossimNormalizedU16RemapTable::operator[](ossim_int32 pix) const
+inline ossim_int32 ossimNormalizedU16RemapTable::getEntries() const
+{
+   return TABLE_ENTRIES;
+}
+
+inline ossim_float64 ossimNormalizedU16RemapTable::operator[](
+   ossim_int32 pix) const
 {
-   return (pix < TABLE_ENTRIES ? (pix > 0 ? theTable[pix] : 0.0) : 1.0);  
+   return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);  
 }
 
-inline ossim_float64 ossimNormalizedU16RemapTable::normFromPix(ossim_int32 pix) const
+inline ossim_float64 ossimNormalizedU16RemapTable::normFromPix(
+   ossim_int32 pix) const
 {
-   return (pix < TABLE_ENTRIES ? (pix > 0 ? theTable[pix] : 0.0) : 1.0);
+   return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);
 }
 
-inline ossim_int32 ossimNormalizedU16RemapTable::pixFromNorm(ossim_float64 normPix) const
+inline ossim_int32 ossimNormalizedU16RemapTable::pixFromNorm(
+   ossim_float64 normPix) const
 {
    // un-normalize...
-   ossim_float64 p = normPix * 65535.0;
+   ossim_float64 p = normPix * getNormalizer();
 
-   // Ensure pixel is between 0 and 65535.
-   p = p < 65535.0 ? (p > 0.0 ? p : 0.0) : 65535.0;
+   // Ensure pixel is in range.
+   p = ( (p < TABLE_ENTRIES) ? (p >= 0.0 ? p : 0.0) : getNormalizer());
 
-   //***
-   // If p is between greater than zero and less than one, make it one as it
-   // wasn't a null before.
-   // Add 0.5 to p otherwise as it will be cast to an int for proper rounding.
-   //***
-   p = p > 1.0 ? (p+0.5) : ( !p ? 0.0 : 1.0);
+   // Since going from double to int round...
+   p = ossim::round<ossim_int32>(p);
        
    return static_cast<ossim_int32>(p);
 }
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU8RemapTable.h b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU8RemapTable.h
index e45a98f8cc6f6e8410e9043343befc1b23dcddf9..e8e45b57203d548133435b3906bccd25f623dcbe 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU8RemapTable.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNormalizedU8RemapTable.h
@@ -1,88 +1,108 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
-// Author:  David Burken
-//
 // Description:
 //
 // Contains class declaration for  ossimNormalizedU8RemapTable.  Table for
 // normalizing unsigned 8 bit data.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedU8RemapTable.h 10455 2007-02-08 14:16:25Z gpotts $
+//  $Id: ossimNormalizedU8RemapTable.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimNormalizedU8RemapTable_HEADER
 #define ossimNormalizedU8RemapTable_HEADER
 
 #include <ossim/imaging/ossimNormalizedRemapTable.h>
+#include <ossim/base/ossimCommon.h> /* for round */
 
-//*******************************************************************
-// CLASS:  ossimNormalizedU8RemapTable
-//*******************************************************************
+/**
+ * @class ossimNormalizedU8RemapTable
+ *
+ * @brief Eight bit normalized remap table to go to/from normalized value
+ * to pixel value.
+ */
 class OSSIM_DLL ossimNormalizedU8RemapTable : public ossimNormalizedRemapTable
 {
 public:
-   ossimNormalizedU8RemapTable();
 
-   virtual ~ossimNormalizedU8RemapTable(){}
+   /** @brief default constructor */
+   ossimNormalizedU8RemapTable();
+   /** @brief virtual destructor */
+   virtual ~ossimNormalizedU8RemapTable();
 
+ 
    enum
    {
-      TABLE_ENTRIES   = 256,
-      MAX_TABLE_INDEX = 255
+      TABLE_ENTRIES = 256 // 2^8
    };
-   
+
+   /**
+    * @brief Gets the number of table entries.
+    * @return The number of entries in a table.
+    */
+   virtual ossim_int32 getEntries() const;
+
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
+   virtual ossim_float64 operator[](ossim_int32 pix) const;
+
+   /**
+    *  @brief Gets a normalized value (between '0.0' and '1.0') from
+    *  a pixel value.
+    *
+    *  @return Value between 0.0 and 1.0.
+    */
    virtual ossim_float64 normFromPix(ossim_int32 pix) const;
-      //> Returns a normalized value (between '0.0' and '1.0') from an eight
-      //  bit unsigned char.
-      //<
-   
+
+   /**
+    * @brief Returns an pixel value as an int from a normalized value.
+    *
+    * @return Value between scalar range of remap table.
+    */
    virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
-      //> Returns a pixel value from a normalized value.
-      //  Notes:
-      //  - Valid returns range from '0' to '255' so given a
-      //    value greater than '1.0' method returns '255' and given a
-      //    value less than '0.0' method returns '0.0'.
-      //<
 
-   virtual ossim_float64 operator[](ossim_int32 pix) const;
-      //> Returns a normalized value (between '0.0' and '1.0') from an eight
-      //  bit unsigned char.
-      //<
-   
-private:
-   // Forbid copy constructor and asignment operator.
-   ossimNormalizedU8RemapTable(const ossimNormalizedU8RemapTable& source);
-   ossimNormalizedU8RemapTable& operator=(const ossimNormalizedU8RemapTable&);  
-
-   static ossim_float64  theTable[TABLE_ENTRIES];
+protected:
+
+   static ossim_float64 theTable[TABLE_ENTRIES];
    static bool theTableIsInitialized;
+
 };
 
-inline ossim_float64 ossimNormalizedU8RemapTable::operator[](ossim_int32 pix) const
+inline ossim_int32 ossimNormalizedU8RemapTable::getEntries() const
+{
+   return TABLE_ENTRIES;
+}
+
+inline ossim_float64 ossimNormalizedU8RemapTable::operator[](
+   ossim_int32 pix) const
 {
-   return (pix < TABLE_ENTRIES ? (pix > 0 ? theTable[pix] : 0.0) : 1.0);  
+   return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);  
 }
 
-inline ossim_float64 ossimNormalizedU8RemapTable::normFromPix(ossim_int32 pix) const
+inline ossim_float64 ossimNormalizedU8RemapTable::normFromPix(
+   ossim_int32 pix) const
 {
-   return (pix < TABLE_ENTRIES ? (pix > 0 ? theTable[pix] : 0.0) : 1.0);
+   return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);
 }
 
-inline ossim_int32 ossimNormalizedU8RemapTable::pixFromNorm(ossim_float64 normPix) const
+inline ossim_int32 ossimNormalizedU8RemapTable::pixFromNorm(
+   ossim_float64 normPix) const
 {
    // un-normalize...
-   ossim_float64 p = normPix * 255.0;
+   ossim_float64 p = normPix * getNormalizer();
 
-   // Ensure pixel is between 0 and 255.
-   p = p < 255.0 ? (p > 0.0 ? p : 0.0) : 255.0;
+   // Ensure pixel is in range.
+   p = ( (p < TABLE_ENTRIES) ? (p >= 0.0 ? p : 0.0) : getNormalizer());
 
-   //***
-   // If p is between greater than zero and less than one, make it one as it
-   // wasn't a null before.
-   // Add 0.5 to p otherwise as it will be cast to an int for proper rounding.
-   //***
-   p = p > 1.0 ? (p+0.5) : ( !p ? 0.0 : 1.0);
+   // Since going from double to int round...
+   p = ossim::round<ossim_int32>(p);
        
    return static_cast<ossim_int32>(p);
 }
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimOrthoImageMosaic.h b/Utilities/otbossim/include/ossim/imaging/ossimOrthoImageMosaic.h
index 6fadd7d79322c1c3493e20e450016881881dc8b9..e373dc0d4c97219e51346914e7a176b428aa9047 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimOrthoImageMosaic.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimOrthoImageMosaic.h
@@ -8,30 +8,28 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimOrthoImageMosaic.h 10777 2007-04-25 14:49:17Z gpotts $
+//  $Id: ossimOrthoImageMosaic.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimOrthoImageMosaic_HEADER
 #define ossimOrthoImageMosaic_HEADER
+
 #include <ossim/imaging/ossimImageMosaic.h>
 
 class OSSIMDLLEXPORT ossimOrthoImageMosaic : public ossimImageMosaic
 {
 public:
    ossimOrthoImageMosaic();
-   ossimOrthoImageMosaic(const std::vector<ossimImageSource*>& inputSources);
-   virtual ~ossimOrthoImageMosaic();   
+   ossimOrthoImageMosaic(ossimConnectableObject::ConnectableObjectList& inputSources);
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const;
    virtual void initialize();
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
-  /*!
-   * Used to retrieve the number of overlapping images withint the given
-   * rect.
-   */
+
+   //! Returns the geometry associated with the full mosaic. This object maintains it's own 
+   //! geometry instance.
+   virtual ossimImageGeometry* getImageGeometry();
+
+   //! Used to retrieve the number of overlapping images withint the given rect.
    virtual ossim_uint32 getNumberOfOverlappingImages(const ossimIrect& rect, ossim_uint32 resLevel=0)const;
 
-  /*!
-   * Used to populate the result with the index of the overlapping images.
-   */
+   //! Used to populate the result with the index of the overlapping images.
    virtual void getOverlappingImages(std::vector<ossim_uint32>& result,
                                      const ossimIrect& rect,
                                      ossim_uint32 resLevel=0)const;
@@ -43,23 +41,20 @@ public:
    ossimIrect getRelativeRect(ossim_uint32 index,
                               ossim_uint32 resLevel = 0)const;
 protected:
-   std::vector<ossimDpt>  theInputTiePoints;
-   
-   /*!
-    * Holds R0 delta and will be scaled for different r-level requests
-    *
-    */
-   ossimDpt          theDelta;
+   virtual ~ossimOrthoImageMosaic();   
+   void computeBoundingRect(ossim_uint32 resLevel=0);
    
-   /*!
-    * Will hold the upper left tie of the mosaic.
-    */
-   ossimDpt          theUpperLeftTie;
+   //! If this object is maintaining an ossimImageGeometry, this method needs to be called after 
+   //! each time the contents of the mosaic changes.
+   void updateGeometry();
+
+   std::vector<ossimDpt>  m_InputTiePoints;
+   ossimDpt    m_Delta; //!< Holds R0 delta and will be scaled for different r-level requests
+   ossimDpt    m_UpperLeftTie; //!< Will hold the upper left tie of the mosaic.
+   ossimIrect  m_BoundingRect;
+   ossimString m_Units;
+   ossimRefPtr<ossimImageGeometry> m_Geometry; //!< The input image geometry, altered by the map tiepoint
 
-   ossimIrect        theBoundingRect;
-   ossimString       theUnits;
-   
-   void computeBoundingRect(ossim_uint32 resLevel=0);
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderBase.h b/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderBase.h
index c1b05d6d5d373dc5c0c37e8c069587d0a4f7a4e0..20c82afe71aba7d67a02bdffd77c65b48493d0f5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderBase.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderBase.h
@@ -1,13 +1,15 @@
 //----------------------------------------------------------------------------
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
 // Description:  Base class for overview builders.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewBuilderBase.h 10203 2007-01-09 15:42:22Z dburken $
+// $Id: ossimOverviewBuilderBase.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimOverviewBuilderBase_HEADER
 #define ossimOverviewBuilderBase_HEADER
 
@@ -34,22 +36,14 @@ public:
    /** default constructor */
    ossimOverviewBuilderBase();
 
-   /** virtual destructor */
-   virtual ~ossimOverviewBuilderBase();
-
    /**
     * @brief Sets the input to the builder. (pure virtual)
     * 
     * @param imageSource The input to the builder.
     * 
-    * @param bool youOwnItFlag If true this object own the imageSource
-    * memory and will delete imageSource at destruction or change of
-    * imageSource.
-    * 
     * @return True on successful initializion, false on error.
     */
-   virtual bool setInputSource(ossimImageHandler* imageSource,
-                               bool youOwnItFlag) = 0;
+   virtual bool setInputSource(ossimImageHandler* imageSource) = 0;
 
    /**
     * @brief Sets the output file name. (pure virtual)
@@ -57,6 +51,17 @@ public:
     */
    virtual void setOutputFile(const ossimFilename& file)=0;
 
+   /**
+    * @brief Gets the output file name. (pure virtual)
+    *
+    * @return The output file name or ossimFilename::NIL if it was not set
+    * yet and the image handle has not been initialized.
+    *
+    * @note This will return ossimFilename::NIL unless one of was called,
+    * setInputSource or setOutputFile.
+    */
+   virtual ossimFilename getOutputFile() const=0;
+
    /**
     * @brief Sets the overview output type. (pure virtual)
     * @param type This should be the string representing the type.  This method
@@ -87,6 +92,24 @@ public:
     * @param typeList List of ossimStrings to add to.
     */
    virtual void getTypeNameList(std::vector<ossimString>& typeList)const=0;
+
+   /**
+    * @brief Get the overview stop dimension.
+    * @return The overview stop dimension.
+    */
+   virtual ossim_uint32 getOverviewStopDimension() const;
+
+   /**
+    * @brief Sets the overview stop dimension.
+    *
+    * This controls how many layers will be built. If set to 64 then the
+    * builder will stop when height and width for current level are less
+    * than or equal to 64.  Note a default can be set in the ossim preferences
+    * file, setting the keyword "overview_stop_dimension".
+    * 
+    * @param dim The overview stop dimension
+    */
+   virtual void setOverviewStopDimension(ossim_uint32 dim);
  
    /**
     * @brief Builds the overviews. (pure virtual)
@@ -95,8 +118,37 @@ public:
     */
    virtual bool execute()=0;
 
+   static const char* OVERVIEW_STOP_DIMENSION_KW;
  
 protected:
+   /** virtual destructor */
+   virtual ~ossimOverviewBuilderBase();
+
+   /**
+    *  @brief Gets the required number of res levels.
+    *
+    *  Convenience method to get the required number of reduced resolution
+    *  data sets to get to the smallest dimension of the output tile size.
+    *  Note that this include r0.
+    *
+    *  @param ih Pointer to the image handler.
+    *
+    *  @return number of res levels.
+    */
+   ossim_uint32 getRequiredResLevels(const ossimImageHandler* ih) const;
+  
+   /**
+    * @brief Gets the default stop dimension.
+    *
+    * Looks for overview_stop_dimension, then will use minimum default tile
+    * size if that is not found.
+    * 
+    * @returns Returns the default stop dimension.
+    */
+   ossim_uint32 getDefaultStopDimension() const;
+   
+   ossim_uint32 theOverviewStopDimension;
+   
 
    /** for rtti stuff */
    TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactory.h b/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactory.h
index 649df3563bf7fd74d64153b7ce2a1ef9c4889594..f0987843f050ed990f06144aba71ce6bc88d582d 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactory.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactory.h
@@ -7,7 +7,7 @@
 // Description: The ossim overview builder factory.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewBuilderFactory.h 9930 2006-11-22 19:23:40Z dburken $
+// $Id: ossimOverviewBuilderFactory.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimOverviewBuilderFactory_HEADER
 #define ossimOverviewBuilderFactory_HEADER
@@ -23,8 +23,7 @@ class ossimString;
  * @class ossimOverviewBuilderFactory
  * @brief The ossim overview builder factory.
  */
-class OSSIM_DLL ossimOverviewBuilderFactory:
-   public ossimOverviewBuilderFactoryBase
+class OSSIM_DLL ossimOverviewBuilderFactory : public ossimOverviewBuilderFactoryBase
 {
 public:
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactoryBase.h b/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactoryBase.h
index cdb8c3f4da2086c4b5ca987b1ddc293630c2596d..7adfc24ce5d82b414a2d40ab4c0e6f01e937c90a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactoryBase.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimOverviewBuilderFactoryBase.h
@@ -7,13 +7,14 @@
 // Description: The base class for overview builders.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewBuilderFactoryBase.h 9930 2006-11-22 19:23:40Z dburken $
+// $Id: ossimOverviewBuilderFactoryBase.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimOverviewBuilderFactoryBase_HEADER
 #define ossimOverviewBuilderFactoryBase_HEADER
 
 #include <vector>
 #include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimObjectFactory.h>
 
 class ossimOverviewBuilderBase;
 class ossimString;
@@ -22,7 +23,7 @@ class ossimString;
  * @class ossimOverviewBuilderFactoryBase
  * @brief The base class for factory overview builder factories.
  */
-class OSSIM_DLL ossimOverviewBuilderFactoryBase
+class OSSIM_DLL ossimOverviewBuilderFactoryBase : public ossimObjectFactory
 {
 public:
    /** default constructor hidden from use */
@@ -38,8 +39,7 @@ public:
     * @return Pointer to ossimOverviewBuilderInterface or NULL is not found
     * within registered factories.
     */
-   virtual ossimOverviewBuilderBase* createBuilder(
-      const ossimString& typeName) const = 0;
+   virtual ossimOverviewBuilderBase* createBuilder(const ossimString& typeName) const = 0;
 
    /**
     * @brief Method to populate a list of supported types for the factory.
@@ -48,6 +48,13 @@ public:
     * @param typeList List of ossimStrings to add to.
     */
    virtual void getTypeNameList(std::vector<ossimString>& typeList)const = 0;
+
+   //! This interface is not used
+   virtual ossimObject* createObject(const ossimString&) const { return 0; }
+
+   //! This interface is not used
+   virtual ossimObject* createObject(const ossimKeywordlist&, const char*) const { return 0; }
+
 };
 
 #endif /* #ifndef ossimOverviewBuilderFactoryBase_HEADER */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimOverviewSequencer.h b/Utilities/otbossim/include/ossim/imaging/ossimOverviewSequencer.h
index 5fae070100d0c224a04edae3b0b843facfac3d21..193595929d9ab65cb842926c3051caa52c4a3486 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimOverviewSequencer.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimOverviewSequencer.h
@@ -7,7 +7,7 @@
 // Description: Class definition for sequencer for building overview files.
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewSequencer.h 10269 2007-01-15 15:33:37Z dburken $
+// $Id: ossimOverviewSequencer.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimOverviewSequencer_HEADER
 #define ossimOverviewSequencer_HEADER
 
@@ -29,8 +29,6 @@ public:
    /** default constructor */
    ossimOverviewSequencer();
    
-   /** virtual destructor */
-   virtual ~ossimOverviewSequencer();
    
    /**
     * @return The number of tiles within the area of interest.
@@ -136,6 +134,8 @@ public:
       ossimFilterResampler::ossimFilterResamplerType resampleType);
    
 protected:
+   /** virtual destructor */
+   virtual ~ossimOverviewSequencer();
 
    /**
     * @brief Gets the image rectangle for the input tile for
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimPixelFlipper.h b/Utilities/otbossim/include/ossim/imaging/ossimPixelFlipper.h
index 19d25c39ac89490a3bc659c4d496531ed56e8f96..46b09d75754f2abea7a315542181c37870c41945 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimPixelFlipper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimPixelFlipper.h
@@ -13,7 +13,7 @@
 // This was written to fix partial null pixels.
 // 
 //*************************************************************************
-// $Id: ossimPixelFlipper.h 12623 2008-04-07 14:10:08Z gpotts $
+// $Id: ossimPixelFlipper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimPixelFlipper_HEADER
 #define ossimPixelFlipper_HEADER
 
@@ -70,8 +70,6 @@ public:
    /** default constructor */
    ossimPixelFlipper(ossimObject* owner=NULL);
 
-   /** destructor */
-   virtual ~ossimPixelFlipper();
 
    /** @return "Pixel flipper" as an ossimString. */
    virtual ossimString getShortName()const;
@@ -144,6 +142,8 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
 protected:
+   /** destructor */
+   virtual ~ossimPixelFlipper();
    template <class T> void flipPixels(T dummy,
                                       ossimImageData* inpuTile,
                                       ossim_uint32 resLevel);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimPolyCutter.h b/Utilities/otbossim/include/ossim/imaging/ossimPolyCutter.h
index 413edc2928419551f5bf90f1181e8a7dc29f0ea1..782838e93bef580a1305e3ae0a46c2745d4559d8 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimPolyCutter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimPolyCutter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimPolyCutter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimPolyCutter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimPolyCutter_HEADER
 #define ossimPolyCutter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -31,7 +31,6 @@ public:
    ossimPolyCutter();
     ossimPolyCutter(ossimImageSource* inputSource,
                     const ossimPolygon& polygon);
-   virtual ~ossimPolyCutter();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
@@ -75,6 +74,7 @@ public:
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 protected:
+   virtual ~ossimPolyCutter();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdNitfTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdNitfTileSource.h
index 55b30816240fb7f9e0e3219a6aa309db6b703154..01074034a413d5d3048ed524b3e204528fad5a78 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdNitfTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdNitfTileSource.h
@@ -10,18 +10,21 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimQuickbirdNitfTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimQuickbirdNitfTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimQuickbirdNitfTileSource_HEADER
 #define ossimQuickbirdNitfTileSource_HEADER
 #include <ossim/imaging/ossimNitfTileSource.h>
+#include <ossim/base/ossim2dTo2dTransform.h>
 
 class ossimQuickbirdNitfTileSource : public ossimNitfTileSource
 {
 public:
-  virtual bool open();
-
- protected:
+   virtual bool open();
 
+   virtual ossimImageGeometry* getImageGeometry();
+   
+protected:
+   ossimRefPtr<ossim2dTo2dTransform> m_transform;
 TYPE_DATA   
 };
 #endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdTiffTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdTiffTileSource.h
index 115e8e8c8262c854676cbe9c6814e369691062e4..b405a779144765c17b87ec2581799972b708d9a6 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdTiffTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimQuickbirdTiffTileSource.h
@@ -15,19 +15,22 @@
 // Quick Bird ".TIL" files.
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimQuickbirdTiffTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimQuickbirdTiffTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimQuickbirdTiffTileSource_HEADER
 #define ossimQuickbirdTiffTileSource_HEADER
 
 #include <ossim/imaging/ossimTiffTileSource.h>
+#include <ossim/base/ossim2dTo2dShiftTransform.h>
 
-class ossimQuickbirdTiffTileSource : public ossimTiffTileSource
+class OSSIM_DLL ossimQuickbirdTiffTileSource : public ossimTiffTileSource
 {
 public:
-  virtual bool open();
-
- protected:
-
+   virtual bool open();
+   virtual ossimImageGeometry* getImageGeometry();
+   
+protected:
+   ossimRefPtr<ossim2dTo2dTransform> m_transform;
+   
 TYPE_DATA   
 };
 #endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h
index ad5ca539d0aa229a12e2808e0cd08612b5252bcc..7a1ce21e64fa55ed3c856ce88671a65b2664059b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h
@@ -7,9 +7,10 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRLevelFilter.h 13180 2008-07-16 21:01:56Z dburken $
+// $Id: ossimRLevelFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRLevelFilter_HEADER
 #define ossimRLevelFilter_HEADER
+
 #include <ossim/imaging/ossimImageSourceFilter.h>
 
 /*!
@@ -30,14 +31,13 @@ public:
    /** @brief default constructor */
    ossimRLevelFilter();
 
-   /** @brief virtual destructor. */
-   virtual ~ossimRLevelFilter();
 
    virtual void getDecimationFactor(ossim_uint32 resLevel,
                                     ossimDpt& result)const;
 
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=NULL);
+   //! Returns a pointer reference to the active image geometry at this filter. The input source
+   //! geometry is modified, so we need to maintain our own geometry object as a data member.
+   ossimImageGeometry* getImageGeometry();
 
    virtual void setCurrentRLevel(ossim_uint32 rlevel);
 
@@ -76,14 +76,22 @@ public:
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
 protected:
+   /** @brief virtual destructor. */
+   virtual ~ossimRLevelFilter();
+   
    /*!
     * Initializes result with the sum of decimations from rlevel one to
     * theCurrentRLevel.
     */
    void getSummedDecimation(ossimDpt& result) const;
    
+   //! If this object is maintaining an ossimImageGeometry, this method needs to be called after 
+   //! a scale change so that the geometry's projection is modified accordingly.
+   void updateGeometry();
+
    ossim_uint32 theCurrentRLevel;
    bool         theOverrideGeometryFlag;
+   ossimRefPtr<ossimImageGeometry> m_ScaledGeometry; //!< The input image geometry, altered by the scale
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimReadmeFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimReadmeFileWriter.h
index 2f8c015367a268ae6bb14904fdc662972f7c8d90..a02a1bac3f65923f5b038b8d0a1c2d69ae1b6c2a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimReadmeFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimReadmeFileWriter.h
@@ -8,7 +8,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimReadmeFileWriter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimReadmeFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimReadmeFileWriter_H
 #define ossimReadmeFileWriter_H
@@ -24,8 +24,6 @@ public:
    /** default constructor */
    ossimReadmeFileWriter();
 
-   /** virtual destructor */
-   virtual ~ossimReadmeFileWriter();
 
    /**
     * Satisfies pure virtual from ossimMetadataWriter base.
@@ -48,7 +46,9 @@ public:
     */
    virtual bool hasMetadataType(const ossimString& metadataType)const;
    
-private:
+protected:
+   /** virtual destructor */
+   virtual ~ossimReadmeFileWriter();
    virtual bool writeFile();
    
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimResampler.h b/Utilities/otbossim/include/ossim/imaging/ossimResampler.h
index d163c9e4894e01c3a2733f3ae2354fe15f86d168..bd1457ad347c750b71fb068fa8074573e9405c38 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimResampler.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimResampler.h
@@ -4,7 +4,7 @@
 // 
 // Author:  Garrett Potts
 //*******************************************************************
-//  $Id: ossimResampler.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimResampler.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimResampler_HEADER
 #define ossimResampler_HEADER
@@ -40,8 +40,6 @@ public:
       ossimResampler_BICUBIC          = 3
    };
    ossimResampler();
-   
-   virtual ~ossimResampler();
 
    
    /*!
@@ -143,6 +141,7 @@ public:
          return false;
       }
 protected:
+   virtual ~ossimResampler();
 
    ossimDpt                   theOutputToInputRatio;
    ossimResLevelResamplerType theResamplerType;  
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRgbImage.h b/Utilities/otbossim/include/ossim/imaging/ossimRgbImage.h
index 4232234ec077de8117c2b06ac92899c7b4236dbe..c04ea545f5ed013b41522d82deec1a7af5977057 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRgbImage.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRgbImage.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbImage.h 11830 2007-10-10 13:34:25Z dburken $
+// $Id: ossimRgbImage.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbImage_HEADER
 #define ossimRgbImage_HEADER
 
@@ -27,7 +27,6 @@ public:
     */
    ossimRgbImage(ossimRefPtr<ossimImageData>& currentImageData);
    
-   virtual ~ossimRgbImage();
 
    /**
     * Will construct a new single band image data object.
@@ -322,6 +321,7 @@ public:
    const ossimRefPtr<ossimImageData> getImageData()const;
 
 protected:
+   virtual ~ossimRgbImage();
 
    /**
     * This object operates on the ossimImageData.  Note the
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRgbToGreyFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimRgbToGreyFilter.h
index 30f80e6915748a921d5d7e94f73d8c1bda4f360b..0b7cb76a862f4c5e6743b3b3a836d3262e2d8622 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRgbToGreyFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRgbToGreyFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbToGreyFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbToGreyFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbToGreyFilter_HEADER
 #define ossimRgbToGreyFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -26,7 +26,6 @@ public:
                         double c1 = 1.0/3.0,
                         double c2 = 1.0/3.0,
                         double c3 = 1.0/3.0);
-   virtual ~ossimRgbToGreyFilter();
    
    virtual ossimString getShortName()const;
    virtual ossimString getLongName()const;
@@ -51,6 +50,7 @@ public:
                           const char* prefix=0);
 
 protected:
+   virtual ~ossimRgbToGreyFilter();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsiSource.h b/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsiSource.h
index 3f840b2e78ec7e85dcb5979baef0022517cb7292..5105111097efe6ed13b470f164762b31f8a6356c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsiSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsiSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbToHsiSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbToHsiSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbToHsiSource_HEADER
 #define ossimRgbToHsiSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossimRgbToHsiSource : public ossimImageSourceFilter
 public:
    ossimRgbToHsiSource();
    ossimRgbToHsiSource(ossimImageSource* inputSource);
-   virtual ~ossimRgbToHsiSource();
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
@@ -32,6 +31,7 @@ public:
    virtual void initialize();
 
 protected:
+   virtual ~ossimRgbToHsiSource();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsvSource.h b/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsvSource.h
index 297a291a7efb4d2afbb2a1e9f84387cad57fabd2..82c719b09f870b6a997bdb1a0345f8afabea4f4f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsvSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRgbToHsvSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbToHsvSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbToHsvSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbToHsvSource_HEADER
 #define ossimJpegRgbToYCbCrSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossimRgbToHsvSource : public ossimImageSourceFilter
 public:
    ossimRgbToHsvSource();
    ossimRgbToHsvSource(ossimImageSource* inputSource);
-   virtual ~ossimRgbToHsvSource();
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
@@ -32,6 +31,7 @@ public:
    virtual void initialize();
        
 protected:
+   virtual ~ossimRgbToHsvSource();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRgbToIndexFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimRgbToIndexFilter.h
index fefd998766f993512ccf93824f8a69d7b1a56db8..d66c192cd4e3dcd6285866b419a3d66ed4d93bd0 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRgbToIndexFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRgbToIndexFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbToIndexFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbToIndexFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbToIndexFilter_HEADER
 #define ossimRgbToIndexFilter_HEADER
 #include <ossim/base/ossimRgbVector.h>
@@ -50,7 +50,6 @@ public:
    ossimRgbToIndexFilter();
    ossimRgbToIndexFilter(ossimImageSource* inputSource,
                            const ossimRgbLutDataObject& rgbLut);
-   virtual ~ossimRgbToIndexFilter();
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& origin,
                                                ossim_uint32 resLevel=0);
@@ -83,11 +82,12 @@ public:
     */
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
 protected:
+   virtual ~ossimRgbToIndexFilter();
    void allocate();
    
    virtual ossimRefPtr<ossimImageData> convertInputTile(ossimRefPtr<ossimImageData>& tile);
 
-   ossimRgbLutDataObject       theLut;
+   ossimRefPtr<ossimRgbLutDataObject>       theLut;
    ossimRefPtr<ossimImageData> theTile;
    
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h b/Utilities/otbossim/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h
index ae5f75ff47f3c728e0861e61de452f6047ad0e35..2422b806cfcafd8122a3394780c0c8fd4b56f226 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbToJpegYCbCrSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbToJpegYCbCrSource.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRgbToJpegYCbCrSource_HEADER
 #define ossimRgbToJpegYCbCrSource_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -19,11 +19,11 @@ public:
    
    ossimRgbToJpegYCbCrSource();
    ossimRgbToJpegYCbCrSource(ossimImageSource* inputSource);
-   virtual ~ossimRgbToJpegYCbCrSource();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                                ossim_uint32 resLevel=0);
        
 protected:
+   virtual ~ossimRgbToJpegYCbCrSource();
    ossimRefPtr<ossimImageData> theBlankTile;
 
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimS16ImageData.h b/Utilities/otbossim/include/ossim/imaging/ossimS16ImageData.h
index 60e62340b557ab6a008fcb4f4251373ed6162b89..27f1c5dca586476c355b5d0d6e27360821a59213 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimS16ImageData.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimS16ImageData.h
@@ -13,12 +13,13 @@
 // signed short data.
 //
 //*************************************************************************
-// $Id: ossimS16ImageData.h 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimS16ImageData.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimS16ImageData_HEADER
 #define ossimS16ImageData_HEADER
 
 #include <ossim/imaging/ossimImageData.h>
+#include <ossim/imaging/ossimNormalizedS16RemapTable.h>
 
 class OSSIMDLLEXPORT ossimS16ImageData : public ossimImageData
 {
@@ -33,7 +34,6 @@ public:
 
    ossimS16ImageData(const ossimS16ImageData &rhs);
    
-   virtual ~ossimS16ImageData();
 
    /*!
     * Perform object duplication.
@@ -169,13 +169,12 @@ public:
    virtual void copyNormalizedBufferToTile(ossim_uint32 band,
                                            float* buf);
 protected:
+   virtual ~ossimS16ImageData();
    ossimS16ImageData();
 
 private:
 
-   // Disallow from use...
-   const ossimS16ImageData& operator =(const ossimS16ImageData &rhs)
-                                     {return *this;}
+   static const ossimNormalizedS16RemapTable theRemapTable;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimSFIMFusion.h b/Utilities/otbossim/include/ossim/imaging/ossimSFIMFusion.h
index bb7a49442c05ce63ea6d6fae680d177a38eb1e72..5df3a78e2e5c4eccb3afa4c63d30af5765d47053 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimSFIMFusion.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimSFIMFusion.h
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimSFIMFusion.h 13371 2008-08-02 13:42:42Z gpotts $
+//  $Id: ossimSFIMFusion.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimSFIMFusion_HEADER
 #define ossimSFIMFusion_HEADER
 #include <ossim/imaging/ossimFusionCombiner.h>
@@ -33,7 +33,6 @@ class OSSIM_DLL ossimSFIMFusion : public ossimFusionCombiner,
 {
 public:
    ossimSFIMFusion();
-   virtual ~ossimSFIMFusion();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
    virtual void initialize();
@@ -60,6 +59,7 @@ public:
                           const char* prefix=0);
    
 protected:
+   virtual ~ossimSFIMFusion();
    void setFilters();
    bool computeRegression(ossim_float64& slopeResult,
                           const ossimIpt& origin,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimScalarRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimScalarRemapper.h
index d77f38b11276fbb1a12602dc1c3e5723584b8d86..f03f9faa83e03610f65593e83c7a294b858388c9 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimScalarRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimScalarRemapper.h
@@ -11,7 +11,7 @@
 // This class is used to remap image data from one scalar type to another.
 //
 //*******************************************************************
-//  $Id: ossimScalarRemapper.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimScalarRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimScalarRemapper_HEADER
 #define ossimScalarRemapper_HEADER
 
@@ -24,8 +24,6 @@ public:
    ossimScalarRemapper(ossimImageSource* inputSource,
                        ossimScalarType outputScalarType);
 
-   virtual ~ossimScalarRemapper();
-
    virtual void initialize();
 
    virtual ossimString getLongName()  const;
@@ -85,7 +83,8 @@ public:
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
-private:
+protected:
+   virtual ~ossimScalarRemapper();
 
    /**
     *  Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimScaleFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimScaleFilter.h
index 6947ceccd1133bdc232f48c1830d76154c8b130d..788cbce7e4ef114c24b2986796a5726462b0bf29 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimScaleFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimScaleFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimScaleFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimScaleFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimScaleFilter_HEADER
 #define ossimScaleFilter_HEADER
 #include <vector>
@@ -44,14 +44,13 @@ public:
    ossimScaleFilter();
    ossimScaleFilter(ossimImageSource* inputSource,
                     const ossimDpt& scaleFactor);
-   virtual ~ossimScaleFilter();
    
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                    ossim_uint32 resLevel=0);
    
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const;
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix);
+
+   virtual ossimImageGeometry* getImageGeometry();
    virtual void initialize();
    virtual void getDecimationFactor(ossim_uint32 resLevel,
                                     ossimDpt& result)const
@@ -95,32 +94,32 @@ public:
    void setMinifyFilterType(ossimScaleFilterType filterType)
       {
          setFilterType(filterType,
-                       theMagnifyFilterType);
+                       m_MagnifyFilterType);
       }
    void setMagnifyFilterType(ossimScaleFilterType filterType)
       {
-         setFilterType(theMinifyFilterType,filterType);
+         setFilterType(m_MinifyFilterType,filterType);
       }
    ossimString getMinifyFilterTypeAsString()const
       {
-         return getFilterTypeAsString(theMinifyFilterType);
+         return getFilterTypeAsString(m_MinifyFilterType);
       }
    ossimString getMagnifyFilterTypeAsString()const
       {
-         return getFilterTypeAsString(theMagnifyFilterType);
+         return getFilterTypeAsString(m_MagnifyFilterType);
       }
    void setScaleFactor(const ossimDpt& scale);
    void setBlurFactor(ossim_float64 blur)
       {
-         theBlurFactor = blur;
+         m_BlurFactor = blur;
       }
    ossim_float64 getBlurFactor()const
       {
-         return theBlurFactor;
+         return m_BlurFactor;
       }
    const ossimDpt& getScaleFactor()const
       {
-         return theScaleFactor;
+         return m_ScaleFactor;
       }
    /*!
     * Saves the state of this object.
@@ -133,20 +132,26 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
    
 protected:
-   void allocate();
-   
-   ossimRefPtr<ossimImageData> theBlankTile;
-   ossimRefPtr<ossimImageData> theTile;
-   ossimFilter*                theMinifyFilter;
-   ossimFilter*                theMagnifyFilter;
-   ossimScaleFilterType        theMinifyFilterType;
-   ossimScaleFilterType        theMagnifyFilterType;
-   ossimDpt                    theScaleFactor;
-   ossimDpt                    theInverseScaleFactor;
-   ossimIpt                    theTileSize;
-   ossimIrect                  theInputRect;
-   ossim_float64               theBlurFactor;
+   virtual ~ossimScaleFilter();
+  void allocate();
+
+   //! If this object is maintaining an ossimImageGeometry, this method needs to be called after 
+   //! a scale change so that the geometry's projection is modified accordingly.
+   void updateGeometry();
    
+   ossimRefPtr<ossimImageData> m_BlankTile;
+   ossimRefPtr<ossimImageData> m_Tile;
+   ossimFilter*                m_MinifyFilter;
+   ossimFilter*                m_MagnifyFilter;
+   ossimScaleFilterType        m_MinifyFilterType;
+   ossimScaleFilterType        m_MagnifyFilterType;
+   ossimDpt                    m_ScaleFactor;
+   ossimDpt                    m_InverseScaleFactor;
+   ossimIpt                    m_TileSize;
+   ossimIrect                  m_InputRect;
+   ossim_float64               m_BlurFactor;
+   ossimRefPtr<ossimImageGeometry> m_ScaledGeometry; //!< The input image geometry, altered by the scale
+
    template <class T>
    void runFilterTemplate(T dummy,
                           const ossimIrect& imageRect,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimSrtmTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimSrtmTileSource.h
index 4765636cf70a3120d58acb496519944423124562..97df74d61a543642a19370ae4186511643373e2a 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimSrtmTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimSrtmTileSource.h
@@ -12,7 +12,7 @@
 // Image handler class for a Shuttle Radar Topography Mission (SRTM) file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimSrtmTileSource.h 9262 2006-07-14 20:49:28Z dburken $
+// $Id: ossimSrtmTileSource.h 15800 2009-10-23 20:03:45Z gpotts $
 #ifndef ossimSrtmTileSource_HEADER
 #define ossimSrtmTileSource_HEADER
 
@@ -25,8 +25,6 @@ class OSSIMDLLEXPORT ossimSrtmTileSource : public ossimGeneralRasterTileSource
 public:
    ossimSrtmTileSource();
 
-   virtual ~ossimSrtmTileSource();
-
    virtual ossimString getShortName() const;
    
    virtual ossimString getLongName() const;
@@ -35,14 +33,9 @@ public:
 
    virtual bool open();
    
-   /**
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *
-    *  @return true if geometry info is present, false if not.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   //! Returns the image geometry object associated with this tile source or NULL if non defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   virtual ossimImageGeometry* getInternalImageGeometry();
 
    /**
     * Method to save the state of an object to a keyword list.
@@ -60,8 +53,9 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix = NULL);
 
-private:
-   ossimSrtmSupportData theSrtmSupportData;
+protected:
+   virtual ~ossimSrtmTileSource();
+   ossimSrtmSupportData m_SrtmSupportData;
    
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimSubImageTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimSubImageTileSource.h
index ba0d8d3b53efc678c6ef7b5313f819c7691c4d72..cb5b949eb0863d6bacbd7950c64478d0d964f6bb 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimSubImageTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimSubImageTileSource.h
@@ -14,7 +14,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimSubImageTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimSubImageTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimSubImageTileSource_HEADER
 #define ossimSubImageTileSource_HEADER
@@ -49,7 +49,6 @@ public:
    ossimSubImageTileSource(ossimImageSource* inputSource,
                            const ossimIpt&   offset);
 
-   virtual ~ossimSubImageTileSource();
    /*!
     * Permits setting the image's offset relative to the full image space.
     */
@@ -81,6 +80,8 @@ public:
                           const char* prefix=0)const;
 
 private:
+   virtual ~ossimSubImageTileSource();
+   
    ossimIpt                    theSubImageOffset;
    ossimRefPtr<ossimImageData> theTile;
    TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTableRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimTableRemapper.h
index 0fc25bee6905ec77121b682263152b6286826f74..52fa1f74c8152821d2a0cf03a4050eea71c2188d 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTableRemapper.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTableRemapper.h
@@ -16,7 +16,7 @@
 // uses a normalized remap table (more scalar independent).
 //
 //*************************************************************************
-// $Id: ossimTableRemapper.h 13473 2008-08-22 14:19:49Z gpotts $
+// $Id: ossimTableRemapper.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimTableRemapper_HEADER
 #define ossimTableRemapper_HEADER
 
@@ -35,9 +35,6 @@ public:
    /** default constructor */
    ossimTableRemapper();
 
-   /** virtual destructor */
-   virtual ~ossimTableRemapper();
-
    virtual ossimScalarType getOutputScalarType() const;
     
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tile_rect,
@@ -63,6 +60,8 @@ public:
    friend ostream& operator << (ostream& os,  const ossimTableRemapper& tr);
 
 protected:
+   /** virtual destructor */
+   virtual ~ossimTableRemapper();
 
    /**
     * Method:  setTable
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTiffOverviewBuilder.h b/Utilities/otbossim/include/ossim/imaging/ossimTiffOverviewBuilder.h
index aec69507e413eef19c9c39c7f1413841deff715e..a78eba94e29a119224953f2bb2ad92d06b0fb915 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTiffOverviewBuilder.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTiffOverviewBuilder.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
@@ -9,11 +11,13 @@
 // Contains class declaration for TiffOverviewBuilder.
 //
 //*******************************************************************
-//  $Id: ossimTiffOverviewBuilder.h 11699 2007-09-10 15:23:26Z gpotts $
+//  $Id: ossimTiffOverviewBuilder.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimTiffOverviewBuilder_HEADER
 #define ossimTiffOverviewBuilder_HEADER
 
+#include <vector>
+
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimFilename.h>
 
@@ -121,13 +125,6 @@ public:
     */
    virtual const ossimObject* getObject() const;
 
-   /**
-    * @return The output filename.  This will be derived from the image
-    * handlers filename unless the method buildOverview has been called which
-    * takes a filename.
-    */
-   ossimFilename getOutputFile() const;
-
    /**
     * @return true if input is an image handler.
     */
@@ -140,13 +137,9 @@ public:
     *
     * @param imageSource The input to the builder.
     *
-    * @param bool youOwnItFlag If true this obect will delete imageSource
-    * at destruction.
-    *
     * @return True on successful initializion, false on error.
     */
-   virtual bool setInputSource(ossimImageHandler* imageSource,
-                               bool youOwnItFlag);
+   virtual bool setInputSource(ossimImageHandler* imageSource);
    
    /**
     * @brief Sets the output filename.
@@ -155,6 +148,20 @@ public:
     */
    virtual void  setOutputFile(const ossimFilename& file);
 
+   /**
+    * @brief Gets the output file name. (pure virtual)
+    *
+    * @return The output file name or ossimFilename::NIL if it was not set
+    * yet and the image handle has not been initialized.
+    *
+    * @note This is non-const as a call to this may force initialization of
+    * overview builder output file name if the it was not set already.
+    *
+    * @note This will return ossimFilename::NIL unless one of was called,
+    * setInputSource or setOutputFile.
+    */
+   virtual ossimFilename getOutputFile() const;
+
    void setOutputTileSize(const ossimIpt& tileSize);
 
    /**
@@ -205,34 +212,20 @@ public:
   
 private:
 
-   /**
-    * @brief Method to initialize output file name from image handler.
-    * @return true on success, false on error.
-    */
-   bool initializeOutputFilenamFromHandler();
-   
-   /**
-    *  Returns the number of reduced resolution data sets to get the smallest
-    *  dimension >= 32 && < 64.
-    */
-  ossim_int32 getNumberOfSets() const;
-
    /**
     *  Copy the full resolution image data to the output tif image.
     */
   bool writeR0(TIFF* tif);
 
    /**
-    *  Write reduced resolution data set to the tif file.  "rrds_level" must
-    *  be greater than 1 for this method as it uses subsequent rrds_levels
-    *  from the tif file.
+    *  Write reduced resolution data set to the tif file.
     */
    bool writeRn(ossimImageHandler* imageHandler,
                 TIFF* tif,
-                ossim_uint32 rrdsLevel);
+                ossim_uint32 resLevel);
    
    /**
-    *  Set the tiff tags for the appropriate rrds_level.  Level zero is the
+    *  Set the tiff tags for the appropriate resLevel.  Level zero is the
     *  full resolution image.
     *
     *  @param tif Pointer to the tif file.
@@ -241,33 +234,34 @@ private:
     */
    bool setTags(TIFF* tif,
                 const ossimIrect& outputRect,
-                ossim_int32 rrds_level) const;
+                ossim_int32 resLevel) const;
 
    TIFF* openTiff(const ossimString& filename,
                   const ossimString& openMode);
+
    void closeTiff(TIFF* tif);
+
    // Disallow these...
    ossimTiffOverviewBuilder(const ossimTiffOverviewBuilder& source);
    ossimTiffOverviewBuilder& operator=(const ossimTiffOverviewBuilder& rhs); 
 
-   ossimImageHandler* theImageHandler;
-   bool               theOwnsImageHandlerFlag;
-   ossimFilename      theOutputFile;
-   ossimFilename      theOutputFileTmp;
-   ossim_uint8*       theNullDataBuffer;
-   ossim_int32        theBytesPerPixel;
-   ossim_int32        theBitsPerSample;
-   ossim_int32        theTileWidth;
-   ossim_int32        theTileHeight;
-   ossim_int32        theTileSizeInBytes;
-   ossim_int32        theSampleFormat;
-   ossim_int32        theCurrentTiffDir;
-   ossim_uint16       theTiffCompressType;
-   ossim_int32        theJpegCompressQuality;
+   ossimRefPtr<ossimImageHandler>                 theImageHandler;
+   ossimFilename                                  theOutputFile;
+   std::vector<ossim_uint8>                       theNullDataBuffer;
+   ossim_int32                                    theBytesPerPixel;
+   ossim_int32                                    theBitsPerSample;
+   ossim_int32                                    theTileWidth;
+   ossim_int32                                    theTileHeight;
+   ossim_int32                                    theTileSizeInBytes;
+   ossim_int32                                    theSampleFormat;
+   ossim_int32                                    theCurrentTiffDir;
+   ossim_uint16                                   theTiffCompressType;
+   ossim_int32                                    theJpegCompressQuality;
    ossimFilterResampler::ossimFilterResamplerType theResampleType;
-   vector<double>      theNullPixelValues;
-   bool               theCopyAllFlag;
-   bool               theOutputTileSizeSetFlag;
+   std::vector<double>                            theNullPixelValues;
+   bool                                           theCopyAllFlag;
+   bool                                           theOutputTileSizeSetFlag;
+
 TYPE_DATA   
 };
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h
index 77a2b12d2c5c6380fa82975e29f905ab53fc1226..44a9dec9c84fa27cd7f4a723f18184ebd0b17da4 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //          Frank Warmerdam (warmerdam@pobox.com)
@@ -11,7 +13,7 @@
 // ossimTiffTileSource  is derived from ImageHandler which is derived from
 // TileSource.
 //*******************************************************************
-//  $Id: ossimTiffTileSource.h 11959 2007-10-31 19:22:56Z gpotts $
+//  $Id: ossimTiffTileSource.h 15825 2009-10-27 15:31:44Z dburken $
 
 #ifndef ossimTiffTileSource_HEADER
 #define ossimTiffTileSource_HEADER
@@ -39,19 +41,17 @@ public:
    };
 
    ossimTiffTileSource();
-	
-   virtual ~ossimTiffTileSource();
 
    virtual ossimString getLongName()  const;
    virtual ossimString getShortName() const;
 
-   /*!
+   /**
     *  Returns true if the image_file can be opened and is a valid tiff file.
     */
-  virtual bool open(const ossimFilename& image_file);
-  virtual void close();
-
-   /*!
+   virtual bool open(const ossimFilename& image_file);
+   virtual void close();
+   
+   /**
     *  Returns a pointer to a tile given an origin representing the upper left
     *  corner of the tile to grab from the image.
     *  Satisfies pure virtual from TileSource class.
@@ -59,31 +59,45 @@ public:
    virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& rect,
                                                ossim_uint32 resLevel=0);
    
-   /*!
-     *  Returns the number of bands in the image.
-     *  Satisfies pure virtual from ImageHandler class.
-     */
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
+   
+   /**
+    *  Returns the number of bands in the image.
+    *  Satisfies pure virtual from ImageHandler class.
+    */
    virtual ossim_uint32 getNumberOfInputBands() const;
    virtual ossim_uint32 getNumberOfOutputBands () const;
    
-   /*!
-     *  Returns the number of lines in the image.
-     *  Satisfies pure virtual from ImageHandler class.
-     */
-   virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level = 0) const;
-
-   /*!
+   /**
+    *  Returns the number of lines in the image.
+    *  Satisfies pure virtual from ImageHandler class.
+    */
+   virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel = 0) const;
+   
+   /**
     *  Returns the number of samples in the image.
     *  Satisfies pure virtual from ImageHandler class.
     */
-   virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level = 0) const;
+   virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel = 0) const;
 
-   /*!
+   /**
     *  Returns the number of image file directories in the tiff image.
     */
    virtual ossim_uint32 getNumberOfDirectories() const;
    
-   /*!
+   /**
     * Returns the number of reduced resolution data sets (rrds).
     * Notes:
     *
@@ -95,14 +109,14 @@ public:
     */
    virtual ossim_uint32 getNumberOfDecimationLevels() const;
    
-   /*!
+   /**
     * Method to save the state of an object to a keyword list.
     * Return true if ok or false on error.
     */
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=0)const;
    
-   /*!
+   /**
     * Method to the load (recreate) the state of an object from a keyword
     * list.  Return true if ok or false on error.
     */
@@ -111,22 +125,22 @@ public:
 
    virtual bool isOpen()const;
 
-   /*!
+   /**
     * Returns the output pixel type of the tile source.
     */
    virtual ossimScalarType getOutputScalarType() const;
 
-   /*!
+   /**
     * Returns the width of the output tile.
     */
    virtual ossim_uint32 getTileWidth() const;
    
-   /*!
+   /**
     * Returns the height of the output tile.
     */
    virtual ossim_uint32 getTileHeight() const;
 
-   /*!
+   /**
     *  Returns true if the first directory of the tiff image did not have
     *  the reduced resolution file type set.
     */
@@ -135,15 +149,9 @@ public:
    virtual double getMinPixelValue(ossim_uint32 band=0)const;
    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
    
-   virtual bool isValidRLevel(ossim_uint32 reduced_res_level) const;
-   
-   /*!
-    * Returns the highest available reduced resolution data sets (rrds).
-    * Note:  zero based
-    */
-   ossim_uint32 getHighestReducedResSet() const;
+   virtual bool isValidRLevel(ossim_uint32 resLevel) const;
 
-   /*!
+   /**
     * @return The tile width of the image or 0 if the image is not tiled.
     * Note: this is not the same as the ossimImageSource::getTileWidth which
     * returns the output tile width, which can be different than the
@@ -151,7 +159,7 @@ public:
     */
    virtual ossim_uint32 getImageTileWidth() const;
 
-   /*!
+   /**
     * @return The tile width of the image or 0 if the image is not tiled.
     * Note: this is not the same as the ossimImageSource::getTileHeight which
     * returns the output tile width which can be different than the internal
@@ -169,8 +177,25 @@ public:
    
    virtual std::ostream& print(std::ostream& os) const;
 
+   TIFF* tiffPtr()
+   {
+      return theTiffPtr;
+   }
+#if 0
+   /**
+    * @brief Method to get the image geometry object associated with this
+    * image.
+    *
+    * The geometry contains full-to-local image transform as well as
+    * projection (image-to-world).
+    *
+    * @return ossimImageGeometry* or null if not defined.
+    */
+   virtual ossimImageGeometry* getImageGeometry();
+#endif   
 protected:
-   /*!
+   virtual ~ossimTiffTileSource();
+   /**
     *  Returns true if no errors initializing object.
     *
     *  Notes:
@@ -180,16 +205,19 @@ protected:
     *    between constructor and public open method.
     */
    bool open();
+
+   // Must be protected for derived ossimTerraSarTiffReader.
+   TIFF* theTiffPtr; 
    
 private:
 
-   /*!
+   /**
     *  Adjust point to even tile boundary.  Assumes 0,0 origin.
     *  Shifts in the upper left direction.
     */
    void adjustToStartOfTile(ossimIpt& pt) const;
 
-   /*!
+   /**
     *  If the tiff source has R0 then this returns the current tiff directory
     *  that the tiff pointer is pointing to; else, it returns the current
     *  directory + 1.
@@ -201,22 +229,29 @@ private:
    bool allocateBuffer();
    
    bool loadTile(const ossimIrect& tile_rect,
-                 const ossimIrect& clip_rect);
+                 const ossimIrect& clip_rect,
+                 ossimImageData* result);
    
    bool loadFromRgbaU8Tile(const ossimIrect& tile_rect,
-                           const ossimIrect& clip_rect);
+                           const ossimIrect& clip_rect,
+                           ossimImageData* result);
    
    bool loadFromRgbaU8Strip(const ossimIrect& tile_rect,
-                            const ossimIrect& clip_rect);
-
+                            const ossimIrect& clip_rect,
+                            ossimImageData* result);
+   
    bool loadFromRgbaU8aStrip(const ossimIrect& tile_rect,
-                             const ossimIrect& clip_rect);
+                             const ossimIrect& clip_rect,
+                             ossimImageData* result);
+   
+   bool loadFromScanLine(const ossimIrect& clip_rect,
+                         ossimImageData* result);
+   
+   bool loadFromTile(const ossimIrect& clip_rect,
+                     ossimImageData* result);
    
-   bool loadFromScanLine(const ossimIrect& clip_rect);
-
-   bool loadFromTile(const ossimIrect& clip_rect);
-
    void setReadMethod();
+   
    virtual void initializeBuffers();
 
    /**
@@ -240,7 +275,8 @@ private:
    ossim_uint32         theBufferSize;
    ossimIrect           theBufferRect;
    ossim_uint32         theBufferRLevel;
-   TIFF*                theTiffPtr;
+   ossim_uint32         theCurrentTileWidth;
+   ossim_uint32         theCurrentTileHeight;
 
    ossim_uint16         theSamplesPerPixel;
    ossim_uint16         theBitsPerSample;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTiffWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimTiffWriter.h
index cfe58893367980586296e2f426f74ae5d6bd0820..800c9654a4995a67eec610035e53f526168a5c9d 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTiffWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTiffWriter.h
@@ -9,7 +9,7 @@
 // Contains class declaration for TiffWriter.
 //
 //*******************************************************************
-//  $Id: ossimTiffWriter.h 11683 2007-09-07 17:25:30Z gpotts $
+//  $Id: ossimTiffWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimTiffWriter_HEADER
 #define ossimTiffWriter_HEADER
 
@@ -28,9 +28,7 @@ class OSSIMDLLEXPORT ossimTiffWriter : public ossimImageFileWriter
 public:
 
    ossimTiffWriter();
-   
-   virtual ~ossimTiffWriter();
-   
+      
    enum UnitType
    {
       UNDEFINED                    =     0,
@@ -139,6 +137,7 @@ public:
    bool hasImageType(const ossimString& imageType) const;
    
 protected:
+   virtual ~ossimTiffWriter();
    
    virtual bool writeFile();
 
@@ -211,7 +210,7 @@ protected:
    bool                    theColorLutFlag;
    ossimRefPtr<ossimMapProjectionInfo> theProjectionInfo;
    ossimIpt                theOutputTileSize;
-   ossimNBandLutDataObject theColorLut;
+   ossimRefPtr<ossimNBandLutDataObject> theColorLut;
    ossimFilename           theLutFilename;
    bool                    theForceBigTiffFlag;
    bool                    theBigTiffFlag;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTileCache.h b/Utilities/otbossim/include/ossim/imaging/ossimTileCache.h
index 3b68247c013833233fd5cd2a0c667ab73c12de0b..7e365e9600581568c58f88455e53b09fa75d2529 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTileCache.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTileCache.h
@@ -9,7 +9,7 @@
 // Description: This file contains the cache algorithm
 //
 //***********************************
-// $Id: ossimTileCache.h 14370 2009-04-20 21:40:03Z dburken $
+// $Id: ossimTileCache.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef DataCache_HEADER
 #define DataCache_HEADER
@@ -20,9 +20,9 @@ using namespace std;
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimDpt3d.h>
-
-class ossimDataObject;
-class ossimTileCache
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/base/ossimDataObject.h>
+class OSSIM_DLL ossimTileCache
 {
 public:
    
@@ -84,7 +84,7 @@ protected:
            theOrigin(origin),
            theResLevel(resLevel)
          {}
-      ossimDataObject*    theCachedTile;
+      ossimRefPtr<ossimDataObject>    theCachedTile;
       ossimDpt3d         theOrigin;
       unsigned long      theResLevel;
    };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h
index b0a7e9539863cc6c355fef029a3d9cda707e837e..2913cf54c046593e09fba5b65c1689c4b4b60b57 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h
@@ -18,6 +18,7 @@
 
 #include <ossim/imaging/ossimGeneralRasterTileSource.h>
 #include <ossim/base/ossimDate.h>
+#include <ossim/base/ossimRefPtr.h>
 
 class ossimFfL7;
 
@@ -29,7 +30,7 @@ public:
    ossimTileMapTileSource(const ossimKeywordlist& kwl,
                            const char* prefix=0);
 
-   virtual ~ossimTileMapTileSource();
+
 
    virtual ossimString getShortName() const;
 
@@ -52,17 +53,10 @@ public:
 
    ossimFilename getBandFilename(ossim_uint32 idx)const;
 
-   bool isPan()const;
-   bool isVir()const;
-   bool isTm()const;
+   //! Returns the image geometry object associated with this tile source or NULL if non defined.
+   //! The geometry contains full-to-local image transform as well as projection (image-to-world)
+   virtual ossimImageGeometry* getImageGeometry();
 
-  /*!
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
 
 
    virtual bool loadState(const ossimKeywordlist& kwl,
@@ -81,11 +75,14 @@ public:
     */
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 
+protected:
+  virtual ~ossimTileMapTileSource();
+
 private:
 
    void openHeader(const ossimFilename& file);
 
-   ossimFfL7* theFfHdr;
+   ossimRefPtr<ossimFfL7> theFfHdr;
 
    TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTilePatch.h b/Utilities/otbossim/include/ossim/imaging/ossimTilePatch.h
index 6874e9f1b0ac7cbcd9e10012eb99e2ddeedf949c..4f6203e531f35fd6a0f7a2ee58f72aeb8d627f1c 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTilePatch.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTilePatch.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimTilePatch.h 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimTilePatch.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimTilePatch_HEADER
 #define ossimTilePatch_HEADER
@@ -33,7 +33,6 @@ public:
                   long numberOfComponents = 1,
                   long width=128,
                   long height=128);
-   virtual ~ossimTilePatch();
    
    /*!
     * return the tile boundary aligned rectangle for this
@@ -112,6 +111,8 @@ public:
    void convolve(ossimDiscreteConvolutionKernel* kernel);
    
 protected:
+   virtual ~ossimTilePatch();
+   
    ossimRefPtr<ossimImageData>         thePatchData;
    static ossimDiscreteNearestNeighbor nearestNeighborKernel;
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTopographicCorrectionFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimTopographicCorrectionFilter.h
index 26cf39600e3b24480311831fdec4fec91a59f559..f137139644d068189ca7daee6a171ccb63b0f973 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTopographicCorrectionFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTopographicCorrectionFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimTopographicCorrectionFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimTopographicCorrectionFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimTopographicCorrectionFilter_HEADER
 #define ossimTopographicCorrectionFilter_HEADER
 #include <ossim/imaging/ossimImageCombiner.h>
@@ -66,8 +66,6 @@ public:
    ossimTopographicCorrectionFilter(ossimImageSource* colorSource,
                                     ossimImageSource* elevSource);
    
-   virtual ~ossimTopographicCorrectionFilter();
-      
    ossimRefPtr<ossimImageData> getTile(const  ossimIrect& tileRect,
                                        ossim_uint32 resLevel=0);
    
@@ -146,6 +144,7 @@ public:
    void computeLightDirection();
 
 protected:
+   virtual ~ossimTopographicCorrectionFilter();
    virtual void allocate();
    
    /*!
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTrimFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimTrimFilter.h
index b70a79d3e8433c178d5ecb073789f13044fd5685..2cf239f4268ee4300754c8dd24d23fc2b7336995 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTrimFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTrimFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimTrimFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimTrimFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimTrimFilter_HEADER
 #define ossimTrimFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -18,7 +18,6 @@ class ossimTrimFilter : public ossimImageSourceFilter
 {
 public:
    ossimTrimFilter();
-   virtual ~ossimTrimFilter();
 
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const;
    virtual void getValidImageVertices(vector<ossimIpt>& validVertices,
@@ -58,6 +57,7 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 
 protected:
+   virtual ~ossimTrimFilter();
    double theLeftPercent;
    double theRightPercent;
    double theTopPercent;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimU11ImageData.h b/Utilities/otbossim/include/ossim/imaging/ossimU11ImageData.h
index 7ee39577ba7567fdf0c6befdc3b8a77ab5a96771..7574e58af5ac429e15adfb05b2bed7c40ec9cd25 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimU11ImageData.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimU11ImageData.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2001 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -20,7 +19,7 @@
 //        If you want anything else use the less efficient ossimImageData.
 //
 //*************************************************************************
-// $Id: ossimU11ImageData.h 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimU11ImageData.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimU11ImageData_HEADER
 #define ossimU11ImageData_HEADER
@@ -41,7 +40,6 @@ public:
 
    ossimU11ImageData(const ossimU11ImageData &rhs);
    
-   virtual ~ossimU11ImageData();
 
    virtual ossimObject* dup()const;
 
@@ -173,14 +171,11 @@ public:
                                            float* buf);
 
 protected:
+   virtual ~ossimU11ImageData();
    ossimU11ImageData();
 
 private:
 
-   // Disallow from use...
-   const ossimU11ImageData& operator =(const ossimU11ImageData &rhs)
-                                     {return *this;}
-
    static const ossimNormalizedU11RemapTable theRemapTable;
    
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimU16ImageData.h b/Utilities/otbossim/include/ossim/imaging/ossimU16ImageData.h
index 0e515738b81c55c6ddef54ef215766afd0c0d48d..9ee18927f0b11f072673d9ffb4567cdce0e3da62 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimU16ImageData.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimU16ImageData.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2001 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -20,7 +19,7 @@
 //        If you want anything else use the less efficient ossimImageData.
 //
 //*************************************************************************
-// $Id: ossimU16ImageData.h 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimU16ImageData.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimU16ImageData_HEADER
 #define ossimU16ImageData_HEADER
@@ -41,7 +40,6 @@ public:
 
    ossimU16ImageData(const ossimU16ImageData &rhs);
 
-   virtual ~ossimU16ImageData();
 
    /*!
     * Perform object duplication.
@@ -176,15 +174,12 @@ public:
    virtual void copyNormalizedBufferToTile(ossim_uint32 band,
                                            float* buf);
 protected:
+   virtual ~ossimU16ImageData();
    ossimU16ImageData();
 
 
 private:
 
-   // Disallow from use...
-   const ossimU16ImageData& operator =(const ossimU16ImageData &rhs)
-                                     {return *this;}
-
    static const ossimNormalizedU16RemapTable theRemapTable;
    
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimU8ImageData.h b/Utilities/otbossim/include/ossim/imaging/ossimU8ImageData.h
index 4e814abfe864b42ce0009ea6dfcdbe2764add5a3..60570f94db65687c741eade0e445875723563ba5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimU8ImageData.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimU8ImageData.h
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2001 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -20,7 +19,7 @@
 //        If you want anything else use the less efficient ossimImageData.
 //
 //*************************************************************************
-// $Id: ossimU8ImageData.h 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimU8ImageData.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimU8ImageData_HEADER
 #define ossimU8ImageData_HEADER
@@ -43,7 +42,6 @@ public:
       :ossimImageData(rhs)
       {}
 
-   virtual ~ossimU8ImageData();
 
    virtual ossimObject* dup()const;
 
@@ -163,10 +161,10 @@ public:
                                            float* buf);
    
    virtual ossim_float64 getMinNormalizedPix() const { return theRemapTable[1]; }
-   
-private:
+protected:
+   virtual ~ossimU8ImageData();
 
-   const ossimU8ImageData& operator =(const ossimU8ImageData &rhs);
+private:
 
    static const ossimNormalizedU8RemapTable theRemapTable;
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimUsgsDemTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimUsgsDemTileSource.h
index a3bfe6b00cf72cea0a15a2059a4650cd06acf804..24938914260eda365474af306106ade20b736726 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimUsgsDemTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimUsgsDemTileSource.h
@@ -1,9 +1,8 @@
 //*******************************************************************
-// Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  See top level LICENSE.txt file.
-//
-// Author: David Burken
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Description:
 //
@@ -12,12 +11,11 @@
 // is intended to be an image handler for USGS dem files.
 //
 //********************************************************************
-// $Id: ossimUsgsDemTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimUsgsDemTileSource.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimUsgsDemTileSource_HEADER
 #define ossimUsgsDemTileSource_HEADER
 
-  // #include <fstream>
 #include <ossim/imaging/ossimImageHandler.h>
 
 class ossimImageData;
@@ -29,11 +27,10 @@ public:
       
    ossimUsgsDemTileSource();
    
-   virtual ~ossimUsgsDemTileSource();
 
    virtual ossimString getShortName() const;
    virtual ossimString getLongName()  const;
-   virtual ossimString className()    const;
+   virtual ossimString getClassName() const;
 
    /**
     *  Returns true if the "theImageFile can be opened.
@@ -48,6 +45,20 @@ public:
 
    virtual ossimRefPtr<ossimImageData> getTile(const  ossimIrect& tile_rect,
                                                ossim_uint32 resLevel=0);
+
+   /**
+    * Method to get a tile.   
+    *
+    * @param result The tile to stuff.  Note The requested rectangle in full
+    * image space and bands should be set in the result tile prior to
+    * passing.  It will be an error if:
+    * result.getNumberOfBands() != this->getNumberOfOutputBands()
+    *
+    * @return true on success false on error.  If return is false, result
+    *  is undefined so caller should handle appropriately with makeBlank or
+    * whatever.
+    */
+   virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
    
    /**
     *  Returns the number of bands in the image.
@@ -99,12 +110,15 @@ public:
                           const char* prefix=0);
    
    /**
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
+    * @brief Initializes theGeometry from USGS DEM header.
+    *
+    * This is called by base ossimImageHandler::getImageGeometry if
+    * theGeometry is not set.  External callers should not go through this
+    * method but call "getImageGeometry" instead for efficiency reasons.
+    * 
+    * @return Pointer to geometry or null if header not found.
     */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   virtual ossimImageGeometry* getInternalImageGeometry();
    
    /**
     * Returns the output pixel type of the tile source.
@@ -139,7 +153,8 @@ public:
 
    virtual bool isOpen()const;
    
-private:
+protected:
+   virtual ~ossimUsgsDemTileSource();
    // Disallow operator= and copy constrution...
    const ossimUsgsDemTileSource& operator=(const  ossimUsgsDemTileSource& rhs);
    ossimUsgsDemTileSource(const ossimUsgsDemTileSource&);
@@ -149,7 +164,8 @@ private:
     */
    template <class T> bool fillBuffer(T, // dummy template variable
                                       const ossimIrect& tile_rect,
-                                      const ossimIrect& clip_rect);
+                                      const ossimIrect& clip_rect,
+                                      ossimImageData* tile);
 
    void gatherStatistics();
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimValueAssignImageSourceFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimValueAssignImageSourceFilter.h
index 99cdf1abb6a83484d15f3b51a95813b15a1ff61b..40dda54aae4088cd097aee3283782f7db2b7a3a5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimValueAssignImageSourceFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimValueAssignImageSourceFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimValueAssignImageSourceFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimValueAssignImageSourceFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimValueAssignImageSourceFilter_HEADER
 #define ossimValueAssignImageSourceFilter_HEADER
 
@@ -49,7 +49,6 @@ public:
    };
    
    ossimValueAssignImageSourceFilter(ossimObject* owner=NULL);
-   virtual ~ossimValueAssignImageSourceFilter();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
                                    ossim_uint32 resLevel=0);
 
@@ -74,6 +73,7 @@ public:
                           const char* prefix=NULL);
    
 protected:
+   virtual ~ossimValueAssignImageSourceFilter();
 
    /**
     * Called on first getTile, will initialize all data needed.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVectorRenderer.h b/Utilities/otbossim/include/ossim/imaging/ossimVectorRenderer.h
index 4f71cfafaab641b583964b3356e7ef920dd215dd..6749ab67411a2a3204d6b090125214954cb0dd01 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVectorRenderer.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVectorRenderer.h
@@ -10,7 +10,7 @@
 // the "rasterizeVectorData" data method.
 //               
 //*******************************************************************
-// $Id: ossimVectorRenderer.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimVectorRenderer.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimVectorRenderer_HEADER
 #define ossimVectorRenderer_HEADER
 
@@ -27,7 +27,6 @@ public:
    ossimVectorRenderer();
    ossimVectorRenderer(ossimImageSource* inputSource,
                        ossimImageViewTransform *transform = NULL);
-   virtual ~ossimVectorRenderer();
       
    /**
     * Renders the vector data to a data object.  The area which is
@@ -89,6 +88,7 @@ public:
    virtual ossim_int32 getNumberOfObjects() const;
 
 protected:
+   virtual ~ossimVectorRenderer();
    
    /**
     * Sets the bounding rectangle of current vector data loaded.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVertexExtractor.h b/Utilities/otbossim/include/ossim/imaging/ossimVertexExtractor.h
index 412d1e6f75483982f76286bf139f797cf8d19fa6..f7479b08f6a6eec908eb3c753ce212f5a1c291d2 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVertexExtractor.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVertexExtractor.h
@@ -5,7 +5,7 @@
 // Author: David Burken (dburken@imagelinks.com)
 //
 //*************************************************************************
-// $Id: ossimVertexExtractor.h 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimVertexExtractor.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimVertexExtractor_HEADER
 #define ossimVertexExtractor_HEADER
@@ -34,7 +34,6 @@ class OSSIMDLLEXPORT ossimVertexExtractor : public ossimOutputSource,
 public:
    ossimVertexExtractor(ossimImageSource* inputSource=NULL);
 
-   virtual ~ossimVertexExtractor();
 
   virtual ossimObject* getObject()
   {
@@ -112,7 +111,8 @@ public:
 
    vector<ossimIpt> getVertices() { return theVertice; }
    
-private:
+protected:
+   virtual ~ossimVertexExtractor();
    /*!
     *  Walks each line from left and right side detecting first non null pixel.
     *  Returns true on success, false on error.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h
index fa87f498e6887864708474a0787bfb37f137c931..074f01ddaf75ae35a9511db3f9a5d58e5a4456f6 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 // 
 //**************************************************************************
-// $Id: ossimVpfAnnotationCoverageInfo.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimVpfAnnotationCoverageInfo.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimVpfAnnotationCoverageInfo_HEADER
 #define ossimVpfAnnotationCoverageInfo_HEADER
 #include <ossim/imaging/ossimVpfAnnotationFeatureInfo.h>
@@ -33,7 +33,7 @@ public:
   void getEnabledFeatures(std::vector<ossimVpfAnnotationFeatureInfo*>& result);
   void getAllFeatures(std::vector<ossimVpfAnnotationFeatureInfo*>& result);
 
-  void transform(ossimProjection* proj);
+  void transform(ossimImageGeometry* geom);
   ossimIrect getBoundingProjectedRect()const;
   void buildCoverage();
   void buildCoverage(const ossimString& feature);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h
index 9bfd583eac89423174a909a5d963b7deccd8104a..4f9bf0cfa943a31c6dfec24463b689d9f63aa5ae 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimVpfAnnotationFeatureInfo.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimVpfAnnotationFeatureInfo.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimVpfAnnotationFeatureInfo_HEADER
 #define ossimVpfAnnotationFeatureInfo_HEADER
 #include <ossim/base/ossimRgbVector.h>
@@ -147,7 +147,7 @@ public:
   }
   void setDrawingFeaturesToAnnotation();
   ossimIrect getBoundingProjectedRect()const;
-  void transform(ossimProjection* proj);
+  void transform(ossimImageGeometry* proj);
   void buildFeature();
   void deleteAllObjects();
   void drawAnnotations(ossimRgbImage* tile);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationLibraryInfo.h b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationLibraryInfo.h
index cfef14dee31e7833fb3665f3d409f62bab9b91ab..92690fbc9078e7366ed189ece05cecbb4f88c497 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationLibraryInfo.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationLibraryInfo.h
@@ -30,7 +30,7 @@ public:
 
   ossimIrect getBoundingProjectedRect()const;
   
-  void transform(ossimProjection* proj);
+  void transform(ossimImageGeometry* geom);
   void buildLibrary();
   void buildLibrary(const ossimString& coverageName, const ossimString& feature);
   void deleteAllCoverage();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationSource.h b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationSource.h
index b9da2c730f22298dffd67c86ab968339c90089d4..dc84b851acbd6954f5850b37cfcb0e76a7309d78 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVpfAnnotationSource.h
@@ -11,7 +11,6 @@ class ossimVpfAnnotationSource : public ossimGeoAnnotationSource
 {
 public:
    ossimVpfAnnotationSource();
-   virtual ~ossimVpfAnnotationSource();
    virtual bool open();
    virtual bool open(const ossimFilename& file);
    virtual bool isOpen()const;
@@ -20,7 +19,7 @@ public:
    virtual ossimFilename getFilename()const;
   virtual void computeBoundingRect();
 
-   virtual void transformObjects(ossimProjection* projection=0);
+   virtual void transformObjects(ossimImageGeometry* geom=0);
 
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=NULL)const;
@@ -33,6 +32,8 @@ public:
   virtual void setAllFeatures(const std::vector<ossimVpfAnnotationFeatureInfo*>& features);
  
 protected:
+   virtual ~ossimVpfAnnotationSource();
+   
    ossimVpfDatabase theDatabase;
    ossimFilename    theFilename;
    std::vector<ossimVpfAnnotationLibraryInfo*> theLibraryInfo;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVpfTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimVpfTileSource.h
index 0f643ed0d02555337bae0b475a2f8d83baa7c46e..f0892290f253cd28d41b509ab2607869c0445727 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimVpfTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimVpfTileSource.h
@@ -7,13 +7,14 @@
 //
 // Author:  Garrett Potts
 //
-// $Id: ossimVpfTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimVpfTileSource.h 15812 2009-10-25 13:09:24Z dburken $
 //----------------------------------------------------------------------------
 #ifndef ossimVpfTileSource_HEADER
 #define ossimVpfTileSource_HEADER
 
 #include <ossim/imaging/ossimVpfAnnotationSource.h>
 #include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/base/ossimRefPtr.h>
 #include <ossim/base/ossimViewInterface.h>
 
 
@@ -23,7 +24,6 @@ class OSSIMDLLEXPORT ossimVpfTileSource : public ossimImageHandler,
 public:
    
    ossimVpfTileSource();
-   virtual ~ossimVpfTileSource();
 
    virtual void close();
 
@@ -97,13 +97,8 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix);
    
-   /*!
-    *  Populates the keyword list with image geometry information.  This
-    *  method is used to relay projection/model information to users.
-    *  Returns true if geometry info is present, false if not.
-    */
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0);
+   //! Returns the image geometry object associated with this tile source or NULL if non defined.
+   virtual ossimImageGeometry* getImageGeometry();
 
    /*!
     * Returns the output pixel type of the tile source.
@@ -148,7 +143,7 @@ public:
 
    virtual const ossimObject* getView()const;
    
-   virtual bool setView(ossimObject*  baseObject, bool ownsTheView = false);
+   virtual bool setView(ossimObject*  baseObject);
 
    void getAllFeatures(std::vector<ossimVpfAnnotationFeatureInfo*>& featureList);
   
@@ -159,7 +154,8 @@ public:
    void computeBoundingRect();
 
 protected:
-   ossimVpfAnnotationSource* theAnnotationSource;
+   virtual ~ossimVpfTileSource();
+   ossimRefPtr<ossimVpfAnnotationSource> m_AnnotationSource;
    
    
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimWatermarkFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimWatermarkFilter.h
index 1a6e34e3583132de6c64df83a4c87583661b8c6c..fa1af2cbb4bdb21001ee1348d84c2a873bdc7c6f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimWatermarkFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimWatermarkFilter.h
@@ -12,7 +12,7 @@
 // Density is base on alpha weight.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimWatermarkFilter.h 12623 2008-04-07 14:10:08Z gpotts $
+// $Id: ossimWatermarkFilter.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimWatermarkFilter_HEADER
 #define ossimWatermarkFilter_HEADER
 
@@ -50,9 +50,6 @@ public:
    /** contructor */
    ossimWatermarkFilter();
 
-   /** destructor */
-   virtual ~ossimWatermarkFilter();
-
    /** @return Short name of filter. */
    virtual ossimString getShortName()   const;
 
@@ -197,7 +194,9 @@ public:
     */
    virtual std::ostream& print(std::ostream& out) const;
 
-private:
+protected:
+   /** destructor */
+   virtual ~ossimWatermarkFilter();
 
    /**
     * Allocates / recomputes things that are needed.  Clears theDirtyFlag
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimWorldFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimWorldFileWriter.h
index 1499f4093f2c1559591750a3e9cbdb9f33d13b10..1688994f99e0c4a8e19c3311a31ee21a712ba628 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimWorldFileWriter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimWorldFileWriter.h
@@ -6,7 +6,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimWorldFileWriter.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimWorldFileWriter.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimWorldFileWriter_H
 #define ossimWorldFileWriter_H
@@ -21,9 +21,6 @@ public:
    /** default constructor */
    ossimWorldFileWriter();
 
-   /** default constructor */
-   virtual ~ossimWorldFileWriter();
-
    /**
     * Load state method:
     *
@@ -79,7 +76,9 @@ public:
     */
    void setLinearUnits(ossimUnitType units);
    
-private:
+protected:
+   /** default constructor */
+   virtual ~ossimWorldFileWriter();
    virtual bool writeFile();
 
    ossimUnitType theUnits;
diff --git a/Utilities/otbossim/include/ossim/kbool/bool_globals.h b/Utilities/otbossim/include/ossim/kbool/bool_globals.h
index b2ec9f0647a6125f03fe3fc8bbd9263e3cd62666..ade19583c15aa554d1816b3d22fb5f223f266fea 100644
--- a/Utilities/otbossim/include/ossim/kbool/bool_globals.h
+++ b/Utilities/otbossim/include/ossim/kbool/bool_globals.h
@@ -1,12 +1,6 @@
 #ifndef bool_globals_HEADER
 #define bool_globals_HEADER
 
-// Disable the warning when truncating from __int64 to const B_INT
-#ifdef _WIN32
-#pragma warning(disable: 4305)
-#pragma warning(disable: 4309)
-#endif
-
 #include <limits> /* for numeric_limits::min/max */
 #include <string>
 #include <ossim/base/ossimConstants.h>
@@ -146,10 +140,4 @@ class A2DKBOOLDLLEXP Bool_Engine_Error
 		int _fatal;
 };
 
-// Re-enable the warning for other files
-#ifdef _WIN32
-#pragma warning(default: 4305)
-#pragma warning(default: 4309)
-#endif
-
 #endif
diff --git a/Utilities/otbossim/include/ossim/kbool/line.h b/Utilities/otbossim/include/ossim/kbool/line.h
index ee797159fceb302216fee9ac7d9ec25b0a9b6aff..eb83e03034a9d911e5a6928ad65ce7a73179a6c2 100644
--- a/Utilities/otbossim/include/ossim/kbool/line.h
+++ b/Utilities/otbossim/include/ossim/kbool/line.h
@@ -6,7 +6,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: line.h 9094 2006-06-13 19:12:40Z dburken $
+    RCS-ID: $Id: line.h 14798 2009-06-29 19:19:22Z dburken $
 */
 
 #ifndef LINE_H
@@ -19,7 +19,7 @@
 #include <ossim/kbool/booleng.h>
 #include <ossim/kbool/link.h>
 
-class A2DKBOOLDLLEXP Bool_Engine;
+class Bool_Engine;
 
 // Status of a point to a line
 enum PointStatus {LEFT_SIDE, RIGHT_SIDE, ON_AREA, IN_AREA};
diff --git a/Utilities/otbossim/include/ossim/kbool/record.h b/Utilities/otbossim/include/ossim/kbool/record.h
index 5b9f347832c079c775500af407e02f799d91dc1e..b29487a3a200f7367ebacf1676c5d14c7e962d00 100644
--- a/Utilities/otbossim/include/ossim/kbool/record.h
+++ b/Utilities/otbossim/include/ossim/kbool/record.h
@@ -5,7 +5,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: record.h 9094 2006-06-13 19:12:40Z dburken $
+    RCS-ID: $Id: record.h 14798 2009-06-29 19:19:22Z dburken $
 */
 
 #ifndef RECORD_H
@@ -26,7 +26,7 @@ enum BEAM_TYPE { NORMAL,FLAT};
 enum DIRECTION  {GO_LEFT,GO_RIGHT};
 
 //extern void DeleteRecordPool();
-class A2DKBOOLDLLEXP Bool_Engine;
+class Bool_Engine;
 
 class A2DKBOOLDLLEXP Record
 {
diff --git a/Utilities/otbossim/include/ossim/parallel/ossimIgen.h b/Utilities/otbossim/include/ossim/parallel/ossimIgen.h
index 1f38363dfe82b7da559bef4883ab9c5b83ec7503..2affe27fea5dd24b9a192b78f70bfb189c35e1df 100644
--- a/Utilities/otbossim/include/ossim/parallel/ossimIgen.h
+++ b/Utilities/otbossim/include/ossim/parallel/ossimIgen.h
@@ -10,7 +10,7 @@
 // Description: Class declaration for image generator.
 //
 //*************************************************************************
-// $Id: ossimIgen.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimIgen.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimIgen_HEADER
 #define ossimIgen_HEADER
 
@@ -44,9 +44,9 @@ public:
    virtual void outputProduct();
    
 protected:
-   ossimConnectableContainer theContainer;
+   ossimRefPtr<ossimConnectableContainer> theContainer;
 
-   ossimProjection*  theProductProjection;
+   ossimRefPtr<ossimProjection>  theProductProjection;
    ossimDrect        theOutputRect;
    bool              theBuildThumbnailFlag;
    ossimIpt          theThumbnailResolution;
diff --git a/Utilities/otbossim/include/ossim/parallel/ossimMpiMasterOverviewSequencer.h b/Utilities/otbossim/include/ossim/parallel/ossimMpiMasterOverviewSequencer.h
index 0471433b6eb6dc36288b9ec2b500c867d2b8630e..85b7e1fc813794b42749d5c841c3f58a27faf530 100644
--- a/Utilities/otbossim/include/ossim/parallel/ossimMpiMasterOverviewSequencer.h
+++ b/Utilities/otbossim/include/ossim/parallel/ossimMpiMasterOverviewSequencer.h
@@ -8,7 +8,7 @@
 // overview files.
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimMpiMasterOverviewSequencer.h 10152 2006-12-30 20:54:39Z dburken $
+// $Id: ossimMpiMasterOverviewSequencer.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMpiMasterOverviewSequencer_HEADER
 #define ossimMpiMasterOverviewSequencer_HEADER
 
@@ -28,9 +28,6 @@ public:
    /** default constructor */
    ossimMpiMasterOverviewSequencer();
    
-   /** virtual destructor */
-   virtual ~ossimMpiMasterOverviewSequencer();
-
    /**
     * This must be called.  We can only initialize this
     * object completely if we know all connections
@@ -65,6 +62,8 @@ public:
    virtual ossimRefPtr<ossimImageData> getNextTile();
    
 protected:
+   /** virtual destructor */
+   virtual ~ossimMpiMasterOverviewSequencer();
 
    int  theRank;
    int  theNumberOfProcessors;
diff --git a/Utilities/otbossim/include/ossim/parallel/ossimMpiSlaveOverviewSequencer.h b/Utilities/otbossim/include/ossim/parallel/ossimMpiSlaveOverviewSequencer.h
index 74b7fd261f4e49a9d44eb9148761866be8169d68..50ac796cd325bc7d73174d3659a77f6a878a5066 100644
--- a/Utilities/otbossim/include/ossim/parallel/ossimMpiSlaveOverviewSequencer.h
+++ b/Utilities/otbossim/include/ossim/parallel/ossimMpiSlaveOverviewSequencer.h
@@ -8,7 +8,7 @@
 // overview files.
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimMpiSlaveOverviewSequencer.h 10152 2006-12-30 20:54:39Z dburken $
+// $Id: ossimMpiSlaveOverviewSequencer.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimMpiSlaveOverviewSequencer_HEADER
 #define ossimMpiSlaveOverviewSequencer_HEADER
 
@@ -25,8 +25,6 @@ public:
    /** default constructor */
    ossimMpiSlaveOverviewSequencer();
    
-   /** virtual destructor */
-   virtual ~ossimMpiSlaveOverviewSequencer();
 
    /**
     * @return Always false for this implementation.
@@ -57,6 +55,8 @@ public:
    virtual void slaveProcessTiles();
    
 protected:
+   /** virtual destructor */
+   virtual ~ossimMpiSlaveOverviewSequencer();
 
    int  theRank;
    int  theNumberOfProcessors;
diff --git a/Utilities/otbossim/include/ossim/parallel/ossimOrthoIgen.h b/Utilities/otbossim/include/ossim/parallel/ossimOrthoIgen.h
index 1a3d8891c75f647a057a6ffc842bdd9f845779c6..e31b1183ce0f9913fe98276fd71a7a6aedca14fc 100644
--- a/Utilities/otbossim/include/ossim/parallel/ossimOrthoIgen.h
+++ b/Utilities/otbossim/include/ossim/parallel/ossimOrthoIgen.h
@@ -1,4 +1,4 @@
-// $Id: ossimOrthoIgen.h 14021 2009-02-06 02:08:19Z gpotts $
+// $Id: ossimOrthoIgen.h 15785 2009-10-21 14:55:04Z dburken $
 #ifndef ossimOrthoIgen_HEADER
 #define ossimOrthoIgen_HEADER
 #include <ossim/base/ossimObject.h>
@@ -100,7 +100,12 @@ public:
    void setThumbnailResolution(const ossimIpt& res);
    void setThumbnailFlag(bool flag);
 
-   bool setupIgenKwl(ossimKeywordlist& kwl);
+   /**
+    * @brief Sets up the igen keyword list for the process.
+    *
+    * This throws ossimException on error.
+    */
+   void setupIgenKwl(ossimKeywordlist& kwl);
    
 protected:
    ossimString theThumbnailRes;
@@ -129,7 +134,9 @@ protected:
    ossim_float64 theHighPercentClip;
    bool          theUseAutoMinMaxFlag;
    bool          theScaleToEightBitFlag;
-   PropertyMap theWriterProperties;
+   // ossimString   theSrsCode;
+   bool          theStdoutFlag;
+   PropertyMap   theWriterProperties;
    
    std::vector<ossimOrthoIgenFilename> theFilenames;
    
@@ -137,9 +144,21 @@ protected:
    
    ossimRefPtr<ossimConnectableObject> setupCutter(ossimKeywordlist& kwl,
                                                    ossimConnectableObject* input);
-   bool setupWriter(ossimKeywordlist& kwl,
+
+   /**
+    * @brief Set up the writer for the process.
+    *
+    * This throws ossimException on error.
+    */
+   void setupWriter(ossimKeywordlist& kwl,
                     ossimConnectableObject* input);
-   bool setupView(ossimKeywordlist& kwl);
+
+   /**
+    * @brief Set up the view for the process.
+    *
+    * This throws ossimException on error.
+    */
+   void setupView(ossimKeywordlist& kwl);
 
    /**
     * Sets up any annotation from --annotate option.
diff --git a/Utilities/otbossim/include/ossim/projection/ossimAdjMapModel.h b/Utilities/otbossim/include/ossim/projection/ossimAdjMapModel.h
index 2573d1996b67f333738a85c3f0ccaa2bd893036b..0637f46fb7f13f5969ae449c7395cb8438b9a088 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimAdjMapModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimAdjMapModel.h
@@ -15,7 +15,7 @@
 // information and error output.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimAdjMapModel.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAdjMapModel.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimAdjMapModel_HEADER
 #define ossimAdjMapModel_HEADER
 
@@ -54,9 +54,6 @@ public:
    //! Constructs given geom filename.
    ossimAdjMapModel(const ossimFilename& geom_filename);
 
-   //! Destructor only deletes the map projection.
-   virtual ~ossimAdjMapModel();
-
    //! Initializes base class data members after map model established.
    //  Returns TRUE if all's well.
    bool initializeFromMap();
@@ -120,6 +117,9 @@ public:
    inline virtual bool useForward()const {return true;} //!ground to image faster (you don't need DEM)
 
 private:
+   //! Destructor only deletes the map projection.
+   virtual ~ossimAdjMapModel();
+   
    //! This is the vector of UNNORMALIZED, BIASED parameters as used in the
    //! model. The collection of normalized, 0-biased, parameters used in
    //! registration are found in the
diff --git a/Utilities/otbossim/include/ossim/projection/ossimAffineProjection.h b/Utilities/otbossim/include/ossim/projection/ossimAffineProjection.h
index 90db4063cbdd0634042aebca6202646c30abfad0..f330a753320d361610885e9672ff21ac448a728b 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimAffineProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimAffineProjection.h
@@ -9,7 +9,7 @@
 //   implementation of a warping interpolation model.
 //
 //*****************************************************************************
-//  $Id: ossimAffineProjection.h 11805 2007-10-05 14:54:28Z dburken $
+//  $Id: ossimAffineProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAffineProjection_HEADER
 #define ossimAffineProjection_HEADER
@@ -17,8 +17,7 @@
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimIpt.h>
 #include <iosfwd>
-
-class ossim2dTo2dTransform;
+#include <ossim/base/ossim2dTo2dTransform.h>
 
 /*!****************************************************************************
  *
@@ -113,8 +112,8 @@ protected:
    /*!
     * Data Members:
     */
-   ossimProjection*      theClientProjection;
-   ossim2dTo2dTransform* theAffineTransform;
+   ossimRefPtr<ossimProjection>      theClientProjection;
+   ossimRefPtr<ossim2dTo2dTransform> theAffineTransform;
    
    TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/projection/ossimAlbersProjection.h b/Utilities/otbossim/include/ossim/projection/ossimAlbersProjection.h
index 76916a9d1a3083cd13a9c0c572a8c318f4b38efe..08dc2b6cb2c78fa976de58050297f478bc41069d 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimAlbersProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimAlbersProjection.h
@@ -9,7 +9,7 @@
 //
 // Calls Geotrans Albers projection code.  
 //*******************************************************************
-//  $Id: ossimAlbersProjection.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimAlbersProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAlbersProjection_HEADER
 #define ossimAlbersProjection_HEADER
@@ -34,8 +34,6 @@ public:
                          double falseEasting,
                          double falseNorthing);
    
-   virtual ~ossimAlbersProjection();
-
    ossimObject *dup()const;
    
    virtual ossimDpt forward(const ossimGpt &worldPoint)    const;
@@ -109,7 +107,8 @@ public:
     */
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
-private:
+protected:
+   virtual ~ossimAlbersProjection();
 
 
    //________________________GEOTRANS__________________________
diff --git a/Utilities/otbossim/include/ossim/projection/ossimAzimEquDistProjection.h b/Utilities/otbossim/include/ossim/projection/ossimAzimEquDistProjection.h
index 9b5ed4a496c127fe5c9a2dafd3e100ed8c1f8df8..1df0d0532e9413437219b30057bb5f09dcd78154 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimAzimEquDistProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimAzimEquDistProjection.h
@@ -8,7 +8,7 @@
 //
 // Calls Geotrans Equidistant Cylinder projection code.  
 //*******************************************************************
-//  $Id: ossimAzimEquDistProjection.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimAzimEquDistProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimAzimEquDistProjection_HEADER
 #define ossimAzimEquDistProjection_HEADER
@@ -30,7 +30,6 @@ public:
       {
          *this = rhs;
       }
-   virtual ~ossimAzimEquDistProjection(){}
    virtual ossimObject *dup()const
    {
       return new ossimAzimEquDistProjection(*this);
@@ -82,6 +81,8 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
 protected:   
+   virtual ~ossimAzimEquDistProjection(){}
+   
    mutable double abs_Azeq_Origin_Lat;
    mutable double Azeq_a;                  /* Semi-major axis of ellipsoid in meters */
    mutable double Azeq_f;          /* Flattening of ellipsoid */
diff --git a/Utilities/otbossim/include/ossim/projection/ossimBilinearProjection.h b/Utilities/otbossim/include/ossim/projection/ossimBilinearProjection.h
index dc3f5a38434919084532b0c05952a4696882a0bd..a230e74d2be1c8ae0f4cb68e301bac0b01d27b63 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimBilinearProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimBilinearProjection.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 // 
 //********************************************************************
-// $Id: ossimBilinearProjection.h 12136 2007-12-07 14:26:43Z gpotts $
+// $Id: ossimBilinearProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimBilinearProjection_HEADER
 #define ossimBilinearProjection_HEADER
 
@@ -31,7 +31,6 @@ public:
                            const ossimGpt& urg,
                            const ossimGpt& lrg,
                            const ossimGpt& llg);
-   virtual ~ossimBilinearProjection();
    virtual ossimObject *dup()const;
    virtual ossimGpt origin()const;
    
@@ -90,7 +89,11 @@ public:
     */
    virtual bool isAffectedByElevation() const { return false; } 
    
+   //! Access method for tie point information
+   void getTiePoints(std::vector<ossimDpt>& lsPt, std::vector<ossimGpt>& geoPt) const;
+
 protected:
+   virtual ~ossimBilinearProjection();
    void initializeBilinear();
 
    /**
diff --git a/Utilities/otbossim/include/ossim/projection/ossimCadrgProjection.h b/Utilities/otbossim/include/ossim/projection/ossimCadrgProjection.h
index 06177498510ed679834a8c76c55c7c9d50f542d0..38f9c3d9980baf1ade59bce893df534b383be0f1 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimCadrgProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimCadrgProjection.h
@@ -1,23 +1,23 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimCadrgProjection.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimCadrgProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimCadrgProjection_HEADER
 #define ossimCadrgProjection_HEADER
 #include <ossim/projection/ossimMapProjection.h>
 
-class ossimCadrgProjection : public ossimMapProjection
+class OSSIM_DLL ossimCadrgProjection : public ossimMapProjection
 {
 public:
    ossimCadrgProjection();
 
                        
-   virtual ~ossimCadrgProjection();
    virtual ossimObject *dup()const;
    virtual ossimGpt inverse(const ossimDpt &eastingNorthing)const;
    virtual ossimDpt forward(const ossimGpt &latLon)const;
@@ -52,6 +52,7 @@ public:
       }
       
 protected:
+   virtual ~ossimCadrgProjection();
    /*
     * Are from the ADRG Mil spec for 1:1,000,000 and
     * are scales for each zone.
diff --git a/Utilities/otbossim/include/ossim/projection/ossimCoarseGridModel.h b/Utilities/otbossim/include/ossim/projection/ossimCoarseGridModel.h
index da1fab1d4c019ddf5e4dd7ce379aa35f1d475382..2090b6010cababea3596ecc9a2e8a23a45667ff9 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimCoarseGridModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimCoarseGridModel.h
@@ -14,7 +14,7 @@
 //   implementation of an interpolation sensor model.
 //
 //*****************************************************************************
-//  $Id: ossimCoarseGridModel.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimCoarseGridModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimCoarseGridModel_HEADER
 #define ossimCoarseGridModel_HEADER
@@ -24,6 +24,7 @@
 #include <ossim/base/ossimDblGrid.h>
 #include <ossim/base/ossimFilename.h>
 
+class ossimImageGeometry;
 /******************************************************************************
  *
  * CLASS:  ossimCoarseGridModel
@@ -62,12 +63,17 @@ public:
     * The accuracy of the grid can be controlled by the static method
     * setInterpolationError.
     */
-  virtual void buildGrid(const ossimDrect& imageBounds,
-			 ossimProjection* proj,
-                         double heightDelta=500.0,
-                         bool enableHeightFlag=false,
-                         bool makeAdjustableFlag=true);
-
+   virtual void buildGrid(const ossimDrect& imageBounds,
+                          ossimProjection* proj,
+                          double heightDelta=500.0,
+                          bool enableHeightFlag=false,
+                          bool makeAdjustableFlag=true);
+   virtual void buildGrid(const ossimDrect& imageBounds,
+                          ossimImageGeometry* geom,
+                          double heightDelta=500.0,
+                          bool enableHeightFlag=false,
+                          bool makeAdjustableFlag=true);
+   
    /**
     *  This is used when building a grid from a projector.
     *  You can set the interpolation error.  The default is
diff --git a/Utilities/otbossim/include/ossim/projection/ossimFcsiModel.h b/Utilities/otbossim/include/ossim/projection/ossimFcsiModel.h
index b1adccb51c134db4c9fcd9985d82a126f8b1e447..17a15a2a45b97bd74d998aad57becd384afa5118 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimFcsiModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimFcsiModel.h
@@ -59,7 +59,7 @@
 //              Initial coding
 //
 //*****************************************************************************
-//  $Id: ossimFcsiModel.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimFcsiModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimFcsiModel_HEADER
 #define ossimFcsiModel_HEADER
@@ -90,7 +90,6 @@ public:
    ossimFcsiModel(const ossimKeywordlist& geom_kwl);
    ossimFcsiModel(const ossimFcsiModel& rhs);
    
-   virtual ~ossimFcsiModel() { delete theOpticalDistortion; }
 
    enum AdjustParamIndex
    {
@@ -182,6 +181,7 @@ public:
    inline virtual bool useForward()const {return true;} //!ground to image faster (you don't need DEM)
 
 protected:
+   virtual ~ossimFcsiModel() { delete theOpticalDistortion; }
 
    /*!
     * Assigns initial default values to adjustable parameters and related
diff --git a/Utilities/otbossim/include/ossim/projection/ossimIkonosRpcModel.h b/Utilities/otbossim/include/ossim/projection/ossimIkonosRpcModel.h
index deff89a4e1e69dec7c10aac493bf9047ff3523f4..fab35f3f2e918aad9075988db4d228c5b1e19b0a 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimIkonosRpcModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimIkonosRpcModel.h
@@ -13,16 +13,16 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimIkonosRpcModel.h 14413 2009-04-27 17:11:12Z dburken $
+//  $Id: ossimIkonosRpcModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimIkonosRpcModel_HEADER
 #define ossimIkonosRpcModel_HEADER
 
 #include <ossim/base/ossimConstants.h>
 #include <ossim/projection/ossimRpcModel.h>
+#include <ossim/support_data/ossimIkonosMetaData.h>
 
 class ossimFilename;
-class ossimIkonosMetaData;
 
 /*!****************************************************************************
  *
@@ -38,8 +38,6 @@ public:
    ossimIkonosRpcModel(const ossimFilename& metadata,
                        const ossimFilename& rpcdata);
 
-   virtual ~ossimIkonosRpcModel();
-
   virtual bool saveState(ossimKeywordlist& kwl,
 			 const char* prefix=0)const;
 
@@ -60,6 +58,7 @@ public:
    virtual bool parseFile(const ossimFilename& file);
    
 protected:
+   virtual ~ossimIkonosRpcModel();
    void finishConstruction();
    void parseMetaData(const ossimFilename& metadata);
    void parseRpcData (const ossimFilename& rpcdata);
@@ -69,7 +68,7 @@ protected:
 /*    bool parseNitfFile(const ossimFilename& geom_file); */
    bool parseHdrData(const ossimFilename& data_file);
 
-   ossimIkonosMetaData* theSupportData;
+   ossimRefPtr<ossimIkonosMetaData> theSupportData;
 
    TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h b/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h
index 2e546fe364e26a6aefc1c94aa6762b9104b01666..4ce5f8613f08c2efb00b104367b23b00bbaaa020 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h
@@ -34,8 +34,6 @@ public:
    /** @brief default constructor */
    ossimImageProjectionModel();
 
-   /** @brief virtual destructor */
-   virtual ~ossimImageProjectionModel();
 
    /**
     * @brief Method to initialize class from an image handler.
@@ -51,7 +49,9 @@ public:
     */
    const ossimProjection* getProjection() const;
 
-private:
+protected:
+   /** @brief virtual destructor */
+   virtual ~ossimImageProjectionModel();
 
    ossimProjection* theProjection;
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimImageViewAffineTransform.h b/Utilities/otbossim/include/ossim/projection/ossimImageViewAffineTransform.h
index b0e7aa9a397adf4e1c467a5ea87a103be38676d2..b9fcc1929609e65b0d948e63ed69ec30f881e54f 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimImageViewAffineTransform.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimImageViewAffineTransform.h
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimImageViewAffineTransform.h 13459 2008-08-20 12:48:50Z gpotts $
+//  $Id: ossimImageViewAffineTransform.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimImageViewAffineTransform_HEADER
 #define ossimImageViewAffineTransform_HEADER
 #include <ossim/projection/ossimImageViewTransform.h>
@@ -61,7 +61,7 @@ public:
    }
 
    virtual bool isValid()const;
-   virtual bool setView(ossimObject* obj, bool ownsProjection=false);
+   virtual bool setView(ossimObject* obj);
    virtual ossimObject* getView();
    virtual const ossimObject* getView()const;
    
diff --git a/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h b/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h
index 77c0f46c7fc54bd51b0fbc895f5574d8c9076a7e..bb7513a180e2afdfe1110f93498589b36daa12e0 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h
@@ -2,7 +2,8 @@
 //
 // License:  See top level LICENSE.txt file.
 // 
-// AUTHOR: Garrett Potts (gpotts@imagelinks.com)
+// AUTHOR: Garrett Potts (gpotts@imagelinks.com)  
+//         Oscar Kramer (oscar@krameranalytic.com)
 //
 // DESCRIPTION: Contains declaration of ossimImageViewProjectionTransform.
 //    This class provides an image to view transform that utilizes two
@@ -12,144 +13,77 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimImageViewProjectionTransform.h 13516 2008-08-29 14:54:12Z dburken $
+//  $Id: ossimImageViewProjectionTransform.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimImageViewProjectionTransform_HEADER
 #define ossimImageViewProjectionTransform_HEADER
 
 #include <ossim/projection/ossimImageViewTransform.h>
-#include <ossim/projection/ossimProjection.h>
-
-class ossimProjection;
-class ossimMapProjection;
+#include <ossim/imaging/ossimImageGeometry.h>
 
 class OSSIMDLLEXPORT ossimImageViewProjectionTransform : public ossimImageViewTransform
 {
 public:
-   ossimImageViewProjectionTransform(ossimProjection* imageProjection=0,
-                                     ossimProjection* viewProjection=0,
-                                     bool ownsImageProjectionFlag=true,
-                                     bool ownsViewProjectionFlag=true);
+   ossimImageViewProjectionTransform(ossimImageGeometry* imageGeometry=0,
+                                     ossimImageGeometry* viewGeometry=0);
 
-   /** copy constructor */
+   //! copy constructor 
    ossimImageViewProjectionTransform(const ossimImageViewProjectionTransform& src);
 
-   virtual ossimObject* dup()const
-   {
-      return new ossimImageViewProjectionTransform(*this);
-   }
+   virtual ossimObject* dup() const { return new ossimImageViewProjectionTransform(*this); }
    virtual ~ossimImageViewProjectionTransform();
 
-   virtual bool isValid()const
-      {
-         return (theImageProjection&&theViewProjection);
-      }
-  virtual bool isIdentity()const
-  {
-    if(theImageProjection&&theViewProjection)
-      {
-	return (*theImageProjection)==(*theViewProjection);
-      }
-    
-    return true;
-  }
-   virtual void imageToView(const ossimDpt& imagePoint,
-                            ossimDpt&       viewPoint)const;
-   virtual void viewToImage(const ossimDpt& viewPoint,
-                            ossimDpt&       imagePoint)const;
-
-//   virtual void getRoundTripErrorView(ossimDpt& result,
-// 				     const ossimDpt& viewPt)const;
-
-//   virtual void getRoundTripErrorImage(ossimDpt& result,
-// 				      const ossimDpt& imagePt)const;
-   /*!
-    * Will not allocate a new projection.  It will just copy
-    * the pointer and delete the one it owns if they addresses
-    * are different.  It will own the passes in projection.
-    */
-   void setViewProjection(ossimProjection* viewProjection,
-                          bool ownsViewProjection=false);   
-
-   /*!
-    * Will allocate a new projection and copy it.
-    */
-   void setViewProjection(const ossimProjection& viewProjection);
-
-   /*!
-    * Will not allocate a new projection.  It will just copy
-    * the pointer and delete the one it owns if they addresses
-    * are different. Flag indicates whether this becomes owner.
-    */
-   void setImageProjection(ossimProjection* imageProjection,
-                           bool ownsImageProjection=false);
-
-   /*!
-    * Will allocate a new projection and copy it.
-    */
-   void setImageProjection(const ossimProjection& imageProjection);
+   //! Satisfies base class pure virtual. Returns TRUE if both input and output geoms exist.
+   virtual bool isValid() const { return (m_ImageGeometry.valid() && m_ViewGeometry.valid()); }
+
+   //! Returns TRUE if both input and output geometries are identical. Presently implemented as
+   //! limited compare of geometry pointers
+   virtual bool isIdentity() const { return (m_ImageGeometry == m_ViewGeometry); }
+
+   //! Assigns the geometry to use for output view. This object does NOT own the geometry.
+   void setViewGeometry(ossimImageGeometry* g) { m_ViewGeometry = g; }   
+
+   //! Assigns the geometry to use for input image. This object does NOT own the geometry.
+   void setImageGeometry(ossimImageGeometry* g) { m_ImageGeometry = g; }  
+
+   //! Workhorse of the object. Converts image-space to view-space.
+   virtual void imageToView(const ossimDpt& imagePoint, ossimDpt& viewPoint) const;
+
+   //! Other workhorse of the object. Converts view-space to image-space.
+   virtual void viewToImage(const ossimDpt& viewPoint, ossimDpt& imagePoint) const;
 
+   //! Dumps contents to stream
    virtual std::ostream& print(std::ostream& out) const;
    
-   ossimProjection* getImageProjection();
-   ossimProjection* getViewProjection();
-
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
-   virtual ossimObject* getView()
-      {
-         return theViewProjection;
-      }
-   virtual const ossimObject* getView()const
-      {
-         return theViewProjection;
-      }
-
-   virtual ossimDpt getInputMetersPerPixel()const
-      {
-         ossimDpt result;
-
-         result.makeNan();
-
-         if(theImageProjection)
-         {
-            result = theImageProjection->getMetersPerPixel();
-         }
-
-         return result;
-      }
-   virtual ossimDpt getOutputMetersPerPixel()const
-      {
-         ossimDpt result;
-
-         result.makeNan();
-
-         if(theViewProjection)
-         {
-            result = theViewProjection->getMetersPerPixel();
-         }
-
-         return result;
-      }
+   ossimImageGeometry* getImageGeometry()  { return m_ImageGeometry.get(); }
+   ossimImageGeometry* getViewGeometry()   { return m_ViewGeometry.get(); }
+   const ossimImageGeometry* getImageGeometry()const  { return m_ImageGeometry.get(); }
+   const ossimImageGeometry* getViewGeometry()const   { return m_ViewGeometry.get(); }
+   
+   //! OLK: Not sure where this is used, but needed to satisfy ossimViewInterface base class.
+   //! The ownership flag is ignored.
+   virtual bool setView(ossimObject* baseObject);
+   virtual       ossimObject* getView()       { return m_ViewGeometry.get(); }
+   virtual const ossimObject* getView() const { return m_ViewGeometry.get(); }
+
+   //! Returns the GSD of input image.
+   virtual ossimDpt getInputMetersPerPixel()const;
+
+   //! Returns the GSD of the output view.
+   virtual ossimDpt getOutputMetersPerPixel() const;
+
+   //! Gets the image bounding rect in view-space coordinates
    virtual ossimDrect getImageToViewBounds(const ossimDrect& imageRect)const;
    
-   virtual bool loadState(const ossimKeywordlist& kwl,
-                          const char* prefix =0);
+   //! After rewrite for incorporating ossimImageGeometry: No longer needed.  
+   virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix =0);
    
-   virtual bool saveState(ossimKeywordlist& kwl,
-                          const char* prefix = 0)const;
+   //! After rewrite for incorporating ossimImageGeometry: No longer needed.  
+   virtual bool saveState(ossimKeywordlist& kwl, const char* prefix = 0)const;
+
 protected:
-   ossimProjection* theImageProjection;
-   ossimProjection* theViewProjection;
-   bool             theOwnsImageProjFlag;
-   bool             theOwnsViewProjFlag;
-   mutable bool     theSameProjection;
-   mutable bool     theInputMapProjectionFlag;
-   mutable bool     theOutputMapProjectionFlag;
-   void checkSameProjection();
-//    void findWorldPoint(const ossimDpt& imagePoint,
-//                        ossimGpt& worldPt,
-//                        ossimMapProjection* proj)const;
+   ossimRefPtr<ossimImageGeometry> m_ImageGeometry;
+   ossimRefPtr<ossimImageGeometry> m_ViewGeometry;
    
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/projection/ossimLandSatModel.h b/Utilities/otbossim/include/ossim/projection/ossimLandSatModel.h
index b82e6430a7b99fb08b68beea7b92abf5c9013fbf..8443ee136798602335462b7e1b366e158a89d9c7 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimLandSatModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimLandSatModel.h
@@ -11,7 +11,7 @@
 //              Modified selection of adjustable parameters..
 //
 //*****************************************************************************
-//  $Id: ossimLandSatModel.h 14049 2009-03-03 02:25:27Z gpotts $
+//  $Id: ossimLandSatModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimLandSatModel_HEADER
 #define ossimLandSatModel_HEADER
@@ -48,7 +48,6 @@ public:
    ossimLandSatModel(const ossimKeywordlist& geom_kwl);
    ossimLandSatModel(const ossimLandSatModel& rhs);
    virtual ossimObject* dup()const;
-   virtual ~ossimLandSatModel();
 
    enum ProjectionType
    {
@@ -123,6 +122,7 @@ public:
 
 protected:
 
+   virtual ~ossimLandSatModel();
    /*!
     * Initializes the model given a fast format header.
     */
diff --git a/Utilities/otbossim/include/ossim/projection/ossimMapProjection.h b/Utilities/otbossim/include/ossim/projection/ossimMapProjection.h
index f6342f045de39d1566c0c5c360e95a342c52095d..00e1bf4009b72795a7b3f2473e9f956e24fc7e13 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimMapProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimMapProjection.h
@@ -9,7 +9,7 @@
 // Base class for all map projections.
 // 
 //*******************************************************************
-//  $Id: ossimMapProjection.h 13823 2008-10-31 17:21:22Z dburken $
+//  $Id: ossimMapProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimMapProjection_HEADER
 #define ossimMapProjection_HEADER
@@ -35,7 +35,6 @@ public:
                       const ossimGpt& origin=ossimGpt());
 
    ossimMapProjection(const ossimMapProjection& src);
-   virtual ~ossimMapProjection();
 
    virtual ossimGpt origin()const;
 
@@ -126,7 +125,7 @@ public:
    virtual const ossimDpt&   getUlEastingNorthing() const;
    virtual const ossimGpt&   getUlGpt() const;
    virtual const ossimDatum* getDatum() const;
-
+   const ossimEllipsoid&     getEllipsoid() const { return theEllipsoid; }
    virtual bool isGeographic()const;
 
    /**
@@ -286,6 +285,7 @@ public:
    virtual bool isAffectedByElevation() const { return false; }
    
 protected:
+   virtual ~ossimMapProjection();
 
    /**
     * This method verifies that the projection parameters match the current
diff --git a/Utilities/otbossim/include/ossim/projection/ossimMapProjectionFactory.h b/Utilities/otbossim/include/ossim/projection/ossimMapProjectionFactory.h
index 03018e4c4ec86316b5c361244ba8f5a51d1afb66..38b1d26e13d27c685a16f600ca7505db1e084825 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimMapProjectionFactory.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimMapProjectionFactory.h
@@ -13,7 +13,7 @@
 // a projection name and a datum if desired.  Currently the default
 // datum will be WGS84.
 //*******************************************************************
-//  $Id: ossimMapProjectionFactory.h 12081 2007-11-26 21:44:18Z dburken $
+//  $Id: ossimMapProjectionFactory.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimMapProjectionFactory_HEADER
 #define ossimMapProjectionFactory_HEADER
@@ -42,7 +42,6 @@ public:
    virtual ossimProjection* createProjection(const ossimString& name)const;
    virtual ossimProjection* createProjection(const ossimKeywordlist& kwl,
                                              const char* prefix = 0)const;
-
    virtual ossimObject* createObject(const ossimString& typeName)const;
 
    /*!
diff --git a/Utilities/otbossim/include/ossim/projection/ossimMgrs.h b/Utilities/otbossim/include/ossim/projection/ossimMgrs.h
index 582ce5777255a7416968787c8d7397e505d7d607..f3d25ce53371c930e7e75ece13d7e73c6444387d 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimMgrs.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimMgrs.h
@@ -149,7 +149,7 @@ extern "C" {
  */
 
 
-  long Convert_OSSIM_MGRS_To_Geodetic (char *MGRS,
+  long Convert_OSSIM_MGRS_To_Geodetic (const char *MGRS,
                                  double *Latitude,
                                  double *Longitude);
 /*
@@ -185,7 +185,7 @@ extern "C" {
  */
 
 
-  long Convert_OSSIM_MGRS_To_UTM (char   *MGRS,
+  long Convert_OSSIM_MGRS_To_UTM (const char   *MGRS,
                             long   *Zone,
                             char   *Hemisphere,
                             double *Easting,
@@ -227,7 +227,7 @@ extern "C" {
  */
 
 
-  long Convert_OSSIM_MGRS_To_UPS ( char   *MGRS,
+  long Convert_OSSIM_MGRS_To_UPS ( const char   *MGRS,
                              char   *Hemisphere,
                              double *Easting,
                              double *Northing);
diff --git a/Utilities/otbossim/include/ossim/projection/ossimNitfProjectionFactory.h b/Utilities/otbossim/include/ossim/projection/ossimNitfProjectionFactory.h
index f30880df42b860b6c8366fa7e3e6b2385e5bd356..94a67ee360db6397f8258bb5f0c54738e01cd54f 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimNitfProjectionFactory.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimNitfProjectionFactory.h
@@ -9,7 +9,7 @@
 //
 // Contains class declaration for ossimNitfProjectionFactory.
 //
-// $Id: ossimNitfProjectionFactory.h 12081 2007-11-26 21:44:18Z dburken $
+// $Id: ossimNitfProjectionFactory.h 15766 2009-10-20 12:37:09Z gpotts $
 //----------------------------------------------------------------------------
 #ifndef ossimNitfProjectionFactory_HEADER
 #define ossimNitfProjectionFactory_HEADER
@@ -20,7 +20,9 @@
 class ossimProjection;
 class ossimString;
 class ossimGpt;
+class ossimNitfTileSource;
 class ossimNitfImageHeader;
+class ossimNitfFileHeader;
 class ossimDpt;
 
 class OSSIMDLLEXPORT ossimNitfProjectionFactory : public ossimProjectionFactoryBase
@@ -66,6 +68,8 @@ public:
     */
    virtual ossimProjection* createProjection(const ossimKeywordlist& kwl,
                                              const char* prefix = 0)const;
+   
+   virtual ossimProjection* createProjection(ossimImageHandler* handler)const;
    /**
     * Creates an object given a type name.
     *
@@ -91,6 +95,17 @@ public:
    virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
 
 private:
+   /**
+    * This will look for the most accurate sensor model for the NITF.  If non found then we will
+    * use the createProjectionFromHeaders call to create a simple bilinear styl mapping using the 
+    * coordinates of the igeolo.
+    */
+   ossimProjection* createModel(ossimNitfTileSource* nitf)const;
+   
+   ossimProjection* createProjectionFromHeaders(ossimNitfFileHeader* fileHeader,
+                                                ossimNitfImageHeader* imageHeader)const;
+   
+   
    /**
     * @param hdr The nitf image header.
     *
@@ -98,14 +113,12 @@ private:
     *
     * @param geographicLocation This should contain the four corner strings.
     *
-    * @param filename The nitf file name.
-    * 
     * @return Either an  ossimEquDistCylProjection or ossimBilinearProjection
     * depending upon if the corner points line up evenly.
     */
    ossimProjection* makeGeographic(const ossimNitfImageHeader* hdr,
-                                   const ossimString& coordinateSysetm,
-                                   const ossimFilename& filename) const;
+                                   const ossimString& coordinateSysetm)const;//,
+                                   //const ossimFilename& filename) const;
 
    /**
     * @param hdr The nitf image header.
@@ -114,13 +127,11 @@ private:
     *
     * @param geographicLocation This should contain the four corner strings.
     *
-    * @param filename The nitf file name.
-    * 
     * @return ossimUtmProjection
     */
    ossimProjection* makeUtm(const ossimNitfImageHeader* hdr,
-                            const ossimString& coordinateSysetm,
-                            const ossimFilename& filename) const;
+                            const ossimString& coordinateSysetm)const;//,
+                            //const ossimFilename& filename) const;
    
    /**
     * @param hdr The nitf image header.
@@ -213,13 +224,11 @@ private:
     * @param gpts Ground points to initialize from BLOCKA tag.  This should
     * be an empty vector.
     *
-    * @param filename The nitf file name.
-    * 
     * @return true if BLOCKA tag was parsed.
     */
    bool getBlockaPoints(const ossimNitfImageHeader* hdr,
-                        std::vector<ossimGpt>& gpts,
-                        const ossimFilename& filename) const;
+                        std::vector<ossimGpt>& gpts)const;//,
+                        //const ossimFilename& filename) const;
    
    /**
     * Private constructor, users must go through instance() method.
diff --git a/Utilities/otbossim/include/ossim/projection/ossimNitfRpcModel.h b/Utilities/otbossim/include/ossim/projection/ossimNitfRpcModel.h
index 37bd6b17d4b05bd4c6a042afda9e8ca5f9ab92cd..9f6ed1654ade085ad777ab9fb0e7faf53a3deb1c 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimNitfRpcModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimNitfRpcModel.h
@@ -1,7 +1,9 @@
 //*****************************************************************************
 // FILE: ossimNitfRpcModel.h
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR: Oscar Kramer
 //
@@ -12,7 +14,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimNitfRpcModel.h 11720 2007-09-12 14:59:30Z gpotts $
+//  $Id: ossimNitfRpcModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimNitfRpcModel_HEADER
 #define ossimNitfRpcModel_HEADER
@@ -67,8 +69,16 @@ public:
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=0);
 
-   virtual bool parseFile(const ossimFilename& nitfFile);
+   /**
+    * @brief Method to parse an nitf file and initialize model.
+    * @param entryIndex The entry to get model for.  Note the nitf's can have
+    * multiple entries; each with a different projection.
+    * @return true on success, false on error.
+    */
+   virtual bool parseFile(const ossimFilename& nitfFile,
+                          ossim_uint32 entryIndex=0);
    
+   virtual bool parseImageHeader(const ossimNitfImageHeader* ih);
 private:
 
    /**
diff --git a/Utilities/otbossim/include/ossim/projection/ossimProjection.h b/Utilities/otbossim/include/ossim/projection/ossimProjection.h
index 2857ab0d179c31ede83f3a7182f0960ced8285f4..023c3506372aeb881eb5346aec8598db24a11702 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimProjection.h
@@ -7,7 +7,7 @@
 // Description: Base class for all projections (2D-to-3D transform)
 //
 //*******************************************************************
-//  $Id: ossimProjection.h 11805 2007-10-05 14:54:28Z dburken $
+//  $Id: ossimProjection.h 15798 2009-10-23 19:15:20Z gpotts $
 #ifndef ossimProjection_HEADER
 #define ossimProjection_HEADER
 #include <iostream>
@@ -109,7 +109,7 @@ public:
    virtual bool isAffectedByElevation() const=0;
    
 protected:
-   
+  
 
    TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryBase.h b/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryBase.h
index 4932c0b6bf69ca800d9bc3ec917ac92810cefe58..203077ce4a6f5c4bf47c482deb88c1c8067fa790 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryBase.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryBase.h
@@ -4,17 +4,16 @@
 //
 // Author: Garrett Potts
 //*******************************************************************
-//  $Id: ossimProjectionFactoryBase.h 12081 2007-11-26 21:44:18Z dburken $
+//  $Id: ossimProjectionFactoryBase.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimProjectionFactoryBase_HEADER
 #define ossimProjectionFactoryBase_HEADER
 
-#include <list>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimObjectFactory.h>
 
 class ossimProjection;
-
+class ossimImageHandler;
 class OSSIM_DLL ossimProjectionFactoryBase : public ossimObjectFactory
 {
 public:
@@ -39,6 +38,8 @@ public:
     */
    virtual ossimProjection* createProjection(const ossimKeywordlist& kwl,
                                              const char* prefix)const=0;
+   
+   virtual ossimProjection* createProjection(ossimImageHandler* handler)const;
 
 protected:
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h b/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h
index 3edb6adfd2cc240566813506a9965724a5c688f6..736594abef88e54a105710e94ca3228eeddd22ac 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h
@@ -6,19 +6,20 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimProjectionFactoryRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
+// $Id: ossimProjectionFactoryRegistry.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimProjectionFactoryRegistry_HEADER
 #define ossimProjectionFactoryRegistry_HEADER
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimObjectFactory.h>
+#include <ossim/base/ossimFactoryListInterface.h>
+#include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimProjectionFactoryBase.h>
 
-#include <vector>
-#include <list>
-class ossimProjectionFactoryBase;
-class ossimProjection;
-
-class OSSIMDLLEXPORT ossimProjectionFactoryRegistry : public ossimObjectFactory
+class ossimImageHandler;
+class OSSIM_DLL ossimProjectionFactoryRegistry : public ossimObjectFactory,
+                                                 public ossimFactoryListInterface<ossimProjectionFactoryBase,
+                                                                                 ossimProjection>
 {
 public:
 
@@ -26,51 +27,50 @@ public:
    
    static ossimProjectionFactoryRegistry* instance();
 
+   
    ossimProjection* createProjection(const ossimFilename& filename,
                                      ossim_uint32 entryIdx)const;
-   ossimProjection* createProjection(const ossimString& name)const;
+   ossimProjection* createProjection(const ossimString& name)const
+   {
+      return createNativeObjectFromRegistry(name);
+   }
    ossimProjection* createProjection(const ossimKeywordlist& kwl,
                                      const char* prefix=NULL)const;
-
-   virtual ossimObject* createObject(const ossimString& typeName)const;
-
-   /**
+   
+   virtual ossimProjection* createProjection(ossimImageHandler* handler)const;
+   /*!
+    * Creates an object given a type name.
+    */
+   virtual ossimObject* createObject(const ossimString& typeName)const
+   {
+      return createObjectFromRegistry(typeName);
+   }
+   
+   /*!
     * Creates and object given a keyword list.
     */
    virtual ossimObject* createObject(const ossimKeywordlist& kwl,
-                                     const char* prefix=0)const;
+                                     const char* prefix=0)const
+   {
+      return createObjectFromRegistry(kwl, prefix);
+   }
    
    /**
     * This should return the type name of all objects in all factories.
     * This is the name used to construct the objects dynamially and this
     * name must be unique.
     */
-   virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
-
-   /**
-    * Method to add a factory to the list of this registry.
-    *
-    * @param factory Factory to add.
-    *
-    * @param pushToFrontFlag If true the factory is added to the front of the
-    * list.  If false (default behavior) the factory is added to the end of
-    * the list.
-    *
-    * @return true on success, false on error.
-    */
-   bool registerFactory(ossimProjectionFactoryBase* factory,
-                        bool pushToFrontFlag=false);
-   
-   void unregisterFactory(ossimProjectionFactoryBase* factory);
-   bool findFactory(ossimProjectionFactoryBase* factory)const;
-   
+   virtual void getTypeNameList(std::vector<ossimString>& typeList)const
+   {
+      getAllTypeNamesFromRegistry(typeList);
+   }
+      
 protected:
    ossimProjectionFactoryRegistry();
    ossimProjectionFactoryRegistry(const ossimProjectionFactoryRegistry& rhs);
    void operator = (const ossimProjectionFactoryRegistry&);
 
-   std::vector<ossimProjectionFactoryBase*> theFactoryList;
-
+   static ossimProjectionFactoryRegistry* m_instance;
    void initializeDefaults();
 };
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimQuadProjection.h b/Utilities/otbossim/include/ossim/projection/ossimQuadProjection.h
index ec40e9ebb600080741581f88a11e274f61714786..b8c54efe09d7655e4ac652ea1aa87cdcfa6b8e72 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimQuadProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimQuadProjection.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 // 
 //********************************************************************
-// $Id: ossimQuadProjection.h 11805 2007-10-05 14:54:28Z dburken $
+// $Id: ossimQuadProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimQuadProjection_HEADER
 #define ossimQuadProjection_HEADER
 
@@ -24,7 +24,6 @@ class ossimQuadProjection : public ossimProjection
                        const ossimGpt& lrg,
                        const ossimGpt& llg);
                        
-   virtual ~ossimQuadProjection();
    virtual ossimObject *dup()const;
    virtual ossimGpt origin()const;
    
@@ -63,6 +62,8 @@ class ossimQuadProjection : public ossimProjection
    virtual bool isAffectedByElevation() const { return false; }
 
  protected:
+   virtual ~ossimQuadProjection();
+   
    ossimIrect theInputRect;
    ossimGpt theUlg;
    ossimGpt theUrg;
diff --git a/Utilities/otbossim/include/ossim/projection/ossimRpcModel.h b/Utilities/otbossim/include/ossim/projection/ossimRpcModel.h
index 27cfaf0b8176ef7ab0ed9ae99cfb8e9c194c0ff6..e8b5b8a63404849f95b93b4a2ec80c051a4619b1 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimRpcModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimRpcModel.h
@@ -11,7 +11,7 @@
 //   (USM).
 //
 //*****************************************************************************
-//  $Id: ossimRpcModel.h 11521 2007-08-07 21:55:58Z dburken $
+//  $Id: ossimRpcModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimRpcModel_HEADER
 #define ossimRpcModel_HEADER
@@ -65,9 +65,6 @@ public:
    /** @brief copy construtor */
    ossimRpcModel(const ossimRpcModel& copy_this);
 
-   /** @brief virtual destructor */
-   virtual ~ossimRpcModel();
-
    void setAttributes(ossim_float64 theSampleOffset,
                       ossim_float64 theLineOffset,
                       ossim_float64 theSampleScale,
@@ -234,6 +231,9 @@ protected:
       NUM_ADJUSTABLE_PARAMS // not an index
    };
 
+   /** @brief virtual destructor */
+   virtual ~ossimRpcModel();
+   
    //***
    // Methods for computing RPC polynomial and its derivatives:
    //***
diff --git a/Utilities/otbossim/include/ossim/projection/ossimRpcSolver.h b/Utilities/otbossim/include/ossim/projection/ossimRpcSolver.h
index db652f0ee4fc85e2cdfe0be3fc7968181176712f..2a281f3ac9aa71e4cc629d2c69de0e260c0bfd48 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimRpcSolver.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimRpcSolver.h
@@ -1,16 +1,14 @@
 //*****************************************************************************
 // FILE: ossimRpcModel.h
 //
-// Copyright (C) 2004 Intelligence Data Systems, Inc.
-//
-// LICENSE: LGPL
-//
-// see top level LICENSE.txt
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR: Garrett Potts
 //
 //*****************************************************************************
-//  $Id: ossimRpcSolver.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimRpcSolver.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimRpcSolver_HEADER
 #define ossimRpcSolver_HEADER
 
@@ -19,33 +17,37 @@
 #include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimGpt.h>
 #include <ossim/base/ossimDrect.h>
+#include <ossim/base/ossimReferenced.h>
 #include <ossim/matrix/newmat.h>
 #include <ossim/projection/ossimRpcModel.h>
 #include <ossim/projection/ossimRpcProjection.h>
 
 class ossimProjection;
+class ossimImageGeometry;
 class ossimNitfRegisteredTag;
 
-
 /**
- * This currently only support Rational poilynomial B format.  This can be found in
- * the NITF registered commercial tag document.
+ * This currently only support Rational poilynomial B format.  This can be
+ * found in the NITF registered commercial tag document.
+ *
+ * @note x=longitude, y=latitude, z=height
  * 
  * <pre>
  * Format is:
- *          coeff[ 0]       + coeff[ 1]*x     + coeff[ 2]*y     + coeff[ 3]*z     +
- *          coeff[ 4]*x*y   + coeff[ 5]*x*z   + coeff[ 6]*y*z   + coeff[ 7]*x*x   +
- *          coeff[ 8]*y*y   + coeff[ 9]*z*z   + coeff[10]*x*y*z + coeff[11]*x*x*x +
- *          coeff[12]*x*y*y + coeff[13]*x*z*z + coeff[14]*x*x*y + coeff[15]*y*y*y +
- *          coeff[16]*y*z*z + coeff[17]*x*x*z + coeff[18]*y*y*z + coeff[19]*z*z*z;
+ *  coeff[ 0]       + coeff[ 1]*x     + coeff[ 2]*y     + coeff[ 3]*z     +
+ *  coeff[ 4]*x*y   + coeff[ 5]*x*z   + coeff[ 6]*y*z   + coeff[ 7]*x*x   +
+ *  coeff[ 8]*y*y   + coeff[ 9]*z*z   + coeff[10]*x*y*z + coeff[11]*x*x*x +
+ *  coeff[12]*x*y*y + coeff[13]*x*z*z + coeff[14]*x*x*y + coeff[15]*y*y*y +
+ *  coeff[16]*y*z*z + coeff[17]*x*x*z + coeff[18]*y*y*z + coeff[19]*z*z*z;
  *
  *       where coeff is one of XNum, XDen, YNum, and YDen.  So there are 80
  *       coefficients all together.
  *
  *       
- * Currently we use a linear least squares fit to solve the coefficients.  This is the simplest
- * to implement.  We probably relly need a nonlinear minimizer to fit the coefficients but I don't have
- * time to experiment.  Levenberg Marquardt might be a solution to look into.
+ * Currently we use a linear least squares fit to solve the coefficients.
+ * This is the simplest to implement.  We probably relly need a nonlinear
+ * minimizer to fit the coefficients but I don't have time to experiment.
+ * Levenberg Marquardt might be a solution to look into.
  *
  *
  * 
@@ -70,30 +72,36 @@ class ossimNitfRegisteredTag;
  * </pre>
  * 
  */ 
-class OSSIM_DLL ossimRpcSolver
+class OSSIM_DLL ossimRpcSolver : public ossimReferenced
 {
 public:
    /**
-    * The use elvation flag will deterimne if we force the height t be 0.  If the elevation
-    * is enabled then we use the height field of the control points to determine the
-    * coefficients of the RPC00 polynomial.  If its false then we will ignore the height
-    * by setting the height field to 0.0.
+    * The use elvation flag will deterimne if we force the height t be 0.
+    * If the elevation is enabled then we use the height field of the control
+    * points to determine the coefficients of the RPC00 polynomial.  If its
+    * false then we will ignore the height by setting the height field to 0.0.
     *
     * Note:  even if the elevation is enabled all NAN heights are set to 0.0.
     */
    ossimRpcSolver(bool useElevation=false,
                   bool useHeightAboveMSLFlag=false);
 
-	virtual ~ossimRpcSolver(){}
+   
    /**
     * This will convert any projector to an RPC model
     */
    void solveCoefficients(const ossimDrect& imageBouunds,
-                          const ossimProjection& imageProj,
+                          ossimProjection* imageProj,
                           ossim_uint32 xSamples=8,
                           ossim_uint32 ySamples=8,
                           bool shiftTo0Flag=true);
-
+   
+   void solveCoefficients(const ossimDrect& imageBouunds,
+                          ossimImageGeometry* geom,
+                          ossim_uint32 xSamples=8,
+                          ossim_uint32 ySamples=8,
+                          bool shiftTo0Flag=true);
+   
    /**
     * takes associated image points and ground points
     * and solves the coefficents for the rational polynomial for
@@ -109,13 +117,13 @@ public:
    /**
     * Creates and Rpc model from the coefficients
     */
-   ossimRefPtr<ossimRpcModel> createRpcModel()const;
+   ossimImageGeometry* createRpcModel()const;
 
    /**
     * Create a simple rpc projection which is a dumbed down
     * rpc model.
     */
-   ossimRefPtr<ossimRpcProjection> createRpcProjection()const;
+   ossimImageGeometry* createRpcProjection()const;
 
 
    /**
@@ -164,6 +172,8 @@ public:
    ossimRefPtr<ossimNitfRegisteredTag> getNitfRpcBTag() const;
    
 protected:
+	virtual ~ossimRpcSolver(){}
+   
    virtual void solveInitialCoefficients(NEWMAT::ColumnVector& coeff,
                                          const std::vector<double>& f,
                                          const std::vector<double>& x,
diff --git a/Utilities/otbossim/include/ossim/projection/ossimSarModel.h b/Utilities/otbossim/include/ossim/projection/ossimSarModel.h
index e8dfd685f8e36eb4f5da51a1b7b259613c8ca94b..4306da770d4dff8945e21296ea2e3b19e3709635 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimSarModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimSarModel.h
@@ -14,7 +14,7 @@
 //                    21 Mar 2006, paragraph E.3.8, SAR MPDSR
 //
 //----------------------------------------------------------------------------
-// $Id: ossimSarModel.h 11166 2007-06-07 14:12:54Z dburken $
+// $Id: ossimSarModel.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimSarModel_HEADER
 #define ossimSarModel_HEADER
 
@@ -48,9 +48,6 @@ public:
    /** @brief default constructor */
    ossimSarModel();
 
-   /** @brief virtual destructor */
-   virtual ~ossimSarModel();
-
    /**
     * @brief Method to load or recreate the state of an ossimSarModel from
     * a keyword list.
@@ -148,7 +145,10 @@ public:
       const ossimDpt& ipos, NEWMAT::SymmetricMatrix& Cov);
    
 protected:
-
+   /** @brief virtual destructor */
+   virtual ~ossimSarModel();
+   
+   
    /*!
     * Assigns initial default values to adjustable parameters and related
     * members.
diff --git a/Utilities/otbossim/include/ossim/projection/ossimSensorModel.h b/Utilities/otbossim/include/ossim/projection/ossimSensorModel.h
index 01d735e96d5690ccec1b578ee7a487f6b8f8eb7a..a5c8b62081b60de767d44afbaf0ca3f6ecd91c16 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimSensorModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimSensorModel.h
@@ -25,7 +25,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimSensorModel.h 13673 2008-10-03 15:10:52Z gpotts $
+//  $Id: ossimSensorModel.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimSensorModel_HEADER
 #define ossimSensorModel_HEADER
@@ -80,8 +80,6 @@ public:
    ossimSensorModel(const ossimSensorModel& copy_this);
    ossimSensorModel(const ossimKeywordlist& geom_kwl);
 
-   virtual ~ossimSensorModel();
-
    virtual ossimObject* getBaseObject();
    virtual const ossimObject* getBaseObject()const;
    
@@ -245,6 +243,8 @@ public:
    virtual bool isAffectedByElevation() const { return true; }
    
 protected:
+   virtual ~ossimSensorModel();
+   
    /*!
     * METHOD: extrapolate()
     * Extrapolates solutions for points outside of the image. The second
diff --git a/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h b/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h
index 22b8b1e5c9698825fa3954633e6f0d821f22fc5c..4f968dc98779adf244f6916be97b98eca154408f 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h
@@ -10,7 +10,7 @@
 // Contains declaration of class ossimSpot5Model.
 // 
 //*****************************************************************************
-// $Id: ossimSpot5Model.h 13976 2009-01-20 16:00:16Z gpotts $
+// $Id: ossimSpot5Model.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimSpot5Model_HEADER
 #define ossimSpot5Model_HEADER
 
@@ -125,7 +125,7 @@ protected:
 /*    virtual ossimGpt extrapolate (const ossimDpt& ip, */
 /* 				 const double& height=ossim::nan()) const; */
 
-   ossimSpotDimapSupportData* theSupportData;
+   ossimRefPtr<ossimSpotDimapSupportData> theSupportData;
 
    //---
    // Image constant parameters:
diff --git a/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionFactory.h b/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionFactory.h
index 87cab62170fc2ad39b5238e4df1d7bd8cdc5d28f..13ab7dc234c59219044823170fb9a5831d9bf4e6 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionFactory.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionFactory.h
@@ -4,7 +4,7 @@
 //
 // Author: Garrett Potts
 //*******************************************************************
-//  $Id: ossimStatePlaneProjectionFactory.h 12623 2008-04-07 14:10:08Z gpotts $
+//  $Id: ossimStatePlaneProjectionFactory.h 15080 2009-08-15 19:32:07Z dburken $
 #ifndef ossimStatePlaneProjectionFactory_HEADER
 #define ossimStatePlaneProjectionFactory_HEADER
 #include <ossim/projection/ossimProjectionFactoryBase.h>
@@ -42,7 +42,7 @@ public:
                                              const char* prefix=0)const;
 
    virtual const ossimStatePlaneProjectionInfo* getInfo(
-      ossim_int32 pcsCode)const;
+      ossim_uint32 pcsCode)const;
    
    const ossimStatePlaneProjectionInfo* getInfo(const ossimString& name)const;
    virtual ossimObject* createObject(const ossimString& typeName)const;
diff --git a/Utilities/otbossim/include/ossim/projection/ossimTiffProjectionFactory.h b/Utilities/otbossim/include/ossim/projection/ossimTiffProjectionFactory.h
index f96cf8384dc5f68cf36c91bfdb72938383fd1cee..3e3f075e0659f8406b84200461f39ddb7b9eab7f 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimTiffProjectionFactory.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimTiffProjectionFactory.h
@@ -11,7 +11,7 @@
 // a projection name and a datum if desired.  Currently the default
 // datum will be WGS84.
 //*******************************************************************
-//  $Id: ossimTiffProjectionFactory.h 12081 2007-11-26 21:44:18Z dburken $
+//  $Id: ossimTiffProjectionFactory.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimTiffProjectionFactory_HEADER
 #define ossimTiffProjectionFactory_HEADER
@@ -40,6 +40,7 @@ public:
    virtual ossimProjection* createProjection(const ossimString& name)const;
    virtual ossimProjection* createProjection(const ossimKeywordlist& kwl,
                                              const char* prefix = 0)const;
+   ossimProjection* createProjection(ossimImageHandler* handler)const;
 
    virtual ossimObject* createObject(const ossimString& typeName)const;
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimWarpProjection.h b/Utilities/otbossim/include/ossim/projection/ossimWarpProjection.h
index 1c9a2b572423b17947d4ba05521a2dcfc1881a1f..901f75a6d7de6c0f1f3756495117522b36e1a8f8 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimWarpProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimWarpProjection.h
@@ -9,7 +9,7 @@
 //   implementation of a warping interpolation model.
 //
 //*****************************************************************************
-//  $Id: ossimWarpProjection.h 11805 2007-10-05 14:54:28Z dburken $
+//  $Id: ossimWarpProjection.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimWarpProjection_HEADER
 #define ossimWarpProjection_HEADER
@@ -102,15 +102,15 @@ public:
 
    virtual ossim2dTo2dTransform* getWarpTransform()
       {
-         return theWarpTransform;
+         return theWarpTransform.get();
       }
    virtual ossim2dTo2dTransform* getAffineTransform()
       {
-         return theAffineTransform;
+         return theAffineTransform.get();
       }
    virtual ossimProjection* getClientProjection()
       {
-         return theClientProjection;
+         return theClientProjection.get();
       }
    virtual void setNewWarpTransform(ossim2dTo2dTransform* warp);
    virtual void setNewAffineTransform(ossim2dTo2dTransform* affine);
@@ -128,18 +128,18 @@ protected:
    /*!
     * Data Members:
     */
-   ossimProjection*      theClientProjection;
-   ossim2dTo2dTransform* theWarpTransform;
-   ossim2dTo2dTransform* theAffineTransform;
+   ossimRefPtr<ossimProjection>      theClientProjection;
+   ossimRefPtr<ossim2dTo2dTransform> theWarpTransform;
+   ossimRefPtr<ossim2dTo2dTransform> theAffineTransform;
    
    TYPE_DATA
 };
 
 inline bool ossimWarpProjection::isAffectedByElevation() const
 {
-   return ( theClientProjection ?
+   return ( theClientProjection.valid() ?
             theClientProjection->isAffectedByElevation() :
-            true );
+            false );
 }
 
 #endif
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimDemHeader.h b/Utilities/otbossim/include/ossim/support_data/ossimDemHeader.h
index f8836394c1b459fb0f61d8de1a1a3f967e49d525..3684e97321a97f1765ebf342bea6fdc3a41fbf89 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimDemHeader.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimDemHeader.h
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Ken Melero
 //         Orginally written by Jamie Moyers (jmoyers@geeks.com)
@@ -8,7 +10,7 @@
 // Description: This class parses a DEM header.
 //
 //********************************************************************
-// $Id: ossimDemHeader.h 10263 2007-01-14 19:06:41Z dburken $
+// $Id: ossimDemHeader.h 15309 2009-09-01 15:47:15Z dburken $
 
 #ifndef ossimDemHeader_HEADER
 #define ossimDemHeader_HEADER
@@ -19,6 +21,7 @@
 #include <ossim/base/ossimConstants.h>
 #include <ossim/support_data/ossimDemPoint.h>
 
+class ossimFilename;
 class ossimString;
 class ossimKeywordlist;
 
@@ -32,9 +35,33 @@ public:
                                              const ossimDemHeader& header);
    friend OSSIM_DLL std::istream& operator>>(std::istream& s,
                                              ossimDemHeader& header);
-   
-   std::ostream& print(std::ostream& s) const;
-   
+
+   /**
+    * @brief open method that takes a file.
+    *
+    * @param file File name to open.
+    *
+    * @return true on success false on error.
+    */
+   bool open(const ossimFilename& file);
+
+   /**
+    * @brief open method that takes a stream.
+    *
+    * @param is The input stream to read from.
+    *
+    * @return stream
+    */
+   std::istream& open(std::istream& is);
+
+   /**
+    * Print method.
+    *
+    * @param out Stream to print to.
+    * 
+    * @return std::ostream&
+    */   
+   std::ostream& print(std::ostream& out) const;
    
    // Accessors
 
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimDemInfo.h b/Utilities/otbossim/include/ossim/support_data/ossimDemInfo.h
new file mode 100644
index 0000000000000000000000000000000000000000..43acf981a103ad9ee7c16c1d3eda320f8795cfa6
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimDemInfo.h
@@ -0,0 +1,58 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: USGS DEM Info object.
+// 
+//----------------------------------------------------------------------------
+// $Id$
+#ifndef ossimDemInfo_HEADER
+#define ossimDemInfo_HEADER
+
+#include <iosfwd>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/support_data/ossimInfoBase.h>
+
+/**
+ * @brief USGS DEM info class.
+ *
+ * Encapsulates the dumpnitf functionality.
+ */
+class OSSIM_DLL ossimDemInfo : public ossimInfoBase
+{
+public:
+   
+   /** default constructor */
+   ossimDemInfo();
+
+   /** virtual destructor */
+   virtual ~ossimDemInfo();
+
+   /**
+    * @brief open method.
+    *
+    * @param file File name to open.
+    *
+    * @return true on success false on error.
+    */
+   virtual bool open(const ossimFilename& file);
+   
+   /**
+    * Print method.
+    *
+    * @param out Stream to print to.
+    * 
+    * @return std::ostream&
+    */
+   virtual std::ostream& print(std::ostream& out) const;
+
+private:
+   ossimFilename theFile;
+};
+
+#endif /* End of "#ifndef ossimDemInfo_HEADER" */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimDemUtil.h b/Utilities/otbossim/include/ossim/support_data/ossimDemUtil.h
index dbb838546e2b8f9516ebea34ad618b9c3e811aeb..de8053bbcc660b7b24b1eb927846ab092c33d1b1 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimDemUtil.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimDemUtil.h
@@ -11,7 +11,7 @@
 // Description: This class provides some simple utilities for DEMs.
 //
 //********************************************************************
-// $Id: ossimDemUtil.h 14482 2009-05-12 11:42:38Z gpotts $
+// $Id: ossimDemUtil.h 15307 2009-09-01 15:41:07Z dburken $
 
 #ifndef ossimDemUtil_HEADER
 #define ossimDemUtil_HEADER
@@ -22,10 +22,32 @@
 #include <iostream>
 #include <fstream>
 
+class ossimFilename;
+
 class ossimDemUtil
 {
 public:
 
+   /**
+    * @brief Does basic sanity checks to see if file is a dem.
+    *
+    * 1) Check extension for .dem
+    *
+    * 2) Look for file.omd (ossim meta data) file containing keyword
+    *    "dem_type" with value of "usgs_dem".
+    *
+    * 3) Check 512 bytes and make sure there is no binary data.
+    *
+    * @note
+    * There is a keyword list template stored in the templates directory:
+    * "ossim/etc/templates/usgs_dem_template.kwl"
+    *
+    * @param file The file to check.
+    *
+    * @return true on success, false on error.
+    */
+   static bool isUsgsDem(const ossimFilename& file);
+
    /**
     *  Reads a single record from a DEM.
     *  Returns true if succesful. Returns false if EOF or error.
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimFfL5.h b/Utilities/otbossim/include/ossim/support_data/ossimFfL5.h
index dd9a35a3e1dea9fef2696b4c8c1b57cad886a324..56389302ff22356f4bdb1ac6d6ae5cc058fdc444 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimFfL5.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimFfL5.h
@@ -7,7 +7,7 @@
 // Description: Container class for LandSat5 Fast Format header files (RevB & C)
 //
 // ********************************************************************
-// $Id: ossimFfL5.h 10384 2007-01-26 20:32:12Z gpotts $
+// $Id: ossimFfL5.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimFfL5_HEADER
 #define ossimFfL5_HEADER
@@ -31,10 +31,12 @@ class OSSIM_DLL ossimFfL5 : public ossimFfL7
 public:
    ossimFfL5();
    ossimFfL5(const char* headerFile);
-   virtual ~ossimFfL5();
    ossimRefPtr<ossimFfRevb> revb();
    const ossimRefPtr<ossimFfRevb> revb()const;
-   
+ 
+protected:
+   virtual ~ossimFfL5();
+
 private:
    void    readHeaderRevB(const ossimString& header_name);
    int     convertGeoPoint(const char* sptr, ossimGpt& geo_point);
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimFfL7.h b/Utilities/otbossim/include/ossim/support_data/ossimFfL7.h
index 9245581daf07d997c8e0c8329cf22641908608f8..5f5cb75d580edade7e5443d823e5b781f19cfb39 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimFfL7.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimFfL7.h
@@ -8,7 +8,7 @@
 // Description: Container class for LandSat7 Fast Format header files.
 //
 //********************************************************************
-// $Id: ossimFfL7.h 10749 2007-04-23 16:46:15Z dburken $
+// $Id: ossimFfL7.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimFfL7_HEADER
 #define ossimFfL7_HEADER
@@ -42,7 +42,6 @@ class OSSIMDLLEXPORT ossimFfL7 : public ossimReferenced,
 public:
    ossimFfL7  ();
    ossimFfL7  (const char* headerFile);
-   virtual ~ossimFfL7();
    
    void   dump(std::ostream& os) const;
       //> Provides a readable dump of this object.
@@ -178,6 +177,9 @@ public:
    double  theSunElevation;       // degrees
    double  theSunAzimuth;         // degrees
 
+protected:
+   virtual ~ossimFfL7();
+
 private:
    
    void initialize();
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimGeoTiff.h b/Utilities/otbossim/include/ossim/support_data/ossimGeoTiff.h
index 88e192ddaf8eccdd226069378cef2e691ac6d6ee..bda548d26e012f905f53678a87ab3d7d766f6fdb 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimGeoTiff.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimGeoTiff.h
@@ -3,35 +3,42 @@
 //
 // License:  See top level LICENSE.txt file.
 //
-// Author:  David Burken
-//
 // Description:
-// Class definition for ossimGeoTiff which is designed to read and hold tag
+// 
+// Class declaration for ossimGeoTiff which is designed to read and hold tag
 // information.
 //
 //***************************************************************************
-// $Id: ossimGeoTiff.h 12058 2007-11-16 19:31:11Z dburken $
+// $Id: ossimGeoTiff.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimGeoTiff_HEADER
-#define ossimGeoTiff_HEADER
+#define ossimGeoTiff_HEADER 1
+#include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimErrorStatusInterface.h>
 #include <ossim/base/ossimEndian.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
 #include <ossim/base/ossimRefPtr.h>
-  // #include <stdio.h>
+
 #include <vector>
 
 #include <tiffio.h>
+#include <geo_normalize.h>
+#include <OpenThreads/Mutex>
+#include <OpenThreads/ScopedLock>
 
 class ossimFilename;
 class ossimKeywordlist;
 class ossimTieGptSet;
 
-class ossimGeoTiff : public ossimErrorStatusInterface
+class OSSIM_DLL ossimGeoTiff : public ossimErrorStatusInterface
 {
 public:
+   /** default constructor */
+   ossimGeoTiff();
+
    ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx=0);
+
    ~ossimGeoTiff();
   
    enum
@@ -89,7 +96,7 @@ public:
 /*       PHOTO_YCBCR       = 6,   // !CCIR 601  */
 /*       PHOTO_CIELAB      = 8    // !1976 CIE L*a*b* */
 /*    }; */
-
+#if 0
    enum ModelType
    {
       UNKNOWN               = 0,
@@ -97,7 +104,7 @@ public:
       MODEL_TYPE_GEOGRAPHIC = 2,  // Geographic latitude-longitude System 
       MODEL_TYPE_GEOCENTRIC = 3
    };
-
+#endif
    static int getPcsUnitType(ossim_int32 pcsCode);
 
    static bool writeTags(TIFF* tiffOut,
@@ -110,6 +117,26 @@ public:
     */
    bool readTags(const ossimFilename& file, ossim_uint32 entryIdx=0);
 
+   /**
+    * @brief Method to parse the tiff file from an open tiff pointer for a
+    * given index.
+    *
+    * This will initialize this container for a subsequent call to
+    * addImageGeometry.
+    * 
+    * @param tiff The opened TIFF* to read from.
+    * 
+    * @param entryIdx Entry (tiff directory) to read.
+    *
+    * @param ownTiffPtrFlag If true the tiff pointer will be deleted by this
+    * object; else, it will simply zero out the pointer at the end of method.
+    * This allows for external code to pass in their open tiff pointer
+    * without this object closing it.
+    *
+    * @return true on success, false on error.
+    */
+   bool readTags(TIFF* tiff, ossim_uint32 entryIdx, bool ownTiffPtrFlag);
+
    /**
     *  Returns the map zone as an interger.
     */
@@ -220,7 +247,7 @@ private:
    ossim_uint32          theLength;                        // tag 257
    ossim_uint16          theBitsPerSample;                 // tag 258
 
-   ModelType             theModelType;                     // key 1024
+   ossim_uint16          theModelType;                     // key 1024
    ossim_uint16          theRasterType;                    // key 1025
    ossim_uint16          theGcsCode;                       // key 2048
    ossim_uint16          theDatumCode;                     // key 2050
@@ -237,9 +264,11 @@ private:
    mutable double        theOriginLat;                     // key 3081
    double                theFalseEasting;                  // key 3082
    double                theFalseNorthing;                 // key 3083
-   mutable double        theCenterLon;                     // key 3088
-   mutable double        theCenterLat;                     // key 3099
    double                theScaleFactor;                   // key 3092
+   
+   GTIFDefn*             theNormalizedDefinitions;
+   static OpenThreads::Mutex theMutex;
+
 };
 
 #endif
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimIkonosMetaData.h b/Utilities/otbossim/include/ossim/support_data/ossimIkonosMetaData.h
index cab0ffee899417618457c09b9ca6cc3df732045d..0ecece7ac2796ac55c7e9c240d5d1f4cc55d81c3 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimIkonosMetaData.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimIkonosMetaData.h
@@ -9,7 +9,7 @@
 // This class parses a Space Imaging Ikonos meta data file.
 //
 //********************************************************************
-// $Id: ossimIkonosMetaData.h 14412 2009-04-27 16:58:46Z dburken $
+// $Id: ossimIkonosMetaData.h 15766 2009-10-20 12:37:09Z gpotts $
 
 #ifndef ossimIkonosMetaData_HEADER
 #define ossimIkonosMetaData_HEADER
@@ -31,8 +31,6 @@ public:
    /** @brief default constructor */
    ossimIkonosMetaData();
 
-   /** virtual destructor */
-   virtual ~ossimIkonosMetaData();
 
    /**
     * @brief Open method that takes the image file, derives the metadata,
@@ -99,7 +97,11 @@ public:
     * @note Currently NOT implemented.
     */
    bool parseRpcData(const ossimFilename& data_file);
-   
+
+protected:
+   /** virtual destructor */
+   virtual ~ossimIkonosMetaData();
+
 private:
    ossim_float64 theNominalCollectionAzimuth;
    ossim_float64 theNominalCollectionElevation;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimInfoBase.h b/Utilities/otbossim/include/ossim/support_data/ossimInfoBase.h
index c95ce726db84d61f560828e5efc3c5b742ad2eda..13c2e839d68263210ac0cc1cac1c757fc5f31718 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimInfoBase.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimInfoBase.h
@@ -18,6 +18,7 @@
 #include <ossim/base/ossimConstants.h>
 
 class ossimFilename;
+class ossimKeywordlist;
 
 /**
  * @brief Info Base.
@@ -65,6 +66,13 @@ public:
     */
    bool getProcessOverviewFlag() const;
 
+   /**
+    * @brief Method to dump info to a keyword list.
+    * @param kwl The keyword list to initialize.
+    * @return true on success, false on error.
+    */
+   bool getKeywordlist(ossimKeywordlist& kwl);
+
 protected:
    
    bool theOverviewFlag; // If true overview information should be processed.
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimInfoFactoryRegistry.h b/Utilities/otbossim/include/ossim/support_data/ossimInfoFactoryRegistry.h
index ab7b93b5f5f35fcd383aeb4be0e6b2c8c7853247..28be53865443c4fce073153c30334fbac3e6cc0a 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimInfoFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimInfoFactoryRegistry.h
@@ -40,6 +40,13 @@ public:
     */
    void registerFactory(ossimInfoFactoryInterface* factory);
 
+   /**
+    * Method to remove a factory from the registry.  Used by plugins when they
+    * are unloaded.
+    * @param factory Factory to remove.
+    */
+   void unregisterFactory(ossimInfoFactoryInterface* factory);
+
    /**
     * @brief Create method.
     *
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimJ2kCodRecord.h b/Utilities/otbossim/include/ossim/support_data/ossimJ2kCodRecord.h
new file mode 100644
index 0000000000000000000000000000000000000000..e915f1d687bf80407ab7b2dd33e284a990e1ae59
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimJ2kCodRecord.h
@@ -0,0 +1,75 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Container class for J2K Coding style default (COD) record.
+//
+// See document BPJ2K01.00 Table 7-7 Image and tile size (15444-1 Annex A5.1)
+// 
+//----------------------------------------------------------------------------
+// $Id: ossimJ2kCodRecord.h,v 1.5 2005/10/13 21:24:47 dburken Exp $
+#ifndef ossimJ2kCodRecord_HEADER
+#define ossimJ2kCodRecord_HEADER
+
+#include <iosfwd>
+#include <string>
+
+#include <ossim/base/ossimConstants.h>
+
+class OSSIM_DLL ossimJ2kCodRecord
+{
+public:
+   
+   /** default constructor */
+   ossimJ2kCodRecord();
+
+   /** destructor */
+   ~ossimJ2kCodRecord();
+
+   /**
+    * Parse method.  Performs byte swapping as needed.
+    *
+    * @param in Stream to parse.
+    *
+    * @note COD Marker (0xff52) is not read.
+    */
+   void parseStream(std::istream& in);
+
+   /**
+    * @brief print method that outputs a key/value type format adding prefix
+    * to keys.
+    * @param out String to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "j2k." and key is "file_name" key becomes:
+    * "nitf.file_name:"
+    * @return output stream.
+    */
+   std::ostream& print(std::ostream& out,
+                       const std::string& prefix=std::string()) const;
+
+   /** operator<< */
+   friend OSSIM_DLL std::ostream& operator<<(
+      std::ostream& out, const ossimJ2kCodRecord& obj);
+
+   /** segmet marker 0xff52 (big endian) */
+   ossim_uint16 theMarker;
+
+   /** length of segment minus marker */
+   ossim_uint16 theLcod;
+
+   /** Coding style */
+   ossim_uint8 theScod;
+
+   /** Progression order, Number of layers, Multiple component transform. */
+   ossim_uint32 theSGcod;
+
+   /** Code-block style */
+   ossim_uint8 theSPcod;
+
+};
+
+#endif /* End of "#ifndef ossimJ2kCodRecord_HEADER" */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimJ2kInfo.h b/Utilities/otbossim/include/ossim/support_data/ossimJ2kInfo.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6ee298cfb9a5838868bd589f344b1731ab14068
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimJ2kInfo.h
@@ -0,0 +1,124 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: J2K Info object.
+// 
+//----------------------------------------------------------------------------
+// $Id$
+#ifndef ossimJ2kInfo_HEADER
+#define ossimJ2kInfo_HEADER
+
+#include <ossim/base/ossimConstants.h>
+#include <ossim/support_data/ossimInfoBase.h>
+#include <ossim/base/ossimFilename.h>
+
+class ossimEndian;
+
+/**
+ * @brief TIFF info class.
+ *
+ * Encapsulates the listgeo functionality.
+ */
+class OSSIM_DLL ossimJ2kInfo : public ossimInfoBase
+{
+public:
+   
+   /** default constructor */
+   ossimJ2kInfo();
+
+   /** virtual destructor */
+   virtual ~ossimJ2kInfo();
+
+   /**
+    * @brief open method.
+    *
+    * @param file File name to open.
+    *
+    * @return true on success false on error.
+    */
+   virtual bool open(const ossimFilename& file);
+   
+   /**
+    * Print method.
+    *
+    * @param out Stream to print to.
+    * 
+    * @return std::ostream&
+    */
+   virtual std::ostream& print(std::ostream& out) const;
+
+private:
+
+/** Initializes s reference.  Does byte swapping as needed. */
+   void readShort(ossim_uint16& s, std::ifstream& str) const;
+
+   /**
+    * @brief Prints 0xff52 COD_MARKER (0xff52).
+    * @param out Stream to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "j2k." and key is "file_name" key becomes:
+    * "j2k.file_name:"
+    * @param str Input stream to pass to j2k record for parsing.  Should be
+    * just pass the marker.
+    * @return output stream.
+    */
+   std::ostream& printCodMarker(std::ostream& out,
+                                const std::string& prefix,
+                                std::ifstream& str) const;
+
+   /**
+    * @brief Prints 0xff51 SIZ_MARKER (0xff51).
+    * @param out Stream to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "j2k." and key is "file_name" key becomes:
+    * "j2k.file_name:"
+    * @param str Input stream to pass to j2k record for parsing.  Should be
+    * just pass the marker.
+    * @return output stream.
+    */
+   std::ostream& printSizMarker(std::ostream& out,
+                                const std::string& prefix,
+                                std::ifstream& str) const;
+
+   /**
+    * @brief Prints 0xff90 SOT_MARKER (0xff90)
+    * @param out Stream to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "j2k." and key is "file_name" key becomes:
+    * "j2k.file_name:"
+    * @param str Input stream to pass to j2k record for parsing.  Should be
+    * just pass the marker.
+    * @return output stream.
+    */
+   std::ostream& printSotMarker(std::ostream& out,
+                                const std::string& prefix,
+                                std::ifstream& str) const;
+
+   /**
+    * @brief Prints unhandle segment.  This will only print the marker and
+    * record lenght.
+    * @param out Stream to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "j2k." and key is "file_name" key becomes:
+    * "j2k.file_name:"
+    * @param str Input stream to pass to j2k record for parsing.  Should be
+    * just pass the marker.
+    * @param marker.  The marker.
+    * @return output stream.
+    */
+   std::ostream& printUnknownMarker(std::ostream& out,
+                                    const std::string& prefix,
+                                    std::ifstream& str,
+                                    ossim_uint16 marker) const;
+
+   
+   ossimFilename  theFile;
+   ossimEndian*   theEndian;
+};
+
+#endif /* End of "#ifndef ossimJ2kInfo_HEADER" */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h
index df540e368f6573936ed78f7e62578da6e2923806..47d0e85b1ef79cc571caedb8b7d88afca919f1b6 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h
@@ -16,6 +16,7 @@
 #define ossimJ2kSizRecord_HEADER
 
 #include <iosfwd>
+#include <string>
 
 #include <ossim/base/ossimConstants.h>
 
@@ -42,20 +43,23 @@ public:
    ossimScalarType getScalarType() const;
 
    /**
-    * Print method.
-    *
-    * @param out Stream to print to.
-    * 
-    * @return std::ostream&
+    * @brief print method that outputs a key/value type format adding prefix
+    * to keys.
+    * @param out String to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "nitf." and key is "file_name" key becomes:
+    * "nitf.file_name:"
+    * @return output stream.
     */
-   std::ostream& print(std::ostream& out) const;
+   std::ostream& print(std::ostream& out,
+                       const std::string& prefix=std::string()) const;
 
    /** operator<< */
    friend OSSIM_DLL std::ostream& operator<<(
       std::ostream& out, const ossimJ2kSizRecord& obj);
 
    /** segmet marker 0xff51 (big endian) */
-   ossim_uint16 theSizMarker;
+   ossim_uint16 theMarker;
 
    /** length of segment minus marker */
    ossim_uint16 theLsiz;
@@ -67,7 +71,7 @@ public:
    ossim_uint32 theXsiz;
 
    /** height of reference grid */
-   ossim_uint32 theYziz;
+   ossim_uint32 theYsiz;
 
    /**
     * Horizontal offset from the orgin of reference grid to the left side
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h
index 8738afb46b6f7be00ae3b64703b5dd790ba39cdb..9b4cdf754d3779fce5331b9837c5aa6f01d55b7a 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h
@@ -16,6 +16,7 @@
 #define ossimJ2kSotRecord_HEADER
 
 #include <iosfwd>
+#include <string>
 
 #include <ossim/base/ossimConstants.h>
 
@@ -39,14 +40,17 @@ public:
    void parseStream(std::istream& in);
 
    /**
-    * Print method.
-    *
-    * @param out Stream to print to.
-    * 
-    * @return std::ostream&
+    * @brief print method that outputs a key/value type format adding prefix
+    * to keys.
+    * @param out String to output to.
+    * @param prefix This will be prepended to key.
+    * e.g. Where prefix = "nitf." and key is "file_name" key becomes:
+    * "nitf.file_name:"
+    * @return output stream.
     */
-   std::ostream& print(std::ostream& out) const;
-
+   std::ostream& print(std::ostream& out,
+                       const std::string& prefix=std::string()) const;
+   
    /**
     * operator<<.
     */
@@ -54,7 +58,7 @@ public:
       std::ostream& out, const ossimJ2kSotRecord& obj);
 
    /** Start of tile-part marker code. 0xff90 */
-   ossim_uint16 theSotMarker;
+   ossim_uint16 theMarker;
    
    /** Length in bytes of the marker segment. */
    ossim_uint16 theLsot;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfAcftbTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfAcftbTag.h
new file mode 100644
index 0000000000000000000000000000000000000000..ae6062f222d677b93e369dbfae6f952604e491fd
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfAcftbTag.h
@@ -0,0 +1,407 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: ACFTB - Aircraft Infomation Extension Format tag class
+// declaration.
+//
+// See document STDI-0002 (version 3), Appendix E, Table E-6 for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#ifndef ossimNitfAcftbTag_HEADER
+#define ossimNitfAcftbTag_HEADER
+
+#include <ossim/support_data/ossimNitfRegisteredTag.h>
+
+class OSSIM_DLL ossimNitfAcftbTag : public ossimNitfRegisteredTag
+{
+public:
+
+   enum 
+   {
+      CEL_SIZE               = 207,
+      AC_MSN_ID_SIZE         = 20,
+      AC_TAIL_NO_SIZE        = 10,
+      AC_TO_SIZE             = 12,
+      SENSOR_ID_TYPE_SIZE    = 4,
+      SENSOR_ID_SIZE         = 6,
+      SCENE_SOURCE_SIZE      = 1,
+      SCNUM_SIZE             = 6,
+      PDATE_SIZE             = 8,
+      IMHOSTNO_SIZE          = 6,
+      IMREQID_SIZE           = 5,
+      MPLAN_SIZE             = 3,
+      ENTLOC_SIZE            = 25,
+      LOC_ACCY_SIZE          = 6,
+      ENTELV_SIZE            = 6,
+      ELV_UNIT_SIZE          = 1,
+      EXITLOC_SIZE           = 25,
+      EXITELV_SIZE           = 6,
+      TMAP_SIZE              = 7,
+      ROW_SPACING_SIZE       = 7,
+      ROW_SPACING_UNITS_SIZE = 1,
+      COL_SPACING_SIZE       = 7,
+      COL_SPACING_UINTS_SIZE = 1,
+      FOCAL_LENGTH_SIZE      = 6,
+      SENSERIAL_SIZE         = 6,
+      ABSWVER_SIZE           = 7,
+      CAL_DATE_SIZE          = 8,
+      PATCH_TOT_SIZE         = 4,
+      MTI_TOT_SIZE           = 3
+   };
+   
+   /** @brief default constructor */
+   ossimNitfAcftbTag();
+
+   /** @brief destructor */
+   virtual ~ossimNitfAcftbTag();
+
+   /**
+    * @brief Method to return tag name.
+    * @return "ACFTB" as an ossimString.
+    */
+   virtual ossimString getRegisterTagName()const;
+
+   /** @brief Method to parse data from stream. */
+   virtual void parseStream(std::istream& in);
+
+   /** @brief Method to write data to stream. */
+   virtual void writeStream(std::ostream& out);
+
+   /** @return Byte size of this tag. */
+   virtual ossim_uint32 getSizeInBytes()const;
+
+   /** @brief Method to clear all fields including null terminating. */
+   virtual void clearFields();
+
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
+   
+protected:
+
+   /** Type R = Required Type <R> = BCS spaces allowed for entire field */
+   
+   /**
+    * FIELD: AC_MSN_ID
+    *
+    * TYPE: R
+    * 
+    * 20 byte field
+    *
+    * Aircraft Mission Identification
+    */
+   char theAcMsnId[AC_MSN_ID_SIZE+1];
+
+   /**
+    * FIELD: AC_TAIL_NO
+    *
+    * TYPE: <R>
+    * 
+    * 10 byte field
+    *
+    * Aircraft Tail Number
+    */
+   char theAcTailNo[AC_TAIL_NO_SIZE+1];
+   
+   /**
+    * FIELD: AC_TO
+    *
+    * TYPE: <R>
+    * 
+    * 12 byte field
+    *
+    * Aircraft Take-off, CCYYMMDDhhmm
+    */
+   char theAcTo[AC_TO_SIZE+1];
+
+   /**
+    * FIELD: SENSOR_ID_TYPE
+    *
+    * TYPE: R
+    * 
+    * 4 byte field
+    *
+    * Sensor ID Type
+    */
+   char theSensorIdType[SENSOR_ID_TYPE_SIZE+1];
+   
+   /**
+    * FIELD: SENSOR_ID
+    *
+    * TYPE: R
+    * 
+    * 6 byte field
+    *
+    * Sensor ID 
+    */
+   char theSensorId[SENSOR_ID_SIZE+1];
+
+   /**
+    * FIELD: SCENE_SOURCE
+    *
+    * TYPE: <R>
+    * 
+    * 1 byte field
+    *
+    * Scene Source, 0 to 9
+    */
+   char theSceneSource[SCENE_SOURCE_SIZE+1];
+   
+   /**
+    * FIELD: SCNUM
+    *
+    * TYPE: R
+    * 
+    * 6 byte field
+    *
+    * Scene Number, 000000 to 999999
+    */
+   char theScNum[SCNUM_SIZE+1];
+
+   /**
+    * FIELD: PDATE
+    *
+    * TYPE: R
+    * 
+    * 8 byte field
+    *
+    * Processing Date, CCYYMMDD
+    */
+   char thePDate[PDATE_SIZE+1];
+   
+   /**
+    * FIELD: IMHOSTNO
+    *
+    * TYPE: R
+    * 
+    * 6 byte field
+    *
+    * Immediate Scene Host
+    */
+   char theImHostNo[IMHOSTNO_SIZE+1];
+
+   /**
+    * FIELD: IMREQID
+    *
+    * TYPE: R
+    * 
+    * 5 byte field
+    *
+    * Immediate Scene Request ID, 00000, 00001 to 99999
+    */
+   char theImReqID[IMREQID_SIZE+1];
+   
+   /**
+    * FIELD: MPLAN
+    *
+    * TYPE: R
+    * 
+    * 3 byte field
+    *
+    * Mission Plan Mode, 001 to 999
+    */
+   char theMPlan[MPLAN_SIZE+1];
+
+   /**
+    * FIELD: ENTLOC
+    *
+    * TYPE: <R>
+    * 
+    * 25 byte field
+    *
+    * Entry Location
+    */
+   char theEntLoc[ENTLOC_SIZE+1];
+
+   /**
+    * FIELD: LOC_ACCY
+    *
+    * TYPE: R
+    * 
+    * 6 byte field
+    *
+    * Location Accuracy, feet, 000.01 to 999.99, 000000, 000.00
+    */
+   char theLocAccy[LOC_ACCY_SIZE+1];
+   
+   /**
+    * FIELD: ENTELV
+    *
+    * TYPE: <R>
+    * 
+    * 6 byte field
+    *
+    * Entry Elevation, feet or meters, -01000 to +30000
+    */
+   char theEntelv[ENTELV_SIZE+1];
+
+   /**
+    * FIELD: ELV_UNIT
+    *
+    * TYPE: <R>
+    * 
+    * 1 byte field
+    *
+    * Unit of Elevation, f or m
+    */
+   char theElvUnit[ELV_UNIT_SIZE+1];
+   
+   /**
+    * FIELD: EXITLOC
+    *
+    * TYPE: <R>
+    * 
+    * 25 byte field
+    *
+    * Exit Location
+    */
+   char theExitLoc[EXITLOC_SIZE+1];
+
+   /**
+    * FIELD: EXITELV
+    *
+    * TYPE: <R>
+    * 
+    * 6 byte field
+    *
+    * Exit Elevation
+    */
+   char theExitElev[EXITELV_SIZE+1];
+   
+   /**
+    * FIELD: TMAP
+    *
+    * TYPE: <R>
+    * 
+    * 7 byte field
+    *
+    * True Map Angle, degrees, 000.000 to 180.000
+    */
+   char theTMap[TMAP_SIZE+1];
+
+   /**
+    * FIELD: ROW_SPACING
+    *
+    * TYPE: R
+    * 
+    * 7 byte field
+    *
+    * Row Spacing, feet, meters, rads. 
+    */
+   char theRowSpacing[ROW_SPACING_SIZE+1];
+
+   /**
+    * FIELD: ROW_SPACING_UNITS
+    *
+    * TYPE: R
+    * 
+    * 1 byte field
+    *
+    * Unit of Row Spacing, f, m, r or u
+    */
+   char theRowSpacingUnits[ROW_SPACING_UNITS_SIZE+1];
+
+   /**
+    * FIELD: COL_SPACING
+    *
+    * TYPE: R
+    * 
+    * 7 byte field
+    *
+    * Column Spacing
+    */
+   char theColSpacing[COL_SPACING_SIZE+1];
+
+   /**
+    * FIELD: COL_SPACING_UINTS
+    *
+    * TYPE: R
+    * 
+    * 1 byte field
+    *
+    * Unit of Column Spacing
+    */
+   char theColSpacingUnits[COL_SPACING_UINTS_SIZE+1];
+   
+   /**
+    * FIELD: FOCAL_LENGTH
+    *
+    * TYPE: R
+    * 
+    * 6 byte field
+    *
+    * Sensor Focal Length, cm, 000.01 to 899.99, 999.99
+    */
+   char theFocalLength[FOCAL_LENGTH_SIZE+1];
+
+   /**
+    * FIELD: SENSERIAL
+    *
+    * TYPE: <R>
+    * 
+    * 6 byte field
+    *
+    * Sensor vendor's serial number, 000001 to 999999
+    */
+   char theSenserial[SENSERIAL_SIZE+1];
+   
+   /**
+    * FIELD: ABSWVER
+    *
+    * TYPE: <R>
+    * 
+    * 7byte field
+    *
+    * Airborne Software Version
+    */
+   char theAbSwVer[ABSWVER_SIZE+1];
+
+   /**
+    * FIELD: CAL_DATE
+    *
+    * TYPE: <R>
+    * 
+    * 8 byte field
+    *
+    * Calibration Date, CCYYMMDD
+    */
+   char theCalDate[CAL_DATE_SIZE+1];
+   
+   /**
+    * FIELD: PATCH_TOT
+    *
+    * TYPE: R
+    * 
+    * 4 byte field
+    *
+    * Patch Total
+    */
+   char thePatchTot[PATCH_TOT_SIZE+1];
+
+   /**
+    * FIELD: MTI_TOT
+    *
+    * TYPE: R
+    * 
+    * 3 byte field
+    *
+    * MTI Total, SAR: 000 to 999, EO-IR: 000
+    */
+   char theMtiTot[MTI_TOT_SIZE+1];
+   
+TYPE_DATA   
+};
+
+#endif /* matches #ifndef ossimNitfAcftbTag_HEADER */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfAimidbTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfAimidbTag.h
new file mode 100644
index 0000000000000000000000000000000000000000..c1f9ad7422d0d94f2ef6e3c97a1eae51f8972e0e
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfAimidbTag.h
@@ -0,0 +1,287 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: AIMIDB - Additional Image ID Extension Format
+// tag class declaration.
+//
+// See document STDI-0002 (version 3), Appendix E, Table E-3 for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#ifndef ossimNitfAimidbTag_HEADER
+#define ossimNitfAimidbTag_HEADER
+
+#include <ossim/support_data/ossimNitfRegisteredTag.h>
+
+class OSSIM_DLL ossimNitfAimidbTag : public ossimNitfRegisteredTag
+{
+public:
+
+   enum 
+   {
+      CEL_SIZE                    = 89,
+      ACQUISITION_DATE_SIZE       = 14,
+      MISSION_NO_SIZE             = 4,
+      MISSION_IDENTIFICATION_SIZE = 10,
+      FLIGHT_NO_SIZE              = 2,
+      OP_NUM_SIZE                 = 3,
+      CURRENT_SEGMENT_SIZE        = 2,
+      REPRO_NUM_SIZE              = 2,
+      REPLAY_SIZE                 = 3,
+      RESERVED_1_SIZE             = 1,
+      START_TILE_COLUMN_SIZE      = 3,
+      START_TILE_ROW_SIZE         = 5,
+      END_SEGMENT_SIZE            = 2,
+      END_TILE_COLUMN_SIZE        = 3,
+      END_TILE_ROW_SIZE           = 5,
+      COUNTRY_SIZE                = 2,
+      RESERVED_2_SIZE             = 4,
+      LOCATION_SIZE               = 11,
+      RESERVED_3_SIZE             = 13
+    };
+   
+   /** @brief default constructor */
+   ossimNitfAimidbTag();
+
+   /** @brief destructor */
+   virtual ~ossimNitfAimidbTag();
+
+   /**
+    * @brief Method to return tag name.
+    * @return "AIMIDB" as an ossimString.
+    */
+   virtual ossimString getRegisterTagName()const;
+
+   /** @brief Method to parse data from stream. */
+   virtual void parseStream(std::istream& in);
+
+   /** @brief Method to write data to stream. */
+   virtual void writeStream(std::ostream& out);
+
+   /** @return Byte size of this tag. */
+   virtual ossim_uint32 getSizeInBytes()const;
+
+   /** @brief Method to clear all fields including null terminating. */
+   virtual void clearFields();
+
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
+   
+protected:
+
+   /** Type R = Required Type <R> = BCS spaces allowed for entire field */
+   
+   /**
+    * FIELD: ACQUISITION_DATE
+    *
+    * TYPE: R
+    * 
+    * 14 byte field
+    *
+    * CCYYMMDDhhmmss
+    */
+   char theAcquisitionDate[ACQUISITION_DATE_SIZE+1];
+
+   /**
+    * FIELD: MISSION_NO
+    *
+    * TYPE: R
+    *
+    * 4 byte field
+    *
+    * Mission Number
+    */
+   char theMissionNumber[MISSION_NO_SIZE+1];
+
+   /**
+    * FIELD: MISSION_IDENTIFICATION
+    *
+    * TYPE: R
+    *
+    * 10 byte field
+    *
+    * Name of the Mission.
+    */
+   char theMissionIdentification[MISSION_IDENTIFICATION_SIZE+1];
+   
+   /**
+    * FIELD: FLIGHT_NO
+    *
+    * TYPE: R
+    *
+    * 2 byte field
+    *
+    * Flight Number
+    */
+   char theFlightNo[FLIGHT_NO_SIZE+1];
+
+   /**
+    * FIELD: OP_NUM
+    *
+    * TYPE: R
+    *
+    * 3 byte field
+    *
+    * Image Operation Number 000 to 999
+    */
+   char theOpNum[OP_NUM_SIZE+1];
+   
+   /**
+    * FIELD: CURRENT_SEGMENT
+    *
+    * TYPE: R
+    *
+    * 2 byte field
+    *
+    * Current Segment ID, AA to ZZ
+    */
+   char theCurrentSegment[CURRENT_SEGMENT_SIZE+1];
+
+   /**
+    * FIELD: REPRO_NUM
+    *
+    * TYPE: R
+    *
+    * 2 byte field
+    *
+    * Reprocess Number, 00 to 99
+    */
+   char theReproNum[REPRO_NUM_SIZE+1];
+   
+   /**
+    * FIELD: REPLAY
+    *
+    * TYPE: <R>
+    *
+    * 3 byte field
+    *
+    * Replay
+    */
+   char theReplay[REPLAY_SIZE+1];
+
+   /**
+    * FIELD: RESERVED_1
+    *
+    * TYPE: R
+    *
+    * 1 byte field
+    *
+    * 1 space
+    */
+   char theReserved1[RESERVED_1_SIZE+1];
+   
+   /**
+    * FIELD: START_TILE_COLUMN
+    *
+    * TYPE: R
+    *
+    * 3 byte field
+    *
+    * Starting Tile Column Number, 001 to 099
+    */
+   char theStartTileColumn[START_TILE_COLUMN_SIZE+1];
+
+   /**
+    * FIELD: START_TILE_ROW
+    *
+    * TYPE: R
+    *
+    * 5 byte field
+    *
+    * Starting Tile Row Number, 00001 to 99999
+    */
+   char theStartTileRow[START_TILE_ROW_SIZE+1];
+   
+   /**
+    * FIELD: END_SEGMENT
+    *
+    * TYPE: R
+    *
+    * 2 byte field
+    *
+    * Ending Segment, 00, AA to ZZ
+    */
+   char theEndSegment[END_SEGMENT_SIZE+1];
+
+   /**
+    * FIELD: END_TILE_COLUMN
+    *
+    * TYPE: R
+    *
+    * 3 byte field
+    *
+    * Ending Tile Column Number, 001 to 099
+    */
+   char theTileColumn[END_TILE_COLUMN_SIZE+1];
+   
+   /**
+    * FIELD: END_TILE_ROW
+    *
+    * TYPE: R
+    *
+    * 5 byte field
+    *
+    * Ending Tile Row Number, 00001 to 99999
+    */
+   char theTileRow[END_TILE_ROW_SIZE+1];
+
+   /**
+    * FIELD: COUNTRY
+    *
+    * TYPE: <R>
+    *
+    * 2 byte field
+    *
+    * Country Code, AA to ZZ
+    */
+   char theCountry[COUNTRY_SIZE+1];
+   
+   /**
+    * FIELD: RESERVED_2
+    *
+    * TYPE: R
+    *
+    * 4 byte field
+    *
+    * 4 spaces
+    */
+   char theReserved2[RESERVED_2_SIZE+1];
+
+   /**
+    * FIELD: LOCATION
+    *
+    * TYPE: <R>
+    *
+    * 11 byte field
+    *
+    * Location, ddmmXdddmmY, spaces
+    */
+   char theLocation[LOCATION_SIZE+1];
+
+   /**
+    * FIELD: RESERVED_3
+    *
+    * TYPE: R
+    *
+    * 13 byte field
+    *
+    * 13 spaces
+    */
+   char theReserved3[RESERVED_3_SIZE+1];
+   
+TYPE_DATA   
+};
+
+#endif /* matches #ifndef ossimNitfAimidbTag_HEADER */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h
index 6dff7b8077f7fe4841c7b704d652bf2f751a810b..d3b41022c8d292a7e3a50255db510e677b8f898d 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h
@@ -1,13 +1,15 @@
 //----------------------------------------------------------------------------
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
 // Description: Utility class for global nitf methods.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfCommon.h 13619 2008-09-29 19:10:31Z gpotts $
+// $Id: ossimNitfCommon.h 15410 2009-09-11 19:45:38Z dburken $
 #ifndef ossimNitfCommon_HEADER
 #define ossimNitfCommon_HEADER
 
@@ -16,6 +18,7 @@
 #include <iostream>
 
 class ossimDpt;
+class ossimIrect;
 
 /** class ossimNitfCommon for global utility methods */   
 class OSSIM_DLL ossimNitfCommon
@@ -141,6 +144,38 @@ public:
                                                      const ossimDpt& ur,
                                                      const ossimDpt& lr,
                                                      const ossimDpt& ll);
+
+   /**
+    * @brief Get the nitf pixel type string from scalar type.
+    *
+    * @param scalarType The scalar type.
+    *
+    * @return Pixel type as string, e.g.: "INT", "SI", "R"
+    */
+   static ossimString getNitfPixelType(ossimScalarType scalarType);
+
+   /**
+    * @brief Get compression rate (COMRAT) which is bits perpixel per band.
+    *
+    * This corresponds to the nitf image header COMRAT field.  Return is in
+    * the form of Nxyz "N" for numerically lossles, where "xyz"
+    * indicates the expected achieved bit rate (in bits per pixel per band)
+    * for the final layer of each tile. The decimal point is implicit and
+    * assumed to be one digit from the right (i.e. xy.z).
+    * 
+    * @param rect Image rectangles.
+    * @param bands
+    * @param scalar
+    * @param lengthInBytes Compressed length of image pixels.
+    * @return Approximate number of bits per pixel for the compressed image as
+    * a string which follows the nitf comrat field convention.  This will
+    * return an empty string if comrat is bigger than three digits.
+    */
+   static ossimString getCompressionRate(const ossimIrect& rect,
+                                         ossim_uint32 bands,
+                                         ossimScalarType scalar,
+                                         ossim_uint64 lengthInBytes);
+   
    
 }; // End of class ossimNitfCommon.
    
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegment.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegment.h
index 6dae20109b11234248b13598f8dee2b305d51681..b3636c2299891eb70cb5b348a93c660e0690c058 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegment.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegment.h
@@ -8,7 +8,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfDataExtensionSegment.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfDataExtensionSegment.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNitfDataExtensionSegment_HEADER
 #define ossimNitfDataExtensionSegment_HEADER
 
@@ -22,10 +22,12 @@ public:
    friend std::ostream& operator <<(std::ostream &out,
                                     const ossimNitfDataExtensionSegment &data);
    ossimNitfDataExtensionSegment(){}
-   virtual ~ossimNitfDataExtensionSegment(){}
    virtual void parseStream(std::istream &in)=0;
    virtual const ossimNitfTagInformation&  getTagInformation()const=0;
-   
+
+protected:
+   virtual ~ossimNitfDataExtensionSegment(){}
+
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.h
index a7931b77ef515434158ab3a404b22dea0c234f01..866da5f0e7b0eb9024ac73be5040e764abd72ac4 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.h
@@ -8,7 +8,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfDataExtensionSegmentV2_0.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfDataExtensionSegmentV2_0.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNitfDataExtensionSegmentV2_0_HEADER
 #define ossimNitfDataExtensionSegmentV2_0_HEADER
 #include <ossim/support_data/ossimNitfDataExtensionSegment.h>
@@ -35,13 +35,14 @@ class OSSIMDLLEXPORT ossimNitfDataExtensionSegmentV2_0 : public ossimNitfDataExt
 {
 public:
    ossimNitfDataExtensionSegmentV2_0();
-   virtual ~ossimNitfDataExtensionSegmentV2_0();
    virtual void parseStream(std::istream &in);
    virtual std::ostream& print(std::ostream& out)const;
    virtual const ossimNitfTagInformation&  getTagInformation()const
       {
          return theTag;
       }
+protected:
+   virtual ~ossimNitfDataExtensionSegmentV2_0();
 
 private:
    void clearFields();
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h
index bcd86a8f85718e02f7557e53639189eb9c430c44..30ba4146ecd5415a8857749f55031997c4ac2606 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfEmbeddedRpfDes.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfEmbeddedRpfDes.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNitfEmbeddedRpfDes_HEADER
 #define ossimNitfEmbeddedRpfDes_HEADER
 
@@ -21,7 +21,6 @@ class OSSIMDLLEXPORT ossimNitfEmbeddedRpfDes : public ossimNitfRegisteredTag
 {
 public:
    ossimNitfEmbeddedRpfDes();
-   virtual ~ossimNitfEmbeddedRpfDes();
    /*!
     * This will return the name of the registered tag for this
     * user defined header.
@@ -38,6 +37,8 @@ public:
     */
    virtual std::ostream& print(std::ostream& out,
                                const std::string& prefix=std::string()) const;
+protected:
+   virtual ~ossimNitfEmbeddedRpfDes();
 
 TYPE_DATA
 private:
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfEngrdaTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfEngrdaTag.h
new file mode 100644
index 0000000000000000000000000000000000000000..80aa1f662239bbfd4b5dc17dde8254788eadaa83
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfEngrdaTag.h
@@ -0,0 +1,157 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: ENGRDA - Engineering Data tag class declaration.
+//
+// See document STDI-0002 (version 3), Appendix N for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#ifndef ossimNitfEngrdaTag_HEADER
+#define ossimNitfEngrdaTag_HEADER
+
+#include <string>
+#include <vector>
+
+#include <ossim/support_data/ossimNitfRegisteredTag.h>
+
+class OSSIM_DLL ossimNitfEngrdaTag : public ossimNitfRegisteredTag
+{
+public:
+
+   enum 
+   {
+      RESRC_SIZE   = 20,
+      RECNT_SIZE   = 3,
+      ENGLN_SIZE   = 2,
+      ENGMTXC_SIZE = 4,
+      ENGMTXR_SIZE = 4,
+      ENGTYP_SIZE  = 1,
+      ENGDTS_SIZE  = 1,
+      ENGDATU_SIZE = 2,
+      ENGDATC_SIZE = 8,
+      TMP_BUF_SIZE = 128
+   };
+   
+   /** @brief default constructor */
+   ossimNitfEngrdaTag();
+
+   /** @brief destructor */
+   virtual ~ossimNitfEngrdaTag();
+
+   /**
+    * @brief Method to return tag name.
+    * @return "ENGRDA" as an ossimString.
+    */
+   virtual ossimString getRegisterTagName()const;
+
+   /** @brief Method to parse data from stream. */
+   virtual void parseStream(std::istream& in);
+
+   /** @brief Method to write data to stream. */
+   virtual void writeStream(std::ostream& out);
+
+   /** @return Byte size of this tag. */
+   virtual ossim_uint32 getSizeInBytes()const;
+
+   /** @brief Method to clear all fields including null terminating. */
+   virtual void clearFields();
+
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
+   
+protected:
+
+   /** @brief Container class for an Engineering Data Element Record. */
+   class ossimEngDataElement
+   {
+   public:
+      /** ENGLBL - label */
+      std::string theEngLbl;
+
+      /** ENGMTXC - column count */
+      ossim_uint16 theEngMtxC;
+
+      /** ENGMTXR - row count */
+      ossim_uint16 theEngMtxR;
+
+      /** ENGTYP - data type */
+      ossim_int8  theEngTyp;
+
+      /** ENGDTS - data size in bytes */
+      ossim_uint8 theEngDts;
+
+      /** ENGDATU - units */
+      std::string theEngDatU;
+
+      /** ENGDATA - data */
+      std::vector<ossim_uint8> theEngDat;
+   };
+
+   /**
+    * @brief Method to print out a ossimEngDataElement object.
+    * @param out Stream to print to.
+    * @param element The element to print.
+    * @param elIndex The index of the element array index.
+    * @param prefix  The prefix to add to key.
+    */
+   std::ostream& printData(std::ostream& out,
+                           const ossimEngDataElement& element,
+                           ossim_uint32 elIndex,
+                           const std::string& prefix) const;
+
+   /**
+    * @brief Method to convert value to a string, padding with zero's,
+    * left justified.
+    * @param v The value to convert.
+    * @param w The width of the string field.
+    * @param s The string to stuff.
+    */
+   template <class T> void getValueAsString(T v,
+                                            ossim_uint16 w,
+                                            std::string& s) const;
+
+   /** Type R = Required Type <R> = BCS spaces allowed for entire field */
+   
+   /**
+    * FIELD: RESRC
+    *
+    * TYPE: R
+    * 
+    * 20 byte field
+    *
+    * Unique Source System Name.
+    */
+   char theReSrc[RESRC_SIZE+1];
+   
+   /**
+    * FIELD: RECNT
+    *
+    * TYPE: R
+    * 
+    * 20 byte field
+    *
+    * Unique Source System Name.
+    */
+   char theReCnt[RECNT_SIZE+1];
+
+   std::vector<ossimEngDataElement> theData;
+
+   ossim_uint32 theTreLength;
+   
+TYPE_DATA   
+};
+
+#endif /* matches #ifndef ossimNitfEngrdaTag_HEADER */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFile.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFile.h
index cd8bc4aeee5d69f5cc012ddd5f2eb9544df8e12b..206d7f9fde5d0d9a3b7b1c0a019902c4c56e5fc2 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFile.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFile.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFile.h 14243 2009-04-07 20:35:45Z dburken $
+// $Id: ossimNitfFile.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNitfFile_HEADER
 #define ossimNitfFile_HEADER
 
@@ -41,17 +41,19 @@ public:
    /**
     * @brief print method that outputs a key/value type format adding prefix
     * to keys.
-    * @param out String to output to.
+    * @param out Stream to output to.
     * @param prefix This will be prepended to key.
     * e.g. Where prefix = "nitf." and key is "file_name" key becomes:
     * "nitf.file_name:"
+    * @param printOverviews If true overview, if present(e.g. rpf's) will be
+    * printed.
     * @return output stream.
     */
    std::ostream& print(std::ostream& out,
-                       const std::string& prefix=std::string()) const;
+                       const std::string& prefix=std::string(),
+                       bool printOverviews=false) const;
    
    ossimNitfFile();
-   virtual ~ossimNitfFile();
 
    /*!
     *  Opens the nitf file and attempts to parse.
@@ -62,14 +64,15 @@ public:
    /*!
     * Will return the header.
     */
-   const ossimRefPtr<ossimNitfFileHeader> getHeader()const;
+   const ossimNitfFileHeader* getHeader()const;
+   ossimNitfFileHeader* getHeader();
    ossimIrect getImageRect()const;
    
-   ossimNitfImageHeader*  getNewImageHeader(long imageNumber)const;
-   ossimNitfSymbolHeader* getNewSymbolHeader(long symbolNumber)const;
-   ossimNitfLabelHeader*  getNewLabelHeader(long labelNumber)const;
-   ossimNitfTextHeader*   getNewTextHeader(long textNumber)const;
-   ossimNitfDataExtensionSegment* getNewDataExtensionSegment(long dataExtNumber)const;
+   ossimNitfImageHeader*  getNewImageHeader(ossim_uint32 imageNumber)const;
+   ossimNitfSymbolHeader* getNewSymbolHeader(ossim_uint32 symbolNumber)const;
+   ossimNitfLabelHeader*  getNewLabelHeader(ossim_uint32 labelNumber)const;
+   ossimNitfTextHeader*   getNewTextHeader(ossim_uint32 textNumber)const;
+   ossimNitfDataExtensionSegment* getNewDataExtensionSegment(ossim_uint32 dataExtNumber)const;
    
    ossimString getVersion()const;
 
@@ -77,6 +80,7 @@ public:
    ossimFilename getFilename() const;
 
 protected:
+   virtual ~ossimNitfFile();
    ossimNitfImageHeader* allocateImageHeader()const;
    
    ossimFilename                    theFilename;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeader.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeader.h
index 016d48ef12c9ae7750cf750be1e1c8a05eacf24e..fe4c0052c15a22ab200f15b57c5fee67aaacaaac 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeader.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeader.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeader.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfFileHeader.h 14662 2009-06-07 16:15:23Z dburken $
 #ifndef ossimNitfFileHeader_HEADER
 #define ossimNitfFileHeader_HEADER
 
@@ -138,7 +138,7 @@ public:
    virtual bool getTag(ossimNitfTagInformation& tagInfo,
                        const ossimString& tagName)const;
    
-   virtual ossim_int32 getFileSize()const=0;
+   virtual ossim_int64 getFileSize()const=0;
    virtual const char* getVersion()const=0;
    virtual const char* getDateTime()const=0;
    virtual ossimDrect getImageRect()const=0;
@@ -150,16 +150,18 @@ public:
    bool hasText()const;
    bool hasLabels()const;
    bool hasDataExtSegments()const;
-   virtual ossimNitfImageHeader* getNewImageHeader(ossim_int32 imageNumber,
+
+   virtual ossimNitfImageHeader* getNewImageHeader(ossim_uint32 imageNumber,
                                                    std::istream& in)const=0;
-   virtual ossimNitfSymbolHeader* getNewSymbolHeader(ossim_int32 symbolNumber,
+   virtual ossimNitfSymbolHeader* getNewSymbolHeader(ossim_uint32 symbolNumber,
                                                     std::istream& in)const=0;
-   virtual ossimNitfLabelHeader* getNewLabelHeader(ossim_int32 labelNumber,
+   virtual ossimNitfLabelHeader* getNewLabelHeader(ossim_uint32 labelNumber,
                                                    std::istream& in)const=0;
-   virtual ossimNitfTextHeader* getNewTextHeader(ossim_int32 textNumber,
+   virtual ossimNitfTextHeader* getNewTextHeader(ossim_uint32 textNumber,
                                                 std::istream& in)const=0;
    virtual ossimNitfDataExtensionSegment* getNewDataExtensionSegment(
-      ossim_int32 dataExtNumber, std::istream& in)const=0;
+      ossim_uint32 dataExtNumber, std::istream& in)const=0;
+   
    virtual ossimNitfImageHeader*    allocateImageHeader()const=0;
    virtual ossimNitfSymbolHeader*   allocateSymbolHeader()const=0;
    virtual ossimNitfLabelHeader*    allocateLabelHeader()const=0;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h
index ceb95232c9c35e574f804af9cf23f4b66ef9865a..8fd985e3082be7fd6a3dfb5989ea42943eb9e56d 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_0.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfFileHeaderV2_0.h 14662 2009-06-07 16:15:23Z dburken $
 #ifndef ossimNitfFileHeaderV2_0_HEADER
 #define ossimNitfFileHeaderV2_0_HEADER
 
@@ -26,11 +26,11 @@ public:
    friend std::ostream& operator <<(std::ostream& out,
                                     const ossimNitfImageInfoRecordV2_0 &data);
 
-   ossim_int32 getHeaderLength()const;
-   ossim_int32 getImageLength()const;
-   ossim_int32 getTotalLength()const;
+   ossim_uint32 getHeaderLength()const;
+   ossim_uint64 getImageLength()const;
+   ossim_uint64 getTotalLength()const;
    void setSubheaderLength(ossim_uint32 length);
-   void setImageLength(ossim_uint32 length);
+   void setImageLength(ossim_uint64 length);
 
    /*!
     * Is a 6 byte numeric 0-999999
@@ -173,7 +173,7 @@ public:
    virtual ossim_int32 getNumberOfTextSegments()const;
    virtual ossim_int32 getNumberOfDataExtSegments()const;
    virtual ossim_int32 getHeaderSize()const;
-   virtual ossim_int32 getFileSize()const;
+   virtual ossim_int64 getFileSize()const;
    virtual ossimString getSecurityClassification()const;
    
    virtual const char* getDateTime()const;
@@ -184,16 +184,17 @@ public:
    virtual void addImageInfoRecord(const ossimNitfImageInfoRecordV2_0& recordInfo);
    virtual void replaceImageInfoRecord(ossim_uint32 i, const ossimNitfImageInfoRecordV2_0& recordInfo);
 
-   virtual ossimNitfImageHeader*  getNewImageHeader(ossim_int32 imageNumber,
+   virtual ossimNitfImageHeader*  getNewImageHeader(ossim_uint32 imageNumber,
                                                     std::istream& in)const;
-   virtual ossimNitfSymbolHeader* getNewSymbolHeader(ossim_int32 symbolNumber,
+   virtual ossimNitfSymbolHeader* getNewSymbolHeader(ossim_uint32 symbolNumber,
                                                      std::istream& in)const;
-   virtual ossimNitfLabelHeader* getNewLabelHeader(ossim_int32 labelNumber,
+   virtual ossimNitfLabelHeader* getNewLabelHeader(ossim_uint32 labelNumber,
                                                    std::istream& in)const;
-   virtual ossimNitfTextHeader*   getNewTextHeader(ossim_int32 textNumber,
+   virtual ossimNitfTextHeader*   getNewTextHeader(ossim_uint32 textNumber,
                                                    std::istream& in)const;
-   virtual ossimNitfDataExtensionSegment* getNewDataExtensionSegment(ossim_int32 dataExtNumber,
-                                                                     std::istream& in)const;
+   virtual ossimNitfDataExtensionSegment* getNewDataExtensionSegment(
+      ossim_uint32 dataExtNumber, std::istream& in)const;
+   
    virtual ossimNitfImageHeader*  allocateImageHeader()const;
    virtual ossimNitfSymbolHeader* allocateSymbolHeader()const;
    virtual ossimNitfLabelHeader*  allocateLabelHeader()const;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_1.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_1.h
index 67ebcf986654c3d72ef6b0ebd96930c757c0f739..3133a8a6bd5bdcab8ea2558dae39768325e8ef59 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_1.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_1.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_1.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfFileHeaderV2_1.h 14662 2009-06-07 16:15:23Z dburken $
 #ifndef ossimNitfFileHeaderV2_1_HEADER
 #define ossimNitfFileHeaderV2_1_HEADER
 
@@ -25,12 +25,12 @@ public:
    friend std::ostream& operator <<(std::ostream& out,
                                     const ossimNitfImageInfoRecordV2_1 &data);
    
-   ossim_int32 getHeaderLength()const;
-   ossim_int32 getImageLength()const;
-   ossim_int32 getTotalLength()const;
+   ossim_uint32 getHeaderLength()const;
+   ossim_uint64 getImageLength()const;
+   ossim_uint64 getTotalLength()const;
    
    void setSubheaderLength(ossim_uint32 length);
-   void setImageLength(ossim_uint32 length);
+   void setImageLength(ossim_uint64 length);
    
    /**
     * Is a 6 byte numeric 000439-999999
@@ -129,7 +129,7 @@ public:
    virtual ossim_int32 getNumberOfTextSegments()const;
    virtual ossim_int32 getNumberOfDataExtSegments()const;
    virtual ossim_int32 getHeaderSize()const;
-   virtual ossim_int32 getFileSize()const;
+   virtual ossim_int64 getFileSize()const;
    virtual const char* getVersion()const;
    virtual const char* getDateTime()const;
    virtual ossimDrect getImageRect()const;
@@ -137,16 +137,16 @@ public:
    virtual void addImageInfoRecord(const ossimNitfImageInfoRecordV2_1& recordInfo);
    virtual void replaceImageInfoRecord(int i, const ossimNitfImageInfoRecordV2_1& recordInfo);
    
-   virtual ossimNitfImageHeader*  getNewImageHeader(ossim_int32 imageNumber,
+   virtual ossimNitfImageHeader*  getNewImageHeader(ossim_uint32 imageNumber,
                                                     std::istream& in)const;
-   virtual ossimNitfSymbolHeader* getNewSymbolHeader(ossim_int32 symbolNumber,
+   virtual ossimNitfSymbolHeader* getNewSymbolHeader(ossim_uint32 symbolNumber,
                                                      std::istream& in)const;
-   virtual ossimNitfLabelHeader* getNewLabelHeader(ossim_int32 labelNumber,
+   virtual ossimNitfLabelHeader* getNewLabelHeader(ossim_uint32 labelNumber,
                                                    std::istream& in)const;
-   virtual ossimNitfTextHeader* getNewTextHeader(ossim_int32 textNumber,
+   virtual ossimNitfTextHeader* getNewTextHeader(ossim_uint32 textNumber,
                                                    std::istream& in)const;
    virtual ossimNitfDataExtensionSegment* getNewDataExtensionSegment(
-      ossim_int32 dataExtNumber, std::istream& in)const;
+      ossim_uint32 dataExtNumber, std::istream& in)const;
 
    virtual ossimNitfImageHeader*  allocateImageHeader()const;
    virtual ossimNitfSymbolHeader* allocateSymbolHeader()const;
@@ -271,7 +271,7 @@ private:
     * all the bytes read for the header portion.  This can be used
     * to skip past the header data.
     */
-   ossim_int32 theHeaderSize;
+   ossim_uint32 theHeaderSize;
 
    /**
     * This will be pre-computed when the header file is opened.  This is
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h
index 75b726c8c826289f4dc5e456eae919416e3496fb..f1efdce6935579faa8c480d0b9a88c3ec385202f 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h
@@ -1,9 +1,10 @@
 #ifndef ossimNitfFileHeaderV2_X_HEADER
 #define ossimNitfFileHeaderV2_X_HEADER
+#include <ossim/base/ossimConstants.h>
 #include <ossim/support_data/ossimNitfFileHeader.h>
 #include <ossim/base/ossimDate.h>
 
-class ossimNitfFileHeaderV2_X : public ossimNitfFileHeader
+class OSSIM_DLL ossimNitfFileHeaderV2_X : public ossimNitfFileHeader
 {
 public:
    ossimNitfFileHeaderV2_X();
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfIchipbTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfIchipbTag.h
index 1d6852ca554ffbeff248d77e352b34ff6160a69f..747230b97e9c71fc25449ae2f41914bf961f0b3a 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfIchipbTag.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfIchipbTag.h
@@ -11,7 +11,7 @@
 // http://164.214.2.51/ntb/baseline/docs/stdi0002/final.pdf
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfIchipbTag.h 10177 2007-01-03 19:22:09Z gpotts $
+// $Id: ossimNitfIchipbTag.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimNitfIchipbTag_HEADER
 #define ossimNitfIchipbTag_HEADER
 
@@ -20,7 +20,7 @@
 
 class ossimDpt;
 class ossimDrect;
-
+class ossim2dTo2dTransform;
 class OSSIM_DLL ossimNitfIchipbTag : public ossimNitfRegisteredTag
 {
 public:
@@ -93,13 +93,13 @@ public:
    virtual void clearFields();
    
    /**
-    * Print method.
-    *
-    * @param out Stream to print to.
-    * 
-    * @return std::ostream&
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
     */
-   virtual std::ostream& print(std::ostream& out) const;
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
 
    /**
     * @return The Non-linear transformation flag.
@@ -244,17 +244,8 @@ public:
     */
    void getFullImageRect(ossimDrect& rect) const;
 
-   /**
-    * Initializes offset with the sub image offset.
-    *
-    * @param pt The point to initialize with the offset.
-    *
-    * @note Rectangle is shifted by -0.5 since per spec (0,0) is the
-    * considered the upper left corner of the upper left pixel and we use a
-    * point method where (0,0) refers to the center of the pixel.
-    */
-   void getSubImageOffset(ossimDpt& pt) const;
-
+   ossim2dTo2dTransform* newTransform()const;
+   
    virtual void setProperty(ossimRefPtr<ossimProperty> property);
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_0.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_0.h
index eb252a23024270658becf1a0e5384f1a3a7a3cd2..9702655b4936fbc2e174ef6b77e893875a948f15 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_0.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_0.h
@@ -9,15 +9,16 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageBandV2_0.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfImageBandV2_0.h 15416 2009-09-11 20:58:51Z dburken $
 #ifndef ossimNitfImageBandV2_0_HEADER
 #define ossimNitfImageBandV2_0_HEADER
 
 #include <string>
+#include <ossim/base/ossimConstants.h>
 #include <ossim/support_data/ossimNitfImageBand.h>
 #include <ossim/support_data/ossimNitfImageLutV2_0.h>
 
-class ossimNitfImageBandV2_0 : public ossimNitfImageBand
+class OSSIM_DLL ossimNitfImageBandV2_0 : public ossimNitfImageBand
 {
 public:
    
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_1.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_1.h
index 7eda389a8614457880f2196cc8fb2ec86ee3979b..f782c61fb0672c515ed8f300aa658bde2be18990 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_1.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageBandV2_1.h
@@ -5,14 +5,15 @@
 // Author:  David Burken <dburken@imagelinks.com>
 //
 //********************************************************************
-// $Id: ossimNitfImageBandV2_1.h 9147 2006-06-20 14:17:50Z dburken $
+// $Id: ossimNitfImageBandV2_1.h 15416 2009-09-11 20:58:51Z dburken $
 
 #ifndef ossimNitfImageBandV2_1_HEADER
 #define ossimNitfImageBandV2_1_HEADER
 
+#include <ossim/base/ossimConstants.h>
 #include <ossim/support_data/ossimNitfImageBandV2_0.h>
 
-class ossimNitfImageBandV2_1 : public ossimNitfImageBandV2_0
+class OSSIM_DLL ossimNitfImageBandV2_1 : public ossimNitfImageBandV2_0
 {
 public:
 
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h
index aef68c046b5c9c935fb38ac6d2fc74dc584bccfb..4b67dfe6420d773222f34cbf757b74012c76f294 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeader.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfImageHeader.h 15436 2009-09-17 00:12:59Z dburken $
 #ifndef ossimNitfImageHeader_HEADER
 #define ossimNitfImageHeader_HEADER
 
@@ -94,6 +94,16 @@ public:
 
    /** @return IMAG field */
    virtual ossimString  getImageMagnification()const=0;
+
+   /**
+    * @brief Convenience method to get the decimation factor as a double from
+    * the string returned be the getImageMagnification() method.
+    *
+    * @param result Initialized with the decimation factor as a double.
+    * Will return an ossim::nan() if something bad happens like the string is
+    * empty so callers should check result with ossim::isnan(result).
+    */
+   virtual void getDecimationFactor(ossim_float64& result) const;
    
    virtual bool hasBlockMaskRecords()const=0;
    virtual bool hasPadPixelMaskRecords()const=0;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h
index 7852fbd88040b655d4f321567a6ba016d56e93ed..8d7485d00edfb42eb25e2f960cfbedbf3e938dfa 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_0.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfImageHeaderV2_0.h 15611 2009-10-08 18:50:33Z dburken $
 #ifndef ossimNitfImageHeaderV2_0_HEADER
 #define ossimNitfImageHeaderV2_0_HEADER
 #include <ossim/support_data/ossimNitfImageHeaderV2_X.h>
@@ -56,14 +56,13 @@ public:
 
    /** @return The IDATIM field unparsed. */
    virtual ossimString  getImageDateAndTime() const;
-   
    virtual ossimString  getAcquisitionDateMonthDayYear(
       ossim_uint8 separationChar='-')const;
    virtual ossimString  getCategory()const;
    virtual ossimString  getImageSource()const;
    virtual ossimString  getRepresentation()const;
    virtual ossimString  getCoordinateSystem()const;
-   virtual ossimString  getGeographicLocation()const;
+
    virtual ossimString  getPixelValueType()const;
    virtual bool         hasBlockMaskRecords()const;
    virtual bool         hasPadPixelMaskRecords()const;
@@ -82,25 +81,6 @@ public:
                             const ossimNitfImageBandV2_0& info);
    virtual void setNumberOfRows(ossim_uint32 rows);
    virtual void setNumberOfCols(ossim_uint32 cols);
-   virtual void setGeographicLocationDms(const ossimDpt& ul,
-                                         const ossimDpt& ur,
-                                         const ossimDpt& lr,
-                                         const ossimDpt& ll);
-   
-   virtual void setGeographicLocationDecimalDegrees(const ossimDpt& ul,
-                                                    const ossimDpt& ur,
-                                                    const ossimDpt& lr,
-                                                    const ossimDpt& ll);
-   virtual void setUtmNorth(ossim_uint32 zone,
-                            const ossimDpt& ul,
-                            const ossimDpt& ur,
-                            const ossimDpt& lr,
-                            const ossimDpt& ll);
-   virtual void setUtmSouth(ossim_uint32 zone,
-                            const ossimDpt& ul,
-                            const ossimDpt& ur,
-                            const ossimDpt& lr,
-                            const ossimDpt& ll);
    
    static const ossimString ISCODE_KW;
    static const ossimString ISCTLH_KW;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_1.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_1.h
index a7be3a45957ddd46bdf09c11f66a475714e773e3..ae90e6f566bb2c78bea3ef5187afac576be711ef 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_1.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_1.h
@@ -8,7 +8,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_1.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfImageHeaderV2_1.h 15611 2009-10-08 18:50:33Z dburken $
 
 #ifndef ossimNitfImageHeaderV2_1_HEADER
 #define ossimNitfImageHeaderV2_1_HEADER
@@ -59,7 +59,6 @@ public:
    virtual ossimString getCategory()const;
    virtual ossimString getRepresentation()const;
    virtual ossimString getCoordinateSystem()const;
-   virtual ossimString getGeographicLocation()const;
    virtual ossimString getPixelValueType()const;
 
 
@@ -79,26 +78,6 @@ public:
    virtual void setNumberOfRows(ossim_uint32 rows);
    virtual void setNumberOfCols(ossim_uint32 cols);
 
-   virtual void setGeographicLocationDms(const ossimDpt& ul,
-                                         const ossimDpt& ur,
-                                         const ossimDpt& lr,
-                                         const ossimDpt& ll);
-   
-   virtual void setGeographicLocationDecimalDegrees(const ossimDpt& ul,
-                                                    const ossimDpt& ur,
-                                                    const ossimDpt& lr,
-                                                    const ossimDpt& ll);
-   virtual void setUtmNorth(ossim_uint32 zone,
-                            const ossimDpt& ul,
-                            const ossimDpt& ur,
-                            const ossimDpt& lr,
-                            const ossimDpt& ll);
-   virtual void setUtmSouth(ossim_uint32 zone,
-                            const ossimDpt& ul,
-                            const ossimDpt& ur,
-                            const ossimDpt& lr,
-                            const ossimDpt& ll);
-                            
    virtual void setSecurityClassificationSystem(const ossimString& value);
    virtual void setCodewords(const ossimString& value);
    virtual void setControlAndHandling(const ossimString& value);
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h
index 352808f89b67259d1dd94828d149c9c83aeeef40..2b507f45adb061914901dfc0ba6073fc44af960c 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h
@@ -1,8 +1,9 @@
 #ifndef ossimNitfImageHeaderV2_X_HEADER
 #define ossimNitfImageHeaderV2_X_HEADER
+#include <ossim/base/ossimConstants.h>
 #include <ossim/support_data/ossimNitfImageHeader.h>
 
-class ossimNitfImageHeaderV2_X : public ossimNitfImageHeader
+class OSSIM_DLL ossimNitfImageHeaderV2_X : public ossimNitfImageHeader
 {
 public:
    ossimNitfImageHeaderV2_X();
@@ -72,6 +73,28 @@ public:
     */
    virtual ossimString  getImageMagnification()const;
 
+   virtual void setGeographicLocationDms(const ossimDpt& ul,
+                                         const ossimDpt& ur,
+                                         const ossimDpt& lr,
+                                         const ossimDpt& ll);
+   
+   virtual void setGeographicLocationDecimalDegrees(const ossimDpt& ul,
+                                                    const ossimDpt& ur,
+                                                    const ossimDpt& lr,
+                                                    const ossimDpt& ll);
+   virtual void setUtmNorth(ossim_uint32 zone,
+                            const ossimDpt& ul,
+                            const ossimDpt& ur,
+                            const ossimDpt& lr,
+                            const ossimDpt& ll);
+   
+   virtual void setUtmSouth(ossim_uint32 zone,
+                            const ossimDpt& ul,
+                            const ossimDpt& ur,
+                            const ossimDpt& lr,
+                            const ossimDpt& ll);
+  
+
    static const ossimString IID1_KW;
    static const ossimString IDATIM_KW;
    static const ossimString TGTID_KW;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfMstgtaTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfMstgtaTag.h
new file mode 100644
index 0000000000000000000000000000000000000000..3845ee15f6f5ef329babcb5a723a966f93a096dc
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfMstgtaTag.h
@@ -0,0 +1,226 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: MSTGTA Mission Target Information Extension Format
+// tag class declaration.
+//
+// See document STDI-0002 Table 8-16 for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#ifndef ossimNitfMstgtaTag_HEADER
+#define ossimNitfMstgtaTag_HEADER
+
+#include <ossim/support_data/ossimNitfRegisteredTag.h>
+
+class OSSIM_DLL ossimNitfMstgtaTag : public ossimNitfRegisteredTag
+{
+public:
+
+   enum 
+   {
+      TGT_NUM_SIZE       = 5,
+      TGT_ID_SIZE        = 12,
+      TGT_BE_SIZE        = 15,
+      TGT_PRI_SIZE       = 3,
+      TGT_REQ_SIZE       = 12,
+      TGT_LTIOV_SIZE     = 12,
+      TGT_TYPE_SIZE      = 1,
+      TGT_COLL_SIZE      = 1,
+      TGT_CAT_SIZE       = 5,
+      TGT_UTC_SIZE       = 7,
+      TGT_ELEV_SIZE      = 6,
+      TGT_ELEV_UNIT_SIZE = 1,
+      TGT_LOC_SIZE       = 21
+    };
+   
+   /** @brief default constructor */
+   ossimNitfMstgtaTag();
+
+   /** @brief destructor */
+   virtual ~ossimNitfMstgtaTag();
+
+   /**
+    * @brief Method to return tag name.
+    * @return "MSTGTA" as an ossimString.
+    */
+   virtual ossimString getRegisterTagName()const;
+
+   /** @brief Method to parse data from stream. */
+   virtual void parseStream(std::istream& in);
+
+   /** @brief Method to write data to stream. */
+   virtual void writeStream(std::ostream& out);
+
+   /** @return Byte size of this tag. */
+   virtual ossim_uint32 getSizeInBytes()const;
+
+   /** @brief Method to clear all fields including null terminating. */
+   virtual void clearFields();
+
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
+   
+protected:
+
+   /** Type R = Required Type <R> = BCS spaces allowed for entire field */
+   
+   /**
+    * FIELD: TGT_NUM
+    *
+    * TYPE: R
+    * 
+    * 5 byte field
+    *
+    * 00001 ti 99999
+    */
+   char theTgtNum[TGT_NUM_SIZE+1];
+
+   /**
+    * FIELD: TGT_ID
+    *
+    * TYPE: <R>
+    *
+    * 12 byte field
+    *
+    * Disignator of Target, alphnumeric.
+    */
+   char theTgtId[TGT_ID_SIZE+1];
+
+   /**
+    * FIELD: TGT_BE
+    *
+    * TYPE: <R>
+    * 
+    * 15 byte field
+    * 
+    * alphnumeric
+    */
+   char theTgtBe[TGT_BE_SIZE+1];
+
+   /**
+    * FIELD: TGT_PRI
+    *
+    * TYPE: <R>
+    *
+    * 3 byte field
+    * 
+    * Target priority, 1 = top, 2 = 2nd...  001 to 999
+    */
+   char theTgtPri[TGT_PRI_SIZE+1];
+
+   /**
+    * FIELD: TGT_REQ
+    *
+    * TYPE: <R>
+    *
+    * 12 byte field
+    * 
+    * Target requester. alphnumeric 
+    */
+   char theTgtReq[TGT_REQ_SIZE+1];
+
+   /**
+    * FIELD: TGT_LTIOV
+    *
+    * TYPE: <R>
+    * 
+    * 12 byte field
+    * 
+    * Latest Time Information of Value CCYYMMDDhhmm
+    */
+   char theTgtLtiov[TGT_LTIOV_SIZE+1];
+
+   /**
+    * FIELD: TGT_TYPE
+    *
+    * TYPE: <R>
+    *
+    * 1 byte field
+    * 
+    * Pre-Planned Target Type: 0 = point, 1 = strip, 2 = area, 0 to 9.
+    */
+   char theTgtType[TGT_TYPE_SIZE+1];
+
+   /**
+    * FIELD: TGT_COLL
+    *
+    * TYPE: R
+    * 
+    * 1 byte field
+    * 
+    * Pre-Planned Collection Technique: 0 to 9
+    */
+   char theTgtColl[TGT_COLL_SIZE+1];
+
+   /**
+    * FIELD: TGT_CAT
+    *
+    * TYPE: <R>
+    *
+    * 5 byte field
+    * 
+    * Target Functional Category Code 10000 to 99999
+    */
+   char theTgtCat[TGT_CAT_SIZE+1];
+
+   /**
+    * FIELD: TGT_UTC
+    *
+    * TYPE: <R>
+    * 
+    * 7 byte field
+    *
+    * Planned Time at Target hhmmssZ
+    */
+   char theTgtUtc[TGT_UTC_SIZE+1];
+
+   /**
+    * FIELD: TGT_ELEV
+    *
+    * TYPE: <R>
+    * 
+    * 6 byte field
+    * 
+    * Target Elevation -01000 to +30000 feet or meters
+    */
+   char theTgtElev[TGT_ELEV_SIZE+1];
+
+   /**
+    * FIELD: TGT_ELEV_UNIT
+    *
+    * TYPE: <R>
+    * 
+    * 1 byte field
+    * 
+    * Unit of Target Elevation, f = feet, m = meters
+    */
+   char theTgtElevUnit[TGT_ELEV_UNIT_SIZE+1];
+
+   /**
+    * FIELD: TGT_LOC
+    *
+    * TYPE: R
+    *
+    * 21 byte field
+    * 
+    * Target Location
+    */
+   char theTgtLoc[TGT_LOC_SIZE+1];
+   
+TYPE_DATA   
+};
+
+#endif /* matches #ifndef ossimNitfMstgtaTag_HEADER */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfProjectionParameterTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfProjectionParameterTag.h
index af30cfba42ec0118bb33048777b8fbe390f5b73c..21c86e20a553d2d37b1305e45d9f0c09f598134f 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfProjectionParameterTag.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfProjectionParameterTag.h
@@ -1,15 +1,14 @@
 //*******************************************************************
-// Copyright (C) 2004 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
+// License:  LGPL
 //
-// see top level LICENSE.txt
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Garrett Potts
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfProjectionParameterTag.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfProjectionParameterTag.h 14586 2009-05-20 22:45:03Z dburken $
 
 #ifndef ossimNitfProjectionParameterTag_HEADER
 #define ossimNitfProjectionParameterTag_HEADER
@@ -24,7 +23,16 @@ public:
    virtual ossimString getRegisterTagName()const;
    virtual void parseStream(std::istream& in);
    virtual void writeStream(std::ostream& out);
-   virtual std::ostream& print(std::ostream& out)const;
+
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
+
    virtual ossim_uint32 getSizeInBytes()const;
    virtual void clearFields();
    virtual void clearParameters();
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfRpcBase.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfRpcBase.h
index d4455fdbbef942aeeae1de840b3e43789bcce46f..ee919250183617c8d3abd2b10abb9084dceb48f6 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfRpcBase.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfRpcBase.h
@@ -1,9 +1,8 @@
 //*******************************************************************
-// Copyright (C) 2000 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
-//
-// see top level LICENSE.txt
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Garrett Potts
 //
@@ -14,7 +13,7 @@
 // See: http://164.214.2.51/ntb/baseline/docs/stdi0002/final.pdf
 //
 //********************************************************************
-// $Id: ossimNitfRpcBase.h 11982 2007-11-02 16:34:45Z dburken $
+// $Id: ossimNitfRpcBase.h 14576 2009-05-20 13:58:45Z dburken $
 #ifndef ossimNitfRpcBase_HEADER
 #define ossimNitfRpcBase_HEADER
 #include <ossim/support_data/ossimNitfRegisteredTag.h>
@@ -358,15 +357,14 @@ class OSSIM_DLL ossimNitfRpcBase : public ossimNitfRegisteredTag
   void setSampleDenominatorCoeff(ossim_uint32 idx,
                                const ossimString& coeff);
 
-
-  /**
-   * Print method.
-   *
-   * @param out Stream to print to.
-   * 
-   * @return std::ostream&
-   */
-  virtual std::ostream& print(std::ostream& out) const;
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix=std::string()) const;
 
   virtual void setProperty(ossimRefPtr<ossimProperty> property);
   virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfSensraTag.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfSensraTag.h
index 1e8cda52b64f13eb36ea87ea6c814c60f09108b7..9c4342f9acd1fec53cae687b71d885c45303c1fe 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfSensraTag.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfSensraTag.h
@@ -1,15 +1,15 @@
 //*******************************************************************
 //
-// LICENSE: LGPL
+// License:  LGPL
 //
-// see top level LICENSE.txt
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Walt Bunch
 //
 // Description: Nitf support class for SENSRA - Sensor parameters extension.
 // 
 //********************************************************************
-// $Id: ossimNitfSensraTag.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfSensraTag.h 14659 2009-06-05 17:37:39Z dburken $
 #ifndef ossimNitfSensraTag_HEADER
 #define ossimNitfSensraTag_HEADER
 #include <ossim/support_data/ossimNitfRegisteredTag.h>
@@ -56,6 +56,15 @@ public:
    virtual ossim_uint32 getSizeInBytes()const;
    virtual void clearFields();
 
+   /**
+    * @brief Print method that outputs a key/value type format
+    * adding prefix to keys.
+    * @param out Stream to output to.
+    * @param prefix Prefix added to key like "image0.";
+    */
+   virtual std::ostream& print(std::ostream& out,
+                               const std::string& prefix) const;
+   
   // The set methods below taking ossimString args will truncate and
   // pad with spaces, as necessary, to match enumed size
    void setRefRow(ossimString refRow);
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimRpfToc.h b/Utilities/otbossim/include/ossim/support_data/ossimRpfToc.h
index 2272e06565fffd3e7983e3e6c3d05f2f24791eb7..1a111b916c1d00080046ca91a6f48bb8d91d0001 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimRpfToc.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimRpfToc.h
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRpfToc.h 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimRpfToc.h 14535 2009-05-18 13:11:55Z dburken $
 #ifndef osimRpfToc_HEADER
 #define osimRpfToc_HEADER
 
@@ -44,7 +44,8 @@ public:
     * @return output stream.
     */
    std::ostream& print(std::ostream& out,
-                       const std::string& prefix=std::string()) const;
+                       const std::string& prefix=std::string(),
+                       bool printOverviews=false) const;
    
    unsigned long getNumberOfEntries()const{return (ossim_uint32)theTocEntryList.size();}
    const ossimRpfTocEntry* getTocEntry(unsigned long index)const;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h b/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h
index 39775b75185eec8425319f8277e80201ec6ad081..f008ec3ede8947b56658de067f8891e4eeafeef7 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h
@@ -10,7 +10,7 @@
 // Contains declaration of class ossimSpotDimapSupportData.
 //
 //*****************************************************************************
-// $Id: ossimSpotDimapSupportData.h 14206 2009-04-01 12:11:20Z gpotts $
+// $Id: ossimSpotDimapSupportData.h 15766 2009-10-20 12:37:09Z gpotts $
 #ifndef ossimSpotDimapSupportData_HEADER
 #define ossimSpotDimapSupportData_HEADER
 
@@ -54,7 +54,6 @@ public:
                              bool  processSwir=false);
 
    virtual ossimObject* dup()const;
-   virtual ~ossimSpotDimapSupportData();
 
    void clearFields();
    bool loadXmlFile(const ossimFilename& file,
@@ -155,6 +154,9 @@ public:
                           const char* prefix = 0)const;
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix = 0);
+protected:
+   virtual ~ossimSpotDimapSupportData();
+
 private:
    void getLagrangeInterpolation(const ossim_float64& t,
                                  const std::vector<ossimDpt3d>& V,
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimTiffInfo.h b/Utilities/otbossim/include/ossim/support_data/ossimTiffInfo.h
index 73bbf1510fa2b73e7db07e4d4ca5d4c36044d7f6..7cb87cd639748c0a61ebe98658d2f8bb20bfae8f 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimTiffInfo.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimTiffInfo.h
@@ -13,11 +13,18 @@
 #ifndef ossimTiffInfo_HEADER
 #define ossimTiffInfo_HEADER
 
+#include <iosfwd>
+#include <string>
+#include <vector>
+
 #include <ossim/base/ossimConstants.h>
 #include <ossim/support_data/ossimInfoBase.h>
 #include <ossim/base/ossimFilename.h>
 
+class ossimDpt;
 class ossimEndian;
+class ossimKeywordlist;
+class ossimTieGptSet;
 
 /**
  * @brief TIFF info class.
@@ -34,91 +41,100 @@ public:
    /** virtual destructor */
    virtual ~ossimTiffInfo();
 
+   /**
+    * Anonymous enumerations.  Note prefixed with 'O' to avoid conflict with
+    * libtiff.
+    */
    enum
    {
-      UNDEFINED                        = 0,
-      PIXEL_IS_AREA                    = 1,
-      PIXEL_IS_POINT                   = 2,
-      TIFFTAG_SUBFILETYPE              = 254,
-      TIFFTAG_IMAGEWIDTH               = 256,
-      TIFFTAG_IMAGELENGTH              = 257,
-      TIFFTAG_BITSPERSAMPLE            = 258,
-      TIFFTAG_COMPRESSION              = 259,
-      TIFFTAG_PHOTOMETRIC              = 262,
-      TIFFTAG_IMAGEDESCRIPTION         = 270,
-      TIFFTAG_MODEL                    = 272,
-      TIFFTAG_STRIPOFFSETS             = 273,
-      TIFFTAG_ORIENTATION	       = 274,
-      TIFFTAG_SAMPLESPERPIXEL          = 277,
-      TIFFTAG_ROWSPERSTRIP             = 278,
-      TIFFTAG_STRIPBYTECOUNTS          = 279,
-      TIFFTAG_MINSAMPLEVALUE           = 280,
-      TIFFTAG_MAXSAMPLEVALUE           = 281,
-      TIFFTAG_XRESOLUTION              = 282,
-      TIFFTAG_YRESOLUTION              = 283,
-      TIFFTAG_PLANARCONFIG             = 284,
-      TIFFTAG_RESOLUTIONUNIT           = 296,
-      TIFFTAG_DATETIME                 = 306,
-      TIFFTAG_TILEWIDTH                = 322,
-      TIFFTAG_TILELENGTH               = 323,
-      TIFFTAG_TILEOFFSETS              = 324,
-      TIFFTAG_TILEBYTECOUNTS           = 325,
-      TIFFTAG_EXTRASAMPLES             = 338,
-      TIFFTAG_SAMPLEFORMAT             = 339,
-      TIFFTAG_SMINSAMPLEVALUE          = 340,
-      TIFFTAG_SMAXSAMPLEVALUE          = 341,
-      SAMPLEFORMAT_UINT                = 1,
-      SAMPLEFORMAT_INT                 = 2,
-      SAMPLEFORMAT_IEEEFP              = 3,
-      SAMPLEFORMAT_VOID                = 4,
-      SAMPLEFORMAT_COMPLEXINT          = 5,
-      SAMPLEFORMAT_COMPLEXIEEEFP       = 6,
-      TIFFTAG_SUBIFD                   = 330,
-      GT_MODEL_TYPE_GEO_KEY            = 1024,
-      GT_RASTER_TYPE_GEO_KEY           = 1025,
-      GT_CITATION_GEO_KEY              = 1026,
-      GEOGRAPHIC_TYPE_GEO_KEY          = 2048,
-      GEOG_CITATION_GEO_KEY            = 2049,
-      GEOG_GEODETIC_DATUM_GEO_KEY      = 2050,
-      GEOG_LINEAR_UNITS_GEO_KEY        = 2052,
-      GEOG_ANGULAR_UNITS_GEO_KEY       = 2054,
-      GEOG_ELLIPSOID_GEO_KEY           = 2056,
-      GEOG_SEMI_MAJOR_AXIS             = 2057,
-      GEOG_SEMI_MINOR_AXIS             = 2058,
-      PROJECTED_CS_TYPE_GEO_KEY        = 3072,
-      PCS_CITATION_GEO_KEY             = 3073,
-      PROJECTION_GEO_KEY               = 3074,
-      PROJ_COORD_TRANS_GEO_KEY         = 3075,
-      LINEAR_UNITS_GEO_KEY             = 3076,
-      PROJ_STD_PARALLEL1_GEO_KEY       = 3078,
-      PROJ_STD_PARALLEL2_GEO_KEY       = 3079,
-      PROJ_NAT_ORIGIN_LONG_GEO_KEY     = 3080,
-      PROJ_NAT_ORIGIN_LAT_GEO_KEY      = 3081,
-      PROJ_FALSE_EASTING_GEO_KEY       = 3082,
-      PROJ_FALSE_NORTHING_GEO_KEY      = 3083,
-      PROJ_CENTER_LONG_GEO_KEY         = 3088,
-      PROJ_CENTER_LAT_GEO_KEY          = 3089,
-      PROJ_SCALE_AT_NAT_ORIGIN_GEO_KEY = 3092,
-      LINEAR_METER                     = 9001,
-      LINEAR_FOOT                      = 9002,
-      LINEAR_FOOT_US_SURVEY            = 9003,
-      ANGULAR_DEGREE                   = 9102,
-      ANGULAR_ARC_MINUTE               = 9103,
-      ANGULAR_ARC_SECOND               = 9104,
-      ANGULAR_GRAD                     = 9105,
-      ANGULAR_GON                      = 9106,
-      ANGULAR_DMS                      = 9107,
-      ANGULAR_DMS_HEMISPHERE           = 9108,
-      PCS_BRITISH_NATIONAL_GRID        = 27700,
-      USER_DEFINED                     = 32767,
-      TIFFTAG_COPYRIGHT                = 33432,
-      MODEL_PIXEL_SCALE_TAG            = 33550,
-      MODEL_TIE_POINT_TAG              = 33922,
-      MODEL_TRANSFORM_TAG              = 34264,
-      TIFFTAG_PHOTOSHOP                = 34377,
-      GEO_KEY_DIRECTORY_TAG            = 34735,
-      GEO_DOUBLE_PARAMS_TAG            = 34736,
-      GEO_ASCII_PARAMS_TAG             = 34737
+      UNDEFINED                           = 0,
+      OPIXEL_IS_AREA                      = 1,
+      OPIXEL_IS_POINT                     = 2,
+      OTIFFTAG_SUBFILETYPE                = 254,
+      OTIFFTAG_IMAGEWIDTH                 = 256,
+      OTIFFTAG_IMAGELENGTH                = 257,
+      OTIFFTAG_BITSPERSAMPLE              = 258,
+      OTIFFTAG_COMPRESSION                = 259,
+      OTIFFTAG_PHOTOMETRIC                = 262,
+      OTIFFTAG_IMAGEDESCRIPTION           = 270,
+      OTIFFTAG_MODEL                      = 272,
+      OTIFFTAG_STRIPOFFSETS               = 273,
+      OTIFFTAG_ORIENTATION                = 274,
+      OTIFFTAG_SAMPLESPERPIXEL            = 277,
+      OTIFFTAG_ROWSPERSTRIP               = 278,
+      OTIFFTAG_STRIPBYTECOUNTS            = 279,
+      OTIFFTAG_MINSAMPLEVALUE             = 280,
+      OTIFFTAG_MAXSAMPLEVALUE             = 281,
+      OTIFFTAG_XRESOLUTION                = 282,
+      OTIFFTAG_YRESOLUTION                = 283,
+      OTIFFTAG_PLANARCONFIG               = 284,
+      OTIFFTAG_RESOLUTIONUNIT             = 296,
+      OTIFFTAG_SOFTWARE                   = 305,
+      OTIFFTAG_DATETIME                   = 306,
+      OTIFFTAG_TILEWIDTH                  = 322,
+      OTIFFTAG_TILELENGTH                 = 323,
+      OTIFFTAG_TILEOFFSETS                = 324,
+      OTIFFTAG_TILEBYTECOUNTS             = 325,
+      OTIFFTAG_EXTRASAMPLES               = 338,
+      OTIFFTAG_SAMPLEFORMAT               = 339,
+      OTIFFTAG_SMINSAMPLEVALUE            = 340,
+      OTIFFTAG_SMAXSAMPLEVALUE            = 341,
+      OSAMPLEFORMAT_UINT                  = 1,
+      OSAMPLEFORMAT_INT                   = 2,
+      OSAMPLEFORMAT_IEEEFP                = 3,
+      OSAMPLEFORMAT_VOID                  = 4,
+      OSAMPLEFORMAT_COMPLEXINT            = 5,
+      OSAMPLEFORMAT_COMPLEXIEEEFP         = 6,
+      OTIFFTAG_SUBIFD                     = 330,
+      OGT_MODEL_TYPE_GEO_KEY              = 1024,
+      OGT_RASTER_TYPE_GEO_KEY             = 1025,
+      OGT_CITATION_GEO_KEY                = 1026,
+      OGEOGRAPHIC_TYPE_GEO_KEY            = 2048,
+      OGEOG_CITATION_GEO_KEY              = 2049,
+      OGEOG_GEODETIC_DATUM_GEO_KEY        = 2050,
+      OGEOG_LINEAR_UNITS_GEO_KEY          = 2052,
+      OGEOG_ANGULAR_UNITS_GEO_KEY         = 2054,
+      OGEOG_ELLIPSOID_GEO_KEY             = 2056,
+      OGEOG_SEMI_MAJOR_AXIS               = 2057,
+      OGEOG_SEMI_MINOR_AXIS               = 2058,
+      OPROJECTED_CS_TYPE_GEO_KEY          = 3072,
+      OPCS_CITATION_GEO_KEY               = 3073,
+      OPROJECTION_GEO_KEY                 = 3074,
+      OPROJ_COORD_TRANS_GEO_KEY           = 3075,
+      OLINEAR_UNITS_GEO_KEY               = 3076,
+      OPROJ_STD_PARALLEL1_GEO_KEY         = 3078,
+      OPROJ_STD_PARALLEL2_GEO_KEY         = 3079,
+      OPROJ_NAT_ORIGIN_LONG_GEO_KEY       = 3080,
+      OPROJ_NAT_ORIGIN_LAT_GEO_KEY        = 3081,
+      OPROJ_FALSE_EASTING_GEO_KEY         = 3082,
+      OPROJ_FALSE_NORTHING_GEO_KEY        = 3083,
+      OPROJ_FALSE_ORIGIN_LONG_GEO_KEY     = 3084,
+      OPROJ_FALSE_ORIGIN_LAT_GEO_KEY      = 3085,
+      OPROJ_FALSE_ORIGIN_EASTING_GEO_KEY  = 3086,
+      OPROJ_FALSE_ORIGIN_NORTHING_GEO_KEY = 3087,
+      OPROJ_CENTER_LONG_GEO_KEY           = 3088,
+      OPROJ_CENTER_LAT_GEO_KEY            = 3089,
+      OPROJ_SCALE_AT_NAT_ORIGIN_GEO_KEY   = 3092,
+      OLINEAR_METER                       = 9001,
+      OLINEAR_FOOT                        = 9002,
+      OLINEAR_FOOT_US_SURVEY              = 9003,
+      OANGULAR_DEGREE                     = 9102,
+      OANGULAR_ARC_MINUTE                 = 9103,
+      OANGULAR_ARC_SECOND                 = 9104,
+      OANGULAR_GRAD                       = 9105,
+      OANGULAR_GON                        = 9106,
+      OANGULAR_DMS                        = 9107,
+      OANGULAR_DMS_HEMISPHERE             = 9108,
+      OPCS_BRITISH_NATIONAL_GRID          = 27700,
+      OUSER_DEFINED                       = 32767,
+      OTIFFTAG_COPYRIGHT                  = 33432,
+      OMODEL_PIXEL_SCALE_TAG              = 33550,
+      OMODEL_TIE_POINT_TAG                = 33922,
+      OMODEL_TRANSFORM_TAG                = 34264,
+      OTIFFTAG_PHOTOSHOP                  = 34377,
+      OGEO_KEY_DIRECTORY_TAG              = 34735,
+      OGEO_DOUBLE_PARAMS_TAG              = 34736,
+      OGEO_ASCII_PARAMS_TAG               = 34737
    };
 
    enum CompressType
@@ -129,22 +145,22 @@ public:
  
    enum PhotoInterpretation
    {
-      PHOTO_MINISWHITE  = 0,   // min value is white 
-      PHOTO_MINISBLACK  = 1,   // min value is black 
-      PHOTO_RGB         = 2,   // RGB color model 
-      PHOTO_PALETTE     = 3,   // color map indexed 
-      PHOTO_MASK        = 4,   // $holdout mask 
-      PHOTO_SEPARATED   = 5,   // !color separations 
-      PHOTO_YCBCR       = 6,   // !CCIR 601 
-      PHOTO_CIELAB      = 8    // !1976 CIE L*a*b*
+      OPHOTO_MINISWHITE  = 0,   // min value is white 
+      OPHOTO_MINISBLACK  = 1,   // min value is black 
+      OPHOTO_RGB         = 2,   // RGB color model 
+      OPHOTO_PALETTE     = 3,   // color map indexed 
+      OPHOTO_MASK        = 4,   // $holdout mask 
+      OPHOTO_SEPARATED   = 5,   // !color separations 
+      OPHOTO_YCBCR       = 6,   // !CCIR 601 
+      OPHOTO_CIELAB      = 8    // !1976 CIE L*a*b*
    };
 
    enum ModelType
    {
-      UNKNOWN               = 0,
-      MODEL_TYPE_PROJECTED  = 1,  // Projection Coordinate System
-      MODEL_TYPE_GEOGRAPHIC = 2,  // Geographic latitude-longitude System 
-      MODEL_TYPE_GEOCENTRIC = 3
+      UNKNOWN                = 0,
+      OMODEL_TYPE_PROJECTED  = 1,  // Projection Coordinate System
+      OMODEL_TYPE_GEOGRAPHIC = 2,  // Geographic latitude-longitude System 
+      OMODEL_TYPE_GEOCENTRIC = 3
    };
 
    enum WordType
@@ -155,23 +171,23 @@ public:
 
    enum
    {
-      TIFF_NOTYPE = 0,      /* placeholder */
-      TIFF_BYTE = 1,        /* 8-bit unsigned integer */
-      TIFF_ASCII = 2,       /* 8-bit bytes w/ last byte null */
-      TIFF_SHORT = 3,       /* 16-bit unsigned integer */
-      TIFF_LONG = 4,        /* 32-bit unsigned integer */
-      TIFF_RATIONAL = 5,    /* 64-bit unsigned fraction */
-      TIFF_SBYTE = 6,       /* !8-bit signed integer */
-      TIFF_UNDEFINED = 7,   /* !8-bit untyped data */
-      TIFF_SSHORT = 8,      /* !16-bit signed integer */
-      TIFF_SLONG = 9,       /* !32-bit signed integer */
-      TIFF_SRATIONAL = 10,  /* !64-bit signed fraction */
-      TIFF_FLOAT = 11,      /* !32-bit IEEE floating point */
-      TIFF_DOUBLE = 12,     /* !64-bit IEEE floating point */
-      TIFF_IFD = 13,        /* %32-bit unsigned integer (offset) */
-      TIFF_LONG8 = 16,      /* BigTIFF 64-bit unsigned integer */
-      TIFF_SLONG8 = 17,     /* BigTIFF 64-bit signed integer */
-      TIFF_IFD8 = 18        /* BigTIFF 64-bit unsigned integer (offset) */
+      OTIFF_NOTYPE = 0,      /* placeholder */
+      OTIFF_BYTE = 1,        /* 8-bit unsigned integer */
+      OTIFF_ASCII = 2,       /* 8-bit bytes w/ last byte null */
+      OTIFF_SHORT = 3,       /* 16-bit unsigned integer */
+      OTIFF_LONG = 4,        /* 32-bit unsigned integer */
+      OTIFF_RATIONAL = 5,    /* 64-bit unsigned fraction */
+      OTIFF_SBYTE = 6,       /* !8-bit signed integer */
+      OTIFF_UNDEFINED = 7,   /* !8-bit untyped data */
+      OTIFF_SSHORT = 8,      /* !16-bit signed integer */
+      OTIFF_SLONG = 9,       /* !32-bit signed integer */
+      OTIFF_SRATIONAL = 10,  /* !64-bit signed fraction */
+      OTIFF_FLOAT = 11,      /* !32-bit IEEE floating point */
+      OTIFF_DOUBLE = 12,     /* !64-bit IEEE floating point */
+      OTIFF_IFD = 13,        /* %32-bit unsigned integer (offset) */
+      OTIFF_LONG8 = 16,      /* BigTIFF 64-bit unsigned integer */
+      OTIFF_SLONG8 = 17,     /* BigTIFF 64-bit signed integer */
+      OTIFF_IFD8 = 18        /* BigTIFF 64-bit unsigned integer (offset) */
    };
 
    /**
@@ -182,7 +198,7 @@ public:
     * @return true on success false on error.
     */
    virtual bool open(const ossimFilename& file);
-   
+
    /**
     * Print method.
     *
@@ -192,6 +208,55 @@ public:
     */
    virtual std::ostream& print(std::ostream& out) const;
 
+   /**
+    * @brief Print method.
+    * 
+    * Print method that takes a stream that should be positions at the start
+    * of tiff stream. This was added to see embedded information on embedded
+    * geotiff's in a geojp2 file.
+    *
+    * @param out Stream to print to.
+    * 
+    * @return std::ostream&
+    */
+   virtual std::ostream& print(std::ifstream& inStr,
+                               std::ostream& outStr) const;
+
+   /**
+    *  @brief extracts geometry info to keyword list.  This method assumes
+    *  that open has been called and theFile is set.
+    *  
+    *  Populates the keyword list with image geometry information.  This
+    *  method is used to relay projection/model information to users.
+    *
+    *  @param geomKwl Keyword list that will be initialized with geometry info.
+    *  Returns true if geometry info is present, false if not.
+    *
+    *  @param entryIndex Entry to get geometry from. 
+    */
+   bool getImageGeometry(ossimKeywordlist& geomKwl,
+                         ossim_uint32 entryIndex) const;
+   /**
+    *  @brief extracts geometry info from stream to keyword list.
+    *  
+    *  Populates the keyword list with image geometry information.  This
+    *  method is used to relay projection/model information to users.
+    *
+    *  @note that the str should be position at start of tiff portion. This
+    *  was written to allow passing a stream positioned at an embedded tiff
+    *  image in a jp2 file.
+    *
+    *  @param str Stream position at start of tiff image.
+    *
+    *  @param geomKwl Keyword list that will be initialized with geometry info.
+    *  Returns true if geometry info is present, false if not.
+    *
+    *  @param entryIndex Entry to get geometry from. 
+    */
+   bool getImageGeometry(std::ifstream& str,
+                         ossimKeywordlist& geomKwl,
+                         ossim_uint32 entryIndex) const;
+
 private:
    
    /** Initializes s reference.  Does byte swapping as needed. */
@@ -221,7 +286,8 @@ private:
     *
     * @return true if stream is good, false if not.
     */
-   bool getOffset(std::streamoff& offset, std::ifstream& str) const;
+   bool getOffset(std::streamoff& offset, std::ifstream& str,
+                  ossim_uint16 version) const;
    
    /**
     * This will read either 2 , 4or 8 bytes depending on the version and
@@ -229,7 +295,8 @@ private:
     *
     * @return true if stream is good, false if not.
     */
-   bool getValue(ossim_uint64& val, std::ifstream& str, WordType type) const;
+   bool getValue(ossim_uint64& val, std::ifstream& str, WordType type,
+                 ossim_uint16 version) const;
    
    ossim_uint64 getArraySizeInBytes(ossim_uint64 length,
                                     ossim_uint16 type) const;
@@ -242,7 +309,7 @@ private:
    /**
     * Eats the value field.  Either 4 or 8 bytes depending on the version.
     */
-   void eatValue(std::ifstream& str) const;
+   void eatValue(std::ifstream& str, ossim_uint16 version) const;
    
    void swapBytes(ossim_uint8* v, ossim_uint16 type, ossim_uint64 count) const;
    
@@ -313,10 +380,202 @@ private:
    /** @brief adds imageN. to prefix where N is zero base directory index. */
    void getDirPrefix(ossim_int32 dirIndex, std::string& prefix) const;
 
+   /**
+    * @brief Gets the required pixel scale from keyword list looking for the
+    * key model_pixel_scale.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param scale The point to initialize.
+    * @return true on success, false on error.
+    */
+   bool getPixelScale(const ossimString& gtiffPrefix,
+                      const ossimKeywordlist& gtiffKwl,
+                      ossimDpt& scale) const;
+   
+   /**
+    * @brief Gets the model_tie_point array.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param ties The array to initialize.
+    * @return true on success, false on error.
+    */
+   bool getTiePoint(const ossimString& gtiffPrefix,
+                    const ossimKeywordlist& gtiffKwl,
+                    std::vector<ossim_float64>& ties) const;
+
+   /**
+    * @brief Gets the model_transform array.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param ties The array to initialize.
+    * @return true on success, false on error.
+    */
+   bool getModelTransform(const ossimString& gtiffPrefix,
+                          const ossimKeywordlist& gtiffKwl,
+                          std::vector<ossim_float64>& xfrm) const;
+
+   /**
+    * @brief Extracts float values from keyword list that match key.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param key to look for.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param floats Array to stuff.  Will have size of zero on failure.
+    * @return true on success, false on error.  If size of array is zero it
+    * will return false.
+    */
+   bool  getFloats(const ossimString& gtiffPrefix,
+                   const ossimString& key,
+                   const ossimKeywordlist& gtiffKwl,
+                   std::vector<ossim_float64>& floats) const;
+
+   /**
+    * @brief Extracts float values from lookup line and puts in floats array.
+    * @param lookup Line to parse like:
+    * "0.00138888888889 0.00138888888889, 0.0"
+    * @param floats Array to stuff.  Will have size of zero on failure.
+    */
+   bool getFloats(const ossimString& line,
+                  std::vector<ossim_float64>& floats) const;
+
+   /**
+    * @brief Gets the pcs code from the keyword list as a string.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param pcsCode The code to initialize.
+    * @return true on success, false on error.
+    */
+   bool getPcsCode(const ossimString& gtiffPrefix,
+                   const ossimKeywordlist& gtiffKwl,
+                   ossimString& pcsCode) const;
+
+   /**
+    * @brief Gets units from keyword list as a string. This will be angular
+    * or linear base on the model type.  The default is meters if not found.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param linearUnits The string to initialize with units.
+    * @return true on success, false on error.
+    */
+   bool getUnits(const ossimString& gtiffPrefix,
+                 const ossimKeywordlist& gtiffKwl,
+                 ossimString& units) const;
+   /**
+    * @brief Gets the linear units from keyword list as a string.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param linearUnits The string to initialize with units.
+    * @return true on success, false on error.
+    */
+   bool getLinearUnits(const ossimString& gtiffPrefix,
+                       const ossimKeywordlist& gtiffKwl,
+                       ossimString& linearUnits) const;
+
+   /**
+    * @brief Gets the units from keyword list as a string.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param angularUnit The string to initialize with units.
+    * @return true on success, false on error.
+    */
+   bool getAngularUnits(const ossimString& gtiffPrefix,
+                        const ossimKeywordlist& gtiffKwl,
+                        ossimString& units) const;
+
+
+   /**
+    * @brief Gets the pixel type (point or area) from keyword list as a string.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param unit The string to initialize with pixel type.
+    * @return true on success, false on error.
+    */   
+   bool getPixelType(const ossimString& gtiffPrefix,
+                     const ossimKeywordlist& gtiffKwl,
+                     ossimString& pixelType) const;
+
+   /**
+    * @brief Gets the model type from keyword list as a string.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param modelType The string to initialize with pixel type.
+    * @return true on success, false on error.
+    */   
+   bool getModelType(const ossimString& gtiffPrefix,
+                     const ossimKeywordlist& gtiffKwl,
+                     ossimString& modeType) const;
+
+   /**
+    * @brief Gets the ossimProjection from keyword list as a string.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @param ossimProj The string to initialize with pixel type.
+    * @return true on success, false on error.
+    */   
+   bool getOssimProjectionName(const ossimString& gtiffPrefix,
+                               const ossimKeywordlist& gtiffKwl,
+                               ossimString& ossimProj) const;
+   
+   /**
+    * @brief Gets the number of lines from keyword list.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @return Number of lines or 0 if lines not found.
+    */   
+   ossim_uint32 getLines(const ossimString& gtiffPrefix,
+                         const ossimKeywordlist& gtiffKwl) const;
+
+   /**
+    * @brief Gets the number of samples from keyword list.
+    * @param gtiffPrefix Prefix for gtiffKwl.
+    * @param gtiffKwl The keyword list with all tiff keywords.
+    * @return Number of lines or 0 if lines not found.
+    */   
+   ossim_uint32 getSamples(const ossimString& gtiffPrefix,
+                           const ossimKeywordlist& gtiffKwl) const;
+
+   bool getStdParallelOne(const ossimString& gtiffPrefix,
+                          const ossimKeywordlist& gtiffKwl,
+                          ossimString& value) const;
+
+   bool getStdParallelTwo(const ossimString& gtiffPrefix,
+                          const ossimKeywordlist& gtiffKwl,
+                          ossimString& value) const;
+   
+   bool getFalseEasting(const ossimString& gtiffPrefix,
+                        const ossimKeywordlist& gtiffKwl,
+                        ossimString& value) const;
+
+   bool getFalseNorthing(const ossimString& gtiffPrefix,
+                         const ossimKeywordlist& gtiffKwl,
+                         ossimString& value) const;
+
+   bool getFalseEastingNorthing(const ossimString& gtiffPrefix,
+                                const ossimKeywordlist& gtiffKwl,
+                                ossimDpt& eastingNorthing) const;
+
+   bool getScaleFactor(const ossimString& gtiffPrefix,
+                       const ossimKeywordlist& gtiffKwl,
+                       ossim_float64& value) const;
+
+   bool getOriginLat(const ossimString& gtiffPrefix,
+                     const ossimKeywordlist& gtiffKwl,
+                     ossim_float64& value) const;
+
+   bool getCentralMeridian(const ossimString& gtiffPrefix,
+                           const ossimKeywordlist& gtiffKwl,
+                           ossim_float64& value) const;
+
+   void getTieSets(const std::vector<ossim_float64>& ties,
+                   ossim_uint32 width,
+                   ossim_uint32 height,
+                   ossimTieGptSet& tieSet) const;
+
+   bool hasOneBasedTiePoints(const std::vector<ossim_float64>& ties,
+                             ossim_uint32 width,
+                             ossim_uint32 height) const;
    
    ossimFilename  theFile;
    ossimEndian*   theEndian;
-   ossim_uint16   theVersion;
 };
 
 #endif /* End of "#ifndef ossimTiffInfo_HEADER" */
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dBilinearTransform.cpp b/Utilities/otbossim/src/ossim/base/ossim2dBilinearTransform.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9069c424be8a73817825c709b4b3af012d0f0504
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/base/ossim2dBilinearTransform.cpp
@@ -0,0 +1,170 @@
+#include <ossim/base/ossim2dBilinearTransform.h>
+#include <ossim/base/ossimLeastSquaresBilin.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <iostream>
+RTTI_DEF1(ossim2dBilinearTransform, "ossim2dBilinearTransform", ossim2dTo2dTransform);
+ossim2dBilinearTransform::ossim2dBilinearTransform()
+{
+   std::fill(m_coefficientsXTerm, m_coefficientsXTerm+4, 0.0);
+   std::fill(m_coefficientsYTerm, m_coefficientsYTerm+4, 0.0);
+   std::fill(m_inverseCoefficientsXTerm, m_inverseCoefficientsXTerm+4, 0.0);
+   std::fill(m_inverseCoefficientsYTerm, m_inverseCoefficientsYTerm+4, 0.0);
+   
+   // setup identity
+   //
+   m_coefficientsXTerm[1] = 1.0;
+   m_coefficientsYTerm[2] = 1.0;
+   m_inverseCoefficientsXTerm[1] = 1.0;
+   m_inverseCoefficientsYTerm[2] = 1.0;
+}
+
+ossim2dBilinearTransform::ossim2dBilinearTransform(const ossim2dBilinearTransform& src)
+:ossim2dTo2dTransform(src)
+{
+   std::copy(src.m_coefficientsXTerm, src.m_coefficientsXTerm+4, m_coefficientsXTerm);
+   std::copy(src.m_coefficientsYTerm, src.m_coefficientsYTerm+4, m_coefficientsYTerm);
+   std::copy(src.m_inverseCoefficientsXTerm, src.m_inverseCoefficientsXTerm+4, m_inverseCoefficientsXTerm);
+   std::copy(src.m_inverseCoefficientsYTerm, src.m_inverseCoefficientsYTerm+4, m_inverseCoefficientsYTerm);
+}
+
+void ossim2dBilinearTransform::setFromPoints(const ossimDpt& in1, const ossimDpt& in2, const ossimDpt& in3, const ossimDpt& in4,
+                                             const ossimDpt& out1, const ossimDpt& out2, const ossimDpt& out3, const ossimDpt& out4)
+{
+   ossimDpt input[4];
+   ossimDpt output[4];
+   
+   input[0] = in1;
+   input[1] = in2;
+   input[2] = in3;
+   input[3] = in4;
+   
+   output[0] = out1;
+   output[1] = out2;
+   output[2] = out3;
+   output[3] = out4;
+   
+   setFromPoints(&input[0], &output[0], 4);
+}
+
+void ossim2dBilinearTransform::setFromPoints(const ossimDpt* input,
+                                             const ossimDpt* output, 
+                                             ossim_uint32 arraySize)
+{
+   ossimLeastSquaresBilin inx;
+   ossimLeastSquaresBilin inversex;
+   ossimLeastSquaresBilin iny;
+   ossimLeastSquaresBilin inversey;
+   ossim_uint32 idx = 0;
+   for(idx=0; idx < arraySize; ++idx)
+   {
+      inx.addSample(input[idx].x, input[idx].y, output[idx].x);
+      inversex.addSample(output[idx].x, output[idx].y, input[idx].x);
+      iny.addSample(input[idx].x, input[idx].y, output[idx].y);
+      inversey.addSample(output[idx].x, output[idx].y, input[idx].y);
+   }
+   inx.solveLS();
+   inversex.solveLS();
+   iny.solveLS();
+   inversey.solveLS();
+   inx.getLSParms(m_coefficientsXTerm[0], m_coefficientsXTerm[1], m_coefficientsXTerm[2], m_coefficientsXTerm[3]);
+   iny.getLSParms(m_coefficientsYTerm[0], m_coefficientsYTerm[1], m_coefficientsYTerm[2], m_coefficientsYTerm[3]);
+   inversex.getLSParms(m_inverseCoefficientsXTerm[0], m_inverseCoefficientsXTerm[1], m_inverseCoefficientsXTerm[2], m_inverseCoefficientsXTerm[3]);
+   inversey.getLSParms(m_inverseCoefficientsYTerm[0], m_inverseCoefficientsYTerm[1], m_inverseCoefficientsYTerm[2], m_inverseCoefficientsYTerm[3]);
+}
+
+bool ossim2dBilinearTransform::saveState(ossimKeywordlist& kwl,
+                                       const char* prefix)const
+{
+   ossimString xterm = (ossimString::toString(m_coefficientsXTerm[0])
+                        +" "+ossimString::toString(m_coefficientsXTerm[1])
+                        +" "+ossimString::toString(m_coefficientsXTerm[2])
+                        +" "+ossimString::toString(m_coefficientsXTerm[3]));
+   ossimString yterm = (ossimString::toString(m_coefficientsYTerm[0])
+                        +" "+ossimString::toString(m_coefficientsYTerm[1])
+                        +" "+ossimString::toString(m_coefficientsYTerm[2])
+                        +" "+ossimString::toString(m_coefficientsYTerm[3]));
+   ossimString inverse_xterm = (ossimString::toString(m_inverseCoefficientsXTerm[0])
+                        +" "+ossimString::toString(m_inverseCoefficientsXTerm[1])
+                        +" "+ossimString::toString(m_inverseCoefficientsXTerm[2])
+                        +" "+ossimString::toString(m_inverseCoefficientsXTerm[3]));
+   ossimString inverse_yterm = (ossimString::toString(m_inverseCoefficientsYTerm[0])
+                        +" "+ossimString::toString(m_inverseCoefficientsYTerm[1])
+                        +" "+ossimString::toString(m_inverseCoefficientsYTerm[2])
+                        +" "+ossimString::toString(m_inverseCoefficientsYTerm[3]));
+   
+   kwl.add(prefix, "xterm", xterm, true);
+   kwl.add(prefix, "yterm", yterm, true);
+   kwl.add(prefix, "inverse_xterm", inverse_xterm, true);
+   kwl.add(prefix, "inverse_yterm", inverse_yterm, true);
+   return ossim2dTo2dTransform::saveState(kwl, prefix);
+}
+
+bool ossim2dBilinearTransform::loadState(const ossimKeywordlist& kwl,
+                                       const char* prefix)
+{
+   bool result = true;
+   ossimString xterm = kwl.find(prefix, "xterm");
+   ossimString yterm = kwl.find(prefix, "yterm");
+   ossimString inverse_xterm = kwl.find(prefix, "inverse_xterm");
+   ossimString inverse_yterm = kwl.find(prefix, "inverse_yterm");
+   
+   std::vector<ossimString> values;
+   xterm.split(values, " ");
+   if(values.size() == 4)
+   {
+      m_coefficientsXTerm[0] = values[0].toDouble();
+      m_coefficientsXTerm[1] = values[1].toDouble();
+      m_coefficientsXTerm[2] = values[2].toDouble();
+      m_coefficientsXTerm[3] = values[3].toDouble();
+   }
+   else 
+   {
+      result = false;
+   }
+   values.clear();
+   yterm.split(values, " ");
+   if(values.size() == 4)
+   {
+      m_coefficientsYTerm[0] = values[0].toDouble();
+      m_coefficientsYTerm[1] = values[1].toDouble();
+      m_coefficientsYTerm[2] = values[2].toDouble();
+      m_coefficientsYTerm[3] = values[3].toDouble();
+   }
+   else 
+   {
+      result = false;
+   }
+   values.clear();
+   inverse_xterm.split(values, " ");
+   if(values.size() == 4)
+   {
+      m_inverseCoefficientsXTerm[0] = values[0].toDouble();
+      m_inverseCoefficientsXTerm[1] = values[1].toDouble();
+      m_inverseCoefficientsXTerm[2] = values[2].toDouble();
+      m_inverseCoefficientsXTerm[3] = values[3].toDouble();
+   }
+   else 
+   {
+      result = false;
+   }
+   values.clear();
+   inverse_yterm.split(values, " ");
+   if(values.size() == 4)
+   {
+      m_inverseCoefficientsYTerm[0] = values[0].toDouble();
+      m_inverseCoefficientsYTerm[1] = values[1].toDouble();
+      m_inverseCoefficientsYTerm[2] = values[2].toDouble();
+      m_inverseCoefficientsYTerm[3] = values[3].toDouble();
+   }
+   else 
+   {
+      result = false;
+   }
+
+   if(result)
+   {
+      result = ossim2dTo2dTransform::loadState(kwl, prefix);
+   }
+   
+   return result;
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dTo2dIdentityTransform.cpp b/Utilities/otbossim/src/ossim/base/ossim2dTo2dIdentityTransform.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a63f25243fa6fb15cc1431344aa4dc620477d1bf
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/base/ossim2dTo2dIdentityTransform.cpp
@@ -0,0 +1,3 @@
+#include <ossim/base/ossim2dTo2dIdentityTransform.h>
+
+RTTI_DEF1(ossim2dTo2dIdentityTransform, "ossim2dTo2dIdentityTransform", ossim2dTo2dTransform);
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dTo2dShiftTransform.cpp b/Utilities/otbossim/src/ossim/base/ossim2dTo2dShiftTransform.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb2194e852c62721e8294daf5c0a655e519b8a6d
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/base/ossim2dTo2dShiftTransform.cpp
@@ -0,0 +1,25 @@
+#include <ossim/base/ossim2dTo2dShiftTransform.h>
+#include <ossim/base/ossimKeywordlist.h>
+RTTI_DEF1(ossim2dTo2dShiftTransform, "ossim2dTo2dShiftTransform", ossim2dTo2dTransform);
+bool ossim2dTo2dShiftTransform::saveState(ossimKeywordlist& kwl,
+                                          const char* prefix)const
+{
+   bool result = ossim2dTo2dTransform::saveState(kwl, prefix);
+   kwl.add(prefix, "shift", m_shift.toString(), true);
+   
+   return result;
+}
+
+bool ossim2dTo2dShiftTransform::loadState(const ossimKeywordlist& kwl,
+                                          const char* prefix)
+{
+   bool result = ossim2dTo2dTransform::loadState(kwl, prefix);
+   
+   ossimString shift = kwl.find(prefix, "shift");
+   if(!shift.empty())
+   {
+      m_shift.toPoint(shift);
+   }
+   
+   return result;
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransform.cpp b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransform.cpp
index bcbb6d56d18e309dc6ef5bbf274eadc0e752f18e..68c9f026695720741360758424987cf6033daba6 100644
--- a/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransform.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransform.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossim2dTo2dTransform.cpp 13664 2008-10-02 19:57:24Z gpotts $
+// $Id: ossim2dTo2dTransform.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <sstream>
@@ -21,6 +21,16 @@ RTTI_DEF1(ossim2dTo2dTransform, "ossim2dTo2dTransform", ossimObject);
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimNotifyContext.h>
 
+// ### CREATE_COPY ###
+// Implementation of static factory method createCopy() requires includes here of ALL 2D-to-2D
+// transform types that need a deep copy capability:
+#include <ossim/base/ossimAffineTransform.h>
+#include <ossim/projection/ossimImageViewAffineTransform.h>
+#include <ossim/projection/ossimImageViewProjectionTransform.h>
+#include <ossim/projection/ossimMeanRadialLensDistortion.h>
+#include <ossim/base/ossimQuadTreeWarp.h>
+#include <ossim/projection/ossimRadialDecentLensDistortion.h>
+
 //***
 // Define Trace flags for use within this file:
 //***
@@ -247,6 +257,24 @@ void ossim2dTo2dTransform::setDxDy(const ossimDpt& dxdy)
    theDxDy.y = dxdy.y;
 }
 
-void ossim2dTo2dTransform::operator=(const ossim2dTo2dTransform& /* rhs */ )
+const ossim2dTo2dTransform& ossim2dTo2dTransform::operator=(const ossim2dTo2dTransform&  rhs )
+{
+   if (this != &rhs)
+   {
+      ossimObject::operator = (rhs);
+      
+      theConvergenceThreshold = rhs.theConvergenceThreshold;
+      theMaxIterations        = rhs.theMaxIterations;
+      theDxDy                 = rhs.theDxDy;
+   }
+   return *this;
+}
+
+std::ostream& ossim2dTo2dTransform::print(std::ostream& out) const
 {
+   out << "convergenceThreshold: " << theConvergenceThreshold << "\n"
+   << "maxIterations:        " << theMaxIterations << "\n"
+   << "dxdy:                 " << theDxDy << "\n";
+   return out;
 }
+
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransformFactory.cpp b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransformFactory.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ebf59db581fde5ebf4c070561c8bb98be68dd06
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransformFactory.cpp
@@ -0,0 +1,54 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Implementation of ossim2dTo2dTransformFactory.
+//
+//**************************************************************************************************
+// $Id$
+#include <ossim/base/ossim2dTo2dTransformFactory.h>
+#include <ossim/base/ossim2dBilinearTransform.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimRefPtr.h>
+
+ossim2dTo2dTransformFactory* ossim2dTo2dTransformFactory::m_instance = 0;
+ossim2dTo2dTransformFactory* ossim2dTo2dTransformFactory::instance()
+{
+   if(!m_instance)
+   {
+      m_instance = new ossim2dTo2dTransformFactory();
+   }
+   return m_instance;
+}
+
+ossim2dTo2dTransform* ossim2dTo2dTransformFactory::createTransform(const ossimString& name)const
+{
+   ossim2dTo2dTransform* result = 0;
+   if(name == STATIC_TYPE_NAME(ossim2dBilinearTransform))
+   {
+      result = new ossim2dBilinearTransform();
+   }
+   
+   return result;
+}
+
+ossim2dTo2dTransform* ossim2dTo2dTransformFactory::createTransform(const ossimKeywordlist& kwl,
+                                                                   const char* prefix)const
+{
+   ossimString type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   ossimRefPtr<ossim2dTo2dTransform> result =  createTransform(type);
+   if(result.valid()&&!result->loadState(kwl, prefix))
+   {
+      result = 0;
+   }
+   
+   return result.release();
+}
+
+void ossim2dTo2dTransformFactory::getTypeNameList(std::vector<ossimString>& typeList)const
+{
+   typeList.push_back(STATIC_TYPE_NAME(ossim2dBilinearTransform));
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransformRegistry.cpp b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransformRegistry.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..37f666bca212a62be075e9b1eee9a2429d3c61d1
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransformRegistry.cpp
@@ -0,0 +1,26 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Implementation of ossim2dTo2dTransformRegistry.
+//
+//**************************************************************************************************
+// $Id$
+#include <ossim/base/ossim2dTo2dTransformRegistry.h>
+#include <ossim/base/ossim2dTo2dTransformFactory.h>
+#include <ossim/base/ossimObjectFactoryRegistry.h>
+ossim2dTo2dTransformRegistry* ossim2dTo2dTransformRegistry::m_instance = 0;
+RTTI_DEF1(ossim2dTo2dTransformRegistry, "ossim2dTo2dTransformRegistry", ossimObjectFactory);
+ossim2dTo2dTransformRegistry* ossim2dTo2dTransformRegistry::instance()
+{
+   if(!m_instance)
+   {
+      m_instance = new ossim2dTo2dTransformRegistry();
+      m_instance->registerFactory(ossim2dTo2dTransformFactory::instance());
+      ossimObjectFactoryRegistry::instance()->registerFactory(m_instance);
+   }
+   
+   return m_instance;
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossimAffineTransform.cpp b/Utilities/otbossim/src/ossim/base/ossimAffineTransform.cpp
index e96e3b08418a174be736eec99947f2ed1e6841dc..4df6c83d23db42d03d57d20d70052174f203f389 100644
--- a/Utilities/otbossim/src/ossim/base/ossimAffineTransform.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimAffineTransform.cpp
@@ -9,7 +9,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAffineTransform.cpp 12953 2008-06-01 16:24:05Z dburken $
+//  $Id: ossimAffineTransform.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <ossim/base/ossimAffineTransform.h>
@@ -24,13 +24,46 @@ RTTI_DEF1(ossimAffineTransform, "ossimAffineTransform", ossim2dTo2dTransform);
 //*****************************************************************************
 ossimAffineTransform::ossimAffineTransform()
    :
+      ossim2dTo2dTransform(),
+      theScale(1.0, 1.0),
+      theRotation(0.0),
+      theTranslation(0.0, 0.0),
+      theAffineEnabledFlag(true),      
       theForwardXform(3, 3),
-      theInverseXform(3, 3),
-      theAffineEnabledFlag(true)
+      theInverseXform(3, 3)
 {
    setIdentity();
 }
 
+ossimAffineTransform::ossimAffineTransform(const ossimAffineTransform& src)
+   :
+      ossim2dTo2dTransform(src),
+      theScale(src.theScale),
+      theRotation(src.theRotation),
+      theTranslation(src.theTranslation),
+      theAffineEnabledFlag(src.theAffineEnabledFlag),
+      theForwardXform(src.theForwardXform),
+      theInverseXform(src.theInverseXform)
+{
+}
+
+const ossimAffineTransform& ossimAffineTransform::operator=(
+   const ossimAffineTransform& rhs)
+{
+   if (this != &rhs)
+   {
+      ossim2dTo2dTransform::operator=(rhs);
+      
+      theScale             = rhs.theScale;
+      theRotation          = rhs.theRotation;
+      theTranslation       = rhs.theTranslation;
+      theAffineEnabledFlag = rhs.theAffineEnabledFlag;
+      theForwardXform      = rhs.theForwardXform;
+      theInverseXform      = rhs.theInverseXform;
+   }
+   return *this;
+}
+
 //*****************************************************************************
 //  METHOD: 
 //*****************************************************************************
diff --git a/Utilities/otbossim/src/ossim/base/ossimColumnVector3d.cpp b/Utilities/otbossim/src/ossim/base/ossimColumnVector3d.cpp
index 090317300c9d0c753e5c302ff9d598c4b1b26a65..5d18f4cd4885668dbc36a60ab199960df1154506 100644
--- a/Utilities/otbossim/src/ossim/base/ossimColumnVector3d.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimColumnVector3d.cpp
@@ -8,7 +8,7 @@
 //              coordinate.
 //
 //*******************************************************************
-//  $Id: ossimColumnVector3d.cpp 11408 2007-07-27 13:43:00Z dburken $
+//  $Id: ossimColumnVector3d.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 #include <ossim/base/ossimColumnVector3d.h>
@@ -17,9 +17,9 @@
 ossimString ossimColumnVector3d::toString(ossim_uint32 precision) const
 {
    std::ostringstream os;
-   os << setiosflags(ios::fixed) << setprecision(precision);
+   os << setprecision(precision);
    
-   os << "( ";
+   os << "(";
    if ( ossim::isnan(data[0]) == false)
    {
       os << data[0];
@@ -28,7 +28,7 @@ ossimString ossimColumnVector3d::toString(ossim_uint32 precision) const
    {
       os << "nan";
    }
-   os << ", ";
+   os << ",";
    if ( ossim::isnan(data[1]) == false )
    {
       os << data[1];
@@ -37,7 +37,7 @@ ossimString ossimColumnVector3d::toString(ossim_uint32 precision) const
    {
       os << "nan";
    }
-   os << ", ";
+   os << ",";
    if ( ossim::isnan(data[2]) == false )
    {
       os << data[2];
@@ -46,7 +46,7 @@ ossimString ossimColumnVector3d::toString(ossim_uint32 precision) const
    {
       os << "nan";
    }
-   os << " )";
+   os << ")";
    
    return ossimString(os.str());
 }
diff --git a/Utilities/otbossim/src/ossim/base/ossimCommon.cpp b/Utilities/otbossim/src/ossim/base/ossimCommon.cpp
index de44f728e783cb242cfc6bacf75e82ef3b430f97..c2c021a0ea908ac5b9bf4144fc81d733f515c0a8 100644
--- a/Utilities/otbossim/src/ossim/base/ossimCommon.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimCommon.cpp
@@ -1,13 +1,15 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: David Burken
 //
 // Description: Common file for global functions.
 //
 //*************************************************************************
-// $Id: ossimCommon.cpp 13666 2008-10-02 19:59:15Z gpotts $
+// $Id: ossimCommon.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 
@@ -20,11 +22,28 @@
 #include <ossim/base/ossimIpt.h>
 #include <ossim/base/ossimDpt3d.h>
 #include <ossim/matrix/newmat.h>
+#include <ossim/base/ossimDpt.h>
 static ossimTrace traceDebug("ossimCommon:debug");
 
 // stores a floating point nan value
 const ossim::IntFloatBitCoercion ossim::nanValue(~ossim_int64(0));
 
+std::istream& ossim::skipws(std::istream& in)
+{
+   int c = in.peek();
+   while( !in.fail() && ossim::isWhiteSpace(c))
+   {
+      in.ignore(1);
+      c = in.peek();
+   }
+   
+   return in;
+}
+bool ossim::isWhiteSpace(int c)
+{
+   return ( (c == ' ') || (c == '\t') || (c == '\n')|| (c == '\r') ) ;
+}
+
 ossimByteOrder ossim::byteOrder()
 {
    union
@@ -280,6 +299,124 @@ ossim_uint32 ossim::scalarSizeInBytes(ossimScalarType scalarType)
   return 1;
 }
 
+bool ossim::isSigned(ossimScalarType scalarType)
+{
+   bool result = false;
+   switch(scalarType)
+   {
+      case OSSIM_SINT8:
+      case OSSIM_SINT16:
+      case OSSIM_SINT32:
+      case OSSIM_FLOAT32:
+      case OSSIM_FLOAT64:
+      {
+         result = true;
+         break;
+      }
+      default:
+      {
+         break;
+      }
+  }
+  return result;
+}
+
+ossim_uint32 ossim::getActualBitsPerPixel(ossimScalarType scalarType)
+{
+   ossim_uint32 actualBitsPerPixel = 0;
+   switch(scalarType)
+   {
+      case OSSIM_UINT8:
+      case OSSIM_SINT8:
+      {
+         actualBitsPerPixel = 8;
+         break;
+      }
+      case OSSIM_USHORT11:
+      {
+         actualBitsPerPixel = 11;
+         break;
+      }
+      case OSSIM_UINT16:
+      case OSSIM_SINT16:
+      {
+         actualBitsPerPixel = 16;
+         break;
+      }
+      case OSSIM_FLOAT32:
+      case OSSIM_NORMALIZED_FLOAT:
+      {
+         actualBitsPerPixel = 32;
+         break;
+      }
+      case OSSIM_FLOAT64:
+      case OSSIM_NORMALIZED_DOUBLE:
+      {
+         actualBitsPerPixel = 64;
+         break;
+      }
+      default:
+      {
+         if (traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << __FILE__ << ":" << __LINE__
+               << "\nUnhandled scalar type:  " << scalarType << std::endl;
+         }
+         break;
+      }
+   }
+   return actualBitsPerPixel;
+}
+
+ossim_uint32 ossim::getBitsPerPixel(ossimScalarType scalarType)
+{
+   ossim_uint32 bitsPerPixel = 0;
+   switch(scalarType)
+   {
+      case OSSIM_UINT8:
+      case OSSIM_SINT8:
+      {
+         bitsPerPixel = 8;
+         break;
+      }
+      case OSSIM_USHORT11:
+      {
+         bitsPerPixel = 16;
+         break;
+      }
+      case OSSIM_UINT16:
+      case OSSIM_SINT16:
+      {
+         bitsPerPixel = 16;
+         break;
+      }
+      case OSSIM_FLOAT32:
+      case OSSIM_NORMALIZED_FLOAT:
+      {
+         bitsPerPixel = 32;
+         break;
+      }
+      case OSSIM_FLOAT64:
+      case OSSIM_NORMALIZED_DOUBLE:
+      {
+         bitsPerPixel = 64;
+         break;
+      }
+      default:
+      {
+         if (traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << __FILE__ << ":" << __LINE__
+               << "\nUnhandled scalar type:  " << scalarType << std::endl;
+         }
+         break;
+      }
+   }
+   return bitsPerPixel;
+}
+
 void ossim::defaultTileSize(ossimIpt& tileSize)
 {
    const char* tileSizeKw = ossimPreferences::instance()->
@@ -540,3 +677,80 @@ void ossim::lexQuotedTokens(const std::string& str,
       start = str.find_first_not_of(whitespace, end);
    }
 }
+
+void ossim::toStringList(ossimString& resultStringOfPoints,
+                         const std::vector<ossimDpt>& pointList)
+{
+   ossim_uint32 idx = 0;
+   for(;idx < pointList.size();++idx)
+   {
+      ossimString pt = pointList[idx].toString();
+      if(resultStringOfPoints.empty())
+      {
+         resultStringOfPoints = pt;
+      }
+      else
+      {
+         resultStringOfPoints += (" " + pt);
+      }
+   }
+}
+
+void ossim::toStringList(ossimString& resultStringOfPoints,
+                         const std::vector<ossimIpt>& pointList)
+{
+   ossim_uint32 idx = 0;
+   for(;idx < pointList.size();++idx)
+   {
+      ossimString pt = pointList[idx].toString();
+      if(resultStringOfPoints.empty())
+      {
+         resultStringOfPoints = pt;
+      }
+      else
+      {
+         resultStringOfPoints += (" " + pt);
+      }
+   }
+}
+
+void ossim::toVector(std::vector<ossimDpt>& result,
+                     const ossimString& stringOfPoints)
+{
+   std::vector<ossimString> splitResult;
+   
+   stringOfPoints.split(splitResult, " ");
+   
+   if(splitResult.size() > 0)
+   {
+      ossimDpt tempPoint;
+      ossim_uint32 idx = 0;
+      for(;idx < splitResult.size(); ++idx)
+      {
+         tempPoint = ossimDpt(0.0,0.0);
+         tempPoint.toPoint(splitResult[idx]);
+         result.push_back(tempPoint);
+      }
+   }
+}
+
+void ossim::toVector(std::vector<ossimIpt>& result,
+                     const ossimString& stringOfPoints)
+{
+   std::vector<ossimString> splitResult;
+   
+   stringOfPoints.split(splitResult, " ");
+   
+   if(splitResult.size() > 0)
+   {
+      ossimDpt tempPoint;
+      ossim_uint32 idx = 0;
+      for(;idx < splitResult.size(); ++idx)
+      {
+         tempPoint = ossimDpt(0.0,0.0);
+         tempPoint.toPoint(splitResult[idx]);
+         result.push_back(tempPoint);
+      }
+   }
+}
+
diff --git a/Utilities/otbossim/src/ossim/base/ossimConnectableContainer.cpp b/Utilities/otbossim/src/ossim/base/ossimConnectableContainer.cpp
index a4c97df210e492acdc448e8682abd287edd73b36..037a3cef2247a785a9d9e5f8f07184430681cd4b 100644
--- a/Utilities/otbossim/src/ossim/base/ossimConnectableContainer.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimConnectableContainer.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimConnectableContainer.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimConnectableContainer.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <algorithm>
 #include <stack>
@@ -95,8 +95,8 @@ ossimConnectableContainer::~ossimConnectableContainer()
    if(theChildListener)
    {
       delete theChildListener;
-      theChildListener = NULL;
    }
+   theChildListener = 0;
 }
 
 ossimConnectableObject* ossimConnectableContainer::findFirstObjectOfType(const RTTItypeid& typeInfo,
@@ -110,7 +110,7 @@ ossimConnectableObject* ossimConnectableContainer::findFirstObjectOfType(const R
    {
       if(((*current).second)->canCastTo(typeInfo))
       {
-         return (*current).second;
+         return (*current).second.get();
       }
       ++current;
    }
@@ -120,7 +120,7 @@ ossimConnectableObject* ossimConnectableContainer::findFirstObjectOfType(const R
       current = theObjectMap.begin();
       while(current != theObjectMap.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
 
          if(child)
          {
@@ -148,7 +148,7 @@ ossimConnectableObject* ossimConnectableContainer::findFirstObjectOfType(const o
    {
       if( ((*current).second)->canCastTo(className) )
       {
-         return (*current).second;
+         return (*current).second.get();
       }
       ++current;
    }
@@ -158,7 +158,7 @@ ossimConnectableObject* ossimConnectableContainer::findFirstObjectOfType(const o
       current = theObjectMap.begin();
       while(current != theObjectMap.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
 
          if(child)
          {
@@ -175,10 +175,10 @@ ossimConnectableObject* ossimConnectableContainer::findFirstObjectOfType(const o
    return result;
 }
 
-std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOfType(const RTTItypeid& typeInfo,
+ossimConnectableObject::ConnectableObjectList ossimConnectableContainer::findAllObjectsOfType(const RTTItypeid& typeInfo,
                                                                                      bool recurse)
 {
-   std::vector<ossimConnectableObject*> result;
+   ossimConnectableObject::ConnectableObjectList result;
 
    connectablObjectMapType::iterator current;
 
@@ -187,7 +187,7 @@ std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOf
    {
       if(((*current).second)->canCastTo(typeInfo))
       {
-         result.push_back( (*current).second);
+         result.push_back( (*current).second.get());
       }
       ++current;
    }
@@ -197,11 +197,11 @@ std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOf
       current = theObjectMap.begin();
       while(current != theObjectMap.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
 
          if(child)
          {
-            std::vector<ossimConnectableObject*> temp;
+            ConnectableObjectList temp;
             temp = child->findAllObjectsOfType(typeInfo, recurse);
             for(long index=0; index < (long)temp.size();++index)
             {
@@ -214,10 +214,10 @@ std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOf
    return result;
 }
 
-std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOfType(const ossimString& className,
+ossimConnectableObject::ConnectableObjectList ossimConnectableContainer::findAllObjectsOfType(const ossimString& className,
                                                                                      bool recurse)
 {
-   std::vector<ossimConnectableObject*> result;
+   ossimConnectableObject::ConnectableObjectList result;
 
    connectablObjectMapType::iterator current;
 
@@ -226,7 +226,7 @@ std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOf
    {
       if(((*current).second)->canCastTo(className))
       {
-         result.push_back( (*current).second);
+         result.push_back( (*current).second.get());
       }
       ++current;
    }
@@ -236,11 +236,11 @@ std::vector<ossimConnectableObject*> ossimConnectableContainer::findAllObjectsOf
       current = theObjectMap.begin();
       while(current != theObjectMap.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
 
          if(child)
          {
-            std::vector<ossimConnectableObject*> temp;
+            ossimConnectableObject::ConnectableObjectList temp;
             temp = child->findAllObjectsOfType(className, true);
             for(long index=0; index < (long)temp.size();++index)
             {
@@ -262,9 +262,9 @@ ossimConnectableObject* ossimConnectableContainer::findObject(const ossimId& id,
 
    while(current != theObjectMap.end())
    {
-      if((*current).second && ((*current).second->getId()==id))
+      if((*current).second.valid() && ((*current).second->getId()==id))
       {
-         return (*current).second;
+         return (*current).second.get();
       }
       ++current;
    }
@@ -275,7 +275,7 @@ ossimConnectableObject* ossimConnectableContainer::findObject(const ossimId& id,
 
       while(current != theObjectMap.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
 
          if(child)
          {
@@ -298,9 +298,9 @@ ossimConnectableObject* ossimConnectableContainer::findObject(const ossimConnect
 
    while(current != theObjectMap.end())
    {
-      if((*current).second && ((*current).second==obj))
+      if((*current).second.valid() && ((*current).second==obj))
       {
-         return (*current).second;
+         return (*current).second.get();
       }
       ++current;
    }
@@ -311,7 +311,7 @@ ossimConnectableObject* ossimConnectableContainer::findObject(const ossimConnect
 
       while(current != theObjectMap.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
 
          if(child)
          {
@@ -329,7 +329,7 @@ ossimConnectableObject* ossimConnectableContainer::findObject(const ossimConnect
 void ossimConnectableContainer::makeUniqueIds()
 {
    connectablObjectMapType::iterator current;
-   std::vector<ossimConnectableObject*> objectList;
+   std::vector<ossimConnectableObject* > objectList;
 
 
    current = theObjectMap.begin();
@@ -337,7 +337,7 @@ void ossimConnectableContainer::makeUniqueIds()
    setId(ossimIdManager::instance()->generateId());
    while(current != theObjectMap.end())
    {
-      objectList.push_back((*current).second);
+      objectList.push_back((*current).second.get());
       ++current;
    }
    theObjectMap.clear();
@@ -375,7 +375,7 @@ ossim_uint32 ossimConnectableContainer::getNumberOfObjects(bool recurse)const
 
       if(recurse)
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).second.get());
          if(child)
          {
             result += child->getNumberOfObjects(true);
@@ -396,7 +396,6 @@ bool ossimConnectableContainer::addChild(ossimConnectableObject* object)
       {
          object->changeOwner(this);
          theObjectMap.insert(std::make_pair(object->getId().getId(), object));
-//         object->addListener((ossimConnectableObjectListener*)this);
          object->addListener(theChildListener);
       }
 
@@ -415,7 +414,7 @@ bool ossimConnectableContainer::removeChild(ossimConnectableObject* object)
       connectablObjectMapType::iterator childIter = theObjectMap.find(object->getId().getId());
       if(childIter != theObjectMap.end())
       {
-         result = (*childIter).second;
+         result = (*childIter).second.get();
          if(result->getOwner() == this)
          {
             result->changeOwner(NULL);
@@ -459,30 +458,30 @@ bool ossimConnectableContainer::saveState(ossimKeywordlist& kwl,
 {
    bool result = true;
    connectablObjectMapType::const_iterator current;
-
+   
    ossim_int32 childIndex = 1;
    current = theObjectMap.begin();
    while(current != theObjectMap.end())
    {
-     ossimString newPrefix = ( (ossimString(prefix) +
-				ossimString("object") +
-				ossimString::toString(childIndex) + "."));
-     if((*current).second)
-       {
-	 bool test = ((*current).second)->saveState(kwl, newPrefix);
-	 if(!test)
-	   {
-	     result = false;
-	   }
-       }
-     ++childIndex;
-     ++current;
+      ossimString newPrefix = ( (ossimString(prefix) +
+                                 ossimString("object") +
+                                 ossimString::toString(childIndex) + "."));
+      if((*current).second.valid())
+      {
+         bool test = ((*current).second)->saveState(kwl, newPrefix);
+         if(!test)
+         {
+            result = false;
+         }
+      }
+      ++childIndex;
+      ++current;
    }
    if(result)
    {
       result = ossimConnectableObject::saveState(kwl, prefix);
    }
-
+   
    return result;
 }
 
@@ -495,7 +494,7 @@ void ossimConnectableContainer::getChildren(std::vector<ossimConnectableObject*>
 
    while(current != theObjectMap.end())
    {
-      temp.push_back((*current).second);
+      temp.push_back((*current).second.get());
    }
    ossim_uint32 i;
    for(i = 0; i < temp.size();++i)
@@ -504,7 +503,7 @@ void ossimConnectableContainer::getChildren(std::vector<ossimConnectableObject*>
       if(!immediateChildrenOnlyFlag)
       {
          ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
-                                                             (*current).second);
+                                                             (*current).second.get());
          if(!inter)
          {
             children.push_back(temp[i]);
@@ -521,7 +520,7 @@ void ossimConnectableContainer::getChildren(std::vector<ossimConnectableObject*>
       for(i = 0; i < temp.size(); ++i)
       {
          ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
-                                                             (*current).second);
+                                                             (*current).second.get());
 
          if(inter)
          {
@@ -542,18 +541,14 @@ void ossimConnectableContainer::deleteAllChildren()
    while(theObjectMap.size())
    {
       current = theObjectMap.begin();
-      temp = (*current).second;
+      temp = (*current).second.get();
       if(temp)
       {
-//         temp->removeListener((ossimConnectableObjectListener*) this);
          temp->removeListener(theChildListener);
+         temp->disconnect();
          (*current).second = NULL;
       }
       theObjectMap.erase(current);
-      if(temp)
-      {
-         delete temp;
-      }
    }
 }
 
@@ -565,7 +560,7 @@ void ossimConnectableContainer::removeAllListeners()
 
    while(current != theObjectMap.end())
    {
-      temp = (*current).second;
+      temp = (*current).second.get();
       if(temp)
       {
          temp->removeListener(theChildListener);
@@ -610,11 +605,11 @@ bool ossimConnectableContainer::addAllObjects(std::map<ossimId,
       {
          ossimNotify(ossimNotifyLevel_DEBUG) << "trying to create source with prefix: " << newPrefix << "\n";
       }
-      ossimObject* object = ossimObjectFactoryRegistry::instance()->createObject(kwl,
+      ossimRefPtr<ossimObject> object = ossimObjectFactoryRegistry::instance()->createObject(kwl,
                                                                                  newPrefix.c_str());
-      if(object)
+      if(object.valid())
       {
-         ossimConnectableObject* connectable = PTR_CAST(ossimConnectableObject, object);
+         ossimConnectableObject* connectable = PTR_CAST(ossimConnectableObject, object.get());
          if(connectable)
          {
             if(traceDebug())
@@ -635,11 +630,6 @@ bool ossimConnectableContainer::addAllObjects(std::map<ossimId,
             }
             addChild(connectable);
          }
-         else
-         {
-            delete object;
-            object = NULL;
-         }
       }
    }
 
@@ -738,7 +728,7 @@ ossimConnectableObject* ossimConnectableContainer::getConnectableObject(
    {
       if (i == index)
       {
-         return (*current).second;
+         return (*current).second.get();
       }
       ++current;
       ++i;
diff --git a/Utilities/otbossim/src/ossim/base/ossimConnectableObject.cpp b/Utilities/otbossim/src/ossim/base/ossimConnectableObject.cpp
index 8092c05b9a8f5ea83a2b147c0dfc0b8cceb71ebe..72bc854f3e9ce9984ec9b51ee8396b61051f4980 100644
--- a/Utilities/otbossim/src/ossim/base/ossimConnectableObject.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimConnectableObject.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimConnectableObject.cpp 13362 2008-08-01 14:02:32Z gpotts $
+// $Id: ossimConnectableObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/base/ossimConnectableObject.h>
 #include <ossim/base/ossimIdManager.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -26,10 +26,10 @@ const char* CONNECTABLE_INPUT_LIST_FIXED_KW  = "input_list_fixed";
 const char* CONNECTABLE_OUTPUT_LIST_FIXED_KW = "output_list_fixed";
 
 ossimConnectableObject::ossimConnectableObject(ossimObject* owner)
-   :ossimObject(),
-    ossimListenerManager(),
-    theInputListIsFixedFlag(false),
-    theOutputListIsFixedFlag(false)
+:ossimObject(),
+ossimListenerManager(),
+theInputListIsFixedFlag(false),
+theOutputListIsFixedFlag(false)
 {
    theId    = ossimIdManager::instance()->generateId();
    theOwner = owner;
@@ -40,45 +40,41 @@ ossimConnectableObject::ossimConnectableObject(ossimObject* owner,
                                                ossim_int32 outputListSize,
                                                bool inputListIsFixedFlag,
                                                bool outputListIsFixedFlag)
-   :ossimObject(),
-    ossimListenerManager(),
-    theInputListIsFixedFlag(inputListIsFixedFlag),
-    theOutputListIsFixedFlag(outputListIsFixedFlag)
+:ossimObject(),
+ossimListenerManager(),
+theInputListIsFixedFlag(inputListIsFixedFlag),
+theOutputListIsFixedFlag(outputListIsFixedFlag)
 {
    theId    = ossimIdManager::instance()->generateId();
    theOwner = owner;
-
+   
    setNumberOfInputs(inputListSize);
    setNumberOfOutputs(outputListSize);
 }
 
 ossimConnectableObject::~ossimConnectableObject()
 {
-
+   
    // tell the immediate listeners that we are destructing.
    ossimObjectDestructingEvent event(this);
-
-//    if(theOwner)
-//    {
-//       ossimListenerManager* manager = PTR_CAST(ossimListenerManager, theOwner);
-
-//       if(manager)
-//       {
-//          // notify the owner that you are destructing
-//          //
-//          manager->fireEvent(event);
-//       }
-//    }
-
+   
+   //    if(theOwner)
+   //    {
+   //       ossimListenerManager* manager = PTR_CAST(ossimListenerManager, theOwner);
+   
+   //       if(manager)
+   //       {
+   //          // notify the owner that you are destructing
+   //          //
+   //          manager->fireEvent(event);
+   //       }
+   //    }
+   
    // notify all other listeners that you are destructing
    //
    fireEvent(event);
    
-   // next we need to make sure that we are detached.
-   //
-   disconnect(this);
-
-}
+ }
 
 void ossimConnectableObject::changeOwner(ossimObject* owner)
 {
@@ -101,15 +97,15 @@ bool ossimConnectableObject::isConnected(ossimConnectableObjectDirectionType dir
    {
       if(getNumberOfInputs())
       {
-         std::vector<ossimConnectableObject*>::const_iterator current = theInputObjectList.begin();
-
+         ConnectableObjectList::const_iterator current = theInputObjectList.begin();
+         
          while(current != theInputObjectList.end())
          {
             if(! (*current))
             {
                return false;
             }
-
+            
             ++current;
          }
       }
@@ -118,57 +114,57 @@ bool ossimConnectableObject::isConnected(ossimConnectableObjectDirectionType dir
          return false;
       }
    }
-
+   
    if(direction & CONNECTABLE_DIRECTION_OUTPUT)
    {
-      std::vector<ossimConnectableObject*>::const_iterator current = theOutputObjectList.begin();
+      ConnectableObjectList::const_iterator current = theOutputObjectList.begin();
       current = theOutputObjectList.begin();
-
+      
       while(current != theOutputObjectList.end())
       {
          if(! (*current))
          {
             return false;
          }
-
+         
          ++current;
       }
    }
-
+   
    return true;
 }
 
 ossimConnectableObject* ossimConnectableObject::findConnectableObject(const ossimId& id)
 {
-   std::vector<ossimConnectableObject*>::iterator current;
-
+   ConnectableObjectList::iterator current;
+   
    current = theInputObjectList.begin();
    while(current != theInputObjectList.end())
    {
-      ossimConnectableObject* temp = *current;
-
+      ossimConnectableObject* temp = (*current).get();
+      
       if(temp->getId() == id)
       {
          return temp;
       }
-
+      
       ++current;
    }
-
+   
    // go through the outputs
    current = theOutputObjectList.begin();
    while(current != theOutputObjectList.end())
    {
-      ossimConnectableObject* temp = *current;
-
+      ossimConnectableObject* temp = (*current).get();
+      
       if(temp->getId() == id)
       {
          return temp;
       }
-
+      
       ++current;
    }
-
+   
    return 0;
 }
 
@@ -176,49 +172,47 @@ ossimConnectableObject* ossimConnectableObject::findObjectOfType(RTTItypeid type
                                                                  ossimConnectableObjectDirectionType directionType,
                                                                  bool recurse)
 {
-   std::vector<ossimConnectableObject*> *connectableList = &theInputObjectList;
-
+   ConnectableObjectList* connectableList = &theInputObjectList;
+   
+   
    if(directionType == CONNECTABLE_DIRECTION_NONE)
    {
       return 0;
    }
-
-  if(directionType == CONNECTABLE_DIRECTION_OUTPUT)
+   
+   if(directionType == CONNECTABLE_DIRECTION_OUTPUT)
    {
       connectableList = &theOutputObjectList;
-
    }
-
-
    // see if it is in the immediate list
    for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
    {
-      if((*connectableList)[index])
+      if((*connectableList)[index].valid())
       {
          if((*connectableList)[index]->canCastTo(typeId))//typeId.can_cast(TYPE_INFO(theInputObjectList[index])))
          {
-            return (*connectableList)[index];
+            return (*connectableList)[index].get();
          }
       }
    }
-
+   
    if(recurse)
    {
-     ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
-						          this);
-     if(inter)
-       {
-            ossimConnectableObject* tempObj = inter->findFirstObjectOfType(typeId);
-            if(tempObj)
-            {
-               return tempObj;
-            }
-       }
-
+      ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
+                                                           this);
+      if(inter)
+      {
+         ossimConnectableObject* tempObj = inter->findFirstObjectOfType(typeId);
+         if(tempObj)
+         {
+            return tempObj;
+         }
+      }
+      
       for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
       {
          inter = PTR_CAST(ossimConnectableContainerInterface,
-		         (*connectableList)[index]);
+                          (*connectableList)[index].get());
          if(inter)
          {
             ossimConnectableObject* tempObj = inter->findFirstObjectOfType(typeId);
@@ -227,7 +221,7 @@ ossimConnectableObject* ossimConnectableObject::findObjectOfType(RTTItypeid type
                return tempObj;
             }
          }
-         if((*connectableList)[index])
+         if((*connectableList)[index].valid())
          {
             ossimConnectableObject* result = (*connectableList)[index]->findObjectOfType(typeId,
                                                                                          directionType,
@@ -239,67 +233,67 @@ ossimConnectableObject* ossimConnectableObject::findObjectOfType(RTTItypeid type
          }
       }
    }
-
+   
    ossimConnectableObject* result = 0;
    for(ossim_uint32 index = 0; (index < connectableList->size())&&!result; ++index)
    {
-      if((*connectableList)[index])
+      if((*connectableList)[index].valid())
       {
          result = ((*connectableList)[index])->findObjectOfType(typeId,
                                                                 directionType,
                                                                 recurse);
       }
    }
-
+   
    return result;
 }
 
 ossimConnectableObject* ossimConnectableObject::findObjectOfType(
-   const ossimString& className,
-   ossimConnectableObjectDirectionType directionType,
-   bool recurse)
+                                                                 const ossimString& className,
+                                                                 ossimConnectableObjectDirectionType directionType,
+                                                                 bool recurse)
 {
-   std::vector<ossimConnectableObject*> *connectableList = &theInputObjectList;
-
+   ConnectableObjectList *connectableList = &theInputObjectList;
+   
    if(directionType == CONNECTABLE_DIRECTION_NONE)
    {
       return 0;
    }
-
-  if(directionType == CONNECTABLE_DIRECTION_OUTPUT)
+   
+   if(directionType == CONNECTABLE_DIRECTION_OUTPUT)
    {
       connectableList = &theOutputObjectList;
-
+      
    }
-
+   
    // see if it is in the immediate list
    for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
    {
-      if((*connectableList)[index])
+      if((*connectableList)[index].valid())
       {
          if((*connectableList)[index]->canCastTo(className))//typeId.can_cast(TYPE_INFO(theInputObjectList[index])))
          {
-            return (*connectableList)[index];
+            return (*connectableList)[index].get();
          }
       }
    }
-
+   
    if(recurse)
    {
-     ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
-						          this);
-     if(inter)
-       {
-            ossimConnectableObject* tempObj = inter->findFirstObjectOfType(className);
-            if(tempObj)
-            {
-               return tempObj;
-            }
-       }
+      ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
+                                                           this);
+      if(inter)
+      {
+         ossimConnectableObject* tempObj = inter->findFirstObjectOfType(className);
+         if(tempObj)
+         {
+            return tempObj;
+         }
+      }
       for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
       {
          inter = PTR_CAST(ossimConnectableContainerInterface,
-		         (*connectableList)[index]);
+                          (*connectableList)[index].get());
          if(inter)
          {
             ossimConnectableObject* tempObj = inter->findFirstObjectOfType(className);
@@ -308,7 +302,7 @@ ossimConnectableObject* ossimConnectableObject::findObjectOfType(
                return tempObj;
             }
          }
-         if((*connectableList)[index])
+         if((*connectableList)[index].valid())
          {
             ossimConnectableObject* result = (*connectableList)[index]->findObjectOfType(className,
                                                                                          directionType,
@@ -323,40 +317,39 @@ ossimConnectableObject* ossimConnectableObject::findObjectOfType(
    ossimConnectableObject* result = 0;
    for(ossim_uint32 index = 0; (index < connectableList->size())&&!result; ++index)
    {
-      if((*connectableList)[index])
+      if((*connectableList)[index].valid())
       {
          result = ((*connectableList)[index])->findObjectOfType(className,
                                                                 directionType,
                                                                 recurse);
-         // Return ...
       }
    }
-
+   
    return result;
 }
 
 ossimConnectableObject* ossimConnectableObject::findInputObjectOfType(
-   const ossimString& className)
+                                                                      const ossimString& className)
 {
    // See if we are of class type.
    if (canCastTo(className))
    {
       return this;
    }
-
+   
    // If we are a container, look inside for type.
    ossimConnectableContainerInterface* container =
-      PTR_CAST(ossimConnectableContainerInterface, this);
+   PTR_CAST(ossimConnectableContainerInterface, this);
    if (container)
    {
       const ossim_uint32 NUMBER_OF_OBJECTS =
-         container->getNumberOfObjects(false);
+      container->getNumberOfObjects(false);
       if (NUMBER_OF_OBJECTS)
       {
          for (ossim_uint32 idx = NUMBER_OF_OBJECTS; idx > 0; --idx) 
          {
             ossimConnectableObject* result =
-               container->getConnectableObject(idx-1);
+            container->getConnectableObject(idx-1);
             if (result)
             {
                if (result->canCastTo(className))
@@ -367,12 +360,12 @@ ossimConnectableObject* ossimConnectableObject::findInputObjectOfType(
          }
       }
    }
-
+   
    if ( getInputListIsFixedFlag() && (theInputObjectList.size() == 1) )
    {
       // Look at the input connection.
-      ossimConnectableObject* input = theInputObjectList[0];
-
+      ossimConnectableObject* input = theInputObjectList[0].get();
+      
       if(input)
       {
          // See if the input can cast to type.
@@ -383,7 +376,7 @@ ossimConnectableObject* ossimConnectableObject::findInputObjectOfType(
          
          // Look inside the input connection.
          ossimConnectableObject* result =
-            input->findInputObjectOfType(className);
+         input->findInputObjectOfType(className);
          if(result)
          {
             return result;
@@ -391,21 +384,21 @@ ossimConnectableObject* ossimConnectableObject::findInputObjectOfType(
       }
       
    } // End of "Must have fixed input of one."
-
+   
    return 0;
 }
 
 ossim_int32 ossimConnectableObject::findInputIndex(const ossimConnectableObject* object)
 {
-  ossim_int32 i = 0;
+   ossim_int32 i = 0;
    for(i = 0; i < (ossim_int32)theInputObjectList.size(); ++i)
    {
-      if(theInputObjectList[i] == object)
+      if(theInputObjectList[i].get() == object)
       {
          return i;
       }
    }
-
+   
    return -1;
 }
 
@@ -414,13 +407,13 @@ ossim_int32 ossimConnectableObject::findInputIndex(const ossimId& id)
    ossim_int32 i = 0;
    for(i = 0; i < (ossim_int32)theInputObjectList.size(); ++i)
    {
-      if(theInputObjectList[i] &&
+      if(theInputObjectList[i].valid() &&
          (theInputObjectList[i]->getId() == id))
       {
          return i;
       }
    }
-
+   
    return -1;
 }
 
@@ -434,7 +427,7 @@ ossim_int32 ossimConnectableObject::findOutputIndex(const ossimConnectableObject
          return i;
       }
    }
-
+   
    return -1;
 }
 
@@ -443,20 +436,20 @@ ossim_int32 ossimConnectableObject::findOutputIndex(const ossimId& id)
    ossim_int32 i = 0;
    for(i = 0; i < (ossim_int32)theOutputObjectList.size(); ++i)
    {
-      if(theOutputObjectList[i] &&
+      if(theOutputObjectList[i].valid() &&
          (theOutputObjectList[i]->getId() == id))
       {
          return i;
       }
    }
-
+   
    return -1;
 }
 
 ossim_int32 ossimConnectableObject::getMyInputIndexToConnectTo(ossimConnectableObject* object)const
 {
-   std::vector<ossimConnectableObject*>::const_iterator current;
-
+   ConnectableObjectList::const_iterator current;
+   
    ossim_int32 index = 0;
    current = theInputObjectList.begin();
    while(current != theInputObjectList.end())
@@ -474,7 +467,7 @@ ossim_int32 ossimConnectableObject::getMyInputIndexToConnectTo(ossimConnectableO
    if(!theInputListIsFixedFlag)
    {
       if(canConnectMyInputTo((ossim_int32)theInputObjectList.size(),
-                              object))
+                             object))
       {
          return (ossim_int32)theInputObjectList.size();
       }
@@ -484,8 +477,8 @@ ossim_int32 ossimConnectableObject::getMyInputIndexToConnectTo(ossimConnectableO
 
 ossim_int32 ossimConnectableObject::getMyOutputIndexToConnectTo(ossimConnectableObject* object)const
 {
-   std::vector<ossimConnectableObject*>::const_iterator current;
-
+   ConnectableObjectList::const_iterator current;
+   
    ossim_int32 index = 0;
    current = theOutputObjectList.begin();
    while(current != theOutputObjectList.end())
@@ -548,24 +541,24 @@ void ossimConnectableObject::disconnect(const ossimId& id)
    }
 }
 
-ossimConnectableObject* ossimConnectableObject::disconnectMyInput(ossim_int32 inputIndex,
-								  bool disconnectOutputFlag,
-								  bool createEventFlag)
+ossimRefPtr<ossimConnectableObject> ossimConnectableObject::disconnectMyInput(ossim_int32 inputIndex,
+                                                                  bool disconnectOutputFlag,
+                                                                  bool createEventFlag)
 {
    if(theInputObjectList.size() == 0)
    {
       return 0;
    }
-
-   std::vector<ossimConnectableObject*>::iterator current;
-   ossimConnectableObject* result = 0;
-
+   
+   ConnectableObjectList::iterator current;
+   ossimRefPtr<ossimConnectableObject> result = 0;
+   
    if( (inputIndex > -1)&&
-       (inputIndex < (ossim_int32)theInputObjectList.size()))
+      (inputIndex < (ossim_int32)theInputObjectList.size()))
    {
       current = (theInputObjectList.begin()+inputIndex);
-      result = *current;
-
+      result = (*current).get();
+      
       ossim_int32 index = inputIndex;
       if(!theInputListIsFixedFlag)
       {
@@ -576,20 +569,20 @@ ossimConnectableObject* ossimConnectableObject::disconnectMyInput(ossim_int32 in
       {
          *current = 0;
       }
-      if(createEventFlag&&result)
+      if(createEventFlag&&result.valid())
       {
          ossimConnectionEvent event(this,  // owner of message
                                     OSSIM_EVENT_CONNECTION_DISCONNECT_ID,
                                     0,  // new object
-                                    result,// old object
+                                    result.get(),// old object
                                     ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
-
+         
          // send event to all listeners.
          //
          fireEvent(event);
       }
-
-      if(disconnectOutputFlag&&result)
+      
+      if(disconnectOutputFlag&&result.valid())
       {
          result->disconnectMyOutput(this, false, createEventFlag);
       }
@@ -607,20 +600,20 @@ void ossimConnectableObject::disconnectMyInput(ossimConnectableObject* input,
                      createEventFlag);
 }
 
-void ossimConnectableObject::disconnectMyInputs(std::vector<ossimConnectableObject*>& inputList,
+void ossimConnectableObject::disconnectMyInputs(ConnectableObjectList& inputList,
                                                 bool disconnectOutputFlag,
                                                 bool createEventFlag)
 {
    if(theInputObjectList.size() == 0) return;
-   std::vector<ossimConnectableObject*> oldInputs;
-   std::vector<ossimConnectableObject*> newInputs;
+   ConnectableObjectList oldInputs;
+   ConnectableObjectList newInputs;
    ossim_int32 i = 0;
-
+   
    for(i = 0; i < (ossim_int32)inputList.size(); ++i)
    {
-      if(findInputIndex(inputList[i]) >= 0)
+      if(findInputIndex(inputList[i].get()) >= 0)
       {
-         disconnectMyInput(inputList[i], disconnectOutputFlag, false);
+         disconnectMyInput(inputList[i].get(), disconnectOutputFlag, false);
          oldInputs.push_back(inputList[i]);
       }
    }
@@ -635,22 +628,22 @@ void ossimConnectableObject::disconnectMyInputs(std::vector<ossimConnectableObje
    }
 }
 
-ossimConnectableObject* ossimConnectableObject::disconnectMyOutput(ossim_int32 outputIndex,
-								   bool disconnectInputFlag,
-								   bool createEvent)
+ossimRefPtr<ossimConnectableObject> ossimConnectableObject::disconnectMyOutput(ossim_int32 outputIndex,
+                                                                   bool disconnectInputFlag,
+                                                                   bool createEvent)
 {
    if(theOutputObjectList.size() == 0)
-     {
-       return 0;
-     }
-
-   std::vector<ossimConnectableObject*>::iterator current;
-   ossimConnectableObject* result = 0;
+   {
+      return 0;
+   }
+   
+   ConnectableObjectList::iterator current;
+   ossimRefPtr<ossimConnectableObject> result = 0;
    if( (outputIndex > -1)&&
-       (outputIndex < (ossim_int32)theOutputObjectList.size()))
+      (outputIndex < (ossim_int32)theOutputObjectList.size()))
    {
       current = (theOutputObjectList.begin()+outputIndex);
-      result = *current;
+      result = (*current).get();
       ossim_int32 index = outputIndex;
       if(!theOutputListIsFixedFlag)
       {
@@ -666,15 +659,15 @@ ossimConnectableObject* ossimConnectableObject::disconnectMyOutput(ossim_int32 o
          ossimConnectionEvent event(this,  // owner of message
                                     OSSIM_EVENT_CONNECTION_DISCONNECT_ID,
                                     0,  // new object
-                                    result,// old object
+                                    result.get(),// old object
                                     ossimConnectionEvent::OSSIM_OUTPUT_DIRECTION);
-
+         
          // send event to all listeners.
          //
          fireEvent(event);
       }
-
-      if(disconnectInputFlag&&result)
+      
+      if(disconnectInputFlag&&result.valid())
       {
          result->disconnectMyInput(this, false, createEvent);
       }
@@ -689,25 +682,25 @@ void ossimConnectableObject::disconnectMyOutput(ossimConnectableObject* output,
    disconnectMyOutput(findOutputIndex(output), disconnectInputFlag, createEventFlag);
 }
 
-void ossimConnectableObject::disconnectMyOutputs(std::vector<ossimConnectableObject*>& outputList,
-                                                bool disconnectInputFlag,
-                                                bool createEventFlag)
+void ossimConnectableObject::disconnectMyOutputs(ConnectableObjectList& outputList,
+                                                 bool disconnectInputFlag,
+                                                 bool createEventFlag)
 {
    if(theOutputObjectList.size() == 0) return;
-
+   
    if(theOutputObjectList.size() == 1)
    {
       disconnectMyOutput((ossim_int32)0);
       return;
    }
-   std::vector<ossimConnectableObject*> oldOutputs;
-   std::vector<ossimConnectableObject*> newOutputs;
+   ConnectableObjectList oldOutputs;
+   ConnectableObjectList newOutputs;
    ossim_int32 i = 0;
    for(i = 0; i < (ossim_int32)outputList.size(); ++i)
    {
-      if(findOutputIndex(outputList[i]) >= 0)
+      if(findOutputIndex(outputList[i].get()) >= 0)
       {
-         disconnectMyOutput(outputList[i], disconnectInputFlag, false);
+         disconnectMyOutput(outputList[i].get(), disconnectInputFlag, false);
          oldOutputs.push_back(outputList[i]);
       }
    }
@@ -727,19 +720,19 @@ void ossimConnectableObject::disconnectAllInputs()
    if(theInputObjectList.size() == 0) return;
    if(theInputObjectList.size() == 1)
    {
-//     ossimConnectableObject* obj = disconnectMyInput((ossim_int32)0, false);
-     disconnectMyInput((ossim_int32)0);
-//     if(obj)
-//     {
-//        obj->disconnectMyOutput(this, false);
-//     }
-     return;
-   }
-   std::vector<ossimConnectableObject*>::iterator current;
-   std::vector<ossimConnectableObject*> oldInputs = theInputObjectList;
-   std::vector<ossimConnectableObject*> newInputs;
-
-
+      //     ossimConnectableObject* obj = disconnectMyInput((ossim_int32)0, false);
+      disconnectMyInput((ossim_int32)0);
+      //     if(obj)
+      //     {
+      //        obj->disconnectMyOutput(this, false);
+      //     }
+      return;
+   }
+   ConnectableObjectList::iterator current;
+   ConnectableObjectList oldInputs = theInputObjectList;
+   ConnectableObjectList newInputs;
+   
+   
    current = theInputObjectList.begin();
    while(current != theInputObjectList.end())
    {
@@ -759,14 +752,14 @@ void ossimConnectableObject::disconnectAllInputs()
                               oldInputs,
                               ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
    fireEvent(event);
-
+   
    for(ossim_uint32 index = 0; index < oldInputs.size(); ++index)
-     {
-       if(oldInputs[index])
-         {
-	   oldInputs[index]->disconnectMyOutput(this, false);
-         }
-     }
+   {
+      if(oldInputs[index].valid())
+      {
+         oldInputs[index]->disconnectMyOutput(this, false);
+      }
+   }
 }
 
 void ossimConnectableObject::disconnectAllOutputs()
@@ -774,20 +767,20 @@ void ossimConnectableObject::disconnectAllOutputs()
    if(theOutputObjectList.size() == 0) return;
    if(theOutputObjectList.size() == 1)
    {
-//     ossimConnectableObject* obj = disconnectMyOutput((ossim_int32)0, false);
-     disconnectMyOutput((ossim_int32)0);
-//     if(obj)
-//     {
-//        obj->disconnectMyInput(this,
-//                               false);
-//     }
-     return;
+      //     ossimConnectableObject* obj = disconnectMyOutput((ossim_int32)0, false);
+      disconnectMyOutput((ossim_int32)0);
+      //     if(obj)
+      //     {
+      //        obj->disconnectMyInput(this,
+      //                               false);
+      //     }
+      return;
    }
-   std::vector<ossimConnectableObject*>::iterator current;
-
-   std::vector<ossimConnectableObject*> oldOutputs = theOutputObjectList;
-   std::vector<ossimConnectableObject*> newOutputs;
-
+   ConnectableObjectList::iterator current;
+   
+   ConnectableObjectList oldOutputs = theOutputObjectList;
+   ConnectableObjectList newOutputs;
+   
    current = theOutputObjectList.begin();
    while(current != theOutputObjectList.end())
    {
@@ -807,33 +800,33 @@ void ossimConnectableObject::disconnectAllOutputs()
                               oldOutputs,
                               ossimConnectionEvent::OSSIM_OUTPUT_DIRECTION);
    fireEvent(event);
-
+   
    for(ossim_uint32 index = 0; index < oldOutputs.size(); ++index)
-     {
-       if(oldOutputs[index])
-         {
-	   oldOutputs[index]->disconnectMyInput(this, false);
-         }
-     }
+   {
+      if(oldOutputs[index].valid())
+      {
+         oldOutputs[index]->disconnectMyInput(this, false);
+      }
+   }
 }
 
 ossim_int32 ossimConnectableObject::connectMyInputTo(ossimConnectableObject* object,
-					       bool makeOutputConnection,
-					       bool createEventFlag)
+                                                     bool makeOutputConnection,
+                                                     bool createEventFlag)
 {
    if(!object) return false;
-
+   
    ossim_int32 index = findInputIndex(object);
    if(index >= 0) return index;
-
+   
    index = getMyInputIndexToConnectTo(object);
-
+   
    if(index>-1)
    {
       if(index >= (ossim_int32)theInputObjectList.size())
       {
          if(theInputListIsFixedFlag) return -1;
-
+         
          index = (ossim_int32)theInputObjectList.size();
          theInputObjectList.push_back(object);
       }
@@ -846,8 +839,8 @@ ossim_int32 ossimConnectableObject::connectMyInputTo(ossimConnectableObject* obj
          else
          {
             ossimNotify(ossimNotifyLevel_WARN) << "Must issue a detach first!! trying to attach object " << object->getClassName()
-                                               << "\n to input index " << index << " in " << getClassName() << "\n";
-
+            << "\n to input index " << index << " in " << getClassName() << "\n";
+            
             return -1;
          }
       }
@@ -855,14 +848,14 @@ ossim_int32 ossimConnectableObject::connectMyInputTo(ossimConnectableObject* obj
       {
          ossimConnectionEvent event(this,  // owner of message
                                     OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                    theInputObjectList[index],  // new object
+                                    theInputObjectList[index].get(),  // new object
                                     0,// old object
                                     ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
          // send event to any listener.
          //
          fireEvent(event);
       }
-
+      
       if(makeOutputConnection&&object)
       {
          // make sure we tell the input not to connect
@@ -875,20 +868,20 @@ ossim_int32 ossimConnectableObject::connectMyInputTo(ossimConnectableObject* obj
    {
       return index;
    }
-
-  return index;
+   
+   return index;
 }
 
 ossim_int32 ossimConnectableObject::connectMyInputTo(ossim_int32 inputIndex,
-					       ossimConnectableObject* inputObject,
-					       bool makeOutputConnection,
-					       bool createEventFlag)
+                                                     ossimConnectableObject* inputObject,
+                                                     bool makeOutputConnection,
+                                                     bool createEventFlag)
 {
    if(!inputObject)
    {
       if(inputIndex < (ossim_int32)theInputObjectList.size())
       {
-         ossimConnectableObject* oldObject = theInputObjectList[inputIndex];
+         ossimConnectableObject* oldObject = theInputObjectList[inputIndex].get();
          if(theInputListIsFixedFlag)
          {
             theInputObjectList[inputIndex] = 0;
@@ -912,46 +905,46 @@ ossim_int32 ossimConnectableObject::connectMyInputTo(ossim_int32 inputIndex,
       }
       return -1;
    }
-
+   
    ossim_int32 index = findInputIndex(inputObject);
-
+   
    if((index >= 0)&&!inputObject) return index;
    if(!inputObject) return -1;
-
+   
    if(canConnectMyInputTo(inputIndex, inputObject))
    {
       if(inputIndex>-1)
       {
-	ossimConnectableObject* oldObject=0;
+         ossimConnectableObject* oldObject=0;
          if(inputIndex >= (ossim_int32)theInputObjectList.size())
          {
             if(theInputListIsFixedFlag) return -1;
-
+            
             inputIndex = (ossim_int32)theInputObjectList.size();
             theInputObjectList.push_back(inputObject);
          }
          else
          {
-            oldObject = theInputObjectList[inputIndex];
+            oldObject = theInputObjectList[inputIndex].get();
             theInputObjectList[inputIndex] = inputObject;
             if(oldObject)
             {
                oldObject->disconnectMyOutput(this, false);
             }
          }
-
+         
          if(createEventFlag)
          {
             ossimConnectionEvent event(this,  // owner of message
                                        OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                       theInputObjectList[inputIndex],  // new object
+                                       theInputObjectList[inputIndex].get(),  // new object
                                        oldObject,// old object
                                        ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
             // send event to any listener.
             //
             fireEvent(event);
          }
-
+         
          if(makeOutputConnection&&inputObject)
          {
             // make sure we tell the input not to connect
@@ -964,67 +957,67 @@ ossim_int32 ossimConnectableObject::connectMyInputTo(ossim_int32 inputIndex,
       {
          return inputIndex;
       }
-
+      
       return inputIndex;
    }
-
+   
    return -1;
 }
 
-bool ossimConnectableObject::connectMyInputTo(std::vector<ossimConnectableObject*>& inputList,
+bool ossimConnectableObject::connectMyInputTo(ConnectableObjectList& inputList,
                                               bool makeOutputConnection,
                                               bool createEventFlag)
 {
    bool result = true;
-   std::vector<ossimConnectableObject*> oldInputs;
-   std::vector<ossimConnectableObject*> newInputs;
-
+   ConnectableObjectList oldInputs;
+   ConnectableObjectList newInputs;
+   
    if(inputList.size() == 1)
    {
-     if(inputList[0])
-       {
-	 return (connectMyInputTo(inputList[0], makeOutputConnection, createEventFlag) >= 0);
-       }
-     else
-     {
-        if(theInputListIsFixedFlag)
-        {
-	   theInputObjectList[0] = 0;
-        }
-        else
-        {
-	   theInputObjectList.clear();
-        }
-        if(createEventFlag)
-        {
-           ossimConnectionEvent event(this,
-                                      OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                      0,
-                                      theInputObjectList[0],
-                                      ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
-           fireEvent(event);
-        }
-
-        return true;
-     }
+      if(inputList[0].valid())
+      {
+         return (connectMyInputTo(inputList[0].get(), makeOutputConnection, createEventFlag) >= 0);
+      }
+      else
+      {
+         if(theInputListIsFixedFlag)
+         {
+            theInputObjectList[0] = 0;
+         }
+         else
+         {
+            theInputObjectList.clear();
+         }
+         if(createEventFlag)
+         {
+            ossimConnectionEvent event(this,
+                                       OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                       0,
+                                       theInputObjectList[0].get(),
+                                       ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
+            fireEvent(event);
+         }
+         
+         return true;
+      }
    }
    ossim_int32 i = 0;
    for(i = 0; i < (ossim_int32)inputList.size(); ++i)
    {
-      if(inputList[i])
+      if(inputList[i].valid())
       {
-	 if(connectMyInputTo(inputList[i], makeOutputConnection, false)<0)
+         if(connectMyInputTo(inputList[i].get(), makeOutputConnection, false)<0)
          {
             result = false;
          }
-	 else
+         else
          {
             newInputs.push_back(inputList[i]);
          }
       }
       else
       {
-	 newInputs.push_back(0);
+         newInputs.push_back(0);
       }
    }
    if(createEventFlag)
@@ -1040,14 +1033,14 @@ bool ossimConnectableObject::connectMyInputTo(std::vector<ossimConnectableObject
 }
 
 ossim_int32 ossimConnectableObject::connectMyOutputTo(ossimConnectableObject* output,
-						bool makeInputConnection,
-						bool createEventFlag)
+                                                      bool makeInputConnection,
+                                                      bool createEventFlag)
 {
-  ossim_int32 index = findOutputIndex(output);
+   ossim_int32 index = findOutputIndex(output);
    if(index >= 0) return index;
-
+   
    index = getMyOutputIndexToConnectTo(output);
-
+   
    if(index > -1)
    {
       if((index >= (ossim_int32)theOutputObjectList.size())&&
@@ -1065,8 +1058,8 @@ ossim_int32 ossimConnectableObject::connectMyOutputTo(ossimConnectableObject* ou
          else
          {
             ossimNotify(ossimNotifyLevel_WARN) << "Must issue a disconnect first!! trying to connect object " << output->getClassName()
-                                               << "\n to output index " << index << " in " << getClassName() << "\n";
-
+            << "\n to output index " << index << " in " << getClassName() << "\n";
+            
             return -1;
          }
       }
@@ -1074,7 +1067,7 @@ ossim_int32 ossimConnectableObject::connectMyOutputTo(ossimConnectableObject* ou
       {
          ossimConnectionEvent event(this,  // owner of message
                                     OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                    theOutputObjectList[index],  // new object
+                                    theOutputObjectList[index].get(),  // new object
                                     0,// old object
                                     ossimConnectionEvent::OSSIM_OUTPUT_DIRECTION);
          // send event to any listener.
@@ -1093,54 +1086,54 @@ ossim_int32 ossimConnectableObject::connectMyOutputTo(ossimConnectableObject* ou
    {
       return index;
    }
-
+   
    return index;
 }
 
-bool ossimConnectableObject::connectMyOutputTo(std::vector<ossimConnectableObject*>& outputList,
+bool ossimConnectableObject::connectMyOutputTo(ConnectableObjectList& outputList,
                                                bool makeInputConnection,
                                                bool createEventFlag)
 {
    bool result = true;
-   std::vector<ossimConnectableObject*> oldOutputs;
-   std::vector<ossimConnectableObject*> newOutputs;
-
+   ConnectableObjectList oldOutputs;
+   ConnectableObjectList newOutputs;
+   
    if(outputList.size() == 0)
-     {
-       disconnectAllOutputs();
-       return true;
-     }
-   if((outputList.size() == 1)&&outputList[0])
-   {
-     if(outputList[0])
-       {
-	 return (connectMyOutputTo(outputList[0], makeInputConnection, createEventFlag) >= 0);
-       }
-     else
-       {
-	 disconnectAllOutputs();
-       }
+   {
+      disconnectAllOutputs();
+      return true;
    }
-
+   if((outputList.size() == 1)&&outputList[0].valid())
+   {
+      if(outputList[0].valid())
+      {
+         return (connectMyOutputTo(outputList[0].get(), makeInputConnection, createEventFlag) >= 0);
+      }
+      else
+      {
+         disconnectAllOutputs();
+      }
+   }
+   
    ossim_int32 i = 0;
    for(i = 0; i < (ossim_int32)outputList.size(); ++i)
    {
-      if((connectMyOutputTo(outputList[i], makeInputConnection, false)<0)&&outputList[i])
+      if((connectMyOutputTo(outputList[i].get(), makeInputConnection, false)<0)&&outputList[i].valid())
       {
-         newOutputs.push_back(outputList[i]);
+         newOutputs.push_back(outputList[i].get());
          result = false;
       }
    }
    if(createEventFlag&&newOutputs.size())
    {
       ossimConnectionEvent event(this,
-                                      OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                      newOutputs,
-                                      oldOutputs,
-                                      ossimConnectionEvent::OSSIM_OUTPUT_DIRECTION);
+                                 OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                 newOutputs,
+                                 oldOutputs,
+                                 ossimConnectionEvent::OSSIM_OUTPUT_DIRECTION);
       fireEvent(event);
    }
-
+   
    return result;
 }
 
@@ -1148,9 +1141,9 @@ ossimConnectableObject* ossimConnectableObject::getInput(ossim_uint32 index)
 {
    if( (index >= 0) && (index < theInputObjectList.size()))
    {
-      return theInputObjectList[index];
+      return theInputObjectList[index].get();
    }
-
+   
    return 0;
 }
 
@@ -1158,9 +1151,9 @@ const ossimConnectableObject* ossimConnectableObject::getInput(ossim_uint32 inde
 {
    if( (index >= 0) && (index < theInputObjectList.size()))
    {
-      return theInputObjectList[index];
+      return theInputObjectList[index].get();
    }
-
+   
    return 0;
 }
 
@@ -1168,74 +1161,74 @@ ossimConnectableObject* ossimConnectableObject::getOutput(ossim_uint32 index)
 {
    if( (index >= 0) && (index < theOutputObjectList.size()))
    {
-      return theOutputObjectList[index];
+      return theOutputObjectList[index].get();
    }
-
+   
    return 0;
 }
 
-bool ossimConnectableObject::connectInputList(std::vector<ossimConnectableObject*>& inputList)
+bool ossimConnectableObject::connectInputList(ConnectableObjectList& inputList)
 {
    bool result = true;
    ossim_uint32 i = 0;
-   std::vector<ossimConnectableObject*> oldInputs = theInputObjectList;
-   std::vector<ossimConnectableObject*> newInputs;
-   std::vector<ossimConnectableObject*>::const_iterator currentInput = inputList.begin();
-   std::vector<ossimConnectableObject*> tempOld;
+   ConnectableObjectList oldInputs = theInputObjectList;
+   ConnectableObjectList newInputs;
+   ConnectableObjectList::iterator currentInput = inputList.begin();
+   ConnectableObjectList tempOld;
    if(theInputObjectList.size())
-     {
-       for(i = 0; i < theInputObjectList.size(); ++i)
-	 {
-	   if(oldInputs[i])
-	     {
-	       tempOld.push_back(oldInputs[i]);
-	     }
-	   theInputObjectList[i] = 0;
-	 }
-     }
+   {
+      for(i = 0; i < theInputObjectList.size(); ++i)
+      {
+         if(oldInputs[i].valid())
+         {
+            tempOld.push_back(oldInputs[i].get());
+         }
+         theInputObjectList[i] = 0;
+      }
+   }
    if(theInputListIsFixedFlag && (theInputObjectList.size()==0))
    {
       return false;
    }
-
+   
    if(!theInputListIsFixedFlag)
-     {
-       theInputObjectList.clear();
-     }
+   {
+      theInputObjectList.clear();
+   }
    if(tempOld.size())
-     {
-       for(i = 0; i < tempOld.size(); ++ i)
-	 {
-	   tempOld[i]->disconnectMyOutput(this, false);
-	 }
-     }
+   {
+      for(i = 0; i < tempOld.size(); ++ i)
+      {
+         tempOld[i]->disconnectMyOutput(this, false);
+      }
+   }
    //   disconnectAllInputs();
-
+   
    if(inputList.size() == 1)
    {
-      return (connectMyInputTo(inputList[0])>=0);
+      return (connectMyInputTo(inputList[0].get())>=0);
    }
    i = 0;
    while(currentInput != inputList.end())
    {
-      if(!canConnectMyInputTo(i, *currentInput))
+      if(!canConnectMyInputTo(i, (*currentInput).get()))
       {
          result = false;
       }
       ++i;
       ++currentInput;
    }
-
+   
    if(!result)
    {
       return false;
    }
-    // now connect the new outputs
+   // now connect the new outputs
    //
    currentInput = inputList.begin();
    while(currentInput != inputList.end())
    {
-      if(*currentInput)
+      if((*currentInput).valid())
       {
          (*currentInput)->connectMyOutputTo(this, false);
       }
@@ -1246,7 +1239,7 @@ bool ossimConnectableObject::connectInputList(std::vector<ossimConnectableObject
                               newInputs,
                               oldInputs,
                               ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
-
+   
    if(theInputObjectList.size())
    {
       theInputObjectList = inputList;
@@ -1256,59 +1249,59 @@ bool ossimConnectableObject::connectInputList(std::vector<ossimConnectableObject
    {
       theInputObjectList = inputList;
    }
-
+   
    newInputs          = theInputObjectList;
-
-
-
+   
+   
+   
    event = ossimConnectionEvent(this,
-				OSSIM_EVENT_CONNECTION_CONNECT_ID,
-				newInputs,
-				oldInputs,
-				ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
+                                OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                newInputs,
+                                oldInputs,
+                                ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
    fireEvent(event);
-
+   
    return result;
 }
 
-bool ossimConnectableObject::connectOutputList(std::vector<ossimConnectableObject*>& outputList)
+bool ossimConnectableObject::connectOutputList(ConnectableObjectList& outputList)
 {
    bool result = true;
    ossim_int32 index  = 0;
-   std::vector<ossimConnectableObject*> oldOutputs = theOutputObjectList;
-   std::vector<ossimConnectableObject*> newOutputs;
-   std::vector<ossimConnectableObject*>::const_iterator currentOutput = outputList.begin();
-
+   ConnectableObjectList oldOutputs = theOutputObjectList;
+   ConnectableObjectList newOutputs;
+   ConnectableObjectList::const_iterator currentOutput = outputList.begin();
+   
    disconnectAllOutputs();
-
+   
    if(outputList.size() == 1)
    {
-      return (connectMyOutputTo(outputList[0])>=0);
+      return (connectMyOutputTo(outputList[0].get())>=0);
    }
    while(currentOutput != outputList.end())
    {
-      if(!canConnectMyOutputTo(index, *currentOutput))
+      if(!canConnectMyOutputTo(index, (*currentOutput).get()))
       {
          result = false;
       }
       ++currentOutput;
    }
-
+   
    if(!result)
    {
       return false;
    }
-
+   
    theOutputObjectList = outputList;
    newOutputs = theOutputObjectList;
-
+   
    ossimConnectionEvent event(this,
                               OSSIM_EVENT_CONNECTION_CONNECT_ID,
                               newOutputs,
                               oldOutputs,
                               ossimConnectionEvent::OSSIM_OUTPUT_DIRECTION);
    fireEvent(event);
-
+   
    return result;
 }
 
@@ -1321,21 +1314,21 @@ void ossimConnectableObject::setNumberOfInputs(ossim_int32 numberOfInputs)
    ossim_int32 i = 0;
    if(numberOfInputs < (ossim_int32)theInputObjectList.size())
    {
-      std::vector<ossimConnectableObject*> v(theInputObjectList.begin(),
-                                        theInputObjectList.begin()+numberOfInputs);
-      std::vector<ossimConnectableObject*> disconnectList;
-
+      ConnectableObjectList v(theInputObjectList.begin(),
+                              theInputObjectList.begin()+numberOfInputs);
+      ConnectableObjectList disconnectList;
+      
       for(i = numberOfInputs;
           i < (ossim_int32)theInputObjectList.size();
           ++i)
       {
-         if(theInputObjectList[i])
+         if(theInputObjectList[i].valid())
          {
             disconnectList.push_back(theInputObjectList[i]);
          }
       }
       disconnectMyInputs(disconnectList);
-
+      
       theInputObjectList.clear();
       theInputObjectList = v;
    }
@@ -1359,20 +1352,20 @@ void ossimConnectableObject::setNumberOfOutputs(ossim_int32 numberOfOutputs)
    ossim_int32 i = 0;
    if(numberOfOutputs < (ossim_int32)theOutputObjectList.size())
    {
-      std::vector<ossimConnectableObject*> v(theOutputObjectList.begin(),
-                                        theOutputObjectList.begin()+numberOfOutputs);
-      std::vector<ossimConnectableObject*> disconnectList;
+      ConnectableObjectList v(theOutputObjectList.begin(),
+                              theOutputObjectList.begin()+numberOfOutputs);
+      ConnectableObjectList disconnectList;
       for(i = numberOfOutputs;
           i < (ossim_int32)theOutputObjectList.size();
           ++i)
       {
-         if(theOutputObjectList[i])
+         if(theOutputObjectList[i].valid())
          {
             disconnectList.push_back(theOutputObjectList[i]);
          }
       }
       disconnectMyOutputs(disconnectList);
-
+      
       theOutputObjectList.clear();
       theOutputObjectList = v;
    }
@@ -1392,13 +1385,13 @@ const ossimConnectableObject* ossimConnectableObject::getOutput(ossim_uint32 ind
 {
    if( (index >= 0) && (index < theOutputObjectList.size()))
    {
-      return theOutputObjectList[index];
+      return theOutputObjectList[index].get();
    }
-
+   
    return 0;
 }
 
-void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObject*>& result,
+void ossimConnectableObject::findAllInputsOfType(ConnectableObjectList& result,
                                                  const RTTItypeid& typeInfo,
                                                  bool propagateToInputs,
                                                  bool recurseChildren)
@@ -1411,26 +1404,26 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
                                                         this);
    if(inter&&recurseChildren)
    {
-      std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(typeInfo,
-                                                                             true);
-
+      ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo,
+                                                                   true);
+      
       for(j = 0; j < (int)tempList.size(); ++j)
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+         ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
          if(iter == result.end())
          {
-            result.push_back(tempList[j]);
+            result.push_back(tempList[j].get());
          }
       }
    }
-
+   
    for(i = 0; i < (int)getNumberOfInputs(); ++i)
    {
       ossimConnectableObject* current = getInput(i);
       if(current&&(current->canCastTo(typeInfo)))
       {
-         std::vector<ossimConnectableObject*>::iterator position = std::find(result.begin(), result.end(), current);
-
+         ConnectableObjectList::iterator position = std::find(result.begin(), result.end(), current);
+         
          if(position == result.end())
          {
             result.push_back(current);
@@ -1439,17 +1432,17 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
       inter = PTR_CAST(ossimConnectableContainerInterface, current);
       if(inter)
       {
-         std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(typeInfo, true);
+         ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo, true);
          for(j = 0; j < (int)tempList.size(); ++j)
          {
-            std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+            ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
             if(iter == result.end())
             {
                result.push_back(tempList[j]);
             }
          }
       }
-
+      
       if(propagateToInputs&&current)
       {
          current->findAllInputsOfType(result,
@@ -1460,7 +1453,7 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
    }
 }
 
-void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObject*>& result,
+void ossimConnectableObject::findAllInputsOfType(ConnectableObjectList& result,
                                                  const ossimString& className,
                                                  bool propagateToInputs,
                                                  bool recurseChildren)
@@ -1472,12 +1465,12 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
                                                         this);
    if(inter&&recurseChildren)
    {
-      std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(className,
-                                                                             true);
-
+      ConnectableObjectList tempList = inter->findAllObjectsOfType(className,
+                                                                   true);
+      
       for(j = 0; j < (int)tempList.size(); ++j)
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+         ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
          if(iter == result.end())
          {
             result.push_back(tempList[j]);
@@ -1489,7 +1482,7 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
       ossimConnectableObject* current = getInput(i);
       if(current&&(current->canCastTo(className)))
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), current);
+         ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), current);
          if(iter == result.end())
          {
             result.push_back(current);
@@ -1499,17 +1492,17 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
                                                            current);
       if(inter)
       {
-         std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(className, true);
+         ConnectableObjectList tempList = inter->findAllObjectsOfType(className, true);
          for(j = 0; j < (int)tempList.size(); ++j)
          {
-            std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+            ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
             if(iter == result.end())
             {
                result.push_back(tempList[j]);
             }
          }
       }
-
+      
       if(propagateToInputs&&current)
       {
          current->findAllInputsOfType(result,
@@ -1520,7 +1513,7 @@ void ossimConnectableObject::findAllInputsOfType(std::vector<ossimConnectableObj
    }
 }
 
-void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableObject*>& result,
+void ossimConnectableObject::findAllOutputsOfType(ConnectableObjectList& result,
                                                   const RTTItypeid& typeInfo,
                                                   bool propagateToOutputs,
                                                   bool recurseChildren)
@@ -1532,12 +1525,12 @@ void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableOb
                                                         this);
    if(inter&&recurseChildren)
    {
-      std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(typeInfo,
-                                                                             true);
-
+      ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo,
+                                                                   true);
+      
       for(j = 0; j < (int)tempList.size(); ++j)
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+         ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
          if(iter == result.end())
          {
             result.push_back(tempList[j]);
@@ -1552,20 +1545,20 @@ void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableOb
          result.push_back(current);
       }
       ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
-                                                               current);
+                                                           current);
       if(inter)
       {
-         std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(typeInfo, true);
+         ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo, true);
          for(j = 0; j < (int)tempList.size(); ++j)
          {
-            std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+            ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
             if(iter == result.end())
             {
                result.push_back(tempList[j]);
             }
          }
       }
-
+      
       if(propagateToOutputs&&current)
       {
          current->findAllOutputsOfType(result,
@@ -1576,7 +1569,7 @@ void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableOb
    }
 }
 
-void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableObject*>& result,
+void ossimConnectableObject::findAllOutputsOfType(ConnectableObjectList& result,
                                                   const ossimString& className,
                                                   bool propagateToOutputs,
                                                   bool recurseChildren)
@@ -1588,12 +1581,12 @@ void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableOb
                                                         this);
    if(inter&&recurseChildren)
    {
-      std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(className,
-                                                                             true);
-
+      ConnectableObjectList tempList = inter->findAllObjectsOfType(className,
+                                                                   true);
+      
       for(j = 0; j < (int)tempList.size(); ++j)
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+         ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
          if(iter == result.end())
          {
             result.push_back(tempList[j]);
@@ -1605,28 +1598,28 @@ void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableOb
       ossimConnectableObject* current = getOutput(i);
       if(current&&(current->canCastTo(className)))
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), current);
+         ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), current);
          if(iter == result.end())
          {
             result.push_back(current);
          }
       }
       ossimConnectableContainerInterface* inter = PTR_CAST(ossimConnectableContainerInterface,
-                                                               current);
+                                                           current);
       if(inter)
       {
-         std::vector<ossimConnectableObject*> tempList = inter->findAllObjectsOfType(className,
-                                                                                true);
+         ConnectableObjectList tempList = inter->findAllObjectsOfType(className,
+                                                                      true);
          for(j = 0; j < (int)tempList.size(); ++j)
          {
-            std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
+            ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
             if(iter == result.end())
             {
                result.push_back(tempList[j]);
             }
          }
       }
-
+      
       if(propagateToOutputs&&current)
       {
          current->findAllOutputsOfType(result,
@@ -1641,7 +1634,7 @@ void ossimConnectableObject::findAllOutputsOfType(std::vector<ossimConnectableOb
 void ossimConnectableObject::propagateEventToOutputs(ossimEvent& event)
 {
    ossim_uint32 i;
-
+   
    for(i = 0; i <getNumberOfOutputs(); ++i)
    {
       ossimConnectableObject* obj = getOutput(i);
@@ -1657,7 +1650,7 @@ void ossimConnectableObject::propagateEventToOutputs(ossimEvent& event)
 void ossimConnectableObject::propagateEventToInputs(ossimEvent& event)
 {
    ossim_uint32 i;
-
+   
    for(i = 0; i <getNumberOfInputs(); ++i)
    {
       ossimConnectableObject* obj = getInput(i);
@@ -1686,12 +1679,12 @@ ossimRefPtr<ossimProperty> ossimConnectableObject::getProperty(const ossimString
    }
    // "Class name" check for backwards compatibility only.
    else if( (name == "class_name") ||
-            (name == "Class name") ) 
+           (name == "Class name") ) 
    {
       ossimProperty* prop = new ossimTextProperty(name,
                                                   getClassName());
       prop->setReadOnlyFlag(true);
-
+      
       return prop;
    }
    return ossimRefPtr<ossimProperty>();
@@ -1708,29 +1701,29 @@ bool ossimConnectableObject::loadState(const ossimKeywordlist& kwl,
 {
    const char* lookup = kwl.find(prefix,
                                  ossimKeywordNames::ID_KW);
-
+   
    // disconnect(this);
-
+   
    if(lookup)
    {
       theId = ossimId(ossimString(lookup).toLong());
    }
-
+   
    lookup = kwl.find(prefix, CONNECTABLE_INPUT_LIST_FIXED_KW);
    if(lookup)
    {
       theInputListIsFixedFlag = ossimString(lookup).toBool();
    }
-
+   
    lookup = kwl.find(prefix, CONNECTABLE_OUTPUT_LIST_FIXED_KW);
    if(lookup)
    {
       theOutputListIsFixedFlag = ossimString(lookup).toBool();
    }
-
+   
    ossim_int32 numberInputs  = 0;
    ossim_int32 numberOutputs = 0;
-
+   
    ossimString regExpression;
    lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_INPUTS_KW);
    if(lookup)
@@ -1742,7 +1735,7 @@ bool ossimConnectableObject::loadState(const ossimKeywordlist& kwl,
       regExpression = ossimString("^(") + ossimString(prefix) + "input_connection[0-9]+)";
       numberInputs = kwl.getNumberOfSubstringKeys(regExpression);
    }
-
+   
    lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_OUTPUTS_KW);
    if(lookup)
    {
@@ -1759,10 +1752,10 @@ bool ossimConnectableObject::loadState(const ossimKeywordlist& kwl,
    {
       theDescription = lookup;
    }
-
+   
    setNumberOfInputs(numberInputs);
    setNumberOfOutputs(numberOutputs);
-
+   
    return ossimObject::loadState(kwl, prefix);
 }
 
@@ -1770,45 +1763,45 @@ bool ossimConnectableObject::saveState(ossimKeywordlist& kwl,
                                        const char* prefix)const
 {
    ossimObject::saveState(kwl, prefix);
-
+   
    kwl.add(prefix,
            ossimKeywordNames::ID_KW,
            theId.getId(),
            true);
-
+   
    kwl.add(prefix,
            ossimKeywordNames::DESCRIPTION_KW,
            theDescription,
            true);
-
+   
    kwl.add(prefix,
            CONNECTABLE_INPUT_LIST_FIXED_KW,
            theInputListIsFixedFlag,
            true);
-
+   
    kwl.add(prefix,
            CONNECTABLE_OUTPUT_LIST_FIXED_KW,
            theOutputListIsFixedFlag,
            true);
-
+   
    kwl.add(prefix,
-	   ossimKeywordNames::NUMBER_INPUTS_KW,
-	   static_cast<ossim_uint32>(theInputObjectList.size()),
-	   true);
-
+           ossimKeywordNames::NUMBER_INPUTS_KW,
+           static_cast<ossim_uint32>(theInputObjectList.size()),
+           true);
+   
    kwl.add(prefix,
-	   ossimKeywordNames::NUMBER_OUTPUTS_KW,
-	   static_cast<ossim_uint32>(theOutputObjectList.size()),
-	   true);
-
+           ossimKeywordNames::NUMBER_OUTPUTS_KW,
+           static_cast<ossim_uint32>(theOutputObjectList.size()),
+           true);
+   
    ossim_int32 i = 0;
    for(i = 1; i <= (ossim_int32)theInputObjectList.size(); ++i)
    {
       ossimString value = "input_connection" + ossimString::toString(i);
-
+      
       ossim_int32 id;
-
-      if(theInputObjectList[i-1])
+      
+      if(theInputObjectList[i-1].valid())
       {
          id = theInputObjectList[i-1]->getId().getId();
       }
@@ -1821,14 +1814,14 @@ bool ossimConnectableObject::saveState(ossimKeywordlist& kwl,
               id,
               true);
    }
-
+   
    for(i = 1; i <= (ossim_int32)theOutputObjectList.size(); ++i)
    {
       ossimString value = "output_connection" + ossimString::toString(i);
-
+      
       ossim_int32 id;
-
-      if(theOutputObjectList[i-1])
+      
+      if(theOutputObjectList[i-1].valid())
       {
          id = theOutputObjectList[i-1]->getId().getId();
       }
@@ -1841,15 +1834,15 @@ bool ossimConnectableObject::saveState(ossimKeywordlist& kwl,
               id,
               true);
    }
-
+   
    return true;
 }
 
 ossim_uint32 ossimConnectableObject::saveStateOfAllInputs(
-   ossimKeywordlist& kwl,
-   bool              saveThisStateFlag,
-   ossim_uint32      objectIndex,
-   const char*       prefix) const
+                                                          ossimKeywordlist& kwl,
+                                                          bool              saveThisStateFlag,
+                                                          ossim_uint32      objectIndex,
+                                                          const char*       prefix) const
 {
    ossim_uint32 index = objectIndex;
    
@@ -1869,7 +1862,7 @@ ossim_uint32 ossimConnectableObject::saveStateOfAllInputs(
          }
       }
    }
-
+   
    if (saveThisStateFlag)
    {
       ossimString myPrefix;
@@ -1881,7 +1874,7 @@ ossim_uint32 ossimConnectableObject::saveStateOfAllInputs(
       myPrefix += "object";
       myPrefix += ossimString::toString(index);
       myPrefix += ".";
-
+      
       // Save the state of this object.
       saveState(kwl, myPrefix.c_str());
       ++index;
@@ -1891,47 +1884,47 @@ ossim_uint32 ossimConnectableObject::saveStateOfAllInputs(
 }
 
 bool ossimConnectableObject::canConnectMyOutputTo(ossim_int32 myOutputIndex,
-						  const ossimConnectableObject* /* object */ ) const
+                                                  const ossimConnectableObject* /* object */ ) const
 {
-  if(theOutputListIsFixedFlag)
-    {
+   if(theOutputListIsFixedFlag)
+   {
       return ((myOutputIndex >= 0) &&
-	      (myOutputIndex < (ossim_int32)theOutputObjectList.size()));
-    }
-
-  return ((myOutputIndex >= 0) &&
-	  (myOutputIndex  <= (ossim_int32)theOutputObjectList.size()));
+              (myOutputIndex < (ossim_int32)theOutputObjectList.size()));
+   }
+   
+   return ((myOutputIndex >= 0) &&
+           (myOutputIndex  <= (ossim_int32)theOutputObjectList.size()));
 }
 
 bool ossimConnectableObject::moveInputUp(const ossimId& id)
 {
    bool result = false;
-
+   
    if (theInputListIsFixedFlag == false)
    {
       if ( theInputObjectList.size() )
       {
          ossim_int32 indexOfId = findInputIndex(id);
-
+         
          if (indexOfId > 0)
          {
-            std::vector<ossimConnectableObject*> oldInputs =
-               theInputObjectList;
-
+            ConnectableObjectList oldInputs =
+            theInputObjectList;
+            
             // Swap with index above.
-            ossimConnectableObject* tmpObj  = theInputObjectList[indexOfId];
-            theInputObjectList[indexOfId]   = theInputObjectList[indexOfId-1];
+            ossimRefPtr<ossimConnectableObject> tmpObj  = theInputObjectList[indexOfId].get();
+            theInputObjectList[indexOfId]   = theInputObjectList[indexOfId-1].get();
             theInputObjectList[indexOfId-1] = tmpObj;
             result = true;
-
-            std::vector<ossimConnectableObject*> newInputs =
-               theInputObjectList;
-
+            
+            ConnectableObjectList newInputs =
+            theInputObjectList;
+            
             ossimConnectionEvent event(this,
-                                 OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                 newInputs,
-                                 oldInputs,
-                                 ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
+                                       OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                       newInputs,
+                                       oldInputs,
+                                       ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
             fireEvent(event);
          }
       }
@@ -1943,33 +1936,33 @@ bool ossimConnectableObject::moveInputUp(const ossimId& id)
 bool ossimConnectableObject::moveInputDown(const ossimId& id)
 {
    bool result = false;
-
+   
    if (theInputListIsFixedFlag == false)
    {
       if ( theInputObjectList.size() )
       {
          ossim_int32 indexOfId = findInputIndex(id);
-
+         
          if ( indexOfId <
-              static_cast<ossim_int32>(theInputObjectList.size()-1) )
+             static_cast<ossim_int32>(theInputObjectList.size()-1) )
          {
-            std::vector<ossimConnectableObject*> oldInputs =
-               theInputObjectList;
-
+            ConnectableObjectList oldInputs =
+            theInputObjectList;
+            
             // Swap with index below.
-            ossimConnectableObject* tmpObj  = theInputObjectList[indexOfId];
-            theInputObjectList[indexOfId]   = theInputObjectList[indexOfId+1];
+            ossimRefPtr<ossimConnectableObject> tmpObj  = theInputObjectList[indexOfId].get();
+            theInputObjectList[indexOfId]   = theInputObjectList[indexOfId+1].get();
             theInputObjectList[indexOfId+1] = tmpObj;
             result = true;
-
-            std::vector<ossimConnectableObject*> newInputs =
-               theInputObjectList;
-
+            
+            ConnectableObjectList newInputs =
+            theInputObjectList;
+            
             ossimConnectionEvent event(this,
-                                 OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                                 newInputs,
-                                 oldInputs,
-                                 ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
+                                       OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                       newInputs,
+                                       oldInputs,
+                                       ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
             fireEvent(event);
          }
       }
@@ -1986,8 +1979,8 @@ bool ossimConnectableObject::moveInputToTop(const ossimId& id)
    {
       if ( theInputObjectList.size() )
       {
-         std::vector<ossimConnectableObject*>::iterator i =
-            theInputObjectList.begin();
+         ConnectableObjectList::iterator i =
+         theInputObjectList.begin();
          
          while (i != theInputObjectList.end())
          {
@@ -1999,50 +1992,50 @@ bool ossimConnectableObject::moveInputToTop(const ossimId& id)
          }
          
          if ( (i != theInputObjectList.begin()) &&
-              (i != theInputObjectList.end()) )
+             (i != theInputObjectList.end()) )
          {
-            std::vector<ossimConnectableObject*> oldInputs =
-               theInputObjectList;
+            ConnectableObjectList oldInputs =
+            theInputObjectList;
             
-            ossimConnectableObject* obj = *i;               
+            ossimRefPtr<ossimConnectableObject> obj = (*i).get();               
             theInputObjectList.erase(i);
-            theInputObjectList.insert(theInputObjectList.begin(), obj);
+            theInputObjectList.insert(theInputObjectList.begin(), obj.get());
             result = true;
             
-            std::vector<ossimConnectableObject*> newInputs =
-               theInputObjectList;
+            ConnectableObjectList newInputs =
+            theInputObjectList;
             
             ossimConnectionEvent event(
-               this,
-               OSSIM_EVENT_CONNECTION_CONNECT_ID,
-               newInputs,
-               oldInputs,
-               ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
+                                       this,
+                                       OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                       newInputs,
+                                       oldInputs,
+                                       ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
             fireEvent(event);
          }
       }
    }
-
+   
    return result;
 }
-   
+
 bool ossimConnectableObject::moveInputToBottom(const ossimId& id)
 {
    bool result = false;
-
+   
    if (theInputListIsFixedFlag == false)
    {
       if ( theInputObjectList.size() )
       {
-         std::vector<ossimConnectableObject*>::iterator bottom =
-            theInputObjectList.end()-1;
-
+         ConnectableObjectList::iterator bottom =
+         theInputObjectList.end()-1;
+         
          // if not bottom already
          if ( (*bottom)->getId() != id ) 
          {
-            std::vector<ossimConnectableObject*>::iterator i =
-               theInputObjectList.begin();
-
+            ConnectableObjectList::iterator i =
+            theInputObjectList.begin();
+            
             while (i != bottom)
             {
                if ( (*i)->getId() == id )
@@ -2051,26 +2044,26 @@ bool ossimConnectableObject::moveInputToBottom(const ossimId& id)
                }
                ++i;
             }
-
+            
             if (i != bottom)
             {
-               std::vector<ossimConnectableObject*> oldInputs =
-                  theInputObjectList;
+               ConnectableObjectList oldInputs =
+               theInputObjectList;
                
-               ossimConnectableObject* obj = *i;
+               ossimRefPtr<ossimConnectableObject> obj = (*i).get();
                theInputObjectList.erase(i);
                theInputObjectList.push_back(obj);
                result = true;
                
-               std::vector<ossimConnectableObject*> newInputs =
-                  theInputObjectList;
+               ConnectableObjectList newInputs =
+               theInputObjectList;
                
                ossimConnectionEvent event(
-                  this,
-                  OSSIM_EVENT_CONNECTION_CONNECT_ID,
-                  newInputs,
-                  oldInputs,
-                  ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
+                                          this,
+                                          OSSIM_EVENT_CONNECTION_CONNECT_ID,
+                                          newInputs,
+                                          oldInputs,
+                                          ossimConnectionEvent::OSSIM_INPUT_DIRECTION);
                fireEvent(event);
             }
          }
diff --git a/Utilities/otbossim/src/ossim/base/ossimConnectionEvent.cpp b/Utilities/otbossim/src/ossim/base/ossimConnectionEvent.cpp
index 2b305d449f0a894b61ed1a1aac18c54b2abe020a..585197dcf79ebeaa779f93e45dd9d2cf340b7c25 100644
--- a/Utilities/otbossim/src/ossim/base/ossimConnectionEvent.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimConnectionEvent.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimConnectionEvent.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimConnectionEvent.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/base/ossimConnectionEvent.h>
 
@@ -21,8 +21,8 @@ ossimConnectionEvent::ossimConnectionEvent(ossimObject* object, long id)
 ossimConnectionEvent::ossimConnectionEvent(
    ossimObject* object,
    long id,
-   const std::vector<ossimConnectableObject*>& newList,
-   const std::vector<ossimConnectableObject*>& oldList,
+   const ossimConnectableObject::ConnectableObjectList& newList,
+   const ossimConnectableObject::ConnectableObjectList& oldList,
    ossimConnectionDirectionType whichDirection)
    : ossimEvent(object, id),
      theNewObjectList(newList),
@@ -84,21 +84,21 @@ ossim_uint32 ossimConnectionEvent::getNumberOfOldObjects()const
    return theOldObjectList.size();
 }
 
-ossimConnectableObject* ossimConnectionEvent::getOldObject(ossim_uint32 i)const
+ossimConnectableObject* ossimConnectionEvent::getOldObject(ossim_uint32 i)
 {
    if(i < getNumberOfOldObjects())
    {
-      return theOldObjectList[i];
+      return theOldObjectList[i].get();
    }
    
    return (ossimConnectableObject*)NULL;
 }
 
-ossimConnectableObject* ossimConnectionEvent::getNewObject(ossim_uint32 i)const
+ossimConnectableObject* ossimConnectionEvent::getNewObject(ossim_uint32 i)
 {
    if(i < getNumberOfNewObjects())
    {
-      return theNewObjectList[i];
+      return theNewObjectList[i].get();
    }
    
    return (ossimConnectableObject*)NULL;
diff --git a/Utilities/otbossim/src/ossim/base/ossimDataObject.cpp b/Utilities/otbossim/src/ossim/base/ossimDataObject.cpp
index 7d3835b3dacb0425065b2889408b87809449d4c8..77ff3a70921b8778f2e1d2193289308ab4363a02 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDataObject.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDataObject.cpp
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -8,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimDataObject.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimDataObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/base/ossimDataObject.h>
 #include <ossim/base/ossimSource.h>
 #include <ossim/base/ossimScalarTypeLut.h>
@@ -25,7 +24,7 @@ ossimDataObject::ossimDataObject(ossimSource* source,
 
 ossimDataObject::ossimDataObject(const ossimDataObject& rhs)
    : ossimObject(),
-     theOwner(NULL),
+     theOwner(0),
      theDataObjectStatus(rhs.theDataObjectStatus)
 {
 }
@@ -129,7 +128,11 @@ const ossimDataObject* ossimDataObject::operator=(const ossimDataObject* rhs)
 
 const ossimDataObject& ossimDataObject::operator=(const ossimDataObject& rhs)
 {
-   assign(&rhs);
+   if (this != &rhs)
+   {
+      theOwner            = rhs.theOwner;
+      theDataObjectStatus = rhs.theDataObjectStatus; 
+   }
    return *this;
 }
 
diff --git a/Utilities/otbossim/src/ossim/base/ossimDate.cpp b/Utilities/otbossim/src/ossim/base/ossimDate.cpp
index e862766284cf21440c2eed38f5b6b8bd770fa17f..d969ab8f3bc7dad4dc35b154c60dbd887fd3f197 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDate.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDate.cpp
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimDate.cpp 14478 2009-05-08 18:24:22Z dburken $
+// $Id: ossimDate.cpp 15067 2009-08-12 15:14:27Z dburken $
 
 #include <ossim/base/ossimDate.h>
 #include <iomanip>
@@ -110,6 +110,11 @@ int ossimLocalTm::isValid (void) const
             tm_wday < 7 && tm_yday < 367 &&
             tm_sec < 60 && tm_min < 60 && tm_hour < 24);
 }
+void ossimLocalTm::now()
+{
+   time_t t = time(0);
+   *this = *localtime(&t);
+}
 
 void ossimLocalTm::dSfx (std::ostream & os, int fmt) const
 {
@@ -373,7 +378,7 @@ std::ostream &ossimLocalTm::printTime (std::ostream & os, int fmt) const
 int ossimLocalTm::getYear()const
 {
    int result = tm_year;
-   if (result < 200)
+//   if (result < 200)
    {
       result += 1900;
    }
@@ -614,6 +619,31 @@ ossim_float64 ossimLocalTm::deltaInDays(const ossimLocalTm& d)const
    return (getJulian()-d.getJulian());
 }
 
+ossimLocalTm ossimLocalTm::convertToGmt()const
+{
+   struct tm gmt = *this;
+#if !defined(_MSC_VER) 
+   tzset();
+#else
+   _tzset();
+#endif
+
+#ifdef __APPLE__
+   gmt.tm_sec -= tm_gmtoff; // Seconds east of UTC
+#else
+   gmt.tm_sec += timezone; // Seconds west of UTC
+   if ( tm_isdst )
+   {
+      gmt.tm_sec -= 3600; // Subtract an hour.
+   }
+#endif
+   
+   time_t t = mktime(&gmt);
+   ossimLocalTm result(*localtime(&t));
+   
+   return result;
+}
+
 void ossimLocalTm::setTimeNoAdjustmentGivenEpoc(time_t ticks)
 {
    *this = *gmtime(&ticks);
diff --git a/Utilities/otbossim/src/ossim/base/ossimDirectory.cpp b/Utilities/otbossim/src/ossim/base/ossimDirectory.cpp
index 996732d92bb5e7cff29aac2433288a4c47ae0fb7..18b98ba5d611fe4ff226005858fe08acceddffae 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDirectory.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDirectory.cpp
@@ -10,8 +10,9 @@
 // Description: A brief description of the contents of the file.
 //
 //*************************************************************************
-// $Id: ossimDirectory.cpp 11079 2007-05-29 19:58:57Z gpotts $
+// $Id: ossimDirectory.cpp 14776 2009-06-25 14:34:06Z dburken $
 
+#include <cstring> /* for strncasecmp */
 #include <iostream>
 
 #if defined (_WIN32)
@@ -274,3 +275,47 @@ void ossimDirectory::findAllFilesThatMatch(std::vector<ossimFilename>& result,
       }while(getNext(filename));
    }
 }
+
+// ESH 07/2008, Trac #234: OSSIM is case sensitive 
+// when using worldfile templates during ingest
+bool ossimDirectory::findCaseInsensitiveEquivalents(
+   const ossimFilename &filename, 
+   std::vector<ossimFilename>& result,
+   bool bExcludeExactMatch )
+{
+   bool bSuccess = false;
+   ossimFilename candidate;
+   bool bFoundCandidate = getFirst( candidate );
+   int compareSize = static_cast<int>( filename.length() );
+   
+   while( bFoundCandidate == true )
+   {
+      // Do a case insensitive string compare
+#if defined (_WIN32)
+      bool bFoundEquivalent = _strnicmp( filename.c_str(), candidate.c_str(), 
+                                         compareSize ) == 0 ? true : false;
+#else
+      //bool bFoundEquivalent =  strnicmp( filename.c_str(), candidate.c_str(), // 
+      //                                         compareSize ) == 0 ? true : false;
+      bool bFoundEquivalent =  strncasecmp( filename.c_str(), candidate.c_str(), 
+                                            compareSize ) == 0 ? true : false;
+#endif
+      
+      if ( bFoundEquivalent == true )
+      {
+         bool bFoundExact = ( filename == candidate.c_str() ) ? true : false;
+         bool bShouldExclude = ( bFoundExact == true && 
+                                 bExcludeExactMatch == true ) ? true : false;
+         
+         if ( bShouldExclude == false )
+         {
+            bSuccess = true;
+            result.push_back( candidate );
+         }
+      }
+      
+      bFoundCandidate = getNext( candidate );
+   }
+   
+   return bSuccess;
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossimDpt.cpp b/Utilities/otbossim/src/ossim/base/ossimDpt.cpp
index f3f4f647f4cd66be06bc4f26e48b6abc0b49e921..1d8c071cd8c21468b193f0d0922f911865941ce2 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDpt.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDpt.cpp
@@ -8,7 +8,7 @@
 // Contains class definitions for ossimDpt.
 // 
 //*******************************************************************
-//  $Id: ossimDpt.cpp 11408 2007-07-27 13:43:00Z dburken $
+//  $Id: ossimDpt.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <iomanip>
@@ -153,7 +153,32 @@ std::ostream& operator<<(std::ostream& os, const ossimDpt& pt)
 ossimString ossimDpt::toString(ossim_uint32 precision) const
 {
    std::ostringstream os;
-   print(os, precision);
+   os << std::setprecision(precision);
+
+   os << "(";
+   if (ossim::isnan(x) == false)
+   {
+      os << x;
+   }
+   else
+   {
+      os << "nan";
+   }
+   
+   os << ",";
+   
+   if (ossim::isnan(y) == false)
+   {
+      os << y;
+   }
+   else
+   {
+      os << "nan";
+   }
+   
+   os << ")";
+   
+   //print(os, precision);
    return ossimString(os.str());
 }
 
diff --git a/Utilities/otbossim/src/ossim/base/ossimDpt3d.cpp b/Utilities/otbossim/src/ossim/base/ossimDpt3d.cpp
index 7ef3db9b68f357ce8c6043dce763b8f271b70002..4d1babea50a12226ab09e39b8eeeeea2544bd4f6 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDpt3d.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDpt3d.cpp
@@ -5,7 +5,7 @@
 // See LICENSE.txt file in the top level directory for more details.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimDpt3d.cpp 14356 2009-04-20 19:59:03Z dburken $
+// $Id: ossimDpt3d.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 #include <ossim/base/ossimDpt3d.h>
@@ -39,9 +39,9 @@ ossimDpt3d::ossimDpt3d(const ossimIpt &aPt)
 std::string ossimDpt3d::toString(ossim_uint32 precision) const
 {
    std::ostringstream os;
-   os << setiosflags(ios::fixed) << setprecision(precision);
+   os <<  setprecision(precision);
    
-   os << "( ";
+   os << "(";
    if ( ossim::isnan(x) == false)
    {
       os << x;
@@ -50,7 +50,7 @@ std::string ossimDpt3d::toString(ossim_uint32 precision) const
    {
       os << "nan";
    }
-   os << ", ";
+   os << ",";
    if ( ossim::isnan(y) == false )
    {
       os << y;
@@ -59,7 +59,7 @@ std::string ossimDpt3d::toString(ossim_uint32 precision) const
    {
       os << "nan";
    }
-   os << ", ";
+   os << ",";
    if ( ossim::isnan(z) == false )
    {
       os << z;
@@ -68,7 +68,7 @@ std::string ossimDpt3d::toString(ossim_uint32 precision) const
    {
       os << "nan";
    }
-   os << " )";
+   os << ")";
    
    return os.str();
 }
diff --git a/Utilities/otbossim/src/ossim/base/ossimDuration.cpp b/Utilities/otbossim/src/ossim/base/ossimDuration.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bb434cd8cac719fd76bdc6eff6dc3f373bc51ca7
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/base/ossimDuration.cpp
@@ -0,0 +1,269 @@
+//*******************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author: Garrett Potts
+//
+//*************************************************************************
+// $Id$
+#include <ossim/base/ossimDuration.h>
+#include <ossim/base/ossimCommon.h>
+#include <sstream>
+#include <cctype>
+ossimDuration::ossimDuration(const ossimString& iso8601Duration)
+:theSign(1),
+theYears(0),
+theMonths(0),
+theWeeks(0),
+theDays(0),
+theHours(0),
+theMinutes(0),
+theSeconds(0)
+{
+   if(!iso8601Duration.empty())
+   {
+      setByIso8601DurationString(iso8601Duration);
+   }
+}
+
+void ossimDuration::clearFields()
+{
+   theSign = 1; 
+   theYears = 0;
+   theMonths = 0;
+   theWeeks = 0;
+   theDays = 0;
+   theHours = 0;
+   theMinutes = 0;
+   theSeconds = 0; 
+}
+
+static bool isWhiteSpace(int c)
+{
+   return ((c==' ') ||
+           (c=='\n')||
+           (c=='\r')||
+           (c=='\t'));
+}
+
+bool ossimDuration::readIso8601Encoding(std::istream& in)
+{
+   clearFields();
+   
+   if(in.peek()=='-')
+   {
+      theSign = -1;
+      in.ignore();
+   }
+   if(in.peek()!='P')
+   {
+      return false;
+   }
+   // skip the period indicater
+   in.ignore();
+   
+   // now we start parsing the date portion and the time portion
+   ossimString value;
+   bool doneFlag     = false;
+   bool badParseFlag = false;
+   bool doingTimeFlag = false;
+   while(!doneFlag)
+   {
+      int c = in.peek();
+      if(!in)
+      {
+         doneFlag = true;
+      }
+      else
+      {
+         if(isWhiteSpace(c))
+         {
+            doneFlag = true; // parse til blank character is met
+         }
+         else if(isalpha(c))
+         {
+            // we are done with current value 
+            //
+            // check to see if was a Time seaprator of value
+            // 'T'
+            if(c == 'T')
+            {
+               // then it was a time separator so do nothing
+               value = ""; // go ahead and null it out for now
+               doingTimeFlag = true; // now in time parsing portion
+            }
+            else
+            {
+               if(doingTimeFlag)
+               {
+                  // check time values
+                  if(c == 'H')
+                  {
+                     theHours = value.toUInt64();
+                  }
+                  else if(c == 'M')
+                  {
+                     theMinutes = value.toUInt64();
+                  }
+                  else if(c == 'S')
+                  {
+                     theSeconds = value.toFloat64();
+                  }
+                  else
+                  {
+                     doneFlag = true;
+                     badParseFlag = true;
+                  }
+                  value = ""; // reset the value
+               }
+               else // check date characters instead
+               {
+                  if(c == 'Y')
+                  {
+                     theYears = value.toUInt64();
+                  }
+                  else if(c == 'M')
+                  {
+                     theMonths = value.toUInt64();
+                  }
+                  else if(c == 'W')
+                  {
+                     theWeeks = value.toUInt64();
+                  }
+                  else if(c == 'D')
+                  {
+                     theDays = value.toUInt64();
+                  }
+                  else
+                  {
+                     doneFlag = true;
+                     badParseFlag = true;
+                  }
+                  value = ""; // reset the value
+               }
+            }
+         }
+         else if(isdigit(c)||(c=='.'))// not an alphabetic character so add it to the value string
+         {
+            value += static_cast<char>(c);
+         }
+         else
+         {
+            doneFlag = true;
+            badParseFlag = true;
+         }
+      }
+      if(!doneFlag)
+      {
+         in.ignore();
+      }
+   }
+   
+   return badParseFlag;
+}
+
+bool ossimDuration::setByIso8601DurationString(const ossimString& iso8601Duration)
+{
+   if(iso8601Duration.empty())
+   {
+      clearFields();
+      return true;
+   }
+   std::istringstream in(iso8601Duration);
+   return readIso8601Encoding(in);
+}
+
+void ossimDuration::toIso8601DurationString(ossimString& result)
+{
+   result = "";
+   bool hasDatePeriod = ((theYears!=0)||
+                         (theMonths!=0)||
+                         (theWeeks!=0)||
+                         (theDays!=0));
+   bool hasTimePeriod = ((theHours!=0)||
+                         (theMinutes!=0)||
+                         (!ossim::almostEqual(theSeconds, 0.0, .00000000001)));
+   // if no time or date period present then return empty
+   if(!(hasDatePeriod || hasTimePeriod))
+   {
+      return;
+   }
+   if(theSign < 0)
+   {
+      result += "-";
+   }
+   result += "P";
+   if(hasDatePeriod)
+   {
+      if(theYears > 0)
+      {
+         result+=ossimString::toString(theYears);
+         result+="Y";
+      }
+      if(theMonths>0)
+      {
+         result+=ossimString::toString(theMonths);
+         result+="M";
+      }
+      if(theWeeks>0)
+      {
+         result+=ossimString::toString(theWeeks);
+         result+="W";
+      }
+      if(theDays>0)
+      {
+         result+=ossimString::toString(theDays);
+         result+="D";
+      }
+   }
+   if(hasTimePeriod)
+   {
+      result+="T";
+      if(theHours>0)
+      {
+         result+=ossimString::toString(theHours);
+         result+="H";
+      }
+      if(theMinutes>0)
+      {
+         result+=ossimString::toString(theMinutes);
+         result+="M";
+      }
+      if(theSeconds>0)
+      {
+         result+=ossimString::toString(theSeconds, 15);
+         result+="S";
+      }
+   }
+}
+
+ossim_float64 ossimDuration::toSeconds()const
+{
+   ossim_float64 result = theSeconds;
+   
+   if(theMinutes > 0)
+   {
+      result += theMinutes*60.0;
+   }
+   if(theHours > 0)
+   {
+      result += theHours*3600.0;
+   }
+   if(theDays > 0)
+   {
+      result += theDays*86400.0;
+   }
+   if(theWeeks > 0)
+   {
+      result += theWeeks*604800;
+   }
+   if(theSign < 0)
+   {
+      result *= -1.0;
+   }
+   return result;
+}
+
+
diff --git a/Utilities/otbossim/src/ossim/base/ossimFilename.cpp b/Utilities/otbossim/src/ossim/base/ossimFilename.cpp
index 903520c1ff166f342229434b9fd54c19bb3f3d97..4dfd5458cefcffe0455c144997cdf367ad2f0e24 100644
--- a/Utilities/otbossim/src/ossim/base/ossimFilename.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimFilename.cpp
@@ -7,7 +7,7 @@
 // Description: This class provides manipulation of filenames.
 //
 //*************************************************************************
-// $Id: ossimFilename.cpp 14242 2009-04-07 20:18:59Z dburken $
+// $Id: ossimFilename.cpp 14886 2009-07-15 15:40:50Z gpotts $
 
 #include <ossim/ossimConfig.h>  /* to pick up platform defines */
 
@@ -210,17 +210,26 @@ ossimFilename::ossimFilename()
 
 ossimFilename::ossimFilename(const ossimFilename& src)
    : ossimString(src)
-{}
+{
+}
+
 ossimFilename::ossimFilename(const ossimString& src)
    : ossimString(src)
-{}
+{
+	convertToNative();
+}
+
 ossimFilename::ossimFilename(const char* src)
    : ossimString(src)
-{}
+{
+	convertToNative();
+}
 
 template <class Iter> ossimFilename::ossimFilename(Iter s, Iter e)
    : ossimString(s, e)
-{}
+{
+	convertToNative();
+}
 
 bool ossimFilename::operator == (const ossimFilename& rhs)const
 {
@@ -434,13 +443,13 @@ ossimFilename ossimFilename::expand() const
       if ( needsExpansion() )
       {
 
-#if defined(_WIN32)
-         result.convertBackToForwardSlashes();
-#endif
+//#if defined(_WIN32)
+//         result.convertBackToForwardSlashes();
+//#endif
 
          bool addCwd = false;
          
-         if ( (size() > 1) && (*(begin()) == '~') && (*(begin()+1) == '/') )
+         if ( (size() > 1) && (*(begin()) == '~') && (*(begin()+1) == thePathSeparator) )
          {
             ossimFilename homeDir =
                ossimEnvironmentUtility::instance()->getUserDir();
@@ -449,13 +458,13 @@ ossimFilename ossimFilename::expand() const
             result = homeDir.dirCat(s);
          }
          else if( (size() > 1) &&
-                  (*(begin()) == '.') && (*(begin()+1) == '/') )
+                  (*(begin()) == '.') && (*(begin()+1) == thePathSeparator) )
          {
             // dot slash i.e. ./foo
             addCwd = true;
          }
          else if ( (size() > 2)  && (*(begin()) == '.')
-                   && (*(begin()+1) == '.') && (*(begin()+2) == '/') )
+                   && (*(begin()+1) == '.') && (*(begin()+2) == thePathSeparator) )
          {
             // ../foo
             addCwd = true;
@@ -487,10 +496,6 @@ ossimFilename ossimFilename::expand() const
          {
             // now expand any environment variable substitutions
             
-#if defined(_WIN32)
-            result.convertBackToForwardSlashes();
-#endif        
-            
             ossimFilename finalResult;
             const char* tempPtr = result.c_str();
             ossim_int32 startIdx = -1;
@@ -517,7 +522,7 @@ ossimFilename ossimFilename::expand() const
                         getEnvironmentVariable(ossimString(tempPtr+startIdx,
                                                            tempPtr+scanIdx)));
 #if defined(_WIN32) // do windows style replacment
-                     value.convertBackToForwardSlashes();
+ //                    value.convertBackToForwardSlashes();
 #endif
                      finalResult += value;
                      // reset start idx indicator to not set so we are ready for next pattern
@@ -540,14 +545,17 @@ ossimFilename ossimFilename::expand() const
                   ++scanIdx;
                }
             }
+#if defined(_WIN32)
+
+#else        
             finalResult.gsub("//", "/", true);
-            
+#endif       
             result = finalResult;
          
          } // matches:  if ( result.needsExpansion() )
 
 #if defined(_WIN32)
-         result.convertForwardToBackSlashes();
+ //        result.convertForwardToBackSlashes();
 #endif        
 
       } // matches: if ( needsExpansion() )
@@ -667,9 +675,9 @@ ossimFilename ossimFilename::file() const
 {
    ossimFilename file = *this;
 
-   file.convertBackToForwardSlashes();
+   //file.convertBackToForwardSlashes();
 
-   size_type pos = file.rfind('/');
+   size_type pos = file.rfind(thePathSeparator);
    if (pos == npos)
       return *this;
    else
@@ -679,13 +687,13 @@ ossimFilename ossimFilename::file() const
 ossimFilename ossimFilename::path() const
 {
    ossimFilename file = *this;
-   file.convertBackToForwardSlashes();
+   //file.convertBackToForwardSlashes();
 
     // finds the last occurrence of the given string; in this case '/';
-    size_type pos = file.rfind('/');
+    size_type pos = file.rfind(thePathSeparator);
 
     if (pos == 0)
-       return ossimFilename(ossimFilename("/"));
+       return ossimFilename(ossimFilename(thePathSeparator));
     if (pos == npos)
     {
        // We got to the end of the file and did not find a path separator.
@@ -720,10 +728,10 @@ ossimFilename ossimFilename::drive()const
 ossimFilename ossimFilename::fileNoExtension()const
 {
    ossimFilename f = *this;
-   f.convertBackToForwardSlashes();
+   //f.convertBackToForwardSlashes();
 
    size_type dot_pos   = f.rfind('.');
-   size_type slash_pos = f.rfind('/');
+   size_type slash_pos = f.rfind(thePathSeparator);
 
    if(dot_pos == npos)
    {
@@ -910,32 +918,27 @@ ossimFilename ossimFilename::dirCat(const ossimFilename& file) const
    ossimFilename dir      = *this;
    ossimFilename tempFile = file;
       
-#if defined(_WIN32)
-      dir.convertBackToForwardSlashes();
-      tempFile.convertBackToForwardSlashes();
-#endif   
-
    // Check the end and see if it already has a "/".
    string::const_iterator i = dir.end();
 
    --i; // decrement past the trailing null.
 
-   if ( (*i) != '/')
+   if ( (*i) != thePathSeparator)
    {
-      dir += "/";
+      dir += ossimString(thePathSeparator);
    }
 
    // check for dot slash or just slash: ./foo or /foo   
    std::string::iterator iter = tempFile.begin();
    if (iter != tempFile.end())
    {
-      if ((*iter) == '/')
+      if ((*iter) == thePathSeparator)
       {
          ++iter; // skip slash
       }
       else if (tempFile.size() > 1)
       {
-         if ( ((*iter) == '.') &&  ( *(iter + 1) == '/') )
+         if ( ((*iter) == '.') &&  ( *(iter + 1) == thePathSeparator) )
          {
             iter = iter + 2; // skip dot slash
          }
@@ -944,10 +947,6 @@ ossimFilename ossimFilename::dirCat(const ossimFilename& file) const
 
    dir += std::string(iter, tempFile.end());
 
-#if defined(_WIN32)
-      dir.convertForwardToBackSlashes();
-#endif   
-
    return dir;
 }
 
@@ -986,13 +985,13 @@ bool ossimFilename::createDirectory(bool recurseFlag,
    if(exists()) return true;
 
    ossimFilename tempFile = *this;
-   tempFile.convertBackToForwardSlashes();
+   //tempFile.convertBackToForwardSlashes();
    vector<ossimString> result;
 
 
    if(recurseFlag)
    {
-      ossimString::split(result,"/");
+      ossimString::split(result,thePathSeparator);
 
       if(result.size())
       {
@@ -1000,9 +999,9 @@ bool ossimFilename::createDirectory(bool recurseFlag,
 
          for(ossim_uint32 i = 1; i < result.size(); ++i)
          {
-            current += ("/"+result[i]);
+            current += (thePathSeparator+result[i]);
 
-            if(current != "/")
+            if(current != thePathSeparator)
             {
                if(!ossimFilename(current).exists())
                {
@@ -1197,8 +1196,11 @@ bool ossimFilename::isRelative() const
    bool result = true;
    if (size())
    {
+      //---
       // Look for unix "/"...
-      if ( *(begin()) == '/' )
+      // ESH: Look for Windows "\" (with prepending escape character \)
+      //---
+      if ( (*(begin()) == '/') || (*(begin()) == '\\') )
       {
          result = false;
       }
@@ -1236,3 +1238,13 @@ bool ossimFilename::needsExpansion() const
    }
    return result;
 }
+
+void ossimFilename::convertToNative()
+{
+#if defined(_WIN32)
+    convertForwardToBackSlashes();
+#else
+	convertBackToForwardSlashes();
+#endif
+	
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossimGpt.cpp b/Utilities/otbossim/src/ossim/base/ossimGpt.cpp
index a6d4652f8f94b379595ddffd4ce4eae93e55e5c9..43f05f7ba8c6996b5206b8a4c757df8473845d85 100644
--- a/Utilities/otbossim/src/ossim/base/ossimGpt.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimGpt.cpp
@@ -9,7 +9,7 @@
 // LATITUDE AND LONGITUDE VALUES ARE IN DEGREES.
 //
 //*******************************************************************
-//  $Id: ossimGpt.cpp 12447 2008-02-08 17:49:29Z dburken $
+//  $Id: ossimGpt.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <sstream>
@@ -73,7 +73,37 @@ std::ostream& operator<<(std::ostream& os, const ossimGpt& pt)
 ossimString ossimGpt::toString(ossim_uint32 precision) const
 {
    std::ostringstream os;
-   print(os, precision);
+   
+   os << setprecision(precision);
+   os << "(";
+   
+   if(isLatNan())
+   {
+      os << "nan" << ",";
+   }
+   else
+   {
+      os << latd() << ",";
+   }
+   if(isLonNan())
+   {
+      os << "nan" << ",";
+   }
+   else
+   {
+      os << lond() << ",";
+   }
+   if(isHgtNan())
+   {
+      os << "nan" << ",";
+   }
+   else
+   {
+      // millimeter precision for height
+      os << height() << ",";
+   }
+   
+   os << (theDatum?theDatum->code().c_str():"") << ")";
    return ossimString(os.str());
 }
 
diff --git a/Utilities/otbossim/src/ossim/base/ossimHistogram.cpp b/Utilities/otbossim/src/ossim/base/ossimHistogram.cpp
index 8ee74f267ce15806bb371585f08cf0b4e5f6ff2c..9b4caef4a5c3959c1d05083c417945b6a345523a 100644
--- a/Utilities/otbossim/src/ossim/base/ossimHistogram.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimHistogram.cpp
@@ -15,7 +15,7 @@
 // frequency counts for each of these buckets.
 //
 //********************************************************************
-// $Id: ossimHistogram.cpp 13709 2008-10-14 14:55:11Z gpotts $
+// $Id: ossimHistogram.cpp 15766 2009-10-20 12:37:09Z gpotts $
 //
 
 #include <stdio.h>
@@ -1442,11 +1442,11 @@ bool ossimHistogram::saveState(ossimRefPtr<ossimXmlNode> xmlNode)const
    {
       for(idx = 0; idx < num;++idx)
       {
-         out << ossimString::toString(counts[idx], 8, true) << " ";
+         out << ossimString::toString(counts[idx], 8) << " ";
       }
       binValues->setText(out.str());
    }
-   xmlNode->addChildNode(binValues);
+   xmlNode->addChildNode(binValues.get());
    
    return true;
 }
diff --git a/Utilities/otbossim/src/ossim/base/ossimIpt.cpp b/Utilities/otbossim/src/ossim/base/ossimIpt.cpp
index 97f0ed5afa0c73d65a99cb16d7a74df929cee6de..d9225172476222dc539fd51dc4687a6b1c5760c4 100644
--- a/Utilities/otbossim/src/ossim/base/ossimIpt.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimIpt.cpp
@@ -10,7 +10,7 @@
 // Contains class definitions for ipt.
 //
 //*******************************************************************
-//  $Id: ossimIpt.cpp 11347 2007-07-23 13:01:59Z gpotts $
+//  $Id: ossimIpt.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <sstream>
@@ -139,7 +139,30 @@ std::ostream& operator<<(std::ostream& os, const ossimIpt& pt)
 ossimString ossimIpt::toString() const
 {
    std::ostringstream os;
-   print(os);
+   os << "(";
+   
+   if (x != OSSIM_INT_NAN)
+   {
+      os << x;
+   }
+   else
+   {
+      os << "nan";
+   }
+   
+   os << ",";
+   
+   if (y != OSSIM_INT_NAN)
+   {
+      os << y;
+   }
+   else
+   {
+      os << "nan";
+   }
+   
+   os << ")";
+   
    return ossimString(os.str());
 }
 
diff --git a/Utilities/otbossim/src/ossim/base/ossimKeywordNames.cpp b/Utilities/otbossim/src/ossim/base/ossimKeywordNames.cpp
index 23d3666689535a3094ad40dc134b4db5b0d6794d..26c2754c9a58af8f7c3af9e3a4d7533d9075dc48 100644
--- a/Utilities/otbossim/src/ossim/base/ossimKeywordNames.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimKeywordNames.cpp
@@ -8,7 +8,7 @@
 // Description: Common file for global Keywords.
 //
 //*************************************************************************
-// $Id: ossimKeywordNames.cpp 11731 2007-09-17 13:48:57Z gpotts $
+// $Id: ossimKeywordNames.cpp 15464 2009-09-23 19:30:35Z okramer $
 
 #include <ossim/base/ossimKeywordNames.h>
 
@@ -67,6 +67,7 @@ const char* ossimKeywordNames::HEMISPHERE_KW = "hemisphere";
 const char* ossimKeywordNames::HORIZONTAL_SIZE_KW = "horizontal_size";
 const char* ossimKeywordNames::ID_KW ="id";
 const char* ossimKeywordNames::IMAGE_FILE_KW = "image_file";
+const char* ossimKeywordNames::IMAGE_ID_KW = "image_id";
 const char* ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW = "image_model_transform_matrix";
 const char* ossimKeywordNames::IMAGE_MODEL_TRANSFORM_UNIT_KW = "image_model_transform_unit";
 const char* ossimKeywordNames::IMAGE_PATH_KW = "image_path";
@@ -129,6 +130,11 @@ const char* ossimKeywordNames::PROJECTION_KW     = "projection";
 const char* ossimKeywordNames::QUALITY_KW        = "quality";
 const char* ossimKeywordNames::RADIOMETRY_KW = "radiometry";
 const char* ossimKeywordNames::REDUCED_RES_LEVEL_KW = "reduced_res_level";
+const char* ossimKeywordNames::REF_GPT_LAT_KW  = "ref_point_lat";
+const char* ossimKeywordNames::REF_GPT_LON_KW  = "ref_point_lon";
+const char* ossimKeywordNames::REF_GPT_HGT_KW  = "ref_point_hgt";
+const char* ossimKeywordNames::REF_IPT_LINE_KW = "ref_point_line";
+const char* ossimKeywordNames::REF_IPT_SAMP_KW = "ref_point_samp";
 const char* ossimKeywordNames::ROTATION_KW = "rotation";
 const char* ossimKeywordNames::SCALE_PER_PIXEL_X_KW = "scale_per_pixel_x";
 const char* ossimKeywordNames::SCALE_PER_PIXEL_Y_KW = "scale_per_pixel_y";
@@ -138,6 +144,7 @@ const char* ossimKeywordNames::SCALE_FACTOR_X_KW = "scale_factor_x";
 const char* ossimKeywordNames::SCALE_FACTOR_Y_KW = "scale_factor_y";
 const char* ossimKeywordNames::SCALE_X_KW = "scale_x";
 const char* ossimKeywordNames::SCALE_Y_KW = "scale_y";
+const char* ossimKeywordNames::SENSOR_ID_KW = "sensor";
 const char* ossimKeywordNames::STD_PARALLEL_1_KW = "std_parallel_1";
 const char* ossimKeywordNames::STD_PARALLEL_2_KW = "std_parallel_2";
 const char* ossimKeywordNames::THICKNESS_KW = "thickness";
diff --git a/Utilities/otbossim/src/ossim/base/ossimKeywordlist.cpp b/Utilities/otbossim/src/ossim/base/ossimKeywordlist.cpp
index 03ec055e2eff3ae8d2b94c5b500e416dfb42c68c..f0ed580f36f0fc15e3ac235d778a4d0a76ddb797 100644
--- a/Utilities/otbossim/src/ossim/base/ossimKeywordlist.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimKeywordlist.cpp
@@ -5,7 +5,7 @@
 // Description: This class provides capabilities for keywordlists.
 //
 //********************************************************************
-// $Id: ossimKeywordlist.cpp 13081 2008-06-25 19:35:34Z dburken $
+// $Id: ossimKeywordlist.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <fstream>
 #include <list>
@@ -25,7 +25,7 @@ static const char NULL_KEY_NOTICE[]
 
 #ifdef OSSIM_ID_ENABLED
 static const bool TRACE = false;
-static const char OSSIM_ID[] = "$Id: ossimKeywordlist.cpp 13081 2008-06-25 19:35:34Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimKeywordlist.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 ossimKeywordlist::ossimKeywordlist(char delimiter)
@@ -106,7 +106,7 @@ void ossimKeywordlist::add(const ossimKeywordlist& kwl,
    // Check for null prefix.
    ossimString tmpPrefix;
    if (prefix) tmpPrefix = prefix;
-   
+
    regExp.compile(("^("+tmpPrefix+")").c_str());
 
    while(iter != kwl.theMap.end())
@@ -504,18 +504,14 @@ void ossimKeywordlist::add(const char*  prefix,
 void ossimKeywordlist::add(const char* key,
                            ossim_float32 value,
                            bool overwrite,
-                           int precision,
-                           bool trimZeroFlag,
-                           bool scientific)
+                           int precision)
 {
    if (key)
    {
       ossimString k = key;
 
       ossimString v = ossimString::toString(value,
-                                            precision,
-                                            trimZeroFlag,
-                                            scientific);
+                                            precision);
 
       KeywordMap::iterator i = getMapEntry(k);
 
@@ -534,9 +530,7 @@ void ossimKeywordlist::add(const char* prefix,
                            const char* key,
                            ossim_float32 value,
                            bool overwrite,
-                           int precision,
-                           bool trimZeroFlag,
-                           bool scientific)
+                           int precision)
 {
    if (key)
    {
@@ -545,9 +539,7 @@ void ossimKeywordlist::add(const char* prefix,
       k += key;
 
       ossimString v = ossimString::toString(value,
-                                            precision,
-                                            trimZeroFlag,
-                                            scientific);
+                                            precision);
 
       KeywordMap::iterator i = getMapEntry(k);
 
@@ -565,18 +557,14 @@ void ossimKeywordlist::add(const char* prefix,
 void ossimKeywordlist::add(const char* key,
                            ossim_float64 value,
                            bool overwrite,
-                           int precision,
-                           bool trimZeroFlag,
-                           bool scientific)
+                           int precision)
 {
    if (key)
    {
       ossimString k = key;
 
       ossimString v = ossimString::toString(value,
-                                            precision,
-                                            trimZeroFlag,
-                                            scientific);
+                                            precision);
 
       KeywordMap::iterator i = getMapEntry(k);
 
@@ -595,9 +583,7 @@ void ossimKeywordlist::add(const char* prefix,
                            const char* key,
                            ossim_float64 value,
                            bool overwrite,
-                           int precision,
-                           bool trimZeroFlag,
-                           bool scientific)
+                           int precision)
 {
    if (key)
    {
@@ -606,9 +592,7 @@ void ossimKeywordlist::add(const char* prefix,
       k += key;
 
       ossimString v = ossimString::toString(value,
-                                            precision,
-                                            trimZeroFlag,
-                                            scientific);
+                                            precision);
 
       KeywordMap::iterator i = getMapEntry(k);
 
@@ -862,7 +846,7 @@ bool ossimKeywordlist::parseStream(std::istream& is,
    {
       return false;
    }
-   
+
    ossimString line;
 
    while(!is.eof() && is.good())
@@ -930,7 +914,7 @@ bool ossimKeywordlist::parseStream(std::istream& is,
                   theMap.insert(std::make_pair(key, value));
                }
             }
-            
+
          } // End of:  if(pos != line.npos)
 
       } // End of:  if(line != "")
@@ -1203,7 +1187,7 @@ void ossimKeywordlist::downcaseKeywords()
    {
       tempMap.insert(make_pair(ossimString::downcase(iter->first),
                                iter->second));
-                               
+
       ++iter;
    }
    theMap = tempMap;
@@ -1218,7 +1202,7 @@ void ossimKeywordlist::upcaseKeywords()
    {
       tempMap.insert(make_pair(ossimString::upcase(iter->first),
                                iter->second));
-                               
+
       ++iter;
    }
    theMap = tempMap;
diff --git a/Utilities/otbossim/src/ossim/base/ossimMultiBandHistogram.cpp b/Utilities/otbossim/src/ossim/base/ossimMultiBandHistogram.cpp
index 54b967be2999c073c54e8b6968d6f197e7d5cd30..47a76247f39e653f01855a9633d522211af23efd 100644
--- a/Utilities/otbossim/src/ossim/base/ossimMultiBandHistogram.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimMultiBandHistogram.cpp
@@ -7,7 +7,7 @@
 // Description: 
 //
 //*******************************************************************
-//  $Id: ossimMultiBandHistogram.cpp 12911 2008-05-28 13:36:06Z gpotts $
+//  $Id: ossimMultiBandHistogram.cpp 14999 2009-07-27 18:56:11Z gpotts $
 #include <ossim/base/ossimMultiBandHistogram.h>
 #include <ossim/base/ossimHistogram.h>
 #include <ossim/base/ossimKeywordlist.h>
@@ -392,7 +392,7 @@ bool ossimMultiBandHistogram::saveState(ossimRefPtr<ossimXmlNode> xmlNode)const
 
       band->setTag("Band");
       band->addAttribute("idx", ossimString::toString(idx));
-      band->addChildNode(newNode);
+      band->addChildNode(newNode.get());
       if(theHistogramList[idx].valid())
       {         
          theHistogramList[idx]->saveState(newNode);
@@ -401,7 +401,7 @@ bool ossimMultiBandHistogram::saveState(ossimRefPtr<ossimXmlNode> xmlNode)const
       {
          newNode->setTag("ossimHistogram");
       }
-      xmlNode->addChildNode(band);
+      xmlNode->addChildNode(band.get());
    }
 
    return true;
diff --git a/Utilities/otbossim/src/ossim/base/ossimObjectFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/base/ossimObjectFactoryRegistry.cpp
index 08683e2d5bdd4debc83a1f5fe1b83cd158b1736a..19612e270feb1dcd8b01f0467c61715eeb8c2ed1 100644
--- a/Utilities/otbossim/src/ossim/base/ossimObjectFactoryRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimObjectFactoryRegistry.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimObjectFactoryRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
+// $Id: ossimObjectFactoryRegistry.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 
@@ -15,6 +15,7 @@ RTTI_DEF1(ossimObjectFactoryRegistry, "ossimObjectFactoryRegistry", ossimObject)
 #include <ossim/base/ossimObjectFactory.h>
 #include <ossim/base/ossimBaseObjectFactory.h>
 #include <ossim/base/ossimString.h>
+#include <ossim/base/ossimRefPtr.h>
 using namespace std;
 
 
@@ -33,6 +34,7 @@ ossimObjectFactoryRegistry* ossimObjectFactoryRegistry::instance()
    return &sharedInstance;
 }
 
+#if 0
 bool ossimObjectFactoryRegistry::addFactory(ossimObjectFactory* factory)
 {
    return registerFactory(factory);
@@ -132,6 +134,7 @@ ossimObjectFactory* ossimObjectFactoryRegistry::findFactory(ossimObjectFactory*
 
    return NULL;
 }
+#endif
 
 void ossimObjectFactoryRegistry::getTypeNameList(std::vector<ossimString>& typeList,
                                                  const ossimString& baseType)const
@@ -149,18 +152,16 @@ void ossimObjectFactoryRegistry::getTypeNameList(std::vector<ossimString>& typeL
    else
    {
       int i = 0;
-      ossimObject* obj = (ossimObject*)NULL;
+      ossimRefPtr<ossimObject> obj;
       for(i = 0; i < (int)allTypeList.size(); ++i)
       {
          obj = createObject(allTypeList[i]);
-         if(obj)
+         if(obj.valid())
          {
             if(obj->canCastTo(baseType))
             {
                typeList.push_back(allTypeList[i]);
             }
-            delete obj;
-            obj = (ossimObject*)NULL;
          }
       }
    }
diff --git a/Utilities/otbossim/src/ossim/base/ossimRectilinearDataObject.cpp b/Utilities/otbossim/src/ossim/base/ossimRectilinearDataObject.cpp
index 9af5142122150079bc6a19813e588fff747c6b1d..f744ad4499e449dbebcc9cfb610298b3e1366a78 100644
--- a/Utilities/otbossim/src/ossim/base/ossimRectilinearDataObject.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimRectilinearDataObject.cpp
@@ -1,106 +1,99 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts
 // Contributor: David A. Horner (DAH) - http://dave.thehorners.com
 //
 //*************************************************************************
-// $Id: ossimRectilinearDataObject.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimRectilinearDataObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/base/ossimRectilinearDataObject.h>
 #include <ossim/base/ossimScalarTypeLut.h>
 
 RTTI_DEF1(ossimRectilinearDataObject, "ossimRectilinearDataObject", ossimDataObject);
 
-ossimRectilinearDataObject::ossimRectilinearDataObject(const ossimRectilinearDataObject& rhs)
+ossimRectilinearDataObject::ossimRectilinearDataObject()
+   : ossimDataObject(),
+     theNumberOfDataComponents(0),
+     theScalarType(),
+     theDataBuffer(),
+     theSpatialExtents()
+{
+}
+
+ossimRectilinearDataObject::ossimRectilinearDataObject(
+   const ossimRectilinearDataObject& rhs)
    : ossimDataObject(rhs),
      theNumberOfDataComponents(rhs.theNumberOfDataComponents),
-     theNumberOfSpatialComponents(rhs.theNumberOfSpatialComponents),
      theScalarType(rhs.theScalarType),
-     theDataBuffer(0),
-     theSpatialExtents(NULL)
+     theDataBuffer(rhs.theDataBuffer),
+     theSpatialExtents(rhs.theSpatialExtents)
 {
-   theDataBuffer = rhs.theDataBuffer;
-
-   if(rhs.theSpatialExtents)
-   {
-      theSpatialExtents = new ossim_uint32[rhs.theNumberOfSpatialComponents];
-      memcpy(theSpatialExtents, rhs.theSpatialExtents, sizeof(ossim_uint32)*theNumberOfSpatialComponents);
-   }
 }
 
-ossimRectilinearDataObject::ossimRectilinearDataObject(ossim_uint32 numberOfSpatialComponents,
-                                                       ossimSource* owner,
-                                                       ossim_uint32 numberOfDataComponents,
-                                                       ossimScalarType   scalarType,
-                                                       ossimDataObjectStatus status)
+ossimRectilinearDataObject::ossimRectilinearDataObject(
+   ossim_uint32 numberOfSpatialComponents,
+   ossimSource* owner,
+   ossim_uint32 numberOfDataComponents,
+   ossimScalarType   scalarType,
+   ossimDataObjectStatus status)
    :ossimDataObject(owner, OSSIM_NULL),
     theNumberOfDataComponents(numberOfDataComponents),
-    theNumberOfSpatialComponents(numberOfSpatialComponents),
     theScalarType(scalarType),
     theDataBuffer(0),
-    theSpatialExtents(NULL)
+    theSpatialExtents(numberOfSpatialComponents)
 {
-   if(theNumberOfSpatialComponents)
-   {
-      theSpatialExtents = new ossim_uint32[theNumberOfSpatialComponents];
-      memset(theSpatialExtents, 1, theNumberOfSpatialComponents);
-   }
 }
 
-ossimRectilinearDataObject::ossimRectilinearDataObject(ossimSource* owner,
-                                                       ossim_uint32 numberOfDataComponents,
-                                                       ossim_uint32 length,
-                                                       ossimScalarType   scalarType,
-                                                       ossimDataObjectStatus status)
+ossimRectilinearDataObject::ossimRectilinearDataObject(
+   ossimSource* owner,
+   ossim_uint32 numberOfDataComponents,
+   ossim_uint32 length,
+   ossimScalarType   scalarType,
+   ossimDataObjectStatus status)
    :ossimDataObject(owner, OSSIM_NULL),
     theNumberOfDataComponents(numberOfDataComponents),
-    theNumberOfSpatialComponents(1),
     theScalarType(scalarType),
     theDataBuffer(0),
-    theSpatialExtents(NULL)
+    theSpatialExtents(1)
 {
-   
-   theSpatialExtents = new ossim_uint32[1];
    theSpatialExtents[0] = length;
 }
 
-ossimRectilinearDataObject::ossimRectilinearDataObject(ossimSource* owner,
-                                                       ossim_uint32 numberOfDataComponents,
-                                                       ossim_uint32 width,
-                                                       ossim_uint32 height,
-                                                       ossimScalarType   scalarType,
-                                                       ossimDataObjectStatus status)
+ossimRectilinearDataObject::ossimRectilinearDataObject(
+   ossimSource* owner,
+   ossim_uint32 numberOfDataComponents,
+   ossim_uint32 width,
+   ossim_uint32 height,
+   ossimScalarType   scalarType,
+   ossimDataObjectStatus status)
    :ossimDataObject(owner, OSSIM_NULL),
     theNumberOfDataComponents(numberOfDataComponents),
-    theNumberOfSpatialComponents(2),
     theScalarType(scalarType),
     theDataBuffer(0),
-    theSpatialExtents(NULL)
+    theSpatialExtents(2)
 {
-   
-   theSpatialExtents = new ossim_uint32[2];
    theSpatialExtents[0] = width;
    theSpatialExtents[1] = height;
 }
 
-ossimRectilinearDataObject::ossimRectilinearDataObject(ossimSource* owner,
-                                                       ossim_uint32 numberOfDataComponents,
-                                                       ossim_uint32 width,
-                                                       ossim_uint32 height,
-                                                       ossim_uint32 depth,
-                                                       ossimScalarType   scalarType,
-                                                       ossimDataObjectStatus status)
+ossimRectilinearDataObject::ossimRectilinearDataObject(
+   ossimSource* owner,
+   ossim_uint32 numberOfDataComponents,
+   ossim_uint32 width,
+   ossim_uint32 height,
+   ossim_uint32 depth,
+   ossimScalarType   scalarType,
+   ossimDataObjectStatus status)
    :ossimDataObject(owner, OSSIM_NULL),
     theNumberOfDataComponents(numberOfDataComponents),
-    theNumberOfSpatialComponents(3),
     theScalarType(scalarType),
     theDataBuffer(0),
-    theSpatialExtents(NULL)
+    theSpatialExtents(3)
 {
-   
-   theSpatialExtents = new ossim_uint32[3];
    theSpatialExtents[0] = width;
    theSpatialExtents[1] = height;
    theSpatialExtents[2] = depth;
@@ -108,24 +101,15 @@ ossimRectilinearDataObject::ossimRectilinearDataObject(ossimSource* owner,
 
 ossimRectilinearDataObject::~ossimRectilinearDataObject()
 {
-   if(theSpatialExtents)
-   {
-      delete [] theSpatialExtents;
-      theSpatialExtents = NULL;
-   }
-   theNumberOfDataComponents    = 0;
-   theNumberOfSpatialComponents = 0;
 }
 
 ossim_uint32 ossimRectilinearDataObject::computeSpatialProduct()const
 {
-   if(!theSpatialExtents) return 0;
-   ossim_uint32 spatialProduct = 1;
-   for(ossim_uint32 index = 0; index < theNumberOfSpatialComponents; ++index)
+   ossim_uint32 spatialProduct = 0;
+   for(ossim_uint32 index = 0; index < theSpatialExtents.size(); ++index)
    {
       spatialProduct *= theSpatialExtents[index];
    }
-
    return spatialProduct;
 }
 
@@ -137,22 +121,14 @@ void ossimRectilinearDataObject::setNumberOfDataComponents(ossim_uint32 n)
 void ossimRectilinearDataObject::setSpatialExtents(ossim_uint32* extents,
                                                    ossim_uint32 size)
 {
-   if(!extents) return;
-   if((size != theNumberOfSpatialComponents)&&size)
+   if (extents)
    {
-      if(theSpatialExtents)
+      theSpatialExtents.resize(size);
+      for(ossim_uint32 i =0; i < size; ++i)
       {
-         delete [] theSpatialExtents;
-         theSpatialExtents = NULL;
+         theSpatialExtents[i] = extents[i];
       }
-      theSpatialExtents = new ossim_uint32[size];
-   }
-   int i = 0;
-   for(i =0; i < (int)size; ++i)
-   {
-      theSpatialExtents[i] = extents[i];
    }
-   theNumberOfSpatialComponents = size;
 }
 
 void ossimRectilinearDataObject::setScalarType(ossimScalarType type)
@@ -167,12 +143,12 @@ ossim_uint32 ossimRectilinearDataObject::getNumberOfDataComponents() const
 
 ossim_uint32 ossimRectilinearDataObject::getNumberOfSpatialComponents() const
 {
-   return theNumberOfSpatialComponents;
+   return theSpatialExtents.size();
 }
 
 const ossim_uint32* ossimRectilinearDataObject::getSpatialExtents()const
 {
-   return theSpatialExtents;
+   return &(theSpatialExtents.front());
 }
 
 ossimScalarType ossimRectilinearDataObject::getScalarType() const
@@ -205,38 +181,18 @@ const void* ossimRectilinearDataObject::getBuf()const
 
 void ossimRectilinearDataObject::assign(const ossimRectilinearDataObject* data)
 {
-   if(!data) return;
-   ossimDataObject::assign(data);
-
-   //***
-   // This method assumes contiguous buffer for "theData".  Override if
-   // needed.
-   //***
-   
-   if(theNumberOfSpatialComponents != data->theNumberOfSpatialComponents)
+   if(data)
    {
-      delete [] theSpatialExtents;
-      if(data->theNumberOfSpatialComponents)
-      {
-         theSpatialExtents = new ossim_uint32[data->theNumberOfSpatialComponents];
-      }
-      else
+      if (this != data)
       {
-         theSpatialExtents = NULL;
+         ossimDataObject::assign(data);
+         
+         theNumberOfDataComponents    = data->theNumberOfDataComponents;
+         theScalarType                = data->theScalarType;
+         theDataBuffer                = data->theDataBuffer;
+         theSpatialExtents            = data->theSpatialExtents;
       }
    }
-   for(ossim_uint32 index = 0; index < theNumberOfSpatialComponents; ++index)
-   {
-      theSpatialExtents[index] = data->theSpatialExtents[index];
-   }
-   
-   theNumberOfSpatialComponents = data->theNumberOfSpatialComponents;
-   theNumberOfDataComponents    = data->theNumberOfDataComponents;
-   theScalarType                = data->theScalarType;
-   //***
-   // First copy the buffer if there is one.
-   //***
-   theDataBuffer = data->theDataBuffer;
 }
 
 void ossimRectilinearDataObject::initialize()
@@ -258,12 +214,28 @@ ossim_uint32 ossimRectilinearDataObject::getDataSizeInBytes()const
 std::ostream& ossimRectilinearDataObject::print(std::ostream& out) const
 {
    out << "ossimRectilinearDataObject::print:"
-      << "\ntheNumberOfDataComponents:     " << theNumberOfDataComponents
-      << "\ntheNumberOfSpatialComponents:  " << theNumberOfSpatialComponents;
-   
-   out << "\ntheScalarType:                 "
+       << "\ntheNumberOfDataComponents:     " << theNumberOfDataComponents
+       << "\ntheNumberOfSpatialComponents:  " << theSpatialExtents.size()
+       << "\ntheScalarType:                 "
        << (ossimScalarTypeLut::instance()->getEntryString(theScalarType))
        << endl;
-
+   
    return ossimDataObject::print(out);
 }
+
+const ossimRectilinearDataObject& ossimRectilinearDataObject::operator=(
+   const ossimRectilinearDataObject& rhs)
+{
+   if (this != &rhs)
+   {
+      // ossimDataObject initialization:
+      ossimDataObject::operator=(rhs);
+
+      // ossimRectilinearDataObject (this) initialization:
+      theNumberOfDataComponents    = rhs.theNumberOfDataComponents;
+      theScalarType                = rhs.theScalarType;
+      theDataBuffer                = rhs.theDataBuffer;
+      theSpatialExtents            = rhs.theSpatialExtents;
+   }
+   return *this;
+}
diff --git a/Utilities/otbossim/src/ossim/base/ossimString.cpp b/Utilities/otbossim/src/ossim/base/ossimString.cpp
index 90adb312898e53e15fd3d9dac132c34e969ed1ae..b6bfd3d282ec970e747bc318923e07b095f8eb5a 100644
--- a/Utilities/otbossim/src/ossim/base/ossimString.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimString.cpp
@@ -1,12 +1,15 @@
 //*******************************************************************
-// License:  See top level LICENSE.txt file.
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts
 // 
 // Description: This class extends the stl's string class.
 // 
 //********************************************************************
-// $Id: ossimString.cpp 13761 2008-10-22 19:28:35Z gpotts $
+// $Id: ossimString.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <iomanip>
@@ -22,7 +25,7 @@
 static ossimTrace traceDebug("ossimString:debug");
 
 #ifdef OSSIM_ID_ENABLED
-static char OSSIM_ID[] = "$Id: ossimString.cpp 13761 2008-10-22 19:28:35Z gpotts $";
+static char OSSIM_ID[] = "$Id: ossimString.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 ossimString ossimString::upcase(const ossimString& aString)
@@ -461,6 +464,46 @@ int ossimString::toInt(const ossimString& aString)
    return aString.toInt();
 }
 
+ossim_int16 ossimString::toInt16()const
+{
+   ossim_int16 i = 0;
+   if (!empty())
+   {
+      std::istringstream is(*this);
+      is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
+   }
+   return i;
+}
+
+ossim_int16 ossimString::toInt16(const ossimString& aString)
+{
+   return aString.toInt16();
+}
+
+ossim_uint16 ossimString::toUInt16()const
+{
+   ossim_uint16 i = 0;
+   if (!empty())
+   {
+      std::istringstream is(*this);
+      is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
+   }
+   return i;
+}
+
+ossim_uint16 ossimString::toUInt16(const ossimString& aString)
+{
+   return aString.toUInt16();
+}
+
 ossim_int32 ossimString::toInt32()const
 {
    ossim_int32 i = 0;
@@ -738,14 +781,22 @@ ossimString ossimString::toString(ossim_uint64 aValue)
 }
 
 ossimString ossimString::toString(ossim_float32 aValue,
-                                  int precision,
-                                  bool trimZeroFlag,
-                                  bool scientific)
+                                  int precision)
 {
    if ( ossim::isnan(aValue) )
    {
       return ossimString("nan");
    }
+   std::ostringstream s;
+   s << std::setprecision(precision)  << aValue;
+   
+   return    ossimString(s.str());
+
+#if 0
+   if ( ossim::isnan(aValue) )
+   {
+      return ossimString("nan");
+   }
    
    std::ostringstream s;
 
@@ -774,41 +825,24 @@ ossimString ossimString::toString(ossim_float32 aValue,
                             result.begin()+result.size()-1);
       }
 
-#if 0      
-      ossim_uint32 size = result.size();
-      if (size == 1) // A single '.'
-      {
-         result = "0";
-      }
-      else
-      {
-         ossimString::const_iterator i = result.begin();
-         if ((*i) == '.')  // .something like ".129" make "0.129"
-         {
-            // .something like ".129" make "0.129"
-            result.insert(0, 1, '0');
-         }
-         else
-         {
-            i = result.end();
-            --i;
-            if ((*i) == '.') // something. like 129. make 129"
-            {
-               // something. like 129. make "0.129"
-               result.push_back('0');
-            }
-         }
-      }
-#endif
    }
    return result;
+#endif
 }
 
 ossimString ossimString::toString(ossim_float64 aValue,
-                                  int precision,
-                                  bool trimZeroFlag,
-                                  bool scientific)
+                                  int precision)
 {
+   if ( ossim::isnan(aValue) )
+   {
+      return ossimString("nan");
+   }
+   std::ostringstream s;
+   s << std::setprecision(precision)  << aValue;
+   
+   return    ossimString(s.str());
+
+#if 0
    if (aValue == ossim::nan())
    {
       return ossimString("nan");
@@ -842,37 +876,9 @@ ossimString ossimString::toString(ossim_float64 aValue,
          return ossimString(result.begin(),
                             result.begin()+result.size()-1);
       }
-#if 0
-      // Trim all zeroes front and back of the '.'.
-      result = result.trim('0');
-
-      ossim_uint32 size = result.size();
-      if (size == 1) // A single '.'
-      {
-         result = "0.0";
-      }
-      else
-      {
-         ossimString::const_iterator i = result.begin();
-         if ((*i) == '.')  // .something like ".129" make "0.129"
-         {
-            // .something like ".129" make "0.129"
-            result.insert(0, 1, '0');
-         }
-         else
-         {
-            i = result.end();
-            --i;
-            if ((*i) == '.') // something. like 129. make "0.129"
-            {
-               // something. like 129. make "0.129"
-               result.push_back('0');
-            }
-         }
-      }
-#endif
    }
    return result;
+#endif
 }
 
 ossimString ossimString::before(const ossimString& str,
diff --git a/Utilities/otbossim/src/ossim/base/ossimTempFilename.cpp b/Utilities/otbossim/src/ossim/base/ossimTempFilename.cpp
index aa379d8b5be8905d100f427197441b0ba12552a7..96b1b1c1cf540fdc354361be1bc7e948f4efff1d 100644
--- a/Utilities/otbossim/src/ossim/base/ossimTempFilename.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimTempFilename.cpp
@@ -10,10 +10,11 @@
 //              file and will also delete it upon destruction
 //
 //*************************************************************************
-// $Id: ossimTempFilename.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimTempFilename.cpp 15524 2009-09-30 01:02:26Z dburken $
 #include <stdlib.h>
 #include <fstream>
 #include <ossim/base/ossimTempFilename.h>
+#include <ossim/base/ossimEnvironmentUtility.h>
 #include <time.h>
 
 ossimTempFilename::ossimTempFilename(const ossimString& tempDir,
@@ -65,10 +66,10 @@ void ossimTempFilename::generate(bool createAsDirectoryFlag)
 
    if(tempDirCopy == "")
    {
-      tempDirCopy = ossimString(getenv("TEMP"));
+      tempDirCopy = ossimEnvironmentUtility::instance()->getEnvironmentVariable("TEMP");
       if(tempDirCopy=="")
       {
-         tempDirCopy  = ossimString(getenv("TMP"));
+         tempDirCopy  = ossimEnvironmentUtility::instance()->getEnvironmentVariable("TMP");
       }
       if(tempDirCopy == "")
       {
diff --git a/Utilities/otbossim/src/ossim/base/ossimTieGptSet.cpp b/Utilities/otbossim/src/ossim/base/ossimTieGptSet.cpp
index 1297825519e87507fb2ca12616db76ba1ffb55aa..96abecd0e0cd1eb165b9b5f2a4a0c5815953b3f8 100644
--- a/Utilities/otbossim/src/ossim/base/ossimTieGptSet.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimTieGptSet.cpp
@@ -80,7 +80,7 @@ ossimTieGptSet::exportAsGmlNode(ossimString aGmlVersion)const
    for(vector<ossimRefPtr<ossimTieGpt> >::const_iterator it = theTies.begin(); it != theTies.end(); ++it)
    {
       ossimRefPtr<ossimXmlNode> tienode = (*it)->exportAsGmlNode(aGmlVersion);
-      node->addChildNode(tienode);
+      node->addChildNode(tienode.get());
       //TBD : add attribute / counter?
    }
 
diff --git a/Utilities/otbossim/src/ossim/base/ossimViewController.cpp b/Utilities/otbossim/src/ossim/base/ossimViewController.cpp
index 5b9d5106563a392070fcff93242417f50855e21c..75d56b0e0f8844b9e305df6e244e7eae5047bbaa 100644
--- a/Utilities/otbossim/src/ossim/base/ossimViewController.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimViewController.cpp
@@ -33,12 +33,7 @@ ossimViewController::ossimViewController(ossimObject* owner,
 
 ossimViewController::~ossimViewController()
 {
-   if(theView)
-   {
-      delete theView;
-      theView = NULL;
-      propagateView();
-   }
+   theView = 0;
 }
 
 ossimString ossimViewController::getShortName()const
@@ -70,7 +65,7 @@ bool ossimViewController::propagateView()
    if(inter)
    {
       RTTItypeid typeId = STATIC_TYPE_INFO(ossimViewInterface);
-      vector<ossimConnectableObject*> result = inter->findAllObjectsOfType(typeId,
+      ossimConnectableObject::ConnectableObjectList result = inter->findAllObjectsOfType(typeId,
                                                                            true);
       if(result.size() > 0)
       {
@@ -80,32 +75,20 @@ bool ossimViewController::propagateView()
          //
          for(index = 0; index < result.size(); ++index)
          {
-            ossimViewInterface* viewInterface = PTR_CAST(ossimViewInterface, result[index]);
+            ossimViewInterface* viewInterface = PTR_CAST(ossimViewInterface, result[index].get());
 
             if(viewInterface)
             {
-               if(theView)
-               {
-                  ossimObject* dupObject = theView->dup();
-                  if(!viewInterface->setView(dupObject, true))
-                  {
-                     returnResult = false;
-                     delete dupObject;
-                  }
-               }
-               else
+               if(!viewInterface->setView(theView.get()))
                {
-                  if(!viewInterface->setView((ossimObject*)NULL, true))
-                  {
-                     returnResult = false;
-                  }
+                  returnResult = false;
                }
             }
          }
 
          for(index = 0; index < result.size(); ++index)
          {
-            ossimPropertyEvent event(result[index]);
+            ossimPropertyEvent event(result[index].get());
             result[index]->fireEvent(event);
             result[index]->propagateEventToOutputs(event);
          }
@@ -117,11 +100,6 @@ bool ossimViewController::propagateView()
 
 bool ossimViewController::setView(ossimObject* object)
 {
-   if(theView&&(theView != object))
-   {
-      delete theView;
-      theView = NULL;
-   }
    theView = object;
 
    return true;
@@ -129,12 +107,12 @@ bool ossimViewController::setView(ossimObject* object)
 
 ossimObject* ossimViewController::getView()
 {
-   return theView;
+   return theView.get();
 }
 
 const ossimObject* ossimViewController::getView()const
 {
-   return theView;
+   return theView.get();
 }
 
 const ossimObject* ossimViewController::findFirstViewOfType(RTTItypeid typeId)const
@@ -144,7 +122,7 @@ const ossimObject* ossimViewController::findFirstViewOfType(RTTItypeid typeId)co
    if(inter)
    {
       RTTItypeid viewInterfaceType = STATIC_TYPE_INFO(ossimViewInterface);
-      vector<ossimConnectableObject*> result = inter->findAllObjectsOfType(viewInterfaceType,
+      ossimConnectableObject::ConnectableObjectList result = inter->findAllObjectsOfType(viewInterfaceType,
                                                                            true);
       if(result.size() > 0)
       {
@@ -153,7 +131,7 @@ const ossimObject* ossimViewController::findFirstViewOfType(RTTItypeid typeId)co
          for(index = 0; index < result.size(); ++index)
          {
 
-            ossimViewInterface* viewInterface = PTR_CAST(ossimViewInterface, result[index]);
+            ossimViewInterface* viewInterface = PTR_CAST(ossimViewInterface, result[index].get());
 
             if(viewInterface)
             {
diff --git a/Utilities/otbossim/src/ossim/base/ossimXmlNode.cpp b/Utilities/otbossim/src/ossim/base/ossimXmlNode.cpp
index e86cc1f5a84b8f185539c3cef1757029fe367ac4..65d1a30cfbbf5c2a72d9cc320578e4a4346a65d3 100644
--- a/Utilities/otbossim/src/ossim/base/ossimXmlNode.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimXmlNode.cpp
@@ -9,7 +9,7 @@
 // Contains definition of class ossimXmlNode.
 // 
 //*****************************************************************************
-// $Id: ossimXmlNode.cpp 12953 2008-06-01 16:24:05Z dburken $
+// $Id: ossimXmlNode.cpp 15251 2009-08-25 13:13:01Z gpotts $
 
 #include <iostream>
 #include <stack>
@@ -17,7 +17,9 @@
 #include <ossim/base/ossimXmlAttribute.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimNotifyContext.h>
+#include <ossim/base/ossimTrace.h>
 
+static ossimTrace traceDebug("ossimXmlNode:debug");
 static const ossimString XPATH_DELIM ("/");
 
 RTTI_DEF2(ossimXmlNode, "ossimXmlNode", ossimObject, ossimErrorStatusInterface);
@@ -117,19 +119,48 @@ void ossimXmlNode::skipCommentTag(std::istream& in)
 
 bool ossimXmlNode::read(std::istream& in)
 {
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: entered ......" << std::endl;
+   }
    char c;
    in >> xmlskipws;
-   if(in.fail()) return false;
+   if(in.fail())
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+      }
+      return false;
+   }
    if(in.peek() == '<')
    {
       in.ignore(1);
    }
-   if(in.fail()) return false;
+   if(in.fail())
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+      }
+      return false;
+   }
    streampos file_pos = in.tellg();
    ossimString endTag;
 
    
-   if(!readTag(in, theTag)) return false;
+   if(!readTag(in, theTag))
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+      }
+      return false;
+   }
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << "theTag = " << theTag << "\n";
+   }
 //    std::cout << "theTag = " << theTag << std::endl;
 
    if((!in.fail())&&readEndTag(in, endTag))
@@ -137,11 +168,19 @@ bool ossimXmlNode::read(std::istream& in)
       if((endTag == "")||
          (endTag == theTag))
       {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return true;
       }
       else
       {
          setErrorStatus();
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return false;
       }
    }
@@ -160,11 +199,19 @@ bool ossimXmlNode::read(std::istream& in)
       if((endTag == "")||
          (endTag == theTag))
       {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return true;
       }
       else
       {
          setErrorStatus();
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return false;
       }
    }
@@ -174,6 +221,10 @@ bool ossimXmlNode::read(std::istream& in)
    if(c != '>')
    {
       setErrorStatus();
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+      }
       return false;
    }
 
@@ -183,6 +234,10 @@ bool ossimXmlNode::read(std::istream& in)
    //
    if(!readTextContent(in))
    {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+      }
       return false;
    }
    in >> xmlskipws;
@@ -191,6 +246,10 @@ bool ossimXmlNode::read(std::istream& in)
     if(c != '<')
    {
       setErrorStatus();
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+      }
       return false;
    }
    in.ignore(1);
@@ -199,11 +258,19 @@ bool ossimXmlNode::read(std::istream& in)
       if((endTag == "")||
          (endTag == theTag))
       {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return true;
       }
       else
       {
          setErrorStatus();
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return false;
       }
    }
@@ -224,6 +291,10 @@ bool ossimXmlNode::read(std::istream& in)
       else
       {
          setErrorStatus();
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return false;
       }
       in >> xmlskipws;
@@ -232,6 +303,10 @@ bool ossimXmlNode::read(std::istream& in)
       if(c != '<')
       {
          setErrorStatus();
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+         }
          return false;
       }
       in.ignore(1);
@@ -240,16 +315,28 @@ bool ossimXmlNode::read(std::istream& in)
          if((endTag == "")||
             (endTag == theTag))
          {
+            if(traceDebug())
+            {
+               ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+            }
             return true;
          }
          else
          {
             setErrorStatus();
+            if(traceDebug())
+            {
+               ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n"<<__LINE__ << "\n";
+            }
             return false;
          }
       }
    }while((!done)&&(!in.bad()));
 
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::read: leaving ......\n";
+   }
    return true;
 }
 
@@ -651,7 +738,7 @@ ostream& operator << (ostream& os, const ossimXmlNode* xml_node)
 
 void ossimXmlNode::addAttribute(ossimRefPtr<ossimXmlAttribute> attribute)
 {
-   theAttributes.push_back(attribute);
+   theAttributes.push_back(attribute.get());
 }
 
 void ossimXmlNode::addAttribute(const ossimString& name,
@@ -754,7 +841,7 @@ void ossimXmlNode::addChildNode(ossimRefPtr<ossimXmlNode> node)
       node->theParentNode->removeChild(node);
    }
    node->theParentNode = this;
-   theChildNodes.push_back(node);
+   theChildNodes.push_back(node.get());
 }
 
 ossimRefPtr<ossimXmlNode> ossimXmlNode::addChildNode(const ossimString& tagName,
@@ -775,7 +862,7 @@ ossimRefPtr<ossimXmlNode> ossimXmlNode::removeChild(ossimRefPtr<ossimXmlNode> no
    while(iter != theChildNodes.end())
    {
       
-      if(node.get() == iter->get())
+      if(node == iter->get())
       {
          ossimRefPtr<ossimXmlNode> temp = *iter;
 
@@ -919,6 +1006,10 @@ void ossimXmlNode::toKwl(ossimKeywordlist& kwl,
 bool ossimXmlNode::readTag(std::istream& in,
                            ossimString& tag)
 {
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimXmlNode::readTag: entered ......\n";
+   }
    in >> xmlskipws;
 
    tag = "";
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimDtedFactory.cpp b/Utilities/otbossim/src/ossim/elevation/ossimDtedFactory.cpp
index c399865027cd1525b7be54e43c9591722c989e59..162c8edf50a32eb6c0ac2ce0493ff93cce6be1fe 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimDtedFactory.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimDtedFactory.cpp
@@ -13,7 +13,7 @@
 // pure virtual methods that all elevation source factories must implement.
 //
 //**************************************************************************
-// $Id: ossimDtedFactory.cpp 12982 2008-06-04 01:12:46Z dburken $
+// $Id: ossimDtedFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib> /* abs() */
 #include <sstream>
@@ -53,7 +53,7 @@ ossimElevSource* ossimDtedFactory::getNewElevSource(const ossimGpt& gpt) const
    
    ossimElevManager* mgr = ossimElevManager::instance();
    
-   ossimElevSource* dted_ptr = 0;
+   ossimRefPtr<ossimElevSource> dted_ptr;
    
    if (theDirectory == ossimFilename::NIL)
    {
@@ -62,7 +62,7 @@ ossimElevSource* ossimDtedFactory::getNewElevSource(const ossimGpt& gpt) const
          << "DTED directory has not been set!"
          << "\nReturning null elevation source..."
          << std::endl;
-      return dted_ptr;
+      return dted_ptr.release();
    }
    
    // Build up a dted file name.
@@ -121,11 +121,10 @@ ossimElevSource* ossimDtedFactory::getNewElevSource(const ossimGpt& gpt) const
       if ( (!(dted_ptr->getErrorStatus())) &&
            dted_ptr->pointHasCoverage(gpt) )
       {
-         return dted_ptr;
+         return dted_ptr.release();
       }
       else
       {
-         delete dted_ptr;
          dted_ptr = 0;
       }
    }
@@ -148,11 +147,10 @@ ossimElevSource* ossimDtedFactory::getNewElevSource(const ossimGpt& gpt) const
       if ( (!(dted_ptr->getErrorStatus())) &&
            dted_ptr->pointHasCoverage(gpt) )
       {
-         return dted_ptr;
+         return dted_ptr.release();
       }
       else
       {
-         delete dted_ptr;
          dted_ptr = 0;
       }
    }
@@ -175,16 +173,15 @@ ossimElevSource* ossimDtedFactory::getNewElevSource(const ossimGpt& gpt) const
       if ( (!(dted_ptr->getErrorStatus())) &&
            dted_ptr->pointHasCoverage(gpt) )
       {
-         return dted_ptr;
+         return dted_ptr.release();
       }
       else
       {
-         delete dted_ptr;
          dted_ptr = 0;
       }
    }
 
-   return dted_ptr;
+   return dted_ptr.release();
 }
 
 void ossimDtedFactory::createIndex()
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimElevCellHandlerFactory.cpp b/Utilities/otbossim/src/ossim/elevation/ossimElevCellHandlerFactory.cpp
index 422321df137e671b4c1f99576525d2a1830e7405..50a1bc0a3ea23b7caccd71bf1ce2cba13bb9100d 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimElevCellHandlerFactory.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimElevCellHandlerFactory.cpp
@@ -27,7 +27,7 @@
 //              Initial coding.
 //<
 //*****************************************************************************
-//  $Id: ossimElevCellHandlerFactory.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimElevCellHandlerFactory.cpp 14800 2009-06-30 08:58:55Z dburken $
 
 #include <ossim/elevation/ossimElevCellHandlerFactory.h>
 #include <ossim/base/ossimString.h>
@@ -70,7 +70,7 @@ ossimElevCellHandler*
 ossimElevCellHandlerFactory::create(const ossimKeywordlist &keywordList,
                                     const char *prefix) const
 {
-   list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator
+   std::list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator
       elevCellFactory;
 
    ossimElevCellHandler* product = 0;
@@ -92,7 +92,7 @@ ossimElevCellHandlerFactory::create(const ossimKeywordlist &keywordList,
 ossimElevCellHandler*
 ossimElevCellHandlerFactory::create(const ossimString &name) const 
 {
-   list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator
+   std::list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator
       elevCellFactory;
 
    ossimElevCellHandler* product = 0;
@@ -111,11 +111,11 @@ ossimElevCellHandlerFactory::create(const ossimString &name) const
 //  METHOD: ossimElevCellHandlerFactory::getList()
 //  
 //*****************************************************************************
-list<ossimString> ossimElevCellHandlerFactory::getList() const 
+std::list<ossimString> ossimElevCellHandlerFactory::getList() const 
 {
-   list<ossimString> rtn_list;
-   list<ossimString> sub_list;
-   list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator factory_iter;
+   std::list<ossimString> rtn_list;
+   std::list<ossimString> sub_list;
+   std::list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator factory_iter;
 
    factory_iter = theRegistry.begin();
    while(factory_iter != theRegistry.end())
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimElevManager.cpp b/Utilities/otbossim/src/ossim/elevation/ossimElevManager.cpp
index 454f8666b1f4e47aa178e62d2aa58678421e7cfd..70a0a502073fdf505236c585bda9c32595bc148b 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimElevManager.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimElevManager.cpp
@@ -1,7 +1,9 @@
 //**************************************************************************
-// FILE: ossimElevManager.cc
+// FILE: ossimElevManager.cpp
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // DESCRIPTION:
 //   Contains implementation of class ossimElevManager. This object 
@@ -17,7 +19,7 @@
 //              Initial coding.
 //<
 //**************************************************************************
-// $Id: ossimElevManager.cpp 14300 2009-04-14 17:27:00Z gpotts $
+// $Id: ossimElevManager.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <algorithm>
 
@@ -47,7 +49,7 @@ RTTI_DEF1(ossimElevManager, "ossimElevManager" , ossimElevSource)
 static ossimTrace traceDebug ("ossimElevManager:debug");
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimElevManager.cpp 14300 2009-04-14 17:27:00Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimElevManager.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 ossimElevManager* ossimElevManager::theInstance = 0;
@@ -564,15 +566,14 @@ void ossimElevManager::loadElevData(const ossimDrect& ground_rect)
 
 double ossimElevManager::getHeightAboveMSL(const ossimGpt& gpt)
 {
-  // OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if (theEnableFlag)
    {
-
+      //OpenThreads::ScopedReadLock lock(theElevSourceListMutex);
       theElevSourceListMutex.writeLock();
-     //---
-      // Temp set the index to alway start at zero until theElevSourceList is
-      // split by resolution so highest resolution list get searched first.
-      // (drb)
+      //---
+      // Temp set the index to alway start at zero until theElevSourceList
+      // is split by resolution so highest resolution list get searched
+      // first. (drb)
       //---
       theCurrentElevSourceIdx = 0;
       
@@ -612,60 +613,57 @@ double ossimElevManager::getHeightAboveMSL(const ossimGpt& gpt)
          // Increment the index.
          ++theCurrentElevSourceIdx;
       }
+      theElevSourceListMutex.writeUnlock();
+   }
    
+   if (theAutoLoadFlag)
+   {
+      theElevSourceListMutex.writeLock();
+      // theElevSourceListMutex.readLock();
       //---
       // Reset the search index to zero as any cells added will be sorted by
       // resolution and we probably should start the search at the beginning.
       //---
       theCurrentElevSourceIdx = 0;
-      theElevSourceListMutex.writeUnlock();
-
-      if (theAutoLoadFlag)
+      //---
+      // If we got here there were no sources in the list that contained
+      // coverage so go through the list of managers and see if they have
+      // coverage.
+      //---
+      ossimElevSourceFactoryConstIterator sf =
+      theElevSourceFactoryList.begin();
+      
+      while (sf != theElevSourceFactoryList.end())
       {
-         theElevSourceListMutex.readLock();
-        //---
-         // If we got here there were no sources in the list that contained
-         // coverage so go through the list of managers and see if they have
-         // coverage.
-         //---
-         ossimElevSourceFactoryConstIterator sf =
-            theElevSourceFactoryList.begin();
-         
-         while (sf != theElevSourceFactoryList.end())
+         ossimRefPtr<ossimElevSource> source = (*sf)->getNewElevSource(gpt);
+         ossim_uint32 idx = 0;
+         if(source.valid())
          {
-            ossimElevSource* source = (*sf)->getNewElevSource(gpt);
-            ossim_uint32 idx = 0;
-            if(source)
+            for(idx = 0; idx < theElevSourceList.size(); ++idx)
             {
-               for(idx = 0; idx < theElevSourceList.size(); ++idx)
+               if(theElevSourceList[idx]->getFilename() == source->getFilename())
                {
-                  if(theElevSourceList[idx]->getFilename() == source->getFilename())
-                  {
-                     delete source;
-                     source = 0;
-                     break;
-                  }
+                  source = 0;
+                  break;
                }
             }
-            if (source)
+         }
+         if (source.valid())
+         {
+            double d = source->getHeightAboveMSL(gpt);
+            if ( !ossim::isnan(d) )
             {
-               double d = source->getHeightAboveMSL(gpt);
-               if ( !ossim::isnan(d) )
-               {
-                  theElevSourceListMutex.readUnlock();
-                  // Add it to the list.
-                  addElevSource(source);
-                  return d;
-               }
+               theElevSourceListMutex.writeUnlock();
+               // Add it to the list.
+               addElevSource(source.get());
+               return d;
             }
-            ++sf;
-            
-         } // End of while (sf != theElevSourceFactoryList.end())
-         theElevSourceListMutex.readUnlock();
-
-      } // if (theAutoLoadFlag)
-      
-   }  // End of "if (isSourceEnabled())"
+         }
+         ++sf;
+         
+      } // End of while (sf != theElevSourceFactoryList.end())
+      theElevSourceListMutex.writeUnlock();
+   } // if (theAutoLoadFlag)
 
    // If we get here return a null height value.
    return theNullHeightValue;
@@ -1643,11 +1641,11 @@ bool ossimElevManager::openDtedCell(const ossimFilename& file)
       return false;
    }
    
-   ossimElevSource* source = new ossimDtedHandler(file);
+   ossimRefPtr<ossimElevSource> source = new ossimDtedHandler(file);
    if (source->getErrorStatus() == ossimErrorCodes::OSSIM_OK)
    {
       // Add the source to the list.
-      addElevSource(source);
+      addElevSource(source.get());
       
       if (traceDebug())
       {
@@ -1658,7 +1656,7 @@ bool ossimElevManager::openDtedCell(const ossimFilename& file)
    }
    else
    {
-      delete source;
+      source = 0;
       return false;
    }
    return true;
@@ -1678,11 +1676,11 @@ bool ossimElevManager::openSrtmCell(const ossimFilename& file)
       return false;
    }
    
-   ossimElevSource* source = new ossimSrtmHandler(file);
+   ossimRefPtr<ossimElevSource> source = new ossimSrtmHandler(file);
    if (source->getErrorStatus() == ossimErrorCodes::OSSIM_OK)
    {
       // Add the source to the list.
-      addElevSource(source);
+      addElevSource(source.get());
       
       if (traceDebug())
       {
@@ -1693,7 +1691,7 @@ bool ossimElevManager::openSrtmCell(const ossimFilename& file)
    }
    else
    {
-      delete source;
+      source = 0;
       return false;
    }
    return true;
@@ -1701,10 +1699,10 @@ bool ossimElevManager::openSrtmCell(const ossimFilename& file)
 
 bool ossimElevManager::openGeneralRasterCell(const ossimFilename& file)
 {
-   ossimElevSource* source = new  ossimGeneralRasterElevHandler(file);
+   ossimRefPtr<ossimElevSource> source = new  ossimGeneralRasterElevHandler(file);
    if (source->getErrorStatus() == ossimErrorCodes::OSSIM_OK)
    {
-      addElevSource(source);
+      addElevSource(source.get());
       if (traceDebug())
       {
          ossimNotify(ossimNotifyLevel_DEBUG)
@@ -1715,7 +1713,6 @@ bool ossimElevManager::openGeneralRasterCell(const ossimFilename& file)
    }
    else
    {
-      delete source;
       source = 0;
       if (traceDebug())
       {
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimSrtmFactory.cpp b/Utilities/otbossim/src/ossim/elevation/ossimSrtmFactory.cpp
index 673fb23c200b916ef4c35a1fb9b6b183a1a5b274..60a100017e6c9122e1a9258661a3f7470cc961d3 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimSrtmFactory.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimSrtmFactory.cpp
@@ -10,7 +10,7 @@
 // ossimSrtmElevSource given a ground point.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimSrtmFactory.cpp 13282 2008-07-25 15:06:00Z dburken $
+// $Id: ossimSrtmFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib> /* abs() */
 #include <iostream>
@@ -56,7 +56,7 @@ ossimElevSource* ossimSrtmFactory::getNewElevSource(const ossimGpt& gpt) const
 
    ossimElevManager* mgr = ossimElevManager::instance();
    
-   ossimElevSource* srtmPtr = NULL;
+   ossimRefPtr<ossimElevSource> srtmPtr;
 
    if (theDirectory == ossimFilename::NIL)
    {
@@ -66,7 +66,7 @@ ossimElevSource* ossimSrtmFactory::getNewElevSource(const ossimGpt& gpt) const
          << "\nReturning null elevation source..."
          << std::endl;
       
-      return srtmPtr;
+      return srtmPtr.release();
    }
 
    //---
@@ -157,13 +157,12 @@ ossimElevSource* ossimSrtmFactory::getNewElevSource(const ossimGpt& gpt) const
       srtmPtr = new ossimSrtmHandler(srtmFile);
       if (srtmPtr->pointHasCoverage(gpt) )
       {
-         return srtmPtr;
+         return srtmPtr.release();
       }
       else
       {
-         delete srtmPtr;
-         srtmPtr = NULL;
+         srtmPtr = 0;
       }
    }
-   return srtmPtr;
+   return srtmPtr.release();
 }
diff --git a/Utilities/otbossim/src/ossim/font/ossimFontFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/font/ossimFontFactoryRegistry.cpp
index 7a66ef922993ea6da550eb875dcc8700f5414b65..884b76f67d5df83db29278ca039aa8a81f665a1c 100644
--- a/Utilities/otbossim/src/ossim/font/ossimFontFactoryRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/font/ossimFontFactoryRegistry.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 // 
 //********************************************************************
-// $Id: ossimFontFactoryRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
+// $Id: ossimFontFactoryRegistry.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <ossim/font/ossimFontFactoryRegistry.h>
 #include <ossim/font/ossimGdBitmapFont.h>
@@ -20,9 +20,9 @@
 //ossimFontFactoryRegistry* ossimFontFactoryRegistry::theInstance = 0;
 
 ossimFontFactoryRegistry::ossimFontFactoryRegistry()
-   :theDefaultFont(NULL)
+:theDefaultFont(NULL)
 {
-  // theInstance = this;
+   // theInstance = this;
 #if OSSIM_HAS_FREETYPE
    registerFactory(ossimFreeTypeFontFactory::instance());
 #endif
@@ -31,8 +31,8 @@ ossimFontFactoryRegistry::ossimFontFactoryRegistry()
 ossimFontFactoryRegistry* ossimFontFactoryRegistry::instance()
 {
    static ossimFontFactoryRegistry sharedInstance;
-      //theInstance = new ossimFontFactoryRegistry;
-
+   //theInstance = new ossimFontFactoryRegistry;
+   
    return &sharedInstance;
 }
 
@@ -44,7 +44,7 @@ bool ossimFontFactoryRegistry::registerFactory(ossimFontFactoryBase* factory)
       theFactoryList.push_back(factory);
       result = true;
    }
-
+   
    return result;
 }
 
@@ -71,7 +71,7 @@ ossimFont* ossimFontFactoryRegistry::createFont(const ossimFontInformation& info
 {
    ossimFont* result = (ossimFont*)NULL;
    int i = 0;
-
+   
    for(i= 0; ( (i < (int)theFactoryList.size()) &&(!result)); ++i)
    {
       result = theFactoryList[i]->createFont(information);
@@ -84,7 +84,7 @@ ossimFont* ossimFontFactoryRegistry::createFont(const ossimFilename& file)const
 {
    ossimFont* result = (ossimFont*)NULL;
    int i = 0;
-
+   
    for(i= 0; ( (i < (int)theFactoryList.size()) &&(!result)); ++i)
    {
       result = theFactoryList[i]->createFont(file);
@@ -107,7 +107,7 @@ void ossimFontFactoryRegistry::getFontInformationFamilyName(std::vector<ossimFon
 {
    vector<ossimFontInformation> info;
    getFontInformation(info);
-    
+   
    ossimString right = familyName;
    right = right.upcase().trim();
    int i = 0;
@@ -135,7 +135,7 @@ void ossimFontFactoryRegistry::getFontInformationContainingFamilyName(std::vecto
    for(i = 0; i < (int)info.size(); ++i)
    {
       ossimString left  = info[i].theFamilyName;
-
+      
       left  = left.upcase().trim();
       if(left.contains(right))
       {
@@ -150,21 +150,21 @@ ossimFont* ossimFontFactoryRegistry::getDefaultFont()const
    {
       std::vector<ossimFontInformation> infoList;
       getFontInformationContainingFamilyName(infoList,
-					     "Times");
+                                             "Times");
       if(infoList.size() < 1)
-	{
-	  getFontInformationContainingFamilyName(infoList,
-						 "Roman");
-	}
+      {
+         getFontInformationContainingFamilyName(infoList,
+                                                "Roman");
+      }
       if(infoList.size() < 1)
-	{
-	  getFontInformationContainingFamilyName(infoList,
-						 "Sanz");
-	}
+      {
+         getFontInformationContainingFamilyName(infoList,
+                                                "Sanz");
+      }
       if(infoList.size() < 1)
-	{
-	  getFontInformation(infoList);
-	}
+      {
+         getFontInformation(infoList);
+      }
       if(infoList.size())
       {
          theDefaultFont = createFont(infoList[0]);
@@ -177,7 +177,7 @@ ossimFont* ossimFontFactoryRegistry::getDefaultFont()const
                                                  ossimGdSansBold);
       }
    }
-   return theDefaultFont;
+   return theDefaultFont.get();
 }
 
 ossimFontFactoryRegistry::ossimFontFactoryRegistry(const ossimFontFactoryRegistry& /* rhs */ )
diff --git a/Utilities/otbossim/src/ossim/font/ossimFreeTypeFontFactory.cpp b/Utilities/otbossim/src/ossim/font/ossimFreeTypeFontFactory.cpp
index 1a3e9d5bfcd578ceed614375dc6a36d7c80a58d3..29b4a550c6ded80fe351e84464a7f3e5518e52cf 100644
--- a/Utilities/otbossim/src/ossim/font/ossimFreeTypeFontFactory.cpp
+++ b/Utilities/otbossim/src/ossim/font/ossimFreeTypeFontFactory.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 // 
 //********************************************************************
-// $Id: ossimFreeTypeFontFactory.cpp 12179 2007-12-12 21:20:45Z dburken $
+// $Id: ossimFreeTypeFontFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/ossimConfig.h> /* To pick up OSSIM_HAS_FREETYPE. */
 
@@ -44,7 +44,7 @@ ossimFreeTypeFontFactory* ossimFreeTypeFontFactory::instance()
 ossimFont* ossimFreeTypeFontFactory::createFont(const ossimFontInformation& information)const
 
 {
-   ossimFont* result = (ossimFont*)NULL;
+   ossimRefPtr<ossimFont> result;
    
    ossimString rightFamilyName = information.theFamilyName;
    ossimString rightStyleName  = information.theStyleName;
@@ -69,12 +69,11 @@ ossimFont* ossimFreeTypeFontFactory::createFont(const ossimFontInformation& info
                information.thePointSize)
             {
                result = new ossimFreeTypeFont(theFontInformationList[i].theFilename);
-               if(result)
+               if(result.valid())
                {
                   if(result->getErrorStatus())
                   {
-                     delete result;
-                     result = NULL;
+                     result = 0;
                      ossimNotify(ossimNotifyLevel_WARN) <<"WARNING ossimFreeTypeFontFactory::createFont:  unable to open font file "
                                                         << theFontInformationList[i].theFilename << std::endl;
                   }
@@ -84,12 +83,11 @@ ossimFont* ossimFreeTypeFontFactory::createFont(const ossimFontInformation& info
          else
          {
             result = new ossimFreeTypeFont(theFontInformationList[i].theFilename);
-            if(result)
+            if(result.valid())
             {
                if(result->getErrorStatus())
                {
-                  delete result;
-                  result = NULL;
+                  result = 0;
                   ossimNotify(ossimNotifyLevel_WARN) <<  "WARNING ossimFreeTypeFontFactory::createFont: unable to open font file "
                                                      << theFontInformationList[i].theFilename << std::endl;
                }
@@ -107,7 +105,7 @@ ossimFont* ossimFreeTypeFontFactory::createFont(const ossimFontInformation& info
       }         
    }
 
-   if(result)
+   if(result.valid())
    {
       result->setScale(information.theScale.x,
                        information.theScale.y);
@@ -118,20 +116,19 @@ ossimFont* ossimFreeTypeFontFactory::createFont(const ossimFontInformation& info
       result->setRotation(information.theRotation);
    }
    
-   return result;
+   return result.release();
 }
 
 ossimFont* ossimFreeTypeFontFactory::createFont(const ossimFilename& file)const
 {
-   ossimFont* result = new ossimFreeTypeFont(file);
+   ossimRefPtr<ossimFont> result = new ossimFreeTypeFont(file);
 
    if(result->getErrorStatus())
    {
-      delete result;
-      result = (ossimFont*)NULL;
+      result = 0;
    }
    
-   return result;
+   return result.release();
 }
 
 void ossimFreeTypeFontFactory::getFontInformation(std::vector<ossimFontInformation>& informationList)const
@@ -145,7 +142,7 @@ void ossimFreeTypeFontFactory::getFontInformation(std::vector<ossimFontInformati
 
 bool ossimFreeTypeFontFactory::addFile(const ossimFilename& file)
 {
-   ossimFreeTypeFont* font = new ossimFreeTypeFont(file);
+   ossimRefPtr<ossimFreeTypeFont> font = new ossimFreeTypeFont(file);
    
    std::vector<ossimFontInformation> fontInfoList;
    
@@ -167,7 +164,6 @@ bool ossimFreeTypeFontFactory::addFile(const ossimFilename& file)
    }
 
    // Free memory.
-   delete font;
    font = 0;
    
    return result;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAdrgTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAdrgTileSource.cpp
index aa3c067e19ee440cc77004199e0e7cf1ae511de6..126d3caaca4b561c111f640b63c27e379da33470 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAdrgTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAdrgTileSource.cpp
@@ -9,7 +9,7 @@
 //              ADRG file.
 //
 //********************************************************************
-// $Id: ossimAdrgTileSource.cpp 12988 2008-06-04 16:49:43Z gpotts $
+// $Id: ossimAdrgTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 
@@ -30,6 +30,7 @@
 #include <ossim/imaging/ossimTiffTileSource.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimU8ImageData.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
 
 RTTI_DEF1(ossimAdrgTileSource, "ossimAdrgTileSource", ossimImageHandler)
 
@@ -52,25 +53,25 @@ static ossimTrace traceDebug("ossimAdrgTileSource:debug");
 ossimAdrgTileSource::ossimAdrgTileSource()
    :
       ossimImageHandler(),
-      theTile(0),
-      theTileBuffer(0),
-      theFileStr(),
-      theAdrgHeader(0)
+      m_Tile(0),
+      m_TileBuffer(0),
+      m_FileStr(),
+      m_AdrgHeader(0)
 {
    // Construction not complete.  Users should call "open" method.
 }
 
 ossimAdrgTileSource::~ossimAdrgTileSource()
 {
-   if(theAdrgHeader)
+   if(m_AdrgHeader)
    {
-      delete theAdrgHeader;
-      theAdrgHeader = 0;
+      delete m_AdrgHeader;
+      m_AdrgHeader = 0;
    }
-   if (theTileBuffer)
+   if (m_TileBuffer)
    {
-      delete [] theTileBuffer;
-      theTileBuffer = 0;
+      delete [] m_TileBuffer;
+      m_TileBuffer = 0;
    }
 
    close();
@@ -80,60 +81,84 @@ ossimRefPtr<ossimImageData> ossimAdrgTileSource::getTile(
    const ossimIrect& rect,
    ossim_uint32 resLevel)
 {
-   // This tile source bypassed, or invalid res level, return a blank tile.
-   if (!isSourceEnabled() || !isValidRLevel(resLevel))
+   if (m_Tile.valid())
    {
-      return ossimRefPtr<ossimImageData>();
-   }
-
-   if (theOverview)
-   {
-      if (theOverview->hasR0() || resLevel)
+      // Image rectangle must be set prior to calling getTile.
+      m_Tile->setImageRectangle(rect);
+      
+      if ( getTile( m_Tile.get(), resLevel ) == false )
       {
-         return theOverview->getTile(rect, resLevel);
+         if (m_Tile->getDataObjectStatus() != OSSIM_NULL)
+         {
+            m_Tile->makeBlank();
+         }
       }
    }
+   
+   return m_Tile;
+}
 
-   theTile->setImageRectangle(rect);
-   ossimIrect image_rect = getImageRectangle(resLevel);
-   theTile->makeBlank();
+bool ossimAdrgTileSource::getTile(ossimImageData* result,
+                                  ossim_uint32 resLevel)
+{
+   bool status = false;
 
-   //***
-   // See if any point of the requested tile is in the image.
-   //***
-   if ( rect.intersects(image_rect) )
+   //---
+   // Not open, this tile source bypassed, or invalid res level,
+   // return a blank tile.
+   //---
+   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
+       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
    {
-      ossimIrect clip_rect = rect.clipToRect(image_rect);
+      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 ( !rect.completely_within(clip_rect) )
-//       {
-//          // Start with a blank tile.
-//          theTile->makeBlank();
-//       }
-
-      // Load the tile buffer with data from the adrg.
-      if (fillBuffer(rect, clip_rect))
+      if (!status) // Did not get an overview tile.
       {
-         theTile->validate();
+         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.
    }
-//    else
-//    {
-//       theTile->makeBlank();
-//    }
 
-   return theTile;
+   return status;
 }
 
 //*******************************************************************
 // Private Method:
 //*******************************************************************
 bool ossimAdrgTileSource::fillBuffer(const ossimIrect& tile_rect,
-                                     const ossimIrect& clip_rect)
+                                     const ossimIrect& clip_rect,
+                                     ossimImageData* tile)
 {
-//    const ossim_uint8 NULL_PIXEL         = (ossim_uint8)theTile->getNullPix(0);
-   // const ossim_int32 TILE_SIZE_PER_BAND = theTile->getSizePerBand();
-
    //***
    // Shift the upper left corner of the "clip_rect" to the an even chunk
    // boundry.
@@ -147,8 +172,10 @@ bool ossimAdrgTileSource::fillBuffer(const ossimIrect& tile_rect,
    ossim_int32 size_in_x = clip_rect.lr().x - tileOrigin.x + 1;
    ossim_int32 size_in_y = clip_rect.lr().y - tileOrigin.y + 1;
    
-   ossim_int32 tiles_in_x_dir = size_in_x / ADRG_TILE_WIDTH  + (size_in_x % ADRG_TILE_WIDTH  ? 1 : 0);
-   ossim_int32 tiles_in_y_dir = size_in_y / ADRG_TILE_HEIGHT + (size_in_y % ADRG_TILE_HEIGHT ? 1 : 0);
+   ossim_int32 tiles_in_x_dir = size_in_x / ADRG_TILE_WIDTH  +
+      (size_in_x % ADRG_TILE_WIDTH  ? 1 : 0);
+   ossim_int32 tiles_in_y_dir = size_in_y / ADRG_TILE_HEIGHT +
+      (size_in_y % ADRG_TILE_HEIGHT ? 1 : 0);
 
 
    ossimIpt ulTilePt = tileOrigin;
@@ -170,13 +197,13 @@ bool ossimAdrgTileSource::fillBuffer(const ossimIrect& tile_rect,
          {
             ossimIrect tile_clip_rect = clip_rect.clipToRect(adrg_tile_rect);
             
-            //***
+            //---
             // Some point in the chip intersect the tile so grab the
             // data.
-            //***
+            //---
             ossim_int32 row = (ossim_int32) ulTilePt.y / ADRG_TILE_HEIGHT; 
             ossim_int32 col = (ossim_int32) ulTilePt.x / ADRG_TILE_WIDTH;
-            ossim_int32 tileOffset = theAdrgHeader->tim(row, col);
+            ossim_int32 tileOffset = m_AdrgHeader->tim(row, col);
 
             if(tileOffset != 0)
             {
@@ -185,29 +212,25 @@ bool ossimAdrgTileSource::fillBuffer(const ossimIrect& tile_rect,
                int band;
 
                // seek to start of chip
-               theFileStr.seekg(seek_position, ios::beg);
+               m_FileStr.seekg(seek_position, ios::beg);
                for (band=0; band<3; band++)
                {
-                  // Seek to the chip
-//                   theFileStr.seekg(seek_position, ios::beg);
-
                   //***
                   // Read the chip from the ccf file into the chunk buffer.
                   // This will get all the bands.  Bands are interleaved by
                   // chip.
                   //***
-                  if (!theFileStr.read((char*)theTileBuffer,
+                  if (!m_FileStr.read((char*)m_TileBuffer,
                                        ADRG_TILE_SIZE))
                   {
                      theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
                      return false;
                   }
 
-//                  seek_position += BAND_OFFSET;
-                  theTile->loadBand(theTileBuffer,
-                                    adrg_tile_rect,
-                                    tile_clip_rect,
-                                    band);
+                  tile->loadBand(m_TileBuffer,
+                                 adrg_tile_rect,
+                                 tile_clip_rect,
+                                 band);
 
                } // End of band loop.
                
@@ -245,16 +268,16 @@ ossimAdrgTileSource::getImageRectangle(ossim_uint32 reduced_res_level) const
 
 void ossimAdrgTileSource::close()
 {
-   if(theAdrgHeader)
+   if(m_AdrgHeader)
    {
-      delete theAdrgHeader;
-      theAdrgHeader = 0;
+      delete m_AdrgHeader;
+      m_AdrgHeader = 0;
    }
-   if(theFileStr.is_open())
+   if(m_FileStr.is_open())
    {
-      theFileStr.close();
+      m_FileStr.close();
    }
-   theTile = 0;
+   m_Tile = 0;
 }
 
 //*******************************************************************
@@ -273,16 +296,16 @@ bool ossimAdrgTileSource::open()
    {
       close();
    }
-   if(theAdrgHeader)
+   if(m_AdrgHeader)
    {
-      delete theAdrgHeader;
-      theAdrgHeader = 0;
+      delete m_AdrgHeader;
+      m_AdrgHeader = 0;
    }
    // Instantiate support data class to parse header file.
-   theAdrgHeader = new ossimAdrgHeader(theImageFile);
+   m_AdrgHeader = new ossimAdrgHeader(theImageFile);
 
    // Check for errors.
-   if (theAdrgHeader->errorStatus() == ossimErrorCodes::OSSIM_ERROR)
+   if (m_AdrgHeader->errorStatus() == ossimErrorCodes::OSSIM_ERROR)
    {
       if (traceDebug())
       {
@@ -294,17 +317,17 @@ bool ossimAdrgTileSource::open()
       return false;
    }
 
-   theFileStr.open(theAdrgHeader->imageFile().c_str(),
+   m_FileStr.open(m_AdrgHeader->imageFile().c_str(),
                    ios::in | ios::binary);
 
    // Check the file pointer.
-   if(!theFileStr)
+   if(!m_FileStr)
    {
       theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
       if (traceDebug())
       {
          ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nCannot open:  "
-              << theAdrgHeader->imageFile().c_str() << std::endl;
+              << m_AdrgHeader->imageFile().c_str() << std::endl;
       }
       close();
       
@@ -315,27 +338,27 @@ bool ossimAdrgTileSource::open()
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE
-         << "File is opened -> "<< theAdrgHeader->imageFile()<<std::endl;
+         << "File is opened -> "<< m_AdrgHeader->imageFile()<<std::endl;
    }
 
    // allow the base handler to check for other overrides
    completeOpen();
    // Allocate memory.
-   theTile      = ossimImageDataFactory::instance()->create(this, this);
-   theTile->initialize();
-   theTileBuffer  = new ossim_uint8[ADRG_TILE_SIZE];
+   m_Tile      = ossimImageDataFactory::instance()->create(this, this);
+   m_Tile->initialize();
+   m_TileBuffer  = new ossim_uint8[ADRG_TILE_SIZE];
 
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << "\nminLon:   " << theAdrgHeader->minLon()
-         << "\nminLond:  " << theAdrgHeader->minLongitude() 
-         << "\nminLat:   " << theAdrgHeader->minLat()
-         << "\nminLatd:  " << theAdrgHeader->minLatitude()
-         << "\nmaxLon:   " << theAdrgHeader->maxLon()
-         << "\nmaxLond:  " << theAdrgHeader->maxLongitude()
-         << "\nmaxLat:   " << theAdrgHeader->maxLat()
-         << "\nmaxLatd:  " << theAdrgHeader->maxLatitude()
+         << "\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;
    }
    
@@ -372,21 +395,23 @@ bool ossimAdrgTileSource::loadState(const ossimKeywordlist& kwl,
 //*******************************************************************
 // Public method:
 //*******************************************************************
-bool ossimAdrgTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                           const char* prefix)
+ossimImageGeometry*  ossimAdrgTileSource::getImageGeometry()
 {
-   if(ossimImageSource::getImageGeometry(kwl, prefix))
+   ossimImageHandler::getImageGeometry();
+   if(!theGeometry.valid())
    {
-      return true;
+      theGeometry = new ossimImageGeometry;
    }
+   if (theGeometry->hasProjection())
+      return theGeometry.get();
 
    // origin of latitude
-   ossim_float64 originLatitude = (theAdrgHeader->maxLatitude() +
-                                   theAdrgHeader->minLatitude()) / 2.0;
+   ossim_float64 originLatitude = (m_AdrgHeader->maxLatitude() +
+                                   m_AdrgHeader->minLatitude()) / 2.0;
    
    // central meridian.
-   ossim_float64 centralMeridian = (theAdrgHeader->maxLongitude() +
-                                    theAdrgHeader->minLongitude()) / 2.0;
+   ossim_float64 centralMeridian = (m_AdrgHeader->maxLongitude() +
+                                    m_AdrgHeader->minLongitude()) / 2.0;
 
    //---
    // Compute the pixel size in latitude and longitude direction.  This will
@@ -394,18 +419,18 @@ bool ossimAdrgTileSource::getImageGeometry(ossimKeywordlist& kwl,
    //---
    
    // Samples in full image (used to compute degPerPixelX).
-   ossim_float64 samples = theAdrgHeader->samples();
+   ossim_float64 samples = m_AdrgHeader->samples();
    
    // Lines in full image (used to compute degPerPixelX).
-   ossim_float64 lines = theAdrgHeader->lines();
+   ossim_float64 lines = m_AdrgHeader->lines();
 
    // Degrees in latitude direction of the full image.
-   ossim_float64 degrees_in_lat_dir = theAdrgHeader->maxLatitude() -
-      theAdrgHeader->minLatitude();
+   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 = theAdrgHeader->maxLongitude() -
-      theAdrgHeader->minLongitude();
+   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;
@@ -420,19 +445,21 @@ bool ossimAdrgTileSource::getImageGeometry(ossimKeywordlist& kwl,
    //---
 
    // OLD:
-   //    double ul_lat = (theAdrgHeader->maxLatitude() + 
-   //                     theAdrgHeader->startRow()*degPerPixelY) - (degPerPixelY*.5);
-   //    double ul_lon = (theAdrgHeader->minLongitude() -
-   //                     theAdrgHeader->startCol()*degPerPixelX) +  (degPerPixelX*.5); 
+   //    double ul_lat = (m_AdrgHeader->maxLatitude() + 
+   //                     m_AdrgHeader->startRow()*degPerPixelY) - (degPerPixelY*.5);
+   //    double ul_lon = (m_AdrgHeader->minLongitude() -
+   //                     m_AdrgHeader->startCol()*degPerPixelX) +  (degPerPixelX*.5); 
    
-   ossim_float64 ul_lat = (theAdrgHeader->maxLatitude() - 
-                    ( (theAdrgHeader->startRow() - 1) *
+   ossim_float64 ul_lat = (m_AdrgHeader->maxLatitude() - 
+                    ( (m_AdrgHeader->startRow() - 1) *
                       degPerPixelY ) - ( degPerPixelY * 0.5 ) );
-   ossim_float64 ul_lon = (theAdrgHeader->minLongitude() +
-                    ( (theAdrgHeader->startCol() -1) *
+   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",
@@ -516,27 +543,29 @@ bool ossimAdrgTileSource::getImageGeometry(ossimKeywordlist& kwl,
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << "\nminLon:             " << theAdrgHeader->minLon()
-         << "\nminLond:            " << theAdrgHeader->minLongitude() 
-         << "\nminLat:             " << theAdrgHeader->minLat()
-         << "\nminLatd:            " << theAdrgHeader->minLatitude()
-         << "\nmaxLon:             " << theAdrgHeader->maxLon()
-         << "\nmaxLond:            " << theAdrgHeader->maxLongitude()
-         << "\nmaxLat:             " << theAdrgHeader->maxLat()
-         << "\nmaxLatd:            " << theAdrgHeader->maxLatitude()
-         << "\nstartRow:           " << theAdrgHeader->startRow()
-         << "\nstartCol:           " << theAdrgHeader->startCol()
-         << "\nstopRow:            " << theAdrgHeader->stopRow()
-         << "\nstopCol:            " << theAdrgHeader->stopCol()
+         << "\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;
    }
 
-   setImageGeometry(kwl);
+   ossimProjection* new_proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+   theGeometry = new ossimImageGeometry;
+   theGeometry->setProjection(new_proj);  // assumes management of projection instance
 
-   return true;
+   return theGeometry.get();
 }
 
 //*******************************************************************
@@ -552,7 +581,7 @@ ossimScalarType ossimAdrgTileSource::getOutputScalarType() const
 //*******************************************************************
 ossim_uint32 ossimAdrgTileSource::getTileWidth() const
 {
-   return ( theTile.valid() ? theTile->getWidth() : 0 );
+   return ( m_Tile.valid() ? m_Tile->getWidth() : 0 );
 }
 
 //*******************************************************************
@@ -560,7 +589,7 @@ ossim_uint32 ossimAdrgTileSource::getTileWidth() const
 //*******************************************************************
 ossim_uint32 ossimAdrgTileSource::getTileHeight() const
 {
-   return ( theTile.valid() ? theTile->getHeight() : 0 );
+   return ( m_Tile.valid() ? m_Tile->getHeight() : 0 );
 }
 
 //*******************************************************************
@@ -568,11 +597,11 @@ ossim_uint32 ossimAdrgTileSource::getTileHeight() const
 //*******************************************************************
 ossim_uint32 ossimAdrgTileSource::getNumberOfLines(ossim_uint32 reduced_res_level) const
 {
-   if ( (reduced_res_level == 0) && theAdrgHeader )
+   if ( (reduced_res_level == 0) && m_AdrgHeader )
    {
-      return (theAdrgHeader->stopRow() - theAdrgHeader->startRow()) + 1;
+      return (m_AdrgHeader->stopRow() - m_AdrgHeader->startRow()) + 1;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfLines(reduced_res_level);
    }
@@ -585,11 +614,11 @@ ossim_uint32 ossimAdrgTileSource::getNumberOfLines(ossim_uint32 reduced_res_leve
 //*******************************************************************
 ossim_uint32 ossimAdrgTileSource::getNumberOfSamples(ossim_uint32 reduced_res_level) const
 {
-   if ( (reduced_res_level == 0) && theAdrgHeader )
+   if ( (reduced_res_level == 0) && m_AdrgHeader )
    {
-      return (theAdrgHeader->stopCol() - theAdrgHeader->startCol()) + 1;
+      return (m_AdrgHeader->stopCol() - m_AdrgHeader->startCol()) + 1;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfSamples(reduced_res_level);
    }
@@ -633,19 +662,19 @@ ossimString ossimAdrgTileSource::getLongName()const
    return ossimString("adrg reader");
 }
 
-ossimString ossimAdrgTileSource::className()const
+ossimString ossimAdrgTileSource::getClassName()const
 {
    return ossimString("ossimAdrgTileSource");
 }
 
 ossim_uint32 ossimAdrgTileSource::getNumberOfInputBands() const
 {
-   return theAdrgHeader->numberOfBands();
+   return m_AdrgHeader->numberOfBands();
 }
 
 bool ossimAdrgTileSource::isOpen()const
 {
-   return (theAdrgHeader!=0);
+   return (m_AdrgHeader!=0);
 }
 
 void ossimAdrgTileSource::adjustToStartOfTile(ossimIpt& pt) const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationFontObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationFontObject.cpp
index d1148c0fa73e1890a78f05a4f684bf9f012fd0b5..f3fd40a87268903e3b840dc0fbc89e3137851f96 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationFontObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationFontObject.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationFontObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
+// $Id: ossimAnnotationFontObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimAnnotationFontObject.h>
 #include <ossim/font/ossimFontFactoryRegistry.h>
@@ -16,7 +16,6 @@ RTTI_DEF1(ossimAnnotationFontObject, "ossimAnnotationFontObject", ossimAnnotatio
 ossimAnnotationFontObject::ossimAnnotationFontObject()
    :ossimAnnotationObject(),
     theFont(ossimFontFactoryRegistry::instance()->getDefaultFont()),
-    theOwnsFontFlag(false),
     thePosition(0,0),
     theString(""),
     theRotation(0.0),
@@ -40,7 +39,6 @@ ossimAnnotationFontObject::ossimAnnotationFontObject(const ossimIpt& upperLeft,
                                                      unsigned char b)
    :ossimAnnotationObject(r,g,b),
     theFont(ossimFontFactoryRegistry::instance()->getDefaultFont()),
-    theOwnsFontFlag(false),
     theString(s),
     thePixelSize(pixelSize),
     theRotation(rotation),
@@ -74,34 +72,14 @@ ossimAnnotationFontObject::ossimAnnotationFontObject(const ossimAnnotationFontOb
     theVerticalShear(rhs.theVerticalShear),
     theBoundingRect(rhs.theBoundingRect)
 {
-   theOwnsFontFlag = false;
-   if(rhs.theOwnsFontFlag&&theFont)
-   {
-      theFont = (ossimFont*)rhs.theFont->dup();
-      theOwnsFontFlag = true;
-   }
-   else
-   {
-      theFont = rhs.theFont;
-   }
-   
+   theFont = rhs.theFont;
    setFontInfo();
 }
 
 
 ossimAnnotationFontObject::~ossimAnnotationFontObject()
 {
-   if(theFont&&theOwnsFontFlag)
-   {
-      delete theFont;
-      theFont = NULL;
-      theOwnsFontFlag = false;
-   }
-   else
-   {
-      theFont = NULL;
-      theOwnsFontFlag = false;
-   }
+   theFont = 0;
 }
 
 void ossimAnnotationFontObject::draw(ossimRgbImage& anImage)const
@@ -206,7 +184,7 @@ void ossimAnnotationFontObject::draw(ossimRgbImage& anImage)const
 
 std::ostream& ossimAnnotationFontObject::print(std::ostream& out)const
 {
-   if(theFont)
+   if(theFont.valid())
    {
       out << "Family:          " << theFont->getFamilyName() << endl
           << "Style:           " << theFont->getStyleName()  << endl;
@@ -230,7 +208,7 @@ void ossimAnnotationFontObject::getBoundingRect(ossimDrect& rect)const
 void ossimAnnotationFontObject::computeBoundingRect()
 {
    setFontInfo();
-   if(theFont)
+   if(theFont.valid())
    {
       ossimIrect textRect;
       theFont->getBoundingBox(textRect);
@@ -250,21 +228,13 @@ bool ossimAnnotationFontObject::isPointWithin(const ossimDpt& imagePoint)const
    return theBoundingRect.pointWithin(imagePoint);
 }
 
-void ossimAnnotationFontObject::setFont(ossimFont* font,
-                                        bool ownsFontFlag)
+void ossimAnnotationFontObject::setFont(ossimFont* font)
 {
-   if(theOwnsFontFlag)
-   {
-      delete theFont;
-      theFont = (ossimFont*)NULL;
-   }
-   theFont = font;
-   theOwnsFontFlag = ownsFontFlag;
+    theFont = font;
 
    if(!theFont)
    {
       theFont = ossimFontFactoryRegistry::instance()->getDefaultFont();
-      theOwnsFontFlag = false;
    }
 }
 
@@ -286,7 +256,7 @@ void ossimAnnotationFontObject::setUpperLeftPosition(const ossimIpt& position)
 
 void ossimAnnotationFontObject::setFontInfo()const
 {
-   if(theFont)
+   if(theFont.valid())
    {
       theFont->setString(theString);
       theFont->setRotation(theRotation);
@@ -326,7 +296,7 @@ void ossimAnnotationFontObject::setPointSize(const ossimIpt& size)
 {
    thePixelSize = size;
    setFontInfo();
-   if (theFont)
+   if (theFont.valid())
    {
       theFont->getBoundingBox(theBoundingRect);
    }
@@ -338,7 +308,7 @@ void ossimAnnotationFontObject::setRotation(double rotation)
 {
    theRotation = rotation;
    setFontInfo();
-   if (theFont)
+   if (theFont.valid())
    {
       theFont->getBoundingBox(theBoundingRect);
    }
@@ -351,7 +321,7 @@ void ossimAnnotationFontObject::setScale(const ossimDpt& scale)
    theHorizontalScale = scale.x;
    theVerticalScale   = scale.y;
    setFontInfo();
-   if (theFont)
+   if (theFont.valid())
    {
       theFont->getBoundingBox(theBoundingRect);
    }
@@ -364,7 +334,7 @@ void ossimAnnotationFontObject::setShear(const ossimDpt& shear)
    theHorizontalShear = shear.x;
    theVerticalShear   = shear.y;
    setFontInfo();
-   if (theFont)
+   if (theFont.valid())
    {
       theFont->getBoundingBox(theBoundingRect);
    }
@@ -382,7 +352,7 @@ void ossimAnnotationFontObject::setGeometryInformation(const ossimFontInformatio
    theVerticalShear   = info.theShear.y;
    
    setFontInfo();
-   if (theFont)
+   if (theFont.valid())
    {
       theFont->getBoundingBox(theBoundingRect);
    }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationSource.cpp
index 2f01d99a0fc4b753119ce64c5199eb3b501efbca..5f12a5248768eb1f7740cf93c12e49d67f571835 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationSource.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationSource.cpp 11885 2007-10-18 15:23:58Z dburken $
+// $Id: ossimAnnotationSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimAnnotationSource.h>
 #include <ossim/imaging/ossimAnnotationObject.h>
@@ -225,13 +225,12 @@ bool ossimAnnotationSource::deleteObject(ossimAnnotationObject* anObject)
 {
    if(anObject)
    {
-      std::vector<ossimAnnotationObject*>::iterator current =
+      AnnotationObjectListType::iterator current =
          theAnnotationObjectList.begin();
       while(current != theAnnotationObjectList.end())
       {
          if(*current == anObject)
          {
-            delete anObject;
             theAnnotationObjectList.erase(current);
             return true;
          }
@@ -246,7 +245,7 @@ bool ossimAnnotationSource::saveState(ossimKeywordlist& kwl,
                                       const char* prefix)const
 {
    // Save the state of all annotation objects we have.
-   std::vector<ossimAnnotationObject*>::const_iterator obj =
+   AnnotationObjectListType::const_iterator obj =
       theAnnotationObjectList.begin();
    ossim_uint32 objIdx = 0;
    while (obj < theAnnotationObjectList.end())
@@ -287,19 +286,19 @@ bool ossimAnnotationSource::loadState(const ossimKeywordlist& kwl,
       {
          ++numberOfMatches;
          
-         ossimAnnotationObject* obj = 0;
+         ossimRefPtr<ossimAnnotationObject> obj = 0;
          obj = ossimAnnotationObjectFactory::instance()->
             create(kwl, newPrefix.c_str());
-         if (obj)
+         if (obj.valid())
          {
-            if(!addObject(obj))
+            if(!addObject(obj.get()))
             {
                ossimNotify(ossimNotifyLevel_WARN)
                   << "ossimGeoAnnotationSource::loadState\n"
                   << "Object " << obj->getClassName()
                   << " is not a geographic object" << endl;
-               delete obj;
-            }
+               obj = 0;
+           }
          }
       }
 
@@ -325,7 +324,7 @@ void ossimAnnotationSource::computeBoundingRect()
       
       theAnnotationObjectList[0]->getBoundingRect(theRectangle);
       
-      std::vector<ossimAnnotationObject*>::iterator object =
+      AnnotationObjectListType::iterator object =
          (theAnnotationObjectList.begin()+1);
       while(object != theAnnotationObjectList.end())
       {
@@ -344,11 +343,11 @@ void ossimAnnotationSource::computeBoundingRect()
    }
 }
 
-std::vector<ossimAnnotationObject*> ossimAnnotationSource::pickObjects(
+ossimAnnotationSource::AnnotationObjectListType ossimAnnotationSource::pickObjects(
    const ossimDpt& imagePoint)
 {
-   std::vector<ossimAnnotationObject*> result;
-   std::vector<ossimAnnotationObject*>::iterator currentObject;
+   AnnotationObjectListType result;
+   AnnotationObjectListType::iterator currentObject;
 
    currentObject = theAnnotationObjectList.begin();
 
@@ -364,17 +363,17 @@ std::vector<ossimAnnotationObject*> ossimAnnotationSource::pickObjects(
    return result;
 }
 
-std::vector<ossimAnnotationObject*> ossimAnnotationSource::pickObjects(
+ossimAnnotationSource::AnnotationObjectListType ossimAnnotationSource::pickObjects(
    const ossimDrect& imageRect)
 {
-   std::vector<ossimAnnotationObject*> result;
-   std::vector<ossimAnnotationObject*>::iterator currentObject;
+   AnnotationObjectListType result;
+   AnnotationObjectListType::iterator currentObject;
 
    currentObject = theAnnotationObjectList.begin();
 
    while(currentObject != theAnnotationObjectList.end())
    {
-      ossimAnnotationObject* current = (*currentObject);
+      ossimRefPtr<ossimAnnotationObject> current = (*currentObject);
       if(current->isPointWithin(imageRect.ul()))
       {
          result.push_back(*currentObject);
@@ -399,20 +398,7 @@ std::vector<ossimAnnotationObject*> ossimAnnotationSource::pickObjects(
 
 void ossimAnnotationSource::deleteAll()
 {
-   std::vector<ossimAnnotationObject*>::iterator obj;
-
-   obj = theAnnotationObjectList.begin();
-
-   while(obj != theAnnotationObjectList.end())
-   {
-      if(*obj)
-      {
-         delete *obj;
-         *obj = 0;
-      }
-      
-      ++obj;
-   }
+   AnnotationObjectListType::iterator obj;
 
    theAnnotationObjectList.clear();
 }
@@ -423,11 +409,11 @@ void ossimAnnotationSource::drawAnnotations(ossimRefPtr<ossimImageData> tile)
 
    if(theImage->getImageData().valid())
    {
-      std::vector<ossimAnnotationObject*>::iterator object =
+      AnnotationObjectListType::iterator object =
          theAnnotationObjectList.begin();
       while(object != theAnnotationObjectList.end())
       {
-         if(*object)
+         if((*object).valid())
          {
             (*object)->draw(*theImage);
          }
@@ -436,13 +422,13 @@ void ossimAnnotationSource::drawAnnotations(ossimRefPtr<ossimImageData> tile)
    }
 }
 
-const std::vector<ossimAnnotationObject*>&
+const ossimAnnotationSource::AnnotationObjectListType&
 ossimAnnotationSource::getObjectList()const
 {
    return theAnnotationObjectList;
 }
 
-std::vector<ossimAnnotationObject*>& ossimAnnotationSource::getObjectList()
+ossimAnnotationSource::AnnotationObjectListType& ossimAnnotationSource::getObjectList()
 {
    return theAnnotationObjectList;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp
index 6fc89d845d1a5d136fc80d214ac22f526f1b48ef..69c828e44faf53eedf9bab3e2edaaa99bfab4904 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp
@@ -9,7 +9,7 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimAppFixedTileCache.cpp 14481 2009-05-11 12:09:33Z dburken $
+// $Id: ossimAppFixedTileCache.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <sstream>
 #include <ossim/imaging/ossimAppFixedTileCache.h>
@@ -157,17 +157,17 @@ void ossimAppFixedTileCache::flush(ossimAppFixedCacheId cacheId)
 
 void ossimAppFixedTileCache::deleteCache(ossimAppFixedCacheId cacheId)
 {
-   ossimFixedTileCache* cache = getCache(cacheId);
+   ossimRefPtr<ossimFixedTileCache> cache = getCache(cacheId);
    {
       OpenThreads::ScopedWriteLock lock(theMutex);
       std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator iter = theAppCacheMap.find(cacheId);
       
-      if(cache)
+      if(cache.valid())
       {
          theAppCacheMap.erase(iter);
          theCurrentCacheSize -= cache->getCacheSize();
-         delete cache;
       }
+      cache = 0;
    }
 }
 
@@ -289,7 +289,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::addTile(
    {
       OpenThreads::ScopedWriteLock lock(theMutex);
       cacheSize = aCache->getCacheSize();
-      aCache->addTile(data);
+      result  = aCache->addTile(data);
    
       theCurrentCacheSize += (aCache->getCacheSize() - cacheSize);
    }
@@ -300,18 +300,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::addTile(
 void ossimAppFixedTileCache::deleteAll()
 {
    OpenThreads::ScopedWriteLock lock(theMutex);
-   std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator iter = theAppCacheMap.begin();
    theCurrentCacheSize = 0;
-
-   while(iter != theAppCacheMap.end())
-   {
-      if((*iter).second)
-      {
-         delete (*iter).second;
-      }
-      
-      ++iter;
-   }
    theAppCacheMap.clear();
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp
index e7325c6a5323295529d0b0005c6973ee35da68d7..163da1c0d6bb9f3e15a5427d891b76dea1a52bde 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp
@@ -10,7 +10,7 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimAppTileCache.cpp 13214 2008-07-23 17:43:51Z dburken $
+// $Id: ossimAppTileCache.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimAppTileCache.h>
 #include <ossim/imaging/ossimTileCache.h>
@@ -96,11 +96,11 @@ ossimDataObject *ossimAppTileCache::get(ossimAppCacheId id,
    return result;
 }
 
-ossimDataObject* ossimAppTileCache::removeTile(ossimAppCacheId id,
+ossimRefPtr<ossimDataObject> ossimAppTileCache::removeTile(ossimAppCacheId id,
                                               const ossimDpt3d &origin,
                                               unsigned long resLevel)
 {
-   ossimDataObject *result = 0;
+   ossimRefPtr<ossimDataObject> result = 0;
    if(id>0)
    {
       ossimTileCache *aCache = this->get(id);
@@ -110,7 +110,7 @@ ossimDataObject* ossimAppTileCache::removeTile(ossimAppCacheId id,
          result = aCache->remove(origin,
                                  resLevel);
          // adjust the byte count
-         if(result)
+         if(result.valid())
          {
             theCurrentCacheSize -= result->getDataSizeInBytes();
          }
@@ -121,10 +121,10 @@ ossimDataObject* ossimAppTileCache::removeTile(ossimAppCacheId id,
    return result;
 }
 
-ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
-                                          const ossimDpt3d &origin,
-                                          const ossimDataObject* data,
-                                          ossim_uint32 resLevel)
+ossimRefPtr<ossimDataObject> ossimAppTileCache::insert(ossimAppCacheId appId,
+                                                       const ossimDpt3d &origin,
+                                                       const ossimDataObject* data,
+                                                       ossim_uint32 resLevel)
 {
    static const char MODULE[] = "ossimAppTileCache::insert";
    ossimDataObject *result = 0;
@@ -136,21 +136,14 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
       return result;
    }
    
-   ossimDataObject *tileToInsert = 0;
+   ossimRefPtr<ossimDataObject> tileToInsert = 0;
    long dataSize = data->getDataSizeInBytes();
    
    if( (theCurrentCacheSize+dataSize) > theMaxCacheSize)
    {
-      ossimDataObject *tempTile     = 0;
       do
       {
-         tempTile = removeTile();
-
-         if(tempTile)
-         {
-            delete tempTile;
-            tempTile = 0;
-         }
+         ossimRefPtr<ossimDataObject> tile = removeTile();
       }while((theCurrentCacheSize+dataSize) > theMaxCacheSize);
    }
 
@@ -159,7 +152,7 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
       tileToInsert = (ossimDataObject*)data->dup();
 
       result = aCache->insert(origin,
-                              tileToInsert,
+                              tileToInsert.get(),
                               resLevel);
       if(!result)
       {
@@ -167,7 +160,6 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
             << MODULE << " ERROR: can't insert and should not happen"
             << endl;
 
-         delete tileToInsert;
          tileToInsert = 0;
       }
       else
@@ -269,9 +261,9 @@ void ossimAppTileCache::deleteAppCacheFromQueue(ossimAppCacheId appId)
    }
 }
 
-ossimDataObject* ossimAppTileCache::removeTile()
+ossimRefPtr<ossimDataObject> ossimAppTileCache::removeTile()
 {
-   ossimDataObject *result = 0;
+   ossimRefPtr<ossimDataObject> result;
    if(!theUsedQueue.empty())
    {
       ossimAppCacheTileInfo &info = *(theUsedQueue.begin());
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimArcInfoGridWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimArcInfoGridWriter.cpp
index ab266fb02ef7a7822e49371bb48364f0f002476d..e83098960ef7d7cf85bdc774b894baf947e0559a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimArcInfoGridWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimArcInfoGridWriter.cpp
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimArcInfoGridWriter.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimArcInfoGridWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstring>
 #include <cstdio>
@@ -65,18 +65,16 @@ ossimArcInfoGridWriter::~ossimArcInfoGridWriter()
 bool ossimArcInfoGridWriter::writeFile()
 {
    const char* MODULE = "ossimArcInfoGridWriter::writeFile";
-   
-   ossimCastTileSourceFilter* filter = new ossimCastTileSourceFilter;
-   filter->setOutputScalarType(OSSIM_FLOAT);
-   filter->connectMyInputTo(theInputConnection);
-   filter->initialize();
-   
    if(!theInputConnection)
    {
-      delete filter;
-      
       return false;
    }
+   
+   ossimRefPtr<ossimCastTileSourceFilter> filter = new ossimCastTileSourceFilter;
+   filter->setOutputScalarType(OSSIM_FLOAT);
+   filter->connectMyInputTo(theInputConnection.get());
+   filter->initialize();
+   
    open();
 
    // make sure we have a region of interest
@@ -187,7 +185,7 @@ bool ossimArcInfoGridWriter::writeFile()
    }
    
    close();
-   delete filter;
+   filter = 0;
    return result;
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAtbController.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAtbController.cpp
index 831723eebc18911f4a15fff063b990b2a3972f51..28a13865778db690fec2fa1cf7aae1e13d35ec30 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAtbController.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAtbController.cpp
@@ -12,7 +12,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAtbController.cpp 9963 2006-11-28 21:11:01Z gpotts $
+//  $Id: ossimAtbController.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimAtbController.h>
 
@@ -95,12 +95,15 @@ ossimAtbController::ossimAtbController(ossimGridRemapEngine* engine)
    //***
    // Assign default engine if non provided:
    //***
-   delete theGridRemapEngine;
    if (engine)
-      theGridRemapEngine = (ossimGridRemapEngine*)engine->dup();
+   {
+      theGridRemapEngine = engine;
+   }
    else
+   {
       theGridRemapEngine
-         = ossimGridRemapEngineFactory::create(DEFAULT_ATB_REMAP_ENGINE);
+      = ossimGridRemapEngineFactory::create(DEFAULT_ATB_REMAP_ENGINE);
+   }
    
    if (traceExec())  CLOG << "returning..." << endl;
 }
@@ -116,17 +119,8 @@ ossimAtbController::ossimAtbController(ossimGridRemapEngine* engine)
 //*****************************************************************************
 ossimAtbController::~ossimAtbController()
 {
-   if (!theContainer)
-   {
-      //***
-      // No container exists that assumed ownership of the remappers, so delete
-      // them here:
-      //***
-      for (unsigned int i=0; i<getNumberOfInputs(); i++)
-         delete getInput(i);
-   }
-   
-   delete theGridRemapEngine;
+   theContainer = 0;
+   theGridRemapEngine = 0;;
 }
 
 //*****************************************************************************
@@ -142,7 +136,6 @@ void ossimAtbController::initializeWithCombiner(ossimImageCombiner* combiner,
    //***
    // Assign default engine if non provided:
    //***
-   delete theGridRemapEngine;
    if (engine)
       theGridRemapEngine = (ossimGridRemapEngine*)engine->dup();
    else
@@ -188,7 +181,7 @@ void ossimAtbController::initializeWithCombiner(ossimImageCombiner* combiner,
             //***
             remapper = new ossimGridRemapSource(input_image,
                                                 theGridRemapEngine);
-            if (theContainer)
+            if (theContainer.valid())
                theContainer->addChild(remapper);
             
             add_list.push_back(remapper);
@@ -458,7 +451,7 @@ void ossimAtbController::setKernelSize(int side_size)
    static const char MODULE[] = "ossimAtbController::setKernelSize(N)";
    if (traceExec())  CLOG << "entering..." << endl;
 
-   vector<ossimAtbMatchPoint*>::iterator mpi = theMatchPoints.begin();
+   vector<ossimRefPtr<ossimAtbMatchPoint> >::iterator mpi = theMatchPoints.begin();
    while (mpi != theMatchPoints.end())
       (*mpi)->setKernelSize(side_size);
 
@@ -538,24 +531,21 @@ void ossimAtbController::setGridRemapEngine(ossimGridRemapEngine* engine)
    static const char MODULE[] = "ossimAtbController::setGridRemapEngine()";
    if (traceExec())  CLOG << "entering..." << endl;
 
-   if (theGridRemapEngine)
-      delete theGridRemapEngine;
-
    theGridRemapEngine = engine;
 
    //***
    // Communicate the new engine to all member's interested:
    //***
    ossimGridRemapSource* remapper;
-   vector<ossimConnectableObject*>::iterator iter=theInputObjectList.begin();
+   ossimConnectableObject::ConnectableObjectList::iterator iter=theInputObjectList.begin();
    while (iter != theInputObjectList.end())
    {
-      remapper = PTR_CAST(ossimGridRemapSource, *iter);
+      remapper = PTR_CAST(ossimGridRemapSource, (*iter).get());
       remapper->setRemapEngine(engine);
       iter++;
    }
 
-   vector<ossimAtbMatchPoint*>::iterator match_point = theMatchPoints.begin();
+   vector<ossimRefPtr<ossimAtbMatchPoint> >::iterator match_point = theMatchPoints.begin();
    while (match_point != theMatchPoints.end())
    {
       (*match_point)->setGridRemapEngine(engine);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAtbMatchPoint.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAtbMatchPoint.cpp
index e50c790fd94c72326b297665198d42da6d8ed1dd..e115f77ad9415fbc4772e06caf8dd87b85b616e5 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAtbMatchPoint.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAtbMatchPoint.cpp
@@ -9,7 +9,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAtbMatchPoint.cpp 12912 2008-05-28 15:05:54Z gpotts $
+//  $Id: ossimAtbMatchPoint.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimAtbMatchPoint.h>
 #include <ossim/imaging/ossimAtbPointSource.h>
@@ -31,12 +31,7 @@ static ossimTrace traceDebug ("ossimAtbMatchPoint:debug");
 //*****************************************************************************
 ossimAtbMatchPoint::~ossimAtbMatchPoint()
 {
-   vector<ossimAtbPointSource*>::iterator source = thePointSourceList.begin();
-   while (source != thePointSourceList.end())
-   {
-      delete *source;
-      source++;
-   }
+   thePointSourceList.clear();
 }
    
 //*****************************************************************************
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAtbPointSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAtbPointSource.cpp
index 59639104f1d856eb5a9cf0f8d010e763fa174c43..7d99d144f25f77a7f27f896dcc64e1856f5dbca5 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAtbPointSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAtbPointSource.cpp
@@ -12,7 +12,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimAtbPointSource.cpp 9963 2006-11-28 21:11:01Z gpotts $
+//  $Id: ossimAtbPointSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimImageSource.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -111,7 +111,7 @@ void ossimAtbPointSource::setViewPoint(const ossimDpt& view_point)
 
    theViewPoint = view_point;
    
-   if ((theRemapSource) &&
+   if ((theRemapSource.valid()) &&
        (theRemapSource->getBoundingRect().pointWithin(theViewPoint)))
       theViewPointIsValid = true;
    else
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimBandMergeSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimBandMergeSource.cpp
index 44172c3c445f1c2967a3da4df55e44e370544573..d726f09ee2af842964df872f2735cd73957833f0 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimBandMergeSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimBandMergeSource.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBandMergeSource.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimBandMergeSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimBandMergeSource.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
@@ -23,7 +23,7 @@ ossimBandMergeSource::ossimBandMergeSource()
 {
 }
 
-ossimBandMergeSource::ossimBandMergeSource(vector<ossimImageSource*>& inputSources)
+ossimBandMergeSource::ossimBandMergeSource(ossimConnectableObject::ConnectableObjectList& inputSources)
    :ossimImageCombiner(inputSources),
     theNumberOfOutputBands(0),
     theTile(NULL)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimBlendMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimBlendMosaic.cpp
index e8abc33fbfba01c418ec1bd506e6b09ca61fc126..6e0fd5ea88adbc19077400deb6b248ef40bac187 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimBlendMosaic.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimBlendMosaic.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBlendMosaic.cpp 12912 2008-05-28 15:05:54Z gpotts $
+// $Id: ossimBlendMosaic.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimBlendMosaic.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -20,7 +20,7 @@ ossimBlendMosaic::ossimBlendMosaic()
 {
 }
 
-ossimBlendMosaic::ossimBlendMosaic(vector<ossimImageSource*>& inputSources)
+ossimBlendMosaic::ossimBlendMosaic(ossimConnectableObject::ConnectableObjectList& inputSources)
    : ossimImageMosaic(inputSources),
      theNormResult(NULL)
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimCcfTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimCcfTileSource.cpp
index 31a540d4085f118a5586610d476e9d01ecb63afc..f132ef6584e69fc47f258d50c3dc5ee90659fd8e 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimCcfTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimCcfTileSource.cpp
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc.
 //
 // License:  LGPL
 //
@@ -11,7 +10,7 @@
 //
 // Contains class definition for ossimCcfTileSource.
 //*******************************************************************
-//  $Id: ossimCcfTileSource.cpp 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimCcfTileSource.cpp 15502 2009-09-29 17:59:04Z dburken $
 
 #include <algorithm>
 #include <ossim/imaging/ossimCcfTileSource.h>
@@ -63,46 +62,82 @@ ossimCcfTileSource::~ossimCcfTileSource()
 ossimRefPtr<ossimImageData> ossimCcfTileSource::getTile(
    const  ossimIrect& rect, ossim_uint32 resLevel)
 {
-   if (!isSourceEnabled() || !isOpen() ||
-       (resLevel >= theCcfHead.numberOfReducedResSets()) )
+   if (theTile.valid())
    {
-      return ossimRefPtr<ossimImageData>();
+      // Image rectangle must be set prior to calling getTile.
+      theTile->setImageRectangle(rect);
+      
+      if ( getTile( theTile.get(), resLevel ) == false )
+      {
+         if (theTile->getDataObjectStatus() != OSSIM_NULL)
+         {
+            theTile->makeBlank();
+         }
+      }
    }
 
-   theTile->setImageRectangle(rect);
-
-   ossimIrect image_rect = theCcfHead.imageRect(resLevel);
-   
-   //***
-   // See if any point of the requested tile is in the image.
-   //***
-   if ( rect.intersects(image_rect) )
-   {
-      ossimIrect clip_rect = rect.clipToRect(image_rect);
+   return theTile;
+}
 
-      if ( !rect.completely_within(clip_rect) )
-      {
-         // Start with a blank tile.
-         theTile->makeBlank();
-      }
+bool ossimCcfTileSource::getTile(ossimImageData* result,
+                                 ossim_uint32 resLevel)
+{
+   bool status = false;
 
-      // Load the tile buffer with data from the ccf.
-      if (fillBuffer(rect, clip_rect, image_rect, resLevel))
-      {
-         theTile->validate();
-         return theTile;
-      }
-      else
+   //---
+   // 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.
       {
-         // Error in filling buffer.
-         cerr << "ossimCcfTileSource getTile ERROR:  Returning blank tile..."
-              << endl;
-         return ossimRefPtr<ossimImageData>();
+         status = true;
+         
+         ossimIrect tile_rect = result->getImageRectangle();
+         
+         ossimIrect image_rect = theCcfHead.imageRect(resLevel);
+   
+         //---
+         // 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);
+            
+            if ( !tile_rect.completely_within(clip_rect) )
+            {
+               // Start with a blank tile.
+               result->makeBlank();
+            }
+            
+            // Load the tile buffer with data from the ccf.
+            status = fillBuffer(tile_rect,
+                                clip_rect,
+                                image_rect,
+                                resLevel,
+                                result);
+            if (status)
+            {
+               result->validate();
+            }
+         }
       }
+      
+      result->unref();  // Decrement ref count.
    }
 
-   // No part of requested tile within the image rectangle.
-   return ossimRefPtr<ossimImageData>();
+   return status;
 }
 
 //*******************************************************************
@@ -111,7 +146,8 @@ ossimRefPtr<ossimImageData> ossimCcfTileSource::getTile(
 bool ossimCcfTileSource::fillBuffer(const ossimIrect& tile_rect,
                                     const ossimIrect& clip_rect,
                                     const ossimIrect& image_rect,
-                                    ossim_uint32 reduced_res_level)
+                                    ossim_uint32 reduced_res_level,
+                                    ossimImageData* tile)
 {
    bool status = false;
    
@@ -120,25 +156,28 @@ bool ossimCcfTileSource::fillBuffer(const ossimIrect& tile_rect,
    //***
    switch (theCcfHead.pixelType())
    {
-   case OSSIM_UCHAR:
-      status = fillUcharBuffer(tile_rect,
-                               clip_rect,
-                               image_rect,
-                               reduced_res_level);
-      break;
-   case OSSIM_USHORT11:
-   case OSSIM_USHORT16:
-      status = fillUshortBuffer(tile_rect,
-                                clip_rect,
-                                image_rect,
-                                reduced_res_level);
-      break;
-   default:
-      theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
-      cerr << "ossimCcfTileSource fillBuffer ERROR:"
-           << "\nUnsupported pixel type!"
-           << "\nBuffer not filled.  Returning error." << endl;
-      break;
+      case OSSIM_UCHAR:
+         status = fillUcharBuffer(tile_rect,
+                                  clip_rect,
+                                  image_rect,
+                                  reduced_res_level,
+                                  tile);
+         break;
+      case OSSIM_USHORT11:
+      case OSSIM_USHORT16:
+         status = fillUshortBuffer(tile_rect,
+                                   clip_rect,
+                                   image_rect,
+                                   reduced_res_level,
+                                   tile);
+         break;
+      default:
+         theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimCcfTileSource fillBuffer ERROR:"
+            << "\nUnsupported pixel type!"
+            << "\nBuffer not filled.  Returning error." << endl;
+         break;
    }
 
    return status;
@@ -150,11 +189,12 @@ bool ossimCcfTileSource::fillBuffer(const ossimIrect& tile_rect,
 bool ossimCcfTileSource::fillUcharBuffer(const ossimIrect& tile_rect,
                                          const ossimIrect& clip_rect,
                                          const ossimIrect& image_rect,
-                                         ossim_uint32 reduced_res_level)
+                                         ossim_uint32 reduced_res_level,
+                                         ossimImageData* tile)
 {
    if(!isOpen()) return false;
       
-   const ossim_uint32 TILE_SIZE_PER_BAND     = theTile->getSizePerBand();
+   const ossim_uint32 TILE_SIZE_PER_BAND     = tile->getSizePerBand();
    const ossim_uint32 CHIP_SIZE_PER_BAND     = theCcfHead.chipSizePerBand();
    const ossim_uint32 SAMPLES_PER_CHIP       = theCcfHead.samplesPerChip();
    const ossim_uint32 LINES_PER_CHIP         = theCcfHead.linesPerChip();
@@ -285,10 +325,10 @@ bool ossimCcfTileSource::fillUcharBuffer(const ossimIrect& tile_rect,
                      // the tile.
                      //***
                      ossim_uint8* d
-                        = (ossim_uint8*)theTile->getBuf() +
+                        = (ossim_uint8*)tile->getBuf() +
                         band * TILE_SIZE_PER_BAND +
                         (chip_clip_rect.ul().y - tile_rect.ul().y) *
-                        theTile->getWidth() + chip_clip_rect.ul().x -
+                        tile->getWidth() + chip_clip_rect.ul().x -
                         tile_rect.ul().x;      
 
                      // Line loop through a chip.
@@ -308,7 +348,7 @@ bool ossimCcfTileSource::fillUcharBuffer(const ossimIrect& tile_rect,
 
                         // Increment the pointers by one line.
                         s += SAMPLES_PER_CHIP;
-                        d += theTile->getWidth();
+                        d += tile->getWidth();
                      }
                      
                   } // End of band loop.
@@ -340,9 +380,10 @@ bool ossimCcfTileSource::fillUcharBuffer(const ossimIrect& tile_rect,
 bool ossimCcfTileSource::fillUshortBuffer(const ossimIrect& tile_rect,
                                           const ossimIrect& clip_rect,
                                           const ossimIrect& image_rect,
-                                          ossim_uint32 reduced_res_level)
+                                          ossim_uint32 reduced_res_level,
+                                          ossimImageData* tile)
 {
-   const ossim_uint32 TILE_SIZE_PER_BAND     = theTile->getSizePerBand();
+   const ossim_uint32 TILE_SIZE_PER_BAND     = tile->getSizePerBand();
    const ossim_uint32 CHIP_SIZE_PER_BAND     = theCcfHead.chipSizePerBand();
    const ossim_uint32 SAMPLES_PER_CHIP       = theCcfHead.samplesPerChip();
    const ossim_uint32 LINES_PER_CHIP         = theCcfHead.linesPerChip();
@@ -471,10 +512,10 @@ bool ossimCcfTileSource::fillUshortBuffer(const ossimIrect& tile_rect,
                      // the tile.
                      //***
                      ossim_uint16* d
-                        = (ossim_uint16*)theTile->getBuf() +
+                        = (ossim_uint16*)tile->getBuf() +
                         band * TILE_SIZE_PER_BAND +
                         (chip_clip_rect.ul().y - tile_rect.ul().y) *
-                        theTile->getWidth() + chip_clip_rect.ul().x -
+                        tile->getWidth() + chip_clip_rect.ul().x -
                         tile_rect.ul().x;
                      
                      // Line loop through a chip.
@@ -506,7 +547,7 @@ bool ossimCcfTileSource::fillUshortBuffer(const ossimIrect& tile_rect,
 
                         // Increment the pointers by one line.
                         s += SAMPLES_PER_CHIP;
-                        d += theTile->getWidth();
+                        d += tile->getWidth();
                      }
                      
                   } // End of band loop.
@@ -801,7 +842,7 @@ ossimString ossimCcfTileSource::getLongName()const
    return ossimString("ccf reader");
 }
 
-ossimString ossimCcfTileSource::className()const
+ossimString ossimCcfTileSource::getClassName()const
 {
    return ossimString("ossimCcfTileSource");
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimCibCadrgTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimCibCadrgTileSource.cpp
index 479842fe25a2a9c65b2f9a7a905700a42d417b76..5cd095a653ee9ee69bf963190ec4589a1e4f0f49 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimCibCadrgTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimCibCadrgTileSource.cpp
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //********************************************************************
-// $Id: ossimCibCadrgTileSource.cpp 14379 2009-04-20 22:16:35Z dburken $
+// $Id: ossimCibCadrgTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 using namespace std;
 
@@ -41,7 +41,7 @@ using namespace std;
 static ossimTrace traceDebug = ossimTrace("ossimCibCadrgTileSource:debug");
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimCibCadrgTileSource.cpp 14379 2009-04-20 22:16:35Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimCibCadrgTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 RTTI_DEF1(ossimCibCadrgTileSource, "ossimCibCadrgTileSource", ossimImageHandler)
@@ -254,47 +254,81 @@ bool ossimCibCadrgTileSource::open()
 ossimRefPtr<ossimImageData> ossimCibCadrgTileSource::getTile(
    const  ossimIrect& rect, ossim_uint32 resLevel)
 {
-   ossimIpt origin = rect.ul();
-      
-   if(!isOpen())
-   {
-      return ossimRefPtr<ossimImageData>();
-   }
-   ossimIrect imageRect = getImageRectangle();
-   if( (!rect.intersects(imageRect) )||
-       (theProductType == OSSIM_PRODUCT_TYPE_UNKNOWN) )
+   if (theTile.valid())
    {
-      return ossimRefPtr<ossimImageData>();
-   }
-   
-   theTile->setImageRectangle(rect);
-   if (theOverview)
-   {
-      if (theOverview->hasR0() || resLevel)
+      // Image rectangle must be set prior to calling getTile.
+      theTile->setImageRectangle(rect);
+      
+      if ( getTile( theTile.get(), resLevel ) == false )
       {
-         return theOverview->getTile(rect, resLevel);
+         if (theTile->getDataObjectStatus() != OSSIM_NULL)
+         {
+            theTile->makeBlank();
+         }
       }
    }
+   
+   return theTile;
+}
+
+bool ossimCibCadrgTileSource::getTile(ossimImageData* result,
+                                      ossim_uint32 resLevel)
+{
+   bool status = false;
 
    //---
-   // Start with a blank tile in case there is not total coverage for rect.
+   // Not open, this tile source bypassed, or invalid res level,
+   // return a blank tile.
    //---
-   theTile->makeBlank();
-   
-   vector<ossimFrameEntryData> frames = getIntersectingEntries(rect);
-   if(frames.size() > 0)
+   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
+       result && (result->getNumberOfBands() == getNumberOfOutputBands()) &&
+       (theProductType != OSSIM_PRODUCT_TYPE_UNKNOWN) )
    {
       //---
-      // Now lets render each frame.  Note we will have to find subframes
-      // that intersect the rectangle of interest for each frame.
+      // 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.
       //---
-      fillTile(rect, frames);
+      status = getOverviewTile(resLevel, result);
+
+      if (!status) // Did not get an overview tile.
+      {
+         status = true;
+
+         ossimIrect rect = result->getImageRectangle();
 
-      // Revalidate tile status.
-      theTile->validate();
+         ossimIrect imageRect = getImageRectangle();
+
+         if ( rect.intersects(imageRect) )
+         {
+            //---
+            // Start with a blank tile in case there is not total coverage
+            // for rect.
+            //---
+            result->makeBlank();
+   
+            vector<ossimFrameEntryData> frames = getIntersectingEntries(rect);
+            if(frames.size() > 0)
+            {
+               //---
+               // Now lets render each frame.  Note we will have to find
+               // subframes
+               // that intersect the rectangle of interest for each frame.
+               //---
+               fillTile(rect, frames, result);
+               
+               // Revalidate tile status.
+               result->validate();
+            }
+         }
+         else
+         {
+            result->makeBlank();
+         }
+      }
    }
    
-   return theTile;
+   return status;
 }
 
 ossim_uint32 ossimCibCadrgTileSource::getNumberOfInputBands()const
@@ -345,7 +379,7 @@ ossim_uint32 ossimCibCadrgTileSource::getNumberOfLines(ossim_uint32 reduced_res_
    {
       return theNumberOfLines;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfLines(reduced_res_level);
    }
@@ -359,7 +393,7 @@ ossim_uint32 ossimCibCadrgTileSource::getNumberOfSamples(ossim_uint32 reduced_re
    {
       return theNumberOfSamples;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfSamples(reduced_res_level);
    }
@@ -403,22 +437,20 @@ ossimIrect ossimCibCadrgTileSource::getImageRectangle(ossim_uint32 reduced_res_l
    
 
    
-bool ossimCibCadrgTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                            const char* prefix)
+ossimImageGeometry* ossimCibCadrgTileSource::getImageGeometry()
 {
    if(!theEntryToRender)
    {
       return false;
    }
 
-   if (theGeometryKwl.getSize())
-   {
-      kwl = theGeometryKwl;
-      return true;
-   }
+   if (theGeometry.valid())
+      return theGeometry.get();
 
    // datum
    // WGS 84
+   ossimKeywordlist kwl;
+   const char* prefix = 0; // legacy
    kwl.add(prefix,
            ossimKeywordNames::DATUM_KW,
            "WGE",
@@ -679,9 +711,10 @@ bool ossimCibCadrgTileSource::getImageGeometry(ossimKeywordlist& kwl,
                true);        
     }
 
-    setImageGeometry(kwl);
-    
-    return true;
+    // Capture this for next time.
+    theGeometry = new ossimImageGeometry;
+    theGeometry->loadState(kwl, prefix);
+    return theGeometry.get();
 }
    
 ossimScalarType ossimCibCadrgTileSource::getOutputScalarType() const
@@ -706,8 +739,8 @@ ossim_uint32 ossimCibCadrgTileSource::getCurrentEntry()const
 
 bool ossimCibCadrgTileSource::setCurrentEntry(ossim_uint32 entryIdx)
 {
-   // Must clear or getImageGeometry method will use last entries.
-   theGeometryKwl.clear();
+   // Clear the geometry.
+   theGeometry = 0;
 
    // Must clear or openOverview will use last entries.
    theOverviewFile.clear();
@@ -809,7 +842,7 @@ bool ossimCibCadrgTileSource::isValidRLevel(ossim_uint32 reduced_res_level) cons
    {
       return true;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->isValidRLevel(reduced_res_level);
    }
@@ -966,8 +999,10 @@ vector<ossimCibCadrgTileSource::ossimFrameEntryData> ossimCibCadrgTileSource::ge
    return result;
 }
 
-void ossimCibCadrgTileSource::fillTile(const ossimIrect& tileRect,
-                                       const vector<ossimFrameEntryData>& framesInvolved)
+void ossimCibCadrgTileSource::fillTile(
+   const ossimIrect& tileRect,
+   const vector<ossimFrameEntryData>& framesInvolved,
+   ossimImageData* tile)
 {
    ossim_uint32 idx = 0;
    for(idx = 0;
@@ -984,21 +1019,25 @@ void ossimCibCadrgTileSource::fillTile(const ossimIrect& tileRect,
          {
             fillSubTileCib(*theWorkFrame,
                            tileRect,
-                           framesInvolved[idx]);
+                           framesInvolved[idx],
+                           tile);
          }
          else
          {
             fillSubTileCadrg(*theWorkFrame,
                              tileRect,
-                             framesInvolved[idx]);
+                             framesInvolved[idx],
+                             tile);
          }
       }
    }
 }
 
-void ossimCibCadrgTileSource::fillSubTileCadrg(const ossimRpfFrame&  aFrame,
-                                               const ossimIrect& tileRect,
-                                               const ossimFrameEntryData& frameEntryData)
+void ossimCibCadrgTileSource::fillSubTileCadrg(
+   const ossimRpfFrame&  aFrame,
+   const ossimIrect& tileRect,
+   const ossimFrameEntryData& frameEntryData,
+   ossimImageData* tile)
 {;
    // first let's grab the absolute position of the frame rectangle in pixel space
    ossimIrect frameRect(frameEntryData.thePixelCol,
@@ -1017,6 +1056,18 @@ void ossimCibCadrgTileSource::fillSubTileCadrg(const ossimRpfFrame&  aFrame,
       return;
    }
 
+   const vector<ossimRpfColorGrayscaleTable>& colorTable =
+      aFrame.getColorGrayscaleTable();
+
+   // ESH 03/2009 -- Partial fix for ticket #646.
+   // Crash fix on reading RPFs: Make sure the colorTable vector 
+   // has entries before trying to make use of them. 
+   int numTables = colorTable.size();
+   if ( numTables <= 0 )
+   {
+      return;
+   }
+
    ossim_uint8 *tempRows[3];
    
    tempRows[0] = theUncompressedBuffer;
@@ -1048,9 +1099,7 @@ void ossimCibCadrgTileSource::fillSubTileCadrg(const ossimRpfFrame&  aFrame,
                             (offsetRect.lr().y)/256);
    
    ossim_uint32 readPtr  = 0;
-   const vector<ossimRpfColorGrayscaleTable>& colorTable =
-      aFrame.getColorGrayscaleTable();
-   
+
    ossim_int32 row = 0;
    ossim_int32 col = 0;
    ossim_uint32 i = 0;
@@ -1121,18 +1170,21 @@ void ossimCibCadrgTileSource::fillSubTileCadrg(const ossimRpfFrame&  aFrame,
                                   frameRect.ul().y + tempRow,
                                   frameRect.ul().x + tempCol + 255,
                                   frameRect.ul().y + tempRow + 255);
-         theTile->loadTile(theUncompressedBuffer,
-                              subRectToFill,
-                              OSSIM_BSQ);
+         tile->loadTile(theUncompressedBuffer,
+                        subRectToFill,
+                        OSSIM_BSQ);
       }
    }
 }
 
-void ossimCibCadrgTileSource::fillSubTileCib(const ossimRpfFrame&  aFrame,
-                                               const ossimIrect& tileRect,
-                                               const ossimFrameEntryData& frameEntryData)
+void ossimCibCadrgTileSource::fillSubTileCib(
+   const ossimRpfFrame&  aFrame,
+   const ossimIrect& tileRect,
+   const ossimFrameEntryData& frameEntryData,
+   ossimImageData* tile)
 {
-   // first let's grab the absolute position of the frame rectangle in pixel space
+   // first let's grab the absolute position of the frame rectangle in pixel
+   // space
    ossimIrect frameRect(frameEntryData.thePixelCol,
                         frameEntryData.thePixelRow,
                         frameEntryData.thePixelCol + CIBCADRG_FRAME_WIDTH  - 1,
@@ -1149,6 +1201,18 @@ void ossimCibCadrgTileSource::fillSubTileCib(const ossimRpfFrame&  aFrame,
       return;
    }
 
+   const vector<ossimRpfColorGrayscaleTable>& colorTable =
+      aFrame.getColorGrayscaleTable();
+
+   // ESH 03/2009 -- Partial fix for ticket #646.
+   // Crash fix on reading RPFs: Make sure the colorTable vector 
+   // has entries before trying to make use of them. 
+   int numTables = colorTable.size();
+   if ( numTables <= 0 )
+   {
+      return;
+   }
+
    // check to see if it does overlap.  If it doesn't then the width and height
    // will be a single point
    {
@@ -1179,9 +1243,6 @@ void ossimCibCadrgTileSource::fillSubTileCib(const ossimRpfFrame&  aFrame,
                               (offsetRect.lr().x)/256,
                               (offsetRect.lr().y)/256);
 
-      const vector<ossimRpfColorGrayscaleTable>& colorTable =
-                                        aFrame.getColorGrayscaleTable();
-
       ossim_int32 row = 0;
       ossim_int32 col = 0;
       ossim_uint32 i = 0;
@@ -1243,9 +1304,9 @@ void ossimCibCadrgTileSource::fillSubTileCib(const ossimRpfFrame&  aFrame,
                                      frameRect.ul().y + tRow,
                                      frameRect.ul().x + tCol + 255,
                                      frameRect.ul().y + tRow + 255);
-            theTile->loadTile(theUncompressedBuffer,
-                              subRectToFill,
-                              OSSIM_BSQ);
+            tile->loadTile(theUncompressedBuffer,
+                           subRectToFill,
+                           OSSIM_BSQ);
          }
       }
    }  
@@ -1307,11 +1368,7 @@ const ossimRpfTocEntry* ossimCibCadrgTileSource::findFirstFrame()
 
 void ossimCibCadrgTileSource::deleteAll()
 {
-   if(theOverview)
-   {
-      delete theOverview;
-      theOverview = 0;
-   }
+   theOverview = 0;
    if(theTableOfContents)
    {
       delete theTableOfContents;
@@ -1484,7 +1541,12 @@ void ossimCibCadrgTileSource::populateLut()
          const vector<ossimRpfColorGrayscaleTable>& colorTable =
             aFrame.getColorGrayscaleTable();
 
-         ossim_uint32 numElements = colorTable[0].getNumberOfElements();
+         // ESH 03/2009 -- Partial fix for ticket #646.
+         // Crash fix on reading RPFs: Make sure the colorTable vector 
+         // has entries before trying to make use of them. 
+         int numTables = colorTable.size();
+
+         ossim_uint32 numElements = (numTables > 0) ? colorTable[0].getNumberOfElements() : 0;
          if(numElements > 0)
          {
             if((theProductType == OSSIM_PRODUCT_TYPE_CIB)||
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimDdfsubfielddefn.cpp b/Utilities/otbossim/src/ossim/imaging/ossimDdfsubfielddefn.cpp
index 994e9c982aa4d05fc71d73824d6e1de0faa794f2..99cb75cada7c31fcfb3743753415185bdae9c9d9 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimDdfsubfielddefn.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimDdfsubfielddefn.cpp
@@ -26,7 +26,7 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  ******************************************************************************
- * $Id: ossimDdfsubfielddefn.cpp 12978 2008-06-04 00:04:14Z dburken $
+ * $Id: ossimDdfsubfielddefn.cpp 15261 2009-08-26 12:47:58Z dburken $
  */
 
 #include <cstring>
@@ -434,48 +434,71 @@ ossimDDFSubfieldDefn::ExtractFloatData( const char * pachSourceData,
           // Interpret the bytes of data.
           switch( eBinaryFormat )
           {
-            case UInt:
-              if( nFormatWidth == 1 )
-                  return( abyData[0] );
-              else if( nFormatWidth == 2 )
-                  return( *((ossim_uint16 *) abyData) );
-              else if( nFormatWidth == 4 )
-                  return( *((ossim_uint32 *) abyData) );
-              else
-              {
-                  // CPLAssert( false );
-                  return 0.0;
-              }
-            
-            case SInt:
-              if( nFormatWidth == 1 )
-                  return( *((signed char *) abyData) );
-              else if( nFormatWidth == 2 )
-                  return( *((ossim_int16 *) abyData) );
-              else if( nFormatWidth == 4 )
-                  return( *((ossim_int32 *) abyData) );
-              else
-              {
-                  // CPLAssert( false );
-                  return 0.0;
-              }
+             case UInt:
+                if( nFormatWidth == 1 )
+                {
+                   return( abyData[0] );
+                }
+                else if( nFormatWidth == 2 )
+                {
+                   ossim_uint16* ptr = (ossim_uint16*) abyData;
+                   return *ptr;
+                }
+                else if( nFormatWidth == 4 )
+                {
+                   ossim_uint32* ptr = (ossim_uint32*) abyData;
+                   return *ptr;
+                }
+                else
+                {
+                   // CPLAssert( false );
+                   return 0.0;
+                }
+                
+             case SInt:
+                if( nFormatWidth == 1 )
+                {
+                   signed char* ptr = (signed char*) abyData;
+                   return *ptr;
+                }
+                else if( nFormatWidth == 2 )
+                {
+                   ossim_int16* ptr = (ossim_int16*) abyData;
+                   return *ptr;
+                }
+                else if( nFormatWidth == 4 )
+                {
+                   ossim_int32* ptr = (ossim_int32*) abyData;
+                   return *ptr;
+                }
+                else
+                {
+                   // CPLAssert( false );
+                   return 0.0;
+                }
             
-            case FloatReal:
-              if( nFormatWidth == 4 )
-                  return( *((float *) abyData) );
-              else if( nFormatWidth == 8 )
-                  return( *((double *) abyData) );
-              else
-              {
-                  // CPLAssert( false );
-                  return 0.0;
-              }
-
-            case NotBinary:            
-            case FPReal:
-            case FloatComplex:
-              // CPLAssert( false );
-              return 0.0;
+             case FloatReal:
+                if( nFormatWidth == 4 )
+                {
+                   float* ptr = (float*) abyData;
+                   return *ptr;
+                }
+                else if( nFormatWidth == 8 )
+                {
+                   double* ptr = (double*) abyData;
+                   return *ptr;
+                }
+                else
+                {
+                   // CPLAssert( false );
+                   return 0.0;
+                }
+                
+             case NotBinary:            
+             case FPReal:
+             case FloatComplex:
+                // CPLAssert( false );
+                return 0.0;
           }
           break;
           // end of 'b'/'B' case.
@@ -571,56 +594,79 @@ ossimDDFSubfieldDefn::ExtractIntData( const char * pachSourceData,
           {
             case UInt:
               if( nFormatWidth == 4 )
-                  return( (int) *((ossim_uint32 *) abyData) );
-              else if( nFormatWidth == 1 )
-                  return( abyData[0] );
-              else if( nFormatWidth == 2 )
-                  return( *((ossim_uint16 *) abyData) );
-              else
               {
-                  // CPLAssert( false );
-                  return 0;
+                 ossim_uint32* ptr = (ossim_uint32*) abyData;
+                 return *ptr;
               }
-            
-            case SInt:
-              if( nFormatWidth == 4 )
-                  return( *((ossim_int32 *) abyData) );
               else if( nFormatWidth == 1 )
-                  return( *((signed char *) abyData) );
+              {
+                 return( abyData[0] );
+              }
               else if( nFormatWidth == 2 )
-                  return( *((ossim_int16 *) abyData) );
-              else
               {
-                  // CPLAssert( false );
-                  return 0;
+                 ossim_uint16* ptr = (ossim_uint16*)abyData;
+                 return *ptr;
               }
-            
-            case FloatReal:
-              if( nFormatWidth == 4 )
-                  return( (int) *((float *) abyData) );
-              else if( nFormatWidth == 8 )
-                  return( (int) *((double *) abyData) );
               else
               {
-                  // CPLAssert( false );
-                  return 0;
+                 // CPLAssert( false );
+                 return 0;
               }
-
-            case NotBinary:            
-            case FPReal:
-            case FloatComplex:
-              // CPLAssert( false );
-              return 0;
+              
+             case SInt:
+                if( nFormatWidth == 4 )
+                {
+                   ossim_int32* ptr = (ossim_int32 *) abyData;
+                   return *ptr;
+                }
+                else if( nFormatWidth == 1 )
+                {
+                   signed char* ptr = (signed char *) abyData;
+                   return *ptr;
+                }
+                else if( nFormatWidth == 2 )
+                {
+                   ossim_int16* ptr = (ossim_int16 *) abyData;
+                   return *ptr;
+                }
+                else
+                {
+                   // CPLAssert( false );
+                   return 0;
+                }
+                
+             case FloatReal:
+                if( nFormatWidth == 4 )
+                {
+                   float* ptr = (float *) abyData;
+                   return (int) *ptr;
+                }
+                else if( nFormatWidth == 8 )
+                {
+                   double* ptr = (double *) abyData;
+                   return (int) *ptr;
+                }
+                else
+                {
+                   // CPLAssert( false );
+                   return 0;
+                }
+
+             case NotBinary:            
+             case FPReal:
+             case FloatComplex:
+                // CPLAssert( false );
+                return 0;
           }
           break;
           // end of 'b'/'B' case.
       }
-
-      default:
-        // CPLAssert( false );
-        return 0;
+      
+       default:
+          // CPLAssert( false );
+          return 0;
     }
-
+    
     // CPLAssert( false );
     return 0;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimDoqqTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimDoqqTileSource.cpp
index 9af491fc90acfa794f1737baebbd7c92936b6a6b..768fe02010b08e76f6e7d1572679cb308ed661a5 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimDoqqTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimDoqqTileSource.cpp
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimDoqqTileSource.cpp 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimDoqqTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimDoqqTileSource.h>
 #include <ossim/support_data/ossimDoqq.h>
 #include <ossim/imaging/ossimGeneralRasterInfo.h>
@@ -69,17 +69,20 @@ bool ossimDoqqTileSource::open(const ossimFilename& filename)
    return result;
 }
 
-bool ossimDoqqTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                           const char* prefix)
+//**************************************************************************************************
+//! Returns the image geometry object associated with this tile source or NULL if non defined.
+//! The geometry contains full-to-local image transform as well as projection (image-to-world)
+//**************************************************************************************************
+ossimImageGeometry* ossimDoqqTileSource::getImageGeometry()
 {
-   if (theGeometryKwl.getSize())
-   {
-      kwl = theGeometryKwl;
-      return true;
-   }
+   if (theGeometry.valid())
+      return theGeometry.get();
    
    if(theHeaderInformation.valid())
    {
+      ossimKeywordlist kwl;
+      const char* prefix = 0; // legacy
+
       ossimString proj  = theHeaderInformation->theProjection.trim().upcase();
       ossimString datum = theHeaderInformation->theDatum.trim().upcase();
 
@@ -154,11 +157,11 @@ bool ossimDoqqTileSource::getImageGeometry(ossimKeywordlist& kwl,
               true);
 
       // Capture this for next time.
-      setImageGeometry(kwl);
-      
-      return true;
+      theGeometry = new ossimImageGeometry;
+      theGeometry->loadState(kwl, prefix);
+      return theGeometry.get();
    }
-   return false;
+   return 0;
 }
 
 ossimRefPtr<ossimProperty> ossimDoqqTileSource::getProperty(const ossimString& name)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimDtedElevationImageSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimDtedElevationImageSource.cpp
index 989fd4591614838619ab875b24a136317e007dff..fd780f0673b7ae510a28bd971f034573bae375db 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimDtedElevationImageSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimDtedElevationImageSource.cpp
@@ -11,7 +11,7 @@
 //
 // Contains class declaration of ossimDtedElevationImageSource.
 //
-// $Id: ossimDtedElevationImageSource.cpp 11419 2007-07-27 16:24:57Z dburken $
+// $Id: ossimDtedElevationImageSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 //----------------------------------------------------------------------------
 
 #include <vector>
@@ -22,7 +22,6 @@ using namespace std;
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/base/ossimIrect.h>
 #include <ossim/elevation/ossimDtedHandler.h>
-#include <ossim/projection/ossimImageViewProjectionTransform.h>
 #include <ossim/projection/ossimMapProjection.h>
 #include <ossim/imaging/ossimDtedElevationImageSource.h>
 #include <ossim/imaging/ossimDtedTileSource.h>
@@ -71,18 +70,18 @@ ossimRefPtr<ossimImageData> ossimDtedElevationImageSource::getBlock(
    findCells(rect, vf);
 
    // Create a mosaic of them.
-   ossimImageChain* mosaic = createMosaic(vf);
+   ossimRefPtr<ossimImageChain> mosaic = createMosaic(vf);
    if (!mosaic)
    {
-      return NULL;
+      return 0;
    }
 
    // Get the view.
-   ossimMapProjection* view = getView(mosaic);
+   ossimMapProjection* view = getView(mosaic.get());
    if (!view)
    {
-      delete mosaic;
-      return NULL;
+      mosaic = 0;
+      return 0;
    }
    
    // Set the output resolution.
@@ -99,7 +98,7 @@ ossimRefPtr<ossimImageData> ossimDtedElevationImageSource::getBlock(
    
    ossimRefPtr<ossimImageData> result = mosaic->getTile(tileRect);
 
-   delete mosaic;
+   mosaic = 0;
    
    if (traceDebug())
    {
@@ -298,21 +297,21 @@ void ossimDtedElevationImageSource::resampleCellBilinear(
          << endl;
    }
 
-   ossimDtedHandler* dh = new ossimDtedHandler(dtedFile);
+   ossimRefPtr<ossimDtedHandler> dh = new ossimDtedHandler(dtedFile);
    if (!dh)
    {
       return;
    }
    if (dh->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
    {
-      delete dh;
+      dh = 0;
       return;
    }
 
    ossim_float32* buf = id.getFloatBuf();
    if (!buf)
    {
-      delete dh;
+      dh = 0;
       return;
    }
    
@@ -382,8 +381,8 @@ void ossimDtedElevationImageSource::resampleCellBilinear(
          << " Exited..."
          << endl;
    }
-   
-   delete dh;
+
+   dh = 0;
 }
 
 void ossimDtedElevationImageSource::resampleCellNearestNeighbor(
@@ -393,18 +392,18 @@ void ossimDtedElevationImageSource::resampleCellNearestNeighbor(
    const ossimDpt& requestedPostSpacing) const
 {
    // Open the cell.
-   ossimImageHandler* dts = new ossimDtedTileSource();
+   ossimRefPtr<ossimImageHandler> dts = new ossimDtedTileSource();
    dts->open(dtedFile);
 
    if (dts->isOpen() == false)
    {
-      delete dts;
+      dts = 0;
       return;
    }
 
    // Get the post spacing of the cell.
    ossimDpt cellPostSpacing;
-   ((ossimDtedTileSource*)dts)->getPostSpacing(cellPostSpacing);
+   ((ossimDtedTileSource*)dts.get())->getPostSpacing(cellPostSpacing);
 
 //    // Compute the rlevel to grab from.
 //    ossim_uint32 rLevel = computeRLevel(dts->getNumberOfDecimationLevels(),
@@ -600,7 +599,6 @@ ossimImageChain* ossimDtedElevationImageSource::createMosaic(
       return NULL;
    }
    
-   ossimImageChain* chainResult = NULL;
    ossimString defaultDescription="ossimOrthoImageMosaic";;
    ossimKeywordlist kwl;
    
@@ -640,24 +638,23 @@ ossimImageChain* ossimDtedElevationImageSource::createMosaic(
            10,
            true);
    
-    ossimObject* objResult =
-       ossimObjectFactoryRegistry::instance()->createObject(kwl);
-    chainResult      = PTR_CAST(ossimImageChain, objResult);
-    if(chainResult)
-    {
-	chainResult->makeUniqueIds();
-        chainResult->setDescription(defaultDescription);
-        for(idx = 0; idx < inputList.size(); ++idx)
-        {
-           chainResult->connectMyInputTo(inputList[idx]);
-        }
-    }
-    else if(objResult)
-    {
-	delete objResult;
-    }
-    
-    return chainResult;
+   ossimRefPtr<ossimObject> objResult =
+   ossimObjectFactoryRegistry::instance()->createObject(kwl);
+   ossimRefPtr<ossimImageChain> chainResult      = PTR_CAST(ossimImageChain, objResult.get());
+   if(chainResult.valid())
+   {
+      chainResult->makeUniqueIds();
+      chainResult->setDescription(defaultDescription);
+      for(idx = 0; idx < inputList.size(); ++idx)
+      {
+         chainResult->connectMyInputTo(inputList[idx]);
+      }
+   }
+   else
+   {
+      chainResult = 0;
+   }
+   return chainResult.release();
 }
 
 ossimMapProjection* ossimDtedElevationImageSource::getView(
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp
index e9852e66f54772dc9bbce8e95fdb9929a60dbf11..257c93e756741cd3b38efbec774c318f6b107154 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2001 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -12,11 +11,10 @@
 // Contains class declaration for ossimDtedTileSource.
 //
 //********************************************************************
-// $Id: ossimDtedTileSource.cpp 14137 2009-03-25 20:23:05Z dburken $
+// $Id: ossimDtedTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <iostream>
-#include <fstream>
 using namespace std;
 
 #include <ossim/imaging/ossimDtedTileSource.h>
@@ -32,7 +30,6 @@ using namespace std;
 #include <ossim/imaging/ossimTiffTileSource.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimImageData.h>
-#include <ossim/imaging/ossimS16ImageData.h>
 #include <ossim/support_data/ossimDtedVol.h>
 #include <ossim/support_data/ossimDtedHdr.h>
 #include <ossim/support_data/ossimDtedUhl.h>
@@ -91,7 +88,7 @@ ossimString ossimDtedTileSource::getLongName()const
    return ossimString("dted reader");
 }
 
-ossimString ossimDtedTileSource::className()const
+ossimString ossimDtedTileSource::getClassName()const
 {
    return ossimString("ossimDtedTileSource");
 }   
@@ -108,74 +105,78 @@ ossimRefPtr<ossimImageData> ossimDtedTileSource::getTile(
       }
    }
 
-   // This tile source bypassed, or invalid res level, return a blank tile.
-   if (!isOpen()||!isSourceEnabled() || !isValidRLevel(resLevel))
-   {
-      return ossimRefPtr<ossimImageData>();
-   }
-
-   if (theOverview)
+   // Image rectangle must be set prior to calling getTile.
+   theTile->setImageRectangle(tile_rect);
+   
+   if ( getTile( theTile.get(), resLevel ) == false )
    {
-      if (theOverview->hasR0() || resLevel)
+      if (theTile->getDataObjectStatus() != OSSIM_NULL)
       {
-         ossimRefPtr<ossimImageData> temp =
-            theOverview->getTile(tile_rect, resLevel);
-         if(temp.valid() && temp->getBuf())
-         {
-            temp->setMinPix(theTile->getMinPix(), theTile->getNumberOfBands());
-            temp->setMaxPix(theTile->getMaxPix(), theTile->getNumberOfBands());
-            temp->setNullPix(theTile->getNullPix(),
-                             theTile->getNumberOfBands());
-         }
-         else
-         {
-            return ossimRefPtr<ossimImageData>();
-         }
-         return temp;
+         theTile->makeBlank();
       }
    }
 
-   // Set the origing and resize if needed...
-   theTile->setImageRectangle(tile_rect);
-   
-   ossimIrect image_rect = getImageRectangle(resLevel);
+   return theTile;
+}
+
+bool ossimDtedTileSource::getTile(ossimImageData* result,
+                                  ossim_uint32 resLevel)
+{
+   bool status = false;
    
-   //***
-   // See if any point of the requested tile is in the image.
-   //***
-   if ( tile_rect.intersects(image_rect) )
+   //---
+   // Not open, this tile source bypassed, or invalid res level,
+   // return a blank tile.
+   //---
+   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
+       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
    {
-      ossimIrect clip_rect = tile_rect.clipToRect(image_rect);
+      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 ( !tile_rect.completely_within(clip_rect) )
-      {
-         // Start with a blank tile.
-         theTile->makeBlank();
-      }
+      if (!status) // Did not get an overview tile.
+      {  
+         ossimIrect image_rect = getImageRectangle(resLevel);
 
-      // Load the tile buffer with data from the dted cell.
-      if (fillBuffer(tile_rect, clip_rect))
-      {
-         theTile->validate();
-         return theTile;
-      }
-      else
-      {
-         return ossimRefPtr<ossimImageData>();
+         ossimIrect tile_rect = result->getImageRectangle();
+         
+         //---
+         // 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);
+            
+            if ( !tile_rect.completely_within(clip_rect) )
+            {
+               // Start with a blank tile.
+               result->makeBlank();
+            }
+
+            // Load the tile buffer with data from the dted cell.
+            status = fillBuffer(tile_rect, clip_rect, result);
+            
+         } // End of if ( tile_rect.intersects(image_rect) )
       }
-      
-   } // End of if ( tile_rect.intersects(image_rect) )
 
-   // No part of requested tile within the image rectangle.
-   return ossimRefPtr<ossimImageData>();
+       result->unref(); // Decrement ref count.
+   }
    
+   return status;
 }
 
 //*******************************************************************
 // Private Method:
 //*******************************************************************
 bool ossimDtedTileSource::fillBuffer(const ossimIrect& tile_rect,
-                                     const ossimIrect& clip_rect)
+                                     const ossimIrect& clip_rect,
+                                     ossimImageData* tile)
 {
    //***
    // NOTE:
@@ -183,7 +184,7 @@ bool ossimDtedTileSource::fillBuffer(const ossimIrect& tile_rect,
    // The "tile_rect" and "clip_rect" is organized positive line down.
    //***
 
-   const ossim_int32 TILE_WIDTH = theTile->getWidth();
+   const ossim_int32 TILE_WIDTH = tile->getWidth();
    
    //***
    // Position the file pointer to the first record needed.
@@ -200,7 +201,7 @@ bool ossimDtedTileSource::fillBuffer(const ossimIrect& tile_rect,
    // Get a pointer positioned at the first valid pixel in
    // the tile.  Tiles are organized positive line down.
    //***
-   ossim_sint16* d = static_cast<ossim_sint16*>(theTile->getBuf());
+   ossim_sint16* d = static_cast<ossim_sint16*>(tile->getBuf());
    
    // Loop in the longitude or sample direction.
    for (ossim_int32 samp = clip_rect.ul().x; samp <= clip_rect.lr().x; samp++)
@@ -224,7 +225,8 @@ bool ossimDtedTileSource::fillBuffer(const ossimIrect& tile_rect,
       seek_position += theDataRecordSize;
    }
 
-
+   tile->validate();
+   
    return true;
 }
 
@@ -399,20 +401,17 @@ bool ossimDtedTileSource::loadState(const ossimKeywordlist& kwl,
    return false;
 }
 
-bool ossimDtedTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                           const char* prefix)
+//**************************************************************************************************
+// Returns the image geometry object associated with this tile source or NULL if not defined.
+// The geometry contains full-to-local image transform as well as projection (image-to-world)
+//**************************************************************************************************
+ossimImageGeometry* ossimDtedTileSource::getImageGeometry()
 {
-   static const char MODULE[] = "ossimDtedTileSource::getImageGeometry";
+   static const char* MODULE = "ossimDtedTileSource::getImageGeometry() -- ";
 
-   if (traceDebug()) CLOG << " Entered..." << endl;
+   if (theGeometry.valid())
+      return theGeometry.get();
 
-   // Previously saved...
-   if (theGeometryKwl.getSize())
-   {
-      kwl = theGeometryKwl;
-      return true;
-   }   
-      
    if(!theFileStr)
    {
       if (traceDebug())
@@ -455,7 +454,7 @@ bool ossimDtedTileSource::getImageGeometry(ossimKeywordlist& kwl,
    // since the DTED post spacing is considered to be square.  Save its
    // state to the keyword list.
    //***
-   ossimString projPref = prefix?prefix:"";
+//   ossimString projPref = prefix?prefix:"";
 //   const ossimDatum* datum = ossimDatumFactory::instance()->wgs84();
 //    ossimProjection* proj
 //       = new ossimEquDistCylProjection(*(datum->ellipsoid()),
@@ -476,6 +475,8 @@ bool ossimDtedTileSource::getImageGeometry(ossimKeywordlist& kwl,
                 (uhl.latInterval() * (uhl.numLatPoints()-1.0));
    
    // Add the tie point.
+   ossimKeywordlist kwl;
+   const char* prefix = 0; // legacy
    kwl.add(prefix,
            ossimKeywordNames::TYPE_KW,
            "ossimEquDistCylProjection",
@@ -550,10 +551,10 @@ bool ossimDtedTileSource::getImageGeometry(ossimKeywordlist& kwl,
 
    if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "kwl:\n" << kwl << MODULE << " Exited..." << endl;
 
-   // Capture for next time.
-   setImageGeometry(kwl);
-   
-   return true;
+   // Capture this for next time.
+   theGeometry = new ossimImageGeometry;
+   theGeometry->loadState(kwl, prefix);
+   return theGeometry.get();
 }
 
 ossimScalarType
@@ -578,7 +579,7 @@ ossim_uint32 ossimDtedTileSource::getNumberOfLines(ossim_uint32 reduced_res_leve
    {
       return theNumberOfLines;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfLines(reduced_res_level);
    }
@@ -592,7 +593,7 @@ ossim_uint32 ossimDtedTileSource::getNumberOfSamples(ossim_uint32 reduced_res_le
    {
       return theNumberOfSamps;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfSamples(reduced_res_level);
    }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp
index b85a7379aee37939a6d3deb011135761479a680d..09fbf848f222f4845ae1c9dd783a023461c4e425 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp
@@ -10,7 +10,7 @@
 // writing an ERS header file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimERSFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimERSFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimERSFileWriter.h>
 #include <ossim/base/ossimKeywordlist.h>
@@ -67,134 +67,82 @@ bool ossimERSFileWriter::writeFile()
    theHdr.theCelltype = theInputConnection->getOutputScalarType();
    
    // Get the geometry from the input.
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-   
-   // Create the projection.
    ossimMapProjection* mapProj = 0;
-   ossimRefPtr<ossimProjection> proj =
-      ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   if (proj.valid())
+   const ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
+   if (inputGeom)
+      mapProj = PTR_CAST(ossimMapProjection, inputGeom->getProjection());
+   if (mapProj)
    {
-      mapProj = PTR_CAST(ossimMapProjection, proj.get());
-      
-      if (mapProj)
+      // Create the projection info.
+      ossimRefPtr<ossimMapProjectionInfo> projectionInfo
+         = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
+
+      // Set the tie points in the keyword list.
+      ossimKeywordlist kwl;
+      projectionInfo->getGeom(kwl);
+
+      // Get the projection type.
+      const char* lookup;
+      ossimString projection;
+      lookup = kwl.find(ossimKeywordNames::TYPE_KW);
+      if (lookup)
       {
-         // Create the projection info.
-         ossimRefPtr<ossimMapProjectionInfo> projectionInfo
-            = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
-         
-         // Set the tie points in the keyword list.
-         projectionInfo->getGeom(kwl);
-         
-         
-         const char* lookup;
-         // Get the projection type.
-         ossimString projection;
-         lookup = kwl.find(ossimKeywordNames::TYPE_KW);
+         projection = lookup;
+      }
+      else
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimERSFileWriter::writeFile WARNING:"
+            << "\nNo projection type found!\nReturning..."
+            << std::endl;
+         return false; // Have to have the projection type!
+      }
+
+      if (projection == "ossimUtmProjection")
+      {
+         ossimString utm;
+         lookup = kwl.find(ossimKeywordNames::HEMISPHERE_KW);
          if (lookup)
          {
-            projection = lookup;
+            utm = lookup;
+            utm += "UTM";
          }
          else
-         {
-            ossimNotify(ossimNotifyLevel_WARN)
-               << "ossimERSFileWriter::writeFile WARNING:"
-               << "\nNo projection type found!\nReturning..."
-               << std::endl;
-            return false; // Have to have the projection type!
-         }
-         
-         if (projection == "ossimUtmProjection")
-         {
-            ossimString utm;
-            lookup = kwl.find(ossimKeywordNames::HEMISPHERE_KW);
-            if (lookup)
-            {
-               utm = lookup;
-               utm += "UTM";
-            }
-            else
-               return false;
-            
-            lookup = kwl.find(ossimKeywordNames::ZONE_KW);
-            if (lookup)
-               utm += lookup;
-            else
-               return false;
-            
-            theHdr.theProjection = utm;
-            theHdr.theCoordSysType = "EN";
-            
-            
-            //we get tie points
-            lookup = kwl.find(ossimKeywordNames::TIE_POINT_XY_KW);
-            tmp = lookup;
-            if (lookup)
-            {
-               tmp = tmp.trim("(");
-               tmp = tmp.trim(")");
-               ossimString a = tmp.before(",", 0);
-               ossimString b = tmp.after(",", 0);
-               theHdr.theOriginX = a.toDouble();
-               theHdr.theOriginY = b.toDouble();
-            }
-            //set the tie point unit type to meters
-            theHdr.theTieUnitType = OSSIM_METERS;
-            
-         }
-         else if (projection == "ossimEquDistCylProjection")
-         {
-            theHdr.theProjection = "GEODETIC";
-            theHdr.theCoordSysType = "LL";
-            
-            //we get tie points
-            lookup = kwl.find(ossimKeywordNames::TIE_POINT_XY_KW);
-            tmp = lookup;
-            if (lookup)
-            {
-               tmp = tmp.trim("(");
-               tmp = tmp.trim(")");
-               ossimString a = tmp.before(",", 0);
-               ossimString b = tmp.after(",", 0);
-               theHdr.theOriginX = a.toDouble();
-               theHdr.theOriginY = b.toDouble();
-            }
-            //set the tie point unit type to degrees
-            theHdr.theTieUnitType = OSSIM_DEGREES;
+            return false;
 
-         }
+         lookup = kwl.find(ossimKeywordNames::ZONE_KW);
+         if (lookup)
+            utm += lookup;
          else
-         {
-            ossimNotify(ossimNotifyLevel_WARN)
-               << "ossimERSFileWriter::writeFile WARNING:"
-               << "\nOnly LatLon and UTM supported!\nReturning..."
-               << std::endl;
-            return false;		
-         }
+            return false;
 
-         // Get the datum.
-         ossimString datum = "WGS-84";
-         lookup = kwl.find(ossimKeywordNames::DATUM_KW);
+         theHdr.theProjection = utm;
+         theHdr.theCoordSysType = "EN";
+
+
+         //we get tie points
+         lookup = kwl.find(ossimKeywordNames::TIE_POINT_XY_KW);
+         tmp = lookup;
          if (lookup)
          {
-            ossimString os = lookup;
-            if (os == "WGE")
-            {
-               theHdr.theDatum = "WGS84";
-            }
-            else
-            {
-               ossimNotify(ossimNotifyLevel_WARN)
-                  << "ossimERSFileWriter::writeFile WARNING:"
-                  << "\nOnly WGS84 supported!\nReturning..."
-                  << std::endl;
-               return false; // Datum has to be WGS84 for now...
-            }
+            tmp = tmp.trim("(");
+            tmp = tmp.trim(")");
+            ossimString a = tmp.before(",", 0);
+            ossimString b = tmp.after(",", 0);
+            theHdr.theOriginX = a.toDouble();
+            theHdr.theOriginY = b.toDouble();
          }
-		
-         //get cell size
-         lookup = kwl.find(ossimKeywordNames::PIXEL_SCALE_XY_KW);
+         //set the tie point unit type to meters
+         theHdr.theTieUnitType = OSSIM_METERS;
+
+      }
+      else if (projection == "ossimEquDistCylProjection")
+      {
+         theHdr.theProjection = "GEODETIC";
+         theHdr.theCoordSysType = "LL";
+
+         //we get tie points
+         lookup = kwl.find(ossimKeywordNames::TIE_POINT_XY_KW);
          tmp = lookup;
          if (lookup)
          {
@@ -202,21 +150,64 @@ bool ossimERSFileWriter::writeFile()
             tmp = tmp.trim(")");
             ossimString a = tmp.before(",", 0);
             ossimString b = tmp.after(",", 0);
- 
-            theHdr.theCellSizeX = a.toDouble();
-            theHdr.theCellSizeY = b.toDouble();
+            theHdr.theOriginX = a.toDouble();
+            theHdr.theOriginY = b.toDouble();
          }
+         //set the tie point unit type to degrees
+         theHdr.theTieUnitType = OSSIM_DEGREES;
+
+      }
+      else
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimERSFileWriter::writeFile WARNING:"
+            << "\nOnly LatLon and UTM supported!\nReturning..."
+            << std::endl;
+         return false;		
+      }
 
-         //get pixel is area or point
-         if(thePixelType == OSSIM_PIXEL_IS_POINT)
+      // Get the datum.
+      ossimString datum = "WGS-84";
+      lookup = kwl.find(ossimKeywordNames::DATUM_KW);
+      if (lookup)
+      {
+         ossimString os = lookup;
+         if (os == "WGE")
          {
-            theHdr.theOriginX -= theHdr.theCellSizeX/2.0;
-            theHdr.theOriginY += theHdr.theCellSizeY/2.0;
+            theHdr.theDatum = "WGS84";
+         }
+         else
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
+               << "ossimERSFileWriter::writeFile WARNING:"
+               << "\nOnly WGS84 supported!\nReturning..."
+               << std::endl;
+            return false; // Datum has to be WGS84 for now...
          }
       }
 
+      //get cell size
+      lookup = kwl.find(ossimKeywordNames::PIXEL_SCALE_XY_KW);
+      tmp = lookup;
+      if (lookup)
+      {
+         tmp = tmp.trim("(");
+         tmp = tmp.trim(")");
+         ossimString a = tmp.before(",", 0);
+         ossimString b = tmp.after(",", 0);
+
+         theHdr.theCellSizeX = a.toDouble();
+         theHdr.theCellSizeY = b.toDouble();
+      }
+
+      //get pixel is area or point
+      if(thePixelType == OSSIM_PIXEL_IS_POINT)
+      {
+         theHdr.theOriginX -= theHdr.theCellSizeX/2.0;
+         theHdr.theOriginY += theHdr.theCellSizeY/2.0;
+      }
    }
-	   
+
    return theHdr.writeFile(theFilename);
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimERSTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimERSTileSource.cpp
index f75d9e00b25ddd7c6e1706c87c9d92f9093f94b1..ef6328e4effda4b01dcaa06b031659138ca0ca27 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimERSTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimERSTileSource.cpp
@@ -15,7 +15,7 @@
 // as the raster file but with an .ers extension.
 //
 //*******************************************************************
-//  $Id: ossimERSTileSource.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimERSTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimERSTileSource.h>
 #include <ossim/support_data/ossimERS.h>
@@ -141,28 +141,24 @@ bool ossimERSTileSource::open(const ossimFilename& fileName)
 }
    
 
-bool ossimERSTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                          const char* prefix)
+ossimImageGeometry* ossimERSTileSource::getImageGeometry()
 {
-   if (theGeometryKwl.getSize())
-   {
-      kwl = theGeometryKwl;
-      return true;
-   }
-   
+   if (theGeometry.valid())
+      return theGeometry.get();
+
    if(theHdr)
    {
-      
-      bool result = theHdr->toOssimProjectionGeom(kwl, prefix);
+      ossimKeywordlist kwl;
+      bool result = theHdr->toOssimProjectionGeom(kwl);
       if (result == true)
       {
-         // Capture for next time.
-         setImageGeometry(kwl);
+         theGeometry = new ossimImageGeometry;
+         theGeometry->loadState(kwl);
+         return theGeometry.get();
       }
-      return result;
    }
 
-   return false;
+   return 0;
 }
 
 bool ossimERSTileSource::loadState(const ossimKeywordlist& kwl,
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEastingNorthingCutter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEastingNorthingCutter.cpp
index e77a610a03f33db9c10c4af6bdff82e3da853085..d9f66309b5465d1dde53b321eaad09cc7118580c 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimEastingNorthingCutter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimEastingNorthingCutter.cpp
@@ -6,7 +6,7 @@
 //
 // Author:  Garrett Potts
 //
-// $Id: ossimEastingNorthingCutter.cpp 13711 2008-10-14 16:49:38Z gpotts $
+// $Id: ossimEastingNorthingCutter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 //----------------------------------------------------------------------------
 
 #include <sstream>
@@ -44,11 +44,6 @@ ossimEastingNorthingCutter::ossimEastingNorthingCutter(ossimImageSource* inputSo
 
 ossimEastingNorthingCutter::~ossimEastingNorthingCutter()
 {
-   if(theViewProjection)
-   {
-      delete theViewProjection;
-      theViewProjection = 0;
-   }
 }
 
 void ossimEastingNorthingCutter::setEastingNorthingRectangle(const ossimDpt& ul,
@@ -142,8 +137,7 @@ bool ossimEastingNorthingCutter::loadState(const ossimKeywordlist& kwl,
    return ossimRectangleCutFilter::loadState(kwl, prefix);
 }
 
-bool ossimEastingNorthingCutter::setView(ossimObject* baseObject,
-                                         bool ownsTheView)
+bool ossimEastingNorthingCutter::setView(ossimObject* baseObject)
 {
    ossimProjection* tempProj = PTR_CAST(ossimProjection,
                                         baseObject);
@@ -152,20 +146,8 @@ bool ossimEastingNorthingCutter::setView(ossimObject* baseObject,
       return false;
    }
    
-   if(theViewProjection)
-   {
-      delete theViewProjection;
-      theViewProjection = 0;
-   }
 
-   if(ownsTheView)
-   {
-      theViewProjection = tempProj;
-   }
-   else
-   {
-      theViewProjection = (ossimProjection*)tempProj->dup();
-   }
+   theViewProjection = tempProj;
 
    transformVertices();
 
@@ -174,12 +156,12 @@ bool ossimEastingNorthingCutter::setView(ossimObject* baseObject,
 
 ossimObject* ossimEastingNorthingCutter::getView()
 {
-   return theViewProjection;
+   return theViewProjection.get();
 }
 
 const ossimObject* ossimEastingNorthingCutter::getView()const
 {
-   return theViewProjection;
+   return theViewProjection.get();
 }
 
 void ossimEastingNorthingCutter::transformVertices()
@@ -194,7 +176,7 @@ void ossimEastingNorthingCutter::transformVertices()
    }
 
    ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection,
-                                          theViewProjection);
+                                          theViewProjection.get());
    ossimDpt ul;
    ossimDpt lr;
    ossimDpt easting;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp
index 483d0b5f7604e96a6083f22fb64cc525e5612be1..c34cb68aba46e408310a6cb0d0d6c94fe078bbba 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp
@@ -13,7 +13,7 @@
 // writing an ENVI (The Environment for Visualizing Images) header file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimEnviHeaderFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimEnviHeaderFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimEnviHeaderFileWriter.h>
 #include <ossim/base/ossimKeywordlist.h>
@@ -66,29 +66,23 @@ bool ossimEnviHeaderFileWriter::writeFile()
    theHdr.setBands(theInputConnection->getNumberOfOutputBands());
    
    // Get the geometry from the input.
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-
-   // Create the projection.
-   ossimMapProjection* mapProj =  NULL;
-   ossimRefPtr<ossimProjection> proj =
-      ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   if (proj.valid())
+   // Get the geometry from the input.
+   ossimMapProjection* mapProj = 0;
+   const ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
+   if (inputGeom)
+      mapProj = PTR_CAST(ossimMapProjection, inputGeom->getProjection());
+   if (mapProj)
    {
-      mapProj = PTR_CAST(ossimMapProjection, proj.get());
+      // Create the projection info.
+      ossimRefPtr<ossimMapProjectionInfo> projectionInfo
+         = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
+
+      // Set the tie points in the keyword list.
+      ossimKeywordlist kwl;
+      projectionInfo->getGeom(kwl);
 
-      if (mapProj)
-      {
-         // Create the projection info.
-         ossimRefPtr<ossimMapProjectionInfo> projectionInfo
-            = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
-         
-         // Set the tie points in the keyword list.
-         projectionInfo->getGeom(kwl);
-         
-         // Pass it on to envi header to set the map info string from geometry.
-         theHdr.setMapInfo(kwl);
-      }
+      // Pass it on to envi header to set the map info string from geometry.
+      theHdr.setMapInfo(kwl);
    }
 
    return theHdr.writeFile(theFilename);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEquationCombiner.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEquationCombiner.cpp
index 466c8141c014ec319f20fe2ec8d8fdff0c785692..61f1326f4f7dd282fc55cc4fd497ff69f38ad7cf 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimEquationCombiner.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimEquationCombiner.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimEquationCombiner.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimEquationCombiner.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <sstream>
@@ -398,16 +398,16 @@ ossimEquationCombiner::~ossimEquationCombiner()
       theLexer = NULL;
    }
 
-   if(theCastFilter)
+   if(theCastFilter.valid())
    {
-      delete theCastFilter;
-      theCastFilter = (ossimCastTileSourceFilter*)NULL;
+      theCastFilter->disconnect();
+      theCastFilter = 0;
    }
 
-   if(theCastOutputFilter)
+   if(theCastOutputFilter.valid())
    {
-      delete theCastOutputFilter;
-      theCastOutputFilter = NULL;
+      theCastOutputFilter->disconnect();
+      theCastOutputFilter = 0;
    }
    // make sure they are cleared
    clearStacks();
@@ -510,7 +510,7 @@ ossimRefPtr<ossimImageData> ossimEquationCombiner::getTile(
       
       ossimRefPtr<ossimImageData> outputTile =  parseEquation();
 
-      if(theCastOutputFilter)
+      if(theCastOutputFilter.valid())
       {
          outputTile = theCastOutputFilter->applyCast(outputTile);
       }
@@ -543,10 +543,9 @@ void ossimEquationCombiner::setOutputScalarType(ossimScalarType scalarType)
       {
          theOutputScalarType = OSSIM_FLOAT64;
       }
-      if(theCastOutputFilter)
+      if(theCastOutputFilter.valid())
       {
-         delete theCastOutputFilter;
-         theCastOutputFilter = NULL;
+         theCastOutputFilter = 0;
       }
 
       if(theOutputScalarType != OSSIM_FLOAT64)
@@ -633,7 +632,7 @@ void ossimEquationCombiner::initialize()
 
    theTile = ossimImageDataFactory::instance()->create(this, OSSIM_FLOAT64, getNumberOfOutputBands(), getTileWidth(), getTileHeight());
    theTile->initialize();
-   if(theCastOutputFilter)
+   if(theCastOutputFilter.valid())
    {
       theCastOutputFilter->initialize();
    }
@@ -2952,10 +2951,10 @@ bool ossimEquationCombiner::applyConvolution(ossimImageData* &result,
    ossimConnectableObject* obj = getInput(index);
    if(obj)
    {
-      ossimConvolutionSource* conv = new ossimConvolutionSource(NULL, m);
+      ossimRefPtr<ossimConvolutionSource> conv = new ossimConvolutionSource(NULL, m);
 
       conv->connectMyInputTo(0, obj);
-      theCastFilter->connectMyInputTo(0, conv);
+      theCastFilter->connectMyInputTo(0, conv.get());
       
       ossimRefPtr<ossimImageData> tempData =
          theCastFilter->getTile(theTile->getImageRectangle(),
@@ -2968,8 +2967,8 @@ bool ossimEquationCombiner::applyConvolution(ossimImageData* &result,
       {
          result = (ossimImageData*)theTile->dup();
       }
-
-      delete conv;
+      conv->disconnect();
+      conv = 0;
    }
    if(result)
    {
@@ -3010,11 +3009,11 @@ bool ossimEquationCombiner::applyBlurr(ossimImageData* &result,
    ossimConnectableObject* obj = getInput(index);
    if(obj)
    {
-      ossimConvolutionSource* conv = new ossimConvolutionSource(NULL,
+      ossimRefPtr<ossimConvolutionSource> conv = new ossimConvolutionSource(NULL,
                                                                 m);
 
       conv->connectMyInputTo(0, obj);
-      theCastFilter->connectMyInputTo(0, conv);
+      theCastFilter->connectMyInputTo(0, conv.get());
       theCastFilter->initialize();
 
       ossimRefPtr<ossimImageData> tempData =
@@ -3024,7 +3023,8 @@ bool ossimEquationCombiner::applyBlurr(ossimImageData* &result,
       {
          result = (ossimImageData*)tempData->dup();
       }
-      delete conv;
+      conv->disconnect();
+      conv = 0;
    }
 
    if(result)
@@ -3062,11 +3062,11 @@ bool ossimEquationCombiner::applyShift(ossimImageData* &result,
    ossimConnectableObject* obj = getInput(index);
    if(obj)
    {
-      ossimSubImageTileSource* shiftSource =
+      ossimRefPtr<ossimSubImageTileSource> shiftSource =
          new ossimSubImageTileSource(NULL, ossimIpt(x, y));
 
       shiftSource->connectMyInputTo(0, obj);
-      theCastFilter->connectMyInputTo(0, shiftSource);
+      theCastFilter->connectMyInputTo(0, shiftSource.get());
 
        ossimRefPtr<ossimImageData> tempData =
           theCastFilter->getTile(theTile->getImageRectangle(),
@@ -3075,7 +3075,8 @@ bool ossimEquationCombiner::applyShift(ossimImageData* &result,
        {
           result = (ossimImageData*)tempData->dup();
        }
-       delete shiftSource;
+      shiftSource->disconnect();
+      shiftSource = 0;
    }
 
    if(result)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFeatherMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFeatherMosaic.cpp
index 86582b4914f19d7043ab556323c61064167c306c..f48f0f3e6feb2a8cccde4889acc6fcc699335c7b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimFeatherMosaic.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimFeatherMosaic.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimFeatherMosaic.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimFeatherMosaic.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimFeatherMosaic.h>
 #include <ossim/base/ossimDpt.h>
@@ -30,7 +30,7 @@ ossimFeatherMosaic::ossimFeatherMosaic()
 {
 }
 
-ossimFeatherMosaic::ossimFeatherMosaic(std::vector<ossimImageSource*>& inputSources)
+ossimFeatherMosaic::ossimFeatherMosaic(ossimConnectableObject::ConnectableObjectList& inputSources)
    :ossimImageMosaic(inputSources),
     theInputFeatherInformation(NULL),
     theAlphaSum(NULL),
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFftFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFftFilter.cpp
index 88d49c68ff2c5248f976e83315fc7e38c86492dd..e0d24a6127dc69c42717e2042d18615ccee44ee4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimFftFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimFftFilter.cpp
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimFftFilter.cpp 11411 2007-07-27 13:53:51Z dburken $
+//  $Id: ossimFftFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimFftFilter.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
@@ -49,9 +49,9 @@ ossimFftFilter::ossimFftFilter(ossimObject* owner,
 
 ossimFftFilter::~ossimFftFilter()
 {
-   if(theScalarRemapper)
+   if(theScalarRemapper.valid())
    {
-      delete theScalarRemapper;
+      theScalarRemapper->disconnect();
       theScalarRemapper = 0;
    }
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFgdcFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFgdcFileWriter.cpp
index 3e9c1e3cb65f09de11436fa5e4d0685348b478ac..90e2282be83e6a2e095d45d7af0449d2dbfd04ea 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimFgdcFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimFgdcFileWriter.cpp
@@ -11,7 +11,7 @@
 // Committe (FGDC) format.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimFgdcFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimFgdcFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <fstream>
 using namespace std;
@@ -69,28 +69,11 @@ bool ossimFgdcFileWriter::writeFile()
    }
 
    // Get the geometry from the input.
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimFgdcFileWriter::writeFile debug:\n"
-         << "Geometry file:  " << kwl << endl;
-   }
+   ossimMapProjection* mapProj = 0;
+   const ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
+   if (inputGeom)
+      mapProj = PTR_CAST(ossimMapProjection, inputGeom->getProjection());
    
-   // Create the projection.
-   ossimRefPtr<ossimProjection> proj =
-      ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   if (!proj.valid())
-   {
-      ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimFgdcFileWriter::writeFile Could not create projection."
-         << endl;
-      return false;
-   }
-   
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj.get());
    if (!mapProj)
    {
       ossimNotify(ossimNotifyLevel_WARN)
@@ -101,8 +84,6 @@ bool ossimFgdcFileWriter::writeFile()
 
    ossimMapProjectionInfo mpi(mapProj, theInputConnection->getBoundingRect());
 
-   
-
    os << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
       << "<?xml-stylesheet type=\"text/xsl\" href=\"/common/fgdc_classic.xsl\" ?>\n";
    openTag(os, ossimString("metadata"),  true);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp
index 99d9da2e66fdea24239e0e6344b80048564b9a85..09f61973260485d153d18e4e7f1739abbac1eea8 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
@@ -8,7 +10,7 @@
 //
 // Contains class definition for ossimGeneralRasterTileSource.
 //*******************************************************************
-//  $Id: ossimGeneralRasterTileSource.cpp 13768 2008-10-22 19:32:18Z gpotts $
+//  $Id: ossimGeneralRasterTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGeneralRasterTileSource.h>
 #include <ossim/base/ossimConstants.h>
@@ -75,110 +77,140 @@ ossimGeneralRasterTileSource::~ossimGeneralRasterTileSource()
 ossimRefPtr<ossimImageData> ossimGeneralRasterTileSource::getTile(
    const ossimIrect& tile_rect, ossim_uint32 resLevel)
 {
-   if( !isOpen() || !isSourceEnabled() || !isValidRLevel(resLevel) )
+   if (theTile.valid())
    {
-      return ossimRefPtr<ossimImageData>();
+      // Image rectangle must be set prior to calling getTile.
+      theTile->setImageRectangle(tile_rect);
+      
+      if ( getTile( theTile.get(), resLevel ) == false )
+      {
+         if (theTile->getDataObjectStatus() != OSSIM_NULL)
+         {
+            theTile->makeBlank();
+         }
+      }
    }
    
-   // general rasters can have a subimage as an offset so let's make sure we 
-   // shift it if its in the header
-   ossimIrect zeroBasedTileRect = tile_rect - getSubImageOffset(resLevel);
+   return theTile;
+}
 
-   if (theOverview)
+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()) )
    {
-      if (resLevel || theOverview->hasR0())
+      //---
+      // 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)
       {
-         //---
-         // Overviews are not aware of sub image offsets so request a zero
-         // based rectangle.
-         //---
-         ossimRefPtr<ossimImageData> tile =
-            theOverview->getTile(zeroBasedTileRect, resLevel);
-         if (tile.valid())
+         if(getOutputScalarType() == OSSIM_USHORT11)
          {
             //---
-            // Since the overview request was zero based we must reset the
-            // rectangle to be relative to any sub image offset.
+            // Temp fix:
+            // The overview handler could return a tile of OSSIM_UINT16 if
+            // the max sample value was not set to 2047.
             //---
-            tile->setImageRectangle(tile_rect);
-            
-            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.
-               //---
-               tile->setScalarType(OSSIM_USHORT11);
-            }
+            result->setScalarType(OSSIM_USHORT11);
          }
-
-         return tile;
       }
-   }
+      
+      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);
 
-   theTile->setImageRectangle(zeroBasedTileRect);
-   
-   ossimIrect image_rect = ossimIrect(0, 
-				      0, 
-				      getNumberOfSamples(resLevel) - 1,
-				      getNumberOfLines(resLevel) - 1);
+            // This will reallocate the buffer if needed.
+            checkBuffer(tile_rect);
 
-   ossimIrect clip_rect = zeroBasedTileRect.clipToRect(image_rect);
-    
-   checkBuffer(tile_rect);
+            // Initialize the tile if needed as we're going to stuff it.
+            if (result->getDataObjectStatus() == OSSIM_NULL)
+            {
+               result->initialize();
+            }
 
-   //***
-   // Check origin to see if it falls with the image.  If not, return a
-   // blank chip.
-   //***
-   if ( zeroBasedTileRect.intersects(image_rect) )
-   {
-      if ( ! zeroBasedTileRect.completely_within(theBufferRect) )
-      {
-         // A new buffer must be loaded.
-         if ( !zeroBasedTileRect.completely_within(clip_rect) )
-         {
-            //***
-            // Start with a blank tile since the whole tile buffer will not be
-            // filled.
-            //***
-            theTile->makeBlank();
-         }
+            ossimIrect clip_rect = tile_rect.clipToRect(image_rect);
 
-         if(!fillBuffer(clip_rect.ul()))
+            if ( ! tile_rect.completely_within(theBufferRect) )
+            {
+               // 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();
+               }
+               
+               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..."
+                     << endl;
+                  //---
+                  // Error in filling buffer.
+                  //---
+                  setErrorStatus();
+                  status = false;
+               }
+            }
+            
+            result->loadTile(theBuffer,
+                             theBufferRect,
+                             clip_rect,
+                             theBufferInterleave);
+            result->validate();
+
+            // Set the rectangle back.
+            result->setImageRectangle(tile_rect);
+            
+         }
+         else // No intersection.
          {
-            ossimNotify(ossimNotifyLevel_WARN)
-               << "Error from fill buffer..."
-               << endl;
-            //***
-            // Error in filling buffer.
-            //***
-            setErrorStatus();
-            return ossimRefPtr<ossimImageData>();
+            result->makeBlank();
          }
       }
-         
-      theTile->loadTile(theBuffer,
-                        theBufferRect,
-                        clip_rect,
-                        theBufferInterleave);
-      theTile->validate();
    }
-   else
-   {
-      // tile does not intersect the image rectangle.
-      return ossimRefPtr<ossimImageData>();
-   }
-
-   return theTile;
-   
+   return status;
 }
 
 //*******************************************************************
 // Private Method:
 //*******************************************************************
-bool ossimGeneralRasterTileSource::fillBuffer(const ossimIpt& origin)
+     bool ossimGeneralRasterTileSource::fillBuffer(const ossimIpt& origin,
+                                                   const ossimIpt& size)
 {
    static const char MODULE[] = "ossimGeneralRasterTileSource::fillBuffer";
 
@@ -186,25 +218,26 @@ bool ossimGeneralRasterTileSource::fillBuffer(const ossimIpt& origin)
    bool status = false;
    switch (theImageData.interleaveType())
    {
-   case OSSIM_BIP:
-      status = fillBIP(origin);
-      break;
-   case OSSIM_BIL:
-      status = fillBIL(origin);
-      break;
-   case OSSIM_BSQ:
-      status = fillBSQ(origin);
-      break;
-   case OSSIM_BSQ_MULTI_FILE:
-      status = fillBsqMultiFile(origin);
-      break;
-   default:
-      ossimNotify(ossimNotifyLevel_WARN) << MODULE << " ERROR:\n"
-                                         << " Unsupported interleave type:  "
-                                         << ILUT.getEntryString(theImageData.interleaveType())
-                                         << endl;
+      case OSSIM_BIP:
+         status = fillBIP(origin, size);
+         break;
+      case OSSIM_BIL:
+         status = fillBIL(origin, size);
+         break;
+      case OSSIM_BSQ:
+         status = fillBSQ(origin, size);
+         break;
+      case OSSIM_BSQ_MULTI_FILE:
+         status = fillBsqMultiFile(origin, size);
+         break;
+      default:
+         ossimNotify(ossimNotifyLevel_WARN)
+            << MODULE << " ERROR:\n"
+            << " Unsupported interleave type:  "
+            << ILUT.getEntryString(theImageData.interleaveType())
+            << endl;
    }
-
+   
    if (status && theSwapBytesFlag)
    {
       ossimEndian oe;
@@ -219,7 +252,8 @@ bool ossimGeneralRasterTileSource::fillBuffer(const ossimIpt& origin)
 //*******************************************************************
 // Private Method:
 //*******************************************************************
-bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin)
+bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin,
+                                           const ossimIpt& size )
 {
    static const char MODULE[] = "ossimGeneralRasterTileSource::fillBIP";
    
@@ -228,9 +262,9 @@ bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin)
    //***
    theBufferRect.set_ul(origin);
 
-   theBufferRect.set_lry(min( (origin.y + (ossim_int32)theTile->getHeight() -1),
+   theBufferRect.set_lry(min( (origin.y + size.y -1),
                               theImageData.imageRect().lr().y));
-   theBufferRect.set_lrx(min( (origin.x + (ossim_int32)theTile->getWidth() -1),
+   theBufferRect.set_lrx(min( (origin.x + size.x -1),
                               theImageData.imageRect().lr().x));
    
    ossim_sint64 currentLine = origin.y;
@@ -270,7 +304,7 @@ bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin)
    
    ossim_uint8* buf = theBuffer;
 
-   ossim_uint64 height = theTile->getHeight();
+   ossim_uint64 height = size.y;
    
    while ((currentLine <= static_cast<ossim_sint64>(theImageData.imageRect().lr().y)) &&
           linesProcessed < height)
@@ -310,7 +344,8 @@ bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin)
 //*******************************************************************
 // Private Method:
 //*******************************************************************
-bool ossimGeneralRasterTileSource::fillBIL(const ossimIpt& origin)
+bool ossimGeneralRasterTileSource::fillBIL(const ossimIpt& origin,
+                                           const ossimIpt& size)
 {
    static const char MODULE[] = "ossimGeneralRasterTileSource::fillBIL";
    
@@ -318,9 +353,9 @@ bool ossimGeneralRasterTileSource::fillBIL(const ossimIpt& origin)
    // This will fill a buffer the full width of valid samples * tileHeight().
    //***
    theBufferRect.set_ul(origin);
-   theBufferRect.set_lry(min((origin.y + (ossim_int32)theTile->getHeight() - 1),
+   theBufferRect.set_lry(min((origin.y + size.y - 1),
                              theImageData.imageRect().lr().y));
-   theBufferRect.set_lrx(min((origin.x + (ossim_int32)theTile->getWidth() - 1),
+   theBufferRect.set_lrx(min((origin.x + size.x - 1),
                              theImageData.imageRect().lr().x));
    
    ossim_sint64 currentLine = origin.y;
@@ -351,7 +386,7 @@ bool ossimGeneralRasterTileSource::fillBIL(const ossimIpt& origin)
    }
 #endif
 
-   ossim_uint64 height    = theTile->getHeight();
+   ossim_uint64 height    = size.y;
    ossim_sint64 num_bands = theImageData.numberOfBands();
    
    while ((currentLine <= static_cast<ossim_sint64>(theImageData.imageRect().lr().y)) &&
@@ -398,7 +433,8 @@ bool ossimGeneralRasterTileSource::fillBIL(const ossimIpt& origin)
 //*******************************************************************
 // Private Method:
 //*******************************************************************
-bool ossimGeneralRasterTileSource::fillBSQ(const ossimIpt& origin)
+bool ossimGeneralRasterTileSource::fillBSQ(const ossimIpt& origin,
+                                           const ossimIpt& size)
 {
    static const char MODULE[] = "ossimGeneralRasterTileSource::fillBSQ";
 
@@ -407,9 +443,9 @@ bool ossimGeneralRasterTileSource::fillBSQ(const ossimIpt& origin)
    //***
    theBufferRect.set_ul(origin);
    
-   theBufferRect.set_lry(min((origin.y + (ossim_int32)theTile->getHeight() -1),
+   theBufferRect.set_lry(min((origin.y + size.y -1),
                              theImageData.imageRect().lr().y));
-   theBufferRect.set_lrx(min((origin.x + (ossim_int32)theTile->getWidth() - 1),
+   theBufferRect.set_lrx(min((origin.x + size.x - 1),
                              theImageData.imageRect().lr().x));
    
    //***
@@ -449,7 +485,7 @@ bool ossimGeneralRasterTileSource::fillBSQ(const ossimIpt& origin)
       = theImageData.bytesPerRawLine() * theImageData.rawLines();
 
    ossim_int32 num_bands = theImageData.numberOfBands();
-   ossim_int32 height    = theTile->getHeight();
+   ossim_int32 height    = size.y;
    
    for (ossim_int32 band = 0; band < num_bands; ++band)
    {
@@ -501,7 +537,8 @@ bool ossimGeneralRasterTileSource::fillBSQ(const ossimIpt& origin)
 //*******************************************************************
 // Private Method:
 //*******************************************************************
-bool ossimGeneralRasterTileSource::fillBsqMultiFile(const ossimIpt& origin)
+bool ossimGeneralRasterTileSource::fillBsqMultiFile(const ossimIpt& origin,
+                                                    const ossimIpt& size)
 {
    static const char MODULE[]
       = "ossimGeneralRasterTileSource::fillBsqMultiFile";
@@ -514,9 +551,9 @@ bool ossimGeneralRasterTileSource::fillBsqMultiFile(const ossimIpt& origin)
    //***
    theBufferRect.set_ul(origin);
    
-   theBufferRect.set_lry(min((origin.y + (ossim_int32)theTile->getHeight() -1),
+   theBufferRect.set_lry(min((origin.y + size.y -1),
                              theImageData.imageRect().lr().y));
-   theBufferRect.set_lrx(min((origin.x + (ossim_int32)theTile->getWidth() - 1),
+   theBufferRect.set_lrx(min((origin.x + size.x - 1),
                              theImageData.imageRect().lr().x));
    
    //***
@@ -552,7 +589,7 @@ bool ossimGeneralRasterTileSource::fillBsqMultiFile(const ossimIpt& origin)
 #endif
 
    ossim_int32 num_bands = theImageData.numberOfBands();
-   ossim_int32 height    = theTile->getHeight();
+   ossim_int32 height    = size.y;
    
    for (ossim_int32 band = 0; band < num_bands; ++band)
    {
@@ -601,29 +638,6 @@ bool ossimGeneralRasterTileSource::fillBsqMultiFile(const ossimIpt& origin)
    return true;
 }
 
-//*******************************************************************
-// Public Method:
-//*******************************************************************
-// ossimIrect
-// ossimGeneralRasterTileSource::getImageRectangle(ossim_uint32 reduced_res_level) const
-// {
-//   if(reduced_res_level < getNumberOfDecimationLevels())
-//     {
-//       ossimDpt decimation;
-//       getDecimationFactor(reduced_res_level, decimation);
-//       ossimIpt offset = theImageData.subImageOffset();
-//       offset.x = ossim::round<int>(offset.x*decimation.x);
-//       offset.y = ossim::round<int>(offset.y*decimation.y);
-      
-//       return ossimIrect(offset.x,                         // upper left x
-// 			offset.y,                         // upper left y
-// 			offset.x + getNumberOfSamples(reduced_res_level) - 1,  // lower right x
-// 			offset.y + getNumberOfLines(reduced_res_level)   - 1); // lower right y
-//     }
-//   ossimIrect result;
-//   result.makeNan();
-//   return result;
-// }
 //*******************************************************************
 // Public method:
 //*******************************************************************
@@ -689,7 +703,7 @@ ossimGeneralRasterTileSource::isValidRLevel(ossim_uint32 reduced_res_level) cons
    {
       return true;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->isValidRLevel(reduced_res_level);
    }
@@ -716,7 +730,7 @@ ossimGeneralRasterTileSource::getNumberOfLines(ossim_uint32 reduced_res_level) c
    {
       return theImageData.validLines();
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfLines(reduced_res_level);
    }
@@ -734,7 +748,7 @@ getNumberOfSamples(ossim_uint32 reduced_res_level) const
    {
       return theImageData.validSamples();
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfSamples(reduced_res_level);
    }
@@ -888,7 +902,7 @@ bool ossimGeneralRasterTileSource::initializeHandler()
       return false;
    }
    
-   theSubImageOffset = theImageData.subImageOffset();
+//   theSubImageOffset = theImageData.subImageOffset();
 
    ossim_uint32 number_of_bands = theImageData.numberOfBands();
 
@@ -1133,7 +1147,7 @@ ossimString ossimGeneralRasterTileSource::getLongName()const
    return ossimString("general raster reader");
 }
 
-ossimString ossimGeneralRasterTileSource::className()const
+ossimString ossimGeneralRasterTileSource::getClassName()const
 {
    return ossimString("ossimGeneralRasterTileSource");
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterWriter.cpp
index cca21c5c8ebb5b27046eeedad6eb282316ef2fab..751b69067f36542d8eabc6338af3b0581927bcb4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterWriter.cpp
@@ -6,7 +6,7 @@
 // Author:  David Burken
 //
 //*******************************************************************
-//  $Id: ossimGeneralRasterWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimGeneralRasterWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <fstream>
@@ -787,13 +787,13 @@ void ossimGeneralRasterWriter::writeEnviHeader() const
    ossimKeywordlist kwl;
    kwl.add(ossimKeywordNames::INTERLEAVE_TYPE_KW, interleaveType.c_str());
 
-   ossimEnviHeaderFileWriter hdr;
-   hdr.connectMyInputTo(0, theInputConnection);
-   hdr.initialize();
-   hdr.setFilename(headerFile);
-   hdr.loadState(kwl);
-   hdr.setAreaOfInterest(theAreaOfInterest);
-   hdr.execute();
+   ossimRefPtr<ossimEnviHeaderFileWriter> hdr = new ossimEnviHeaderFileWriter;
+   hdr->connectMyInputTo(0, theInputConnection.get());
+   hdr->initialize();
+   hdr->setFilename(headerFile);
+   hdr->loadState(kwl);
+   hdr->setAreaOfInterest(theAreaOfInterest);
+   hdr->execute();
    
    if (traceDebug()) CLOG << " Exited..." << endl;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp
index 1a95f094abeaeec56794a685245d86f5eddbb2aa..fe2544af231553871b72372e30d7b5fc0438245f 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationBitmap.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationBitmap.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGeoAnnotationBitmap.h>
 #include <ossim/projection/ossimProjection.h>
@@ -175,11 +175,11 @@ void ossimGeoAnnotationBitmap::getBoundingRect(ossimDrect& rect)const
    }
 }
 
-void ossimGeoAnnotationBitmap::transform(ossimProjection* projection)
+void ossimGeoAnnotationBitmap::transform(ossimImageGeometry* projection)
 {
    if(projection)
    {
-      projection->worldToLineSample(theCenterPoint, theProjectedPoint);
+      projection->worldToLocal(theCenterPoint, theProjectedPoint);
       theProjectedPoint = ossimIpt(theProjectedPoint);
       if(theImageData.valid())
       {
@@ -191,43 +191,6 @@ void ossimGeoAnnotationBitmap::transform(ossimProjection* projection)
    }
 }
 
-void ossimGeoAnnotationBitmap::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      projection->worldToLineSample(theCenterPoint, theProjectedPoint);
-      if (rrds)
-      {
-         // Transform r0 point to new rrds level.
-         try
-         {
-            ossimDpt rnPt;
-            model.r0ToRn(rrds, theProjectedPoint, rnPt);
-            theProjectedPoint = rnPt;
-            
-         }
-         catch (const ossimException& e)
-         {
-            ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-         }
-      }
-
-      // Not sure about cast???  drb.
-      // theProjectedPoint = ossimIpt(theProjectedPoint);
-      
-      if(theImageData.valid())
-      {
-         ossimDpt origin(theProjectedPoint.x - theImageData->getWidth()/2.0,
-                         theProjectedPoint.y - theImageData->getHeight()/2.0);
-         
-         theImageData->setOrigin(origin);
-      } 
-   }
-      
-}
-
 void ossimGeoAnnotationBitmap::setImageData(
    ossimRefPtr<ossimImageData>& imageData)
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationEllipseObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationEllipseObject.cpp
index 79ddc572bf0d8b0867e366fd9363a4aaebb43f6a..4866c29a2dde19aa18d6671a9b9f0ded3f8a57e2 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationEllipseObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationEllipseObject.cpp
@@ -5,12 +5,11 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationEllipseObject.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationEllipseObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 
 #include <ossim/imaging/ossimGeoAnnotationEllipseObject.h>
-#include <ossim/imaging/ossimAnnotationEllipseObject.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/projection/ossimImageProjectionModel.h>
 #include <ossim/base/ossimException.h>
@@ -47,7 +46,7 @@ ossimGeoAnnotationEllipseObject::ossimGeoAnnotationEllipseObject(
 ossimGeoAnnotationEllipseObject::ossimGeoAnnotationEllipseObject(
    const ossimGeoAnnotationEllipseObject& rhs)
    :ossimGeoAnnotationObject(rhs),
-    theProjectedEllipse(rhs.theProjectedEllipse?(ossimAnnotationEllipseObject*)rhs.theProjectedEllipse->dup():(ossimAnnotationEllipseObject*)0),
+    theProjectedEllipse(rhs.theProjectedEllipse.valid()?(ossimAnnotationEllipseObject*)rhs.theProjectedEllipse->dup():(ossimAnnotationEllipseObject*)0),
     theCenter(rhs.theCenter),
     theWidthHeight(rhs.theWidthHeight),
     theEllipseWidthHeightUnitType(rhs.theEllipseWidthHeightUnitType)
@@ -56,9 +55,8 @@ ossimGeoAnnotationEllipseObject::ossimGeoAnnotationEllipseObject(
 
 ossimGeoAnnotationEllipseObject::~ossimGeoAnnotationEllipseObject()
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
-      delete theProjectedEllipse;
       theProjectedEllipse = 0;
    }
 }
@@ -71,7 +69,7 @@ ossimObject* ossimGeoAnnotationEllipseObject::dup()const
 void ossimGeoAnnotationEllipseObject::applyScale(double x,
                                                  double y)
 {
-   if(theProjectedEllipse) theProjectedEllipse->applyScale(x, y);
+   if(theProjectedEllipse.valid()) theProjectedEllipse->applyScale(x, y);
    theCenter.lond(theCenter.lond()*x);
    theCenter.latd(theCenter.latd()*y);
    theWidthHeight .x *= x;
@@ -89,7 +87,7 @@ std::ostream& ossimGeoAnnotationEllipseObject::print(std::ostream& out)const
 
 void ossimGeoAnnotationEllipseObject::draw(ossimRgbImage& anImage)const
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->draw(anImage);
    }
@@ -97,7 +95,7 @@ void ossimGeoAnnotationEllipseObject::draw(ossimRgbImage& anImage)const
 
 bool ossimGeoAnnotationEllipseObject::intersects(const ossimDrect& rect)const
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->intersects(rect);
    }
@@ -109,7 +107,7 @@ ossimAnnotationObject* ossimGeoAnnotationEllipseObject::getNewClippedObject(cons
 {
    if(intersects(rect))
    {
-      if(theProjectedEllipse)
+      if(theProjectedEllipse.valid())
       {
          return theProjectedEllipse->getNewClippedObject(rect);
       }
@@ -120,7 +118,7 @@ ossimAnnotationObject* ossimGeoAnnotationEllipseObject::getNewClippedObject(cons
 
 void ossimGeoAnnotationEllipseObject::getBoundingRect(ossimDrect& rect)const
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->getBoundingRect(rect);
    }
@@ -132,13 +130,13 @@ void ossimGeoAnnotationEllipseObject::getBoundingRect(ossimDrect& rect)const
 
 void ossimGeoAnnotationEllipseObject::computeBoundingRect()
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->computeBoundingRect();
    }
 }
 
-void ossimGeoAnnotationEllipseObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationEllipseObject::transform(ossimImageGeometry* projection)
 {
    if(!projection)
    {
@@ -150,7 +148,7 @@ void ossimGeoAnnotationEllipseObject::transform(ossimProjection* projection)
    ossimDpt projectedWidthHeight;
 
    // first get the center projected
-   projection->worldToLineSample(theCenter, projectedCenter);
+   projection->worldToLocal(theCenter, projectedCenter);
 
    getWidthHeightInPixels(projectedWidthHeight, projection);
 
@@ -158,44 +156,6 @@ void ossimGeoAnnotationEllipseObject::transform(ossimProjection* projection)
                                              projectedWidthHeight);      
 }
 
-void ossimGeoAnnotationEllipseObject::transform(
-   const ossimImageProjectionModel& model,
-   ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-
-      // Ellipse center, height and width in image space.
-      ossimDpt projectedCenter;
-      ossimDpt projectedWidthHeight;
-
-      // first get the center projected
-      projection->worldToLineSample(theCenter, projectedCenter);
-      
-      if (rrds)
-      {
-         // Transform r0 point to new rrds level.
-         try
-         {
-            ossimDpt rnPt;
-            model.r0ToRn(rrds, projectedCenter, rnPt);
-            projectedCenter = rnPt;
-            
-         }
-         catch (const ossimException& e)
-         {
-            ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-         }
-      }
-
-      getWidthHeightInPixels(projectedWidthHeight, projection);
-      
-      theProjectedEllipse->setCenterWidthHeight(projectedCenter,
-                                                projectedWidthHeight);
-   }
-}
-
 bool ossimGeoAnnotationEllipseObject::saveState(ossimKeywordlist& kwl,
                                                 const char* prefix) const
 {
@@ -292,7 +252,7 @@ void ossimGeoAnnotationEllipseObject::setWidthHeight(const ossimDpt& pt)
 
 void ossimGeoAnnotationEllipseObject::setAzimuth(ossim_float64 azimuth)
 {
-   if (theProjectedEllipse)
+   if (theProjectedEllipse.valid())
    {
       theProjectedEllipse->setAzimuth(azimuth);
    }
@@ -300,7 +260,7 @@ void ossimGeoAnnotationEllipseObject::setAzimuth(ossim_float64 azimuth)
    
 ossim_float64 ossimGeoAnnotationEllipseObject::getAzimuth() const
 {
-   if (theProjectedEllipse)
+   if (theProjectedEllipse.valid())
    {
       return theProjectedEllipse->getAzimuth();
    }
@@ -308,7 +268,7 @@ ossim_float64 ossimGeoAnnotationEllipseObject::getAzimuth() const
 }
 
 void ossimGeoAnnotationEllipseObject::getWidthHeightInPixels(
-   ossimDpt& widthHeight, const ossimProjection* projection) const
+   ossimDpt& widthHeight, const ossimImageGeometry* projection) const
 {
    switch (theEllipseWidthHeightUnitType)
    {
@@ -323,8 +283,8 @@ void ossimGeoAnnotationEllipseObject::getWidthHeightInPixels(
       case OSSIM_MINUTES:
       case OSSIM_SECONDS:
       {
-         ossimGpt origin = projection->origin();
-         ossimDpt gsd = projection->getMetersPerPixel();
+         ossimGpt origin = projection->hasProjection()?projection->getProjection()->origin():ossimGpt();
+         ossimDpt gsd    = projection->getMetersPerPixel();
          
          ossimUnitConversionTool uct(origin,
                                      theWidthHeight.x,
@@ -375,7 +335,7 @@ void ossimGeoAnnotationEllipseObject::setColor(ossim_uint8 r,
                                                ossim_uint8 g,
                                                ossim_uint8 b)
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->setColor(r, g, b);
    }
@@ -384,7 +344,7 @@ void ossimGeoAnnotationEllipseObject::setColor(ossim_uint8 r,
 
 void ossimGeoAnnotationEllipseObject::setThickness(ossim_uint8 thickness)
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->setThickness(thickness);
    }
@@ -392,7 +352,7 @@ void ossimGeoAnnotationEllipseObject::setThickness(ossim_uint8 thickness)
 
 void ossimGeoAnnotationEllipseObject::setFillFlag(bool flag)
 {
-   if(theProjectedEllipse)
+   if(theProjectedEllipse.valid())
    {
       theProjectedEllipse->setFillFlag(flag);
    }
@@ -400,7 +360,7 @@ void ossimGeoAnnotationEllipseObject::setFillFlag(bool flag)
 
 bool ossimGeoAnnotationEllipseObject::getFillFlag() const
 {
-   if (theProjectedEllipse)
+   if (theProjectedEllipse.valid())
    {
       return theProjectedEllipse->getFillFlag();
    }
@@ -409,7 +369,7 @@ bool ossimGeoAnnotationEllipseObject::getFillFlag() const
 
 void ossimGeoAnnotationEllipseObject::setDrawAxesFlag(bool flag)
 {
-   if (theProjectedEllipse)
+   if (theProjectedEllipse.valid())
    {
       theProjectedEllipse->setDrawAxesFlag(flag);
    }
@@ -417,7 +377,7 @@ void ossimGeoAnnotationEllipseObject::setDrawAxesFlag(bool flag)
 
 bool ossimGeoAnnotationEllipseObject::getDrawAxesFlag() const
 {
-   if (theProjectedEllipse)
+   if (theProjectedEllipse.valid())
    {
       return theProjectedEllipse->getDrawAxesFlag();
    }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp
index 32f0711f311ac56c39b0234b83bd0a6c042ea53a..e76551db4bddc2b81ac7dd327774f4992679bead 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp
@@ -4,7 +4,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-//$Id: ossimGeoAnnotationFontObject.cpp 13965 2009-01-14 16:30:52Z gpotts $
+//$Id: ossimGeoAnnotationFontObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 
@@ -43,7 +43,7 @@ ossimGeoAnnotationFontObject::ossimGeoAnnotationFontObject()
       new ossimAnnotationFontObject(ossimIpt(0,0),
                                     ossimString(""));
    
-   theAnnotationFontObject->setFont(theFont, false);
+   theAnnotationFontObject->setFont(theFont.get());
    
 }
 
@@ -83,7 +83,7 @@ ossimGeoAnnotationFontObject::ossimGeoAnnotationFontObject(
    :
    ossimGeoAnnotationObject(rhs),
    theCenterGround(rhs.theCenterGround),
-   theFont(rhs.theFont?(ossimFont*)rhs.theFont->dup():(ossimFont*)NULL),
+   theFont(rhs.theFont.valid()?(ossimFont*)rhs.theFont->dup():(ossimFont*)NULL),
    theFontInfo(),
    theAnnotationFontObject(
       new ossimAnnotationFontObject(
@@ -99,21 +99,13 @@ ossimGeoAnnotationFontObject::ossimGeoAnnotationFontObject(
          rhs.theGreen,
          rhs.theBlue))
 {
-   theAnnotationFontObject->setFont(theFont, false);
+   theAnnotationFontObject->setFont(theFont.get());
 }
 
 ossimGeoAnnotationFontObject::~ossimGeoAnnotationFontObject()
 {
-   if(theAnnotationFontObject)
-   {
-      delete theAnnotationFontObject;
-      theAnnotationFontObject = NULL;
-   }
-   if(theFont)
-   {
-      delete theFont;
-      theFont = NULL;
-   }
+   theAnnotationFontObject = 0;
+   theFont = 0;
 }
 
 ossimObject* ossimGeoAnnotationFontObject::dup()const
@@ -124,24 +116,19 @@ ossimObject* ossimGeoAnnotationFontObject::dup()const
 
 void ossimGeoAnnotationFontObject::setFont(ossimFont* font)
 {
-   if(theFont)
-   {
-     delete theFont;
-     theFont = NULL;
-   }
    theFont = font;
 
-   theAnnotationFontObject->setFont(theFont, false);
+   theAnnotationFontObject->setFont(theFont.get());
 }
 
 ossimFont* ossimGeoAnnotationFontObject::getFont()
 {
-   return theFont;
+   return theFont.get();
 }
 
 void ossimGeoAnnotationFontObject::setPointSize(const ossimIpt& size)
 {
-   if(theAnnotationFontObject)
+   if(theAnnotationFontObject.valid())
    {
       theAnnotationFontObject->setPointSize(size);
    }
@@ -149,7 +136,7 @@ void ossimGeoAnnotationFontObject::setPointSize(const ossimIpt& size)
 
 void ossimGeoAnnotationFontObject::setRotation(double rotation)
 {
-   if(theAnnotationFontObject)
+   if(theAnnotationFontObject.valid())
    {
       theAnnotationFontObject->setRotation(rotation);
    }
@@ -157,7 +144,7 @@ void ossimGeoAnnotationFontObject::setRotation(double rotation)
 
 void ossimGeoAnnotationFontObject::setScale(const ossimDpt& scale)
 {
-   if(theAnnotationFontObject)
+   if(theAnnotationFontObject.valid())
    {
       theAnnotationFontObject->setScale(scale);
    }
@@ -165,7 +152,7 @@ void ossimGeoAnnotationFontObject::setScale(const ossimDpt& scale)
 
 void ossimGeoAnnotationFontObject::setShear(const ossimDpt& shear)
 {
-   if(theAnnotationFontObject)
+   if(theAnnotationFontObject.valid())
    {
       theAnnotationFontObject->setShear(shear);
    }
@@ -175,53 +162,24 @@ void ossimGeoAnnotationFontObject::setColor(ossim_uint8 r,
                                             ossim_uint8 g,
                                             ossim_uint8 b)
 {
-   if(theAnnotationFontObject)
+   if(theAnnotationFontObject.valid())
    {
       theAnnotationFontObject->setColor(r, g, b);
    }
 }
 
-void ossimGeoAnnotationFontObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationFontObject::transform(ossimImageGeometry* projection)
 {
    if(projection)
    {
       ossimDpt ipt;
 
-      projection->worldToLineSample(theCenterGround, ipt);
+      projection->worldToLocal(theCenterGround, ipt);
       theAnnotationFontObject->setCenterPosition(ipt);
       theAnnotationFontObject->computeBoundingRect();
    }
 }
 
-void ossimGeoAnnotationFontObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      ossimDpt projectedCenter;
-      projection->worldToLineSample(theCenterGround, projectedCenter);
-
-      if (rrds)
-      {
-         // Transform r0 point to new rrds level.
-         try
-         {
-            ossimDpt rnPt;
-            model.r0ToRn(rrds, projectedCenter, rnPt);
-            projectedCenter = rnPt; 
-            
-         }
-         catch (const ossimException& e)
-         {
-            ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-         }
-      }
-      theAnnotationFontObject->setCenterPosition(projectedCenter);
-      theAnnotationFontObject->computeBoundingRect();
-   }
-}
-
 void ossimGeoAnnotationFontObject::setCenterGround(const ossimGpt& gpt)
 {
    theCenterGround = gpt;
@@ -229,7 +187,7 @@ void ossimGeoAnnotationFontObject::setCenterGround(const ossimGpt& gpt)
 
 ossimAnnotationFontObject* ossimGeoAnnotationFontObject::getFontObject()
 {
-   return theAnnotationFontObject;
+   return theAnnotationFontObject.get();
 }
 
 void ossimGeoAnnotationFontObject::draw(ossimRgbImage& anImage)const
@@ -303,16 +261,12 @@ bool ossimGeoAnnotationFontObject::loadState(const ossimKeywordlist& kwl,
    theFontInfo.loadState(kwl, prefix);
 
    // See if we can make a font.
-   ossimFont* f = ossimFontFactoryRegistry::instance()->
+   ossimRefPtr<ossimFont> f = ossimFontFactoryRegistry::instance()->
       createFont(theFontInfo);
-   if (f)
+   if (f.valid())
    {
-      if (theFont)
-      {
-         delete theFont;
-      }
       theFont = f;
-      theAnnotationFontObject->setFont(theFont, false);
+      theAnnotationFontObject->setFont(theFont.get());
    }
 
    theAnnotationFontObject->setGeometryInformation(theFontInfo);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp
index ff948885edcdccc64588d6b43518121d672763a2..67f69995e92cb9fcd668e0df0e508ad51069ea1e 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationGdBitmapFont.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationGdBitmapFont.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimGeoAnnotationGdBitmapFont.h>
 #include <ossim/imaging/ossimAnnotationGdBitmapFont.h>
 #include <ossim/projection/ossimProjection.h>
@@ -38,18 +38,14 @@ ossimGeoAnnotationGdBitmapFont::ossimGeoAnnotationGdBitmapFont(const ossimGpt& p
 
 ossimGeoAnnotationGdBitmapFont::ossimGeoAnnotationGdBitmapFont(const ossimGeoAnnotationGdBitmapFont& rhs)
    :ossimGeoAnnotationObject(rhs),
-    theProjectedFont(rhs.theProjectedFont?(ossimAnnotationGdBitmapFont*)theProjectedFont->dup():(ossimAnnotationGdBitmapFont*)0),
+    theProjectedFont(rhs.theProjectedFont.valid()?(ossimAnnotationGdBitmapFont*)theProjectedFont->dup():(ossimAnnotationGdBitmapFont*)0),
     thePosition(rhs.thePosition)
 {
 }
 
 ossimGeoAnnotationGdBitmapFont::~ossimGeoAnnotationGdBitmapFont()
 {
-   if(theProjectedFont)
-   {
-      delete theProjectedFont;
-      theProjectedFont=0;
-   }
+   theProjectedFont=0;
 }
 
 ossimObject* ossimGeoAnnotationGdBitmapFont::dup()const
@@ -62,7 +58,7 @@ void ossimGeoAnnotationGdBitmapFont::applyScale(double x, double y)
    thePosition.lond(thePosition.lond()*x);
    thePosition.latd(thePosition.latd()*y);
 
-   if(theProjectedFont)
+   if(theProjectedFont.valid())
    {
       theProjectedFont->applyScale(x, y);
    }
@@ -87,7 +83,7 @@ void ossimGeoAnnotationGdBitmapFont::getBoundingRect(ossimDrect& rect)const
 
 bool ossimGeoAnnotationGdBitmapFont::intersects(const ossimDrect& rect)const
 {
-   if(theProjectedFont)
+   if(theProjectedFont.valid())
    {
       return theProjectedFont->intersects(rect);
    }
@@ -99,7 +95,7 @@ ossimAnnotationObject* ossimGeoAnnotationGdBitmapFont::getNewClippedObject(const
 {
    if(intersects(rect))
    {
-      if(theProjectedFont)
+      if(theProjectedFont.valid())
       {
          return theProjectedFont->getNewClippedObject(rect);
       }
@@ -113,40 +109,13 @@ void ossimGeoAnnotationGdBitmapFont::computeBoundingRect()
    theProjectedFont->computeBoundingRect();
 }
 
-void ossimGeoAnnotationGdBitmapFont::transform(ossimProjection* projection)
+void ossimGeoAnnotationGdBitmapFont::transform(ossimImageGeometry* projection)
 {
    ossimDpt position;
-   projection->worldToLineSample(thePosition, position);
+   projection->worldToLocal(thePosition, position);
    theProjectedFont->setUpperLeftTextPosition(position);
 }
 
-void ossimGeoAnnotationGdBitmapFont::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      ossimDpt position;
-      projection->worldToLineSample(thePosition, position);
-      
-      if (rrds)
-      {
-         // Transform r0 point to new rrds level.
-         try
-         {
-            ossimDpt rnPt;
-            model.r0ToRn(rrds, position, rnPt);
-            position = rnPt;
-         }
-         catch (const ossimException& e)
-         {
-            ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-         }
-      }
-      theProjectedFont->setUpperLeftTextPosition(position);
-   }
-}
-
 void ossimGeoAnnotationGdBitmapFont::setText(const ossimString& text)
 {
    theProjectedFont->setText(text);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationLineObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationLineObject.cpp
index b5e3ba0db652d55227c8a17772bcddd58ce9e59b..f33083987d44eae24c77a4524eafaad8dcd23fef 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationLineObject.cpp
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationLineObject.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationLineObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimGeoAnnotationLineObject.h>
 #include <ossim/imaging/ossimAnnotationLineObject.h>
 #include <ossim/projection/ossimProjection.h>
@@ -74,48 +74,15 @@ void ossimGeoAnnotationLineObject::applyScale(double x, double y)
    }
 }
 
-void ossimGeoAnnotationLineObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationLineObject::transform(ossimImageGeometry* projection)
 {
    if(projection)
    {
       ossimDpt projectedStart;
       ossimDpt projectedEnd;
       
-      projection->worldToLineSample(theStart, projectedStart);
-      projection->worldToLineSample(theEnd,   projectedEnd);
-
-      theProjectedLineObject->setLine(projectedStart, projectedEnd);
-   }
-}
-
-void ossimGeoAnnotationLineObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      ossimDpt projectedStart;
-      ossimDpt projectedEnd;
-      projection->worldToLineSample(theStart, projectedStart);
-      projection->worldToLineSample(theEnd,   projectedEnd);
-
-      if (rrds)
-      {
-         // Transform r0 point to new rrds level.
-         try
-         {
-            ossimDpt startRnPt;
-            ossimDpt endRnPt;
-            model.r0ToRn(rrds, projectedStart, startRnPt);
-            model.r0ToRn(rrds, projectedEnd,   endRnPt);
-            projectedStart = startRnPt;
-            projectedEnd   = endRnPt;
-         }
-         catch (const ossimException& e)
-         {
-            ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-         }
-      }
+      projection->worldToLocal(theStart, projectedStart);
+      projection->worldToLocal(theEnd,   projectedEnd);
 
       theProjectedLineObject->setLine(projectedStart, projectedEnd);
    }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp
index a559812f73c72ae0a43239fcc09d5a178fbf6a47..b2a3bc3458e766a8756a5afcfe7ef2040dbec80b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiEllipseObject.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationMultiEllipseObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h>
 #include <ossim/imaging/ossimAnnotationMultiEllipseObject.h>
@@ -61,55 +61,18 @@ ossimGeoAnnotationMultiEllipseObject::ossimGeoAnnotationMultiEllipseObject(const
 }
    
 void ossimGeoAnnotationMultiEllipseObject::transform(
-   ossimProjection* projection)
+   ossimImageGeometry* projection)
 {
    const std::vector<ossimGpt>::size_type BOUNDS = thePointList.size();
    theProjectedObject->resize(BOUNDS);
    for(std::vector<ossimGpt>::size_type i = 0; i < BOUNDS; ++i)
    {
-      projection->worldToLineSample(thePointList[i], (*theProjectedObject)[i]);
+      projection->worldToLocal(thePointList[i], (*theProjectedObject)[i]);
       
    }
    computeBoundingRect();
 }
 
-void ossimGeoAnnotationMultiEllipseObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      const std::vector<ossimGpt>::size_type BOUNDS = thePointList.size();
-      theProjectedObject->resize(BOUNDS);
-
-      for (std::vector<ossimGpt>::size_type i = 0; i < BOUNDS; ++i)
-      {
-         ossimDpt r0Pt;
-         projection->worldToLineSample(thePointList[i], r0Pt);
-         
-         if (rrds)
-         {
-            // Transform r0 point to new rrds level.
-            try
-            {
-               ossimDpt rnPt;
-               model.r0ToRn(rrds, r0Pt, rnPt);
-               (*theProjectedObject)[i] = rnPt;
-            }
-            catch (const ossimException& e)
-            {
-               ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-            }
-         }
-         else
-         {
-            (*theProjectedObject)[i] = r0Pt;
-         }
-      }
-      computeBoundingRect();
-   }
-}
-
 void ossimGeoAnnotationMultiEllipseObject::setFillFlag(bool fillFlag)
 {
    theProjectedObject->setFillFlag(fillFlag);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.cpp
index c042e7988edd227a54e2b12525eab3c18caa66ae..2e2ae17ec187d52874ffbfb62ef0d36bc8bc74d4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiPolyLineObject.cpp 13711 2008-10-14 16:49:38Z gpotts $
+// $Id: ossimGeoAnnotationMultiPolyLineObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 
@@ -55,7 +55,7 @@ ossimGeoAnnotationMultiPolyLineObject::ossimGeoAnnotationMultiPolyLineObject(
     theMultiPolyLine(rhs.theMultiPolyLine),
     theBoundingRect(rhs.theBoundingRect),
     theDatum(rhs.theDatum),
-    theProjectedPolyLineObject(rhs.theProjectedPolyLineObject?(ossimAnnotationMultiPolyLineObject*)rhs.theProjectedPolyLineObject->dup():0)
+    theProjectedPolyLineObject(rhs.theProjectedPolyLineObject.valid()?(ossimAnnotationMultiPolyLineObject*)rhs.theProjectedPolyLineObject->dup():0)
 {
 }
 
@@ -66,11 +66,7 @@ ossimObject* ossimGeoAnnotationMultiPolyLineObject::dup()const
 
 ossimGeoAnnotationMultiPolyLineObject::~ossimGeoAnnotationMultiPolyLineObject()
 {
-   if(theProjectedPolyLineObject)
-   {
-      delete theProjectedPolyLineObject;
-      theProjectedPolyLineObject = 0;
-   }
+   theProjectedPolyLineObject = 0;
 }
 
 void ossimGeoAnnotationMultiPolyLineObject::applyScale(double x, double y)
@@ -80,7 +76,7 @@ void ossimGeoAnnotationMultiPolyLineObject::applyScale(double x, double y)
       << endl;
 }
 
-void ossimGeoAnnotationMultiPolyLineObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationMultiPolyLineObject::transform(ossimImageGeometry* projection)
 {
    if(!projection)
    {
@@ -117,7 +113,7 @@ void ossimGeoAnnotationMultiPolyLineObject::transform(ossimProjection* projectio
          tempPoint.latd(theMultiPolyLine[polyI][pointI].lat);
          tempPoint.lond(theMultiPolyLine[polyI][pointI].lon);
          ossimDpt temp;
-         projection->worldToLineSample(tempPoint, temp);
+         projection->worldToLocal(tempPoint, temp);
          if(!temp.hasNans())
          {
 	    multiPolyLine[polyI].addPoint(temp);
@@ -127,74 +123,6 @@ void ossimGeoAnnotationMultiPolyLineObject::transform(ossimProjection* projectio
    }
 }
 
-void ossimGeoAnnotationMultiPolyLineObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      allocateProjectedPolyLine();
-
-      //---
-      // NOTE:
-      // allocateProjectedPolygon() will set theProjectedPolyLineObject to 0 if
-      // theMultiPolyLine is empty (theMultiPolyLine.size() == 0).  So check
-      // before accessing pointer to avoid a core dump.
-      //---
-      if(theProjectedPolyLineObject)
-      {
-         std::vector<ossimPolyLine>& multiPolyLine =
-            theProjectedPolyLineObject->getMultiPolyLine();
-         ossimGpt tempPoint(0,0, ossim::nan(), theDatum);
-   
-         for(vector<ossimPolyLine>::size_type polyI = 0;
-             polyI < theMultiPolyLine.size();
-             ++polyI)
-         {
-            ossimPolyLine polyLine;
-            
-            ossim_uint32 numberOfVertices =
-               theMultiPolyLine[polyI].getNumberOfVertices();
-            for(ossim_uint32 pointI = 0; pointI < numberOfVertices; ++pointI)
-            {
-               tempPoint.latd(theMultiPolyLine[polyI][pointI].lat);
-               tempPoint.lond(theMultiPolyLine[polyI][pointI].lon);
-               ossimDpt r0Pt;
-               projection->worldToLineSample(tempPoint, r0Pt);
-               if ( !r0Pt.hasNans() )
-               {
-                  if (rrds)
-                  {
-                     // Transform r0 point to new rrds level.
-                     try
-                     {
-                        ossimDpt rnPt;
-                        model.r0ToRn(rrds, r0Pt, rnPt);
-                        multiPolyLine[polyI].addPoint(rnPt);
-                     }
-                     catch (const ossimException& e)
-                     {
-                        ossimNotify(ossimNotifyLevel_WARN)
-                           << e.what() << std::endl;
-                     } 
-                  }
-                  else
-                  {
-                     multiPolyLine[polyI].addPoint(r0Pt);
-                  }
-               }
-               
-            } // End point loop
-            
-            multiPolyLine[polyI].roundToIntegerBounds(true);
-            
-         } // End poly line loop
-         
-      } // End if (theProjectedPolyLineObject)
-      
-   } // End if (projection)
-}
-
 std::ostream& ossimGeoAnnotationMultiPolyLineObject::print(std::ostream& out)const
 {
    ossimNotify(ossimNotifyLevel_INFO)
@@ -222,7 +150,7 @@ ossimAnnotationObject* ossimGeoAnnotationMultiPolyLineObject::getNewClippedObjec
 
 void ossimGeoAnnotationMultiPolyLineObject::draw(ossimRgbImage& anImage)const
 {
-   if(theProjectedPolyLineObject)
+   if(theProjectedPolyLineObject.valid())
    {
       theProjectedPolyLineObject->draw(anImage);
    }
@@ -241,11 +169,7 @@ void ossimGeoAnnotationMultiPolyLineObject::addPoint(ossim_uint32 polygonIndex,
       theMultiPolyLine[polygonIndex].addPoint(pt);
       
       // we will have to reset the projected polygon
-      if(theProjectedPolyLineObject)
-      {
-         delete theProjectedPolyLineObject;
-         theProjectedPolyLineObject = 0;
-      }
+      theProjectedPolyLineObject = 0;
    }
 }
 
@@ -253,17 +177,13 @@ void ossimGeoAnnotationMultiPolyLineObject::setMultiPolyLine(
    const vector<ossimPolyLine>& multiPoly)
 {
    theMultiPolyLine = multiPoly;
-   if(theProjectedPolyLineObject)
-   {
-      delete theProjectedPolyLineObject;
-      theProjectedPolyLineObject = 0;
-   }
+   theProjectedPolyLineObject = 0;
 }
 
 void ossimGeoAnnotationMultiPolyLineObject::computeBoundingRect()
 {
    theBoundingRect.makeNan();
-   if(theProjectedPolyLineObject)
+   if(theProjectedPolyLineObject.valid())
    {
       theProjectedPolyLineObject->computeBoundingRect();
       theProjectedPolyLineObject->getBoundingRect(theBoundingRect);
@@ -273,7 +193,7 @@ void ossimGeoAnnotationMultiPolyLineObject::computeBoundingRect()
 
 bool ossimGeoAnnotationMultiPolyLineObject::isPointWithin(const ossimDpt& imagePoint)const
 {
-   if(theProjectedPolyLineObject)
+   if(theProjectedPolyLineObject.valid())
    {
       return theProjectedPolyLineObject->isPointWithin(imagePoint);
    }
@@ -286,7 +206,7 @@ void ossimGeoAnnotationMultiPolyLineObject::setColor(ossim_uint8 r,
                                                      ossim_uint8 b)
 {
    ossimAnnotationObject::setColor(r, g, b);
-   if(theProjectedPolyLineObject)
+   if(theProjectedPolyLineObject.valid())
    {
       theProjectedPolyLineObject->setColor(r, g, b);
    }
@@ -295,7 +215,7 @@ void ossimGeoAnnotationMultiPolyLineObject::setColor(ossim_uint8 r,
 void ossimGeoAnnotationMultiPolyLineObject::setThickness(ossim_uint8 thickness)
 {
    ossimAnnotationObject::setThickness(thickness);
-   if(theProjectedPolyLineObject)
+   if(theProjectedPolyLineObject.valid())
    {
       theProjectedPolyLineObject->setThickness(thickness);
    }
@@ -399,11 +319,7 @@ bool ossimGeoAnnotationMultiPolyLineObject::loadState(
 
 void ossimGeoAnnotationMultiPolyLineObject::allocateProjectedPolyLine()
 {
-   if(theProjectedPolyLineObject)
-   {
-      delete theProjectedPolyLineObject;
-      theProjectedPolyLineObject = 0;
-   }
+   theProjectedPolyLineObject = 0;
    
    if(theMultiPolyLine.size())
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp
index 15c8158fcf878bbf223d643b34ac84ff1f352a7c..6bb1c7fbb28898623d78d47019bfcffa6295074f 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiPolyObject.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationMultiPolyObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGeoAnnotationMultiPolyObject.h>
 #include <ossim/imaging/ossimAnnotationMultiPolyObject.h>
@@ -51,7 +51,7 @@ ossimGeoAnnotationMultiPolyObject::ossimGeoAnnotationMultiPolyObject(const ossim
       theMultiPolygon(rhs.theMultiPolygon),
       theBoundingRect(rhs.theBoundingRect),
       theFillEnabled(rhs.theFillEnabled),
-      theProjectedPolyObject(rhs.theProjectedPolyObject?(ossimAnnotationMultiPolyObject*)rhs.theProjectedPolyObject->dup():0)
+      theProjectedPolyObject(rhs.theProjectedPolyObject.valid()?(ossimAnnotationMultiPolyObject*)rhs.theProjectedPolyObject->dup():0)
 {
 }
 
@@ -62,11 +62,7 @@ ossimObject* ossimGeoAnnotationMultiPolyObject::dup()const
 
 ossimGeoAnnotationMultiPolyObject::~ossimGeoAnnotationMultiPolyObject()
 {
-   if(theProjectedPolyObject)
-   {
-      delete theProjectedPolyObject;
-      theProjectedPolyObject = 0;
-   }
+   theProjectedPolyObject = 0;
 }
 
 void ossimGeoAnnotationMultiPolyObject::applyScale(double x,
@@ -77,7 +73,7 @@ void ossimGeoAnnotationMultiPolyObject::applyScale(double x,
       << endl;
 }
 
-void ossimGeoAnnotationMultiPolyObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationMultiPolyObject::transform(ossimImageGeometry* projection)
 {
    if(!projection)
    {
@@ -107,7 +103,7 @@ void ossimGeoAnnotationMultiPolyObject::transform(ossimProjection* projection)
           pointI < theMultiPolygon[polyI].size();
           ++pointI)
       {
-         projection->worldToLineSample(theMultiPolygon[polyI][pointI],
+         projection->worldToLocal(theMultiPolygon[polyI][pointI],
                                        temp);
          if(!temp.hasNans())
          {
@@ -123,75 +119,6 @@ void ossimGeoAnnotationMultiPolyObject::transform(ossimProjection* projection)
    theProjectedPolyObject->computeBoundingRect();
 }
 
-void ossimGeoAnnotationMultiPolyObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      allocateProjectedPolygon();
-
-      //---
-      // NOTE:
-      // allocateProjectedPolygon() will set theProjectedPolyObject to 0 if
-      // theMultiPolygon is empty (theMultiPolygon.size() == 0).
-      // So check before
-      // accessing pointer to avoid a core dump.
-      //---
-      if (theProjectedPolyObject)
-      {
-         ossimDpt temp;
-         std::vector<ossimPolygon> visiblePolygons;
-         ossimPolygon polygon;
-         for(std::vector<ossimGeoPolygon>::size_type polyI = 0;
-             polyI < theMultiPolygon.size(); ++polyI)
-         {
-            polygon.clear();
-            for(ossim_uint32 pointI = 0;
-                pointI < theMultiPolygon[polyI].size();
-                ++pointI)
-            {
-               ossimDpt r0Pt;
-               projection->worldToLineSample(theMultiPolygon[polyI][pointI],
-                                             r0Pt);
-               if(!r0Pt.hasNans())
-               {
-                  if (rrds)
-                  {
-                     // Transform r0 point to new rrds level.
-                     try
-                     {
-                        ossimDpt rnPt;
-                        model.r0ToRn(rrds, r0Pt, rnPt);
-                        polygon.addPoint(rnPt);
-                     }
-                     catch (const ossimException& e)
-                     {
-                        ossimNotify(ossimNotifyLevel_WARN)
-                           << e.what() << std::endl;
-                     } 
-                  }
-                  else
-                  {
-                     polygon.addPoint(r0Pt);
-                  }
-               }
-               
-            }  // End of point loop.
-            
-            theProjectedPolyObject->addPolygon(polygon);
-            
-         } // End fo polygon loop.
-         
-         // Update the bounding rect.
-         theProjectedPolyObject->computeBoundingRect();
-         
-      } // End: if (theProjectedPolyObject)
-      
-   } // End: if (projection)
-   
-}
-
 std::ostream& ossimGeoAnnotationMultiPolyObject::print(std::ostream& out)const
 {
    ossimNotify(ossimNotifyLevel_NOTICE)
@@ -219,7 +146,7 @@ ossimAnnotationObject* ossimGeoAnnotationMultiPolyObject::getNewClippedObject(co
 
 void ossimGeoAnnotationMultiPolyObject::draw(ossimRgbImage& anImage)const
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->draw(anImage);
    }
@@ -238,11 +165,7 @@ void ossimGeoAnnotationMultiPolyObject::addPoint(ossim_uint32 polygonIndex,
       theMultiPolygon[polygonIndex].addPoint(pt);
       
       // we will have to reset the projected polygon
-      if(theProjectedPolyObject)
-      {
-         delete theProjectedPolyObject;
-         theProjectedPolyObject = 0;
-      }
+      theProjectedPolyObject = 0;
    }
 }
 
@@ -250,11 +173,7 @@ void ossimGeoAnnotationMultiPolyObject::setMultiPolygon(
    const vector<ossimGeoPolygon>& multiPoly)
 {
    theMultiPolygon = multiPoly;
-   if(theProjectedPolyObject)
-   {
-      delete theProjectedPolyObject;
-      theProjectedPolyObject = 0;
-   }
+   theProjectedPolyObject = 0;
 }
 
 void ossimGeoAnnotationMultiPolyObject::setColor(unsigned char r,
@@ -262,7 +181,7 @@ void ossimGeoAnnotationMultiPolyObject::setColor(unsigned char r,
                                                  unsigned char b)
 {
    ossimAnnotationObject::setColor(r, g, b);
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setColor(r, g, b);
    }
@@ -271,7 +190,7 @@ void ossimGeoAnnotationMultiPolyObject::setColor(unsigned char r,
 void ossimGeoAnnotationMultiPolyObject::setThickness(ossim_uint8 thickness)
 {
    ossimAnnotationObject::setThickness(thickness);
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setThickness(thickness);
    }
@@ -280,7 +199,7 @@ void ossimGeoAnnotationMultiPolyObject::setThickness(ossim_uint8 thickness)
 void ossimGeoAnnotationMultiPolyObject::computeBoundingRect()
 {
    theBoundingRect.makeNan();
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->computeBoundingRect();
       theProjectedPolyObject->getBoundingRect(theBoundingRect);
@@ -289,7 +208,7 @@ void ossimGeoAnnotationMultiPolyObject::computeBoundingRect()
 
 bool ossimGeoAnnotationMultiPolyObject::isPointWithin(const ossimDpt& imagePoint)const
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       return theProjectedPolyObject->isPointWithin(imagePoint);
    }
@@ -300,7 +219,7 @@ bool ossimGeoAnnotationMultiPolyObject::isPointWithin(const ossimDpt& imagePoint
 void ossimGeoAnnotationMultiPolyObject::setFillFlag(bool flag)
 {
    theFillEnabled = flag;
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setFillFlag(flag);
    }
@@ -308,11 +227,7 @@ void ossimGeoAnnotationMultiPolyObject::setFillFlag(bool flag)
 
 void ossimGeoAnnotationMultiPolyObject::allocateProjectedPolygon()
 {
-   if(theProjectedPolyObject)
-   {
-      delete theProjectedPolyObject;
-      theProjectedPolyObject = 0;
-   }
+   theProjectedPolyObject = 0;
    
    if(theMultiPolygon.size())
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp
index 54d97b8aedd5ec97bee834b27c00d3ddc1b0e059..07b08e660fbb9ea2fe6fc604c4dd4c9bde74ecd6 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyLineObject.cpp 13348 2008-07-30 15:33:53Z dburken $
+// $Id: ossimGeoAnnotationPolyLineObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimGeoAnnotationPolyLineObject.h>
 #include <ossim/imaging/ossimAnnotationMultiLineObject.h>
 #include <ossim/projection/ossimProjection.h>
@@ -79,7 +79,7 @@ void ossimGeoAnnotationPolyLineObject::applyScale(double x,
       
 }
 
-void ossimGeoAnnotationPolyLineObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationPolyLineObject::transform(ossimImageGeometry* projection)
 {
    // make sure it's not null
    if(!projection)
@@ -97,7 +97,7 @@ void ossimGeoAnnotationPolyLineObject::transform(ossimProjection* projection)
       
       for(std::vector<ossimGpt>::size_type index=0; index < BOUNDS; ++index)
       {
-         projection->worldToLineSample(thePolygon[index], poly[index]);
+         projection->worldToLocal(thePolygon[index], poly[index]);
       }
       
       // update the bounding rect
@@ -105,55 +105,6 @@ void ossimGeoAnnotationPolyLineObject::transform(ossimProjection* projection)
    }
 }
 
-void ossimGeoAnnotationPolyLineObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      std::vector<ossimPolyLine>& polyList =
-         theProjectedMultiLineObject->getPolyLineList();
-      
-      if(polyList.size())
-      {
-         std::vector<ossimDpt>& poly = polyList[0].getVertexList();
-         
-         const std::vector<ossimGpt>::size_type BOUNDS = thePolygon.size();
-         
-         for(std::vector<ossimGpt>::size_type index = 0;
-             index < BOUNDS; ++index)
-         {
-            ossimDpt r0Pt;
-            projection->worldToLineSample(thePolygon[index], r0Pt);
-            
-            if (rrds)
-            {
-               // Transform r0 point to new rrds level.
-               try
-               {
-                  ossimDpt rnPt;
-                  model.r0ToRn(rrds, r0Pt, rnPt);
-                  poly[index] = rnPt;
-               }
-               catch (const ossimException& e)
-               {
-                  ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-               } 
-            }
-            else
-            {
-               poly[index] = r0Pt;
-            }
-            
-         } // End loop though polygon points.
-      }
-      
-      // update the bounding rect
-      theProjectedMultiLineObject->computeBoundingRect();
-      
-   } // End if (projection)
-}
-
 std::ostream& ossimGeoAnnotationPolyLineObject::print(std::ostream& out)const
 {
    out << "number_of_points:  " << thePolygon.size() << endl;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyObject.cpp
index 0a6937e5839c3fe74a7a8d5e72b90e97244c1e04..273d5ee1792be686ce5ea50fac1316b93c777c6b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyObject.cpp
@@ -6,12 +6,11 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyObject.cpp 13387 2008-08-04 21:30:04Z dburken $
+// $Id: ossimGeoAnnotationPolyObject.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 
 #include <ossim/imaging/ossimGeoAnnotationPolyObject.h>
-#include <ossim/imaging/ossimAnnotationPolyObject.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/projection/ossimImageProjectionModel.h>
 #include <ossim/base/ossimException.h>
@@ -72,17 +71,13 @@ ossimGeoAnnotationPolyObject::ossimGeoAnnotationPolyObject(
    const ossimGeoAnnotationPolyObject& rhs)
    :ossimGeoAnnotationObject(rhs),
     thePolygon(rhs.thePolygon),
-    theProjectedPolyObject(rhs.theProjectedPolyObject?(ossimAnnotationPolyObject*)rhs.theProjectedPolyObject->dup():(ossimAnnotationPolyObject*)NULL)
+    theProjectedPolyObject(rhs.theProjectedPolyObject.valid()?(ossimAnnotationPolyObject*)rhs.theProjectedPolyObject->dup():(ossimAnnotationPolyObject*)NULL)
 {
 }
 
 ossimGeoAnnotationPolyObject::~ossimGeoAnnotationPolyObject()
 {
-   if(theProjectedPolyObject)
-   {
-      delete theProjectedPolyObject;
-      theProjectedPolyObject = NULL;
-   }
+   theProjectedPolyObject = NULL;
 }
 
 ossimObject* ossimGeoAnnotationPolyObject::dup()const
@@ -98,14 +93,14 @@ void ossimGeoAnnotationPolyObject::applyScale(double x,
       thePolygon[i].lond(thePolygon[i].lond()*x);
       thePolygon[i].latd(thePolygon[i].latd()*y);
    }
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->applyScale(x, y);
    }
       
 }
 
-void ossimGeoAnnotationPolyObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationPolyObject::transform(ossimImageGeometry* projection)
 {
    // make sure it's not null
    if(!projection)
@@ -117,7 +112,7 @@ void ossimGeoAnnotationPolyObject::transform(ossimProjection* projection)
    
    for(std::vector<ossimGpt>::size_type index=0; index < BOUNDS; ++index)
    {
-      projection->worldToLineSample(thePolygon[index], poly[index]);
+      projection->worldToLocal(thePolygon[index], poly[index]);
    }
 
    // update the bounding rect
@@ -125,46 +120,6 @@ void ossimGeoAnnotationPolyObject::transform(ossimProjection* projection)
    theProjectedPolyObject->computeBoundingRect();
 }
 
-void ossimGeoAnnotationPolyObject::transform(
-   const ossimImageProjectionModel& model, ossim_uint32 rrds)
-{
-   const ossimProjection* projection = model.getProjection();
-   if (projection)
-   {
-      ossimPolygon& poly = theProjectedPolyObject->getPolygon();
-      const std::vector<ossimGpt>::size_type BOUNDS = thePolygon.size();
-
-      for(std::vector<ossimGpt>::size_type index=0; index < BOUNDS; ++index)
-      {
-         ossimDpt r0Pt;
-         projection->worldToLineSample(thePolygon[index], r0Pt);
-
-         if (rrds)
-         {
-            // Transform r0 point to new rrds level.
-            try
-            {
-               ossimDpt rnPt;
-               model.r0ToRn(rrds, r0Pt, rnPt);
-               poly[index] = rnPt;
-            }
-            catch (const ossimException& e)
-            {
-               ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
-            } 
-         }
-         else
-         {
-            poly[index] = r0Pt;
-         }
-      }
-
-      // update the bounding rect
-      theProjectedPolyObject->computeBoundingRect();
-
-   } // End: if (projection)
-}
-
 std::ostream& ossimGeoAnnotationPolyObject::print(std::ostream& out)const
 {
    out << "number_of_points:  " << thePolygon.size() << std::endl;
@@ -183,7 +138,7 @@ std::ostream& ossimGeoAnnotationPolyObject::print(std::ostream& out)const
 
 void ossimGeoAnnotationPolyObject::draw(ossimRgbImage& anImage)const
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->draw(anImage);
    }
@@ -192,7 +147,7 @@ void ossimGeoAnnotationPolyObject::draw(ossimRgbImage& anImage)const
 ossimAnnotationObject* ossimGeoAnnotationPolyObject::getNewClippedObject(
    const ossimDrect& rect)const
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       return theProjectedPolyObject->getNewClippedObject(rect);
    }
@@ -202,7 +157,7 @@ ossimAnnotationObject* ossimGeoAnnotationPolyObject::getNewClippedObject(
 
 bool ossimGeoAnnotationPolyObject::intersects(const ossimDrect& rect)const
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       return theProjectedPolyObject->intersects(rect);
    }
@@ -213,7 +168,7 @@ bool ossimGeoAnnotationPolyObject::intersects(const ossimDrect& rect)const
 void ossimGeoAnnotationPolyObject::getBoundingRect(ossimDrect& rect)const
 {
    rect.makeNan();
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->getBoundingRect(rect);
    }
@@ -221,7 +176,7 @@ void ossimGeoAnnotationPolyObject::getBoundingRect(ossimDrect& rect)const
 
 void ossimGeoAnnotationPolyObject::computeBoundingRect()
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->computeBoundingRect();
    }
@@ -236,7 +191,7 @@ void ossimGeoAnnotationPolyObject::setPolygon(const std::vector<ossimGpt>& poly)
 {
    thePolygon = poly;
    std::vector<ossimDpt> projectedPoints(thePolygon.size());
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setPolygon(projectedPoints);
    }
@@ -246,7 +201,7 @@ void ossimGeoAnnotationPolyObject::setPolygon(const std::vector<ossimGpt>& poly)
 
 void ossimGeoAnnotationPolyObject::setFillFlag(bool flag)
 {
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setFillFlag(flag);
    }
@@ -257,7 +212,7 @@ void ossimGeoAnnotationPolyObject::setColor(ossim_uint8 r,
                                             ossim_uint8 b)
 {
    ossimAnnotationObject::setColor(r, g, b);
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setColor(r, g, b);
    }
@@ -266,7 +221,7 @@ void ossimGeoAnnotationPolyObject::setColor(ossim_uint8 r,
 void ossimGeoAnnotationPolyObject::setThickness(ossim_uint8 thickness)
 {
    ossimAnnotationObject::setThickness(thickness);
-   if(theProjectedPolyObject)
+   if(theProjectedPolyObject.valid())
    {
       theProjectedPolyObject->setThickness(thickness);
    }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationSource.cpp
index 990b610d96f0ee5e120f8f9bbe82d078b10e46cb..eeaddcb4d684d05f9efd341e8570cd2543dd68e9 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationSource.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationSource.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGeoAnnotationSource.h>
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -21,7 +21,7 @@ RTTI_DEF2(ossimGeoAnnotationSource,
 
 ostream& operator <<(ostream& out, const ossimGeoAnnotationSource& rhs)
 {
-   const vector<ossimAnnotationObject*> &tempList = rhs.getObjectList();
+   const ossimAnnotationSource::AnnotationObjectListType &tempList = rhs.getObjectList();
    for(ossim_uint32 index = 0; index < tempList.size(); ++index)
    {
       out << "output " << index << endl;
@@ -31,30 +31,27 @@ ostream& operator <<(ostream& out, const ossimGeoAnnotationSource& rhs)
    return out;
 }
 
-ossimGeoAnnotationSource::ossimGeoAnnotationSource(ossimProjection* projection,
+ossimGeoAnnotationSource::ossimGeoAnnotationSource(ossimImageGeometry* geom,
                                                    bool ownsProjectionFlag)
    :ossimAnnotationSource(),
     ossimViewInterface(),
-    theProjection(projection),
-    theOwnsProjectionFlag(ownsProjectionFlag)
+    m_geometry(geom)
 {
    ossimViewInterface::theObject = this;
 }
 
 ossimGeoAnnotationSource::ossimGeoAnnotationSource(ossimImageSource* inputSource,
-                                                   ossimProjection* projection,
+                                                   ossimImageGeometry* geom,
                                                    bool ownsProjectionFlag)
    :ossimAnnotationSource(inputSource),
     ossimViewInterface(),
-    theProjection(projection),
-    theOwnsProjectionFlag(ownsProjectionFlag)
+    m_geometry(geom)
 {
    ossimViewInterface::theObject = this;
 }
 
 ossimGeoAnnotationSource::~ossimGeoAnnotationSource()
 {
-   removeProjection();
 }
 
 bool ossimGeoAnnotationSource::addObject(ossimAnnotationObject* anObject)
@@ -64,9 +61,9 @@ bool ossimGeoAnnotationSource::addObject(ossimAnnotationObject* anObject)
    if(objectToAdd)
    {
       ossimAnnotationSource::addObject(objectToAdd);
-      if(theProjection)
+      if(m_geometry.valid())
       {
-         objectToAdd->transform(theProjection);
+         objectToAdd->transform(m_geometry.get());
          computeBoundingRect();
       }
       return true;
@@ -75,26 +72,26 @@ bool ossimGeoAnnotationSource::addObject(ossimAnnotationObject* anObject)
    return false;
 }
 
-void ossimGeoAnnotationSource::setProjection(ossimProjection* projection,
-                                             bool ownsProjectionFlag)
+void ossimGeoAnnotationSource::setGeometry(ossimImageGeometry* geom)
 {
-   // remove our current set projection first
-   removeProjection();
-
-   theProjection         = projection;
-   theOwnsProjectionFlag = ownsProjectionFlag;
-   transformObjects(theProjection);
-   
+   m_geometry = geom;
+   transformObjects(m_geometry.get());
 }
 
-bool ossimGeoAnnotationSource::setView(ossimObject* baseObject,
-                                       bool ownsTheView)
+bool ossimGeoAnnotationSource::setView(ossimObject* baseObject)
 {
    ossimProjection* proj = PTR_CAST(ossimProjection, baseObject);
    if(proj)
    {
-      setProjection(proj, ownsTheView);
-
+      if(m_geometry.valid())
+      {
+         m_geometry->setProjection(proj);
+      }
+      else
+      {
+         m_geometry = new ossimImageGeometry(0, proj);
+      }
+      setGeometry(m_geometry.get());
       return true;
    }
 
@@ -103,12 +100,12 @@ bool ossimGeoAnnotationSource::setView(ossimObject* baseObject,
 
 ossimObject* ossimGeoAnnotationSource::getView()
 {
-   return theProjection;
+   return m_geometry.get();
 }
 
 const ossimObject* ossimGeoAnnotationSource::getView()const
 {
-   return theProjection;
+   return m_geometry.get();
 }
 
 void ossimGeoAnnotationSource::computeBoundingRect()
@@ -122,7 +119,7 @@ void ossimGeoAnnotationSource::computeBoundingRect()
       ossimDrect rect;
       theAnnotationObjectList[0]->getBoundingRect(theRectangle);
       
-      vector<ossimAnnotationObject*>::iterator object = (theAnnotationObjectList.begin()+1);
+      AnnotationObjectListType::iterator object = (theAnnotationObjectList.begin()+1);
       while(object != theAnnotationObjectList.end())
       {
          (*object)->getBoundingRect(rect);
@@ -132,19 +129,16 @@ void ossimGeoAnnotationSource::computeBoundingRect()
    }
 }
 
-void ossimGeoAnnotationSource::transformObjects(ossimProjection* projection)
+void ossimGeoAnnotationSource::transformObjects(ossimImageGeometry* geom)
 {
-   if(!theProjection && !projection)
-   {
-      return;
-   }
-   if(!projection)
+   ossimRefPtr<ossimImageGeometry> tempGeom = geom;
+   if(!tempGeom)
    {
-      projection = theProjection;
+      tempGeom = m_geometry.get();
    }
 
-   if(!theProjection) return;
-   vector<ossimAnnotationObject*>::iterator currentObject;
+   if(!tempGeom) return;
+   AnnotationObjectListType::iterator currentObject;
 
    currentObject = theAnnotationObjectList.begin();
 
@@ -153,35 +147,24 @@ void ossimGeoAnnotationSource::transformObjects(ossimProjection* projection)
       // this is safe since we trapped all adds to make
       // sure that each object added to the list is
       // geographic.
-      ossimGeoAnnotationObject* object = static_cast<ossimGeoAnnotationObject*>(*currentObject);
+      ossimGeoAnnotationObject* object = static_cast<ossimGeoAnnotationObject*>((*currentObject).get());
 
       // transform the object to image space.
-      object->transform(projection);
+      object->transform(m_geometry.get());
 
       ++currentObject;
    }
    computeBoundingRect();
 }
 
-void ossimGeoAnnotationSource::removeProjection()
+ossimImageGeometry* ossimGeoAnnotationSource::getImageGeometry()
 {
-   if(theProjection&&theOwnsProjectionFlag)
+   if(!m_geometry.valid())
    {
-      delete theProjection;
+      return ossimImageSource::getImageGeometry();
    }
-
-   theProjection = 0;
-}
-
-bool ossimGeoAnnotationSource::getImageGeometry(ossimKeywordlist& kwl,
-						const char* prefix)
-{
-  if(theProjection)
-    {
-      theProjection->saveState(kwl, prefix);
-      return true;
-    }
-  return ossimImageSource::getImageGeometry(kwl, prefix);
+   
+   return m_geometry.get();
 }
 
 bool ossimGeoAnnotationSource::saveState(ossimKeywordlist& kwl,
@@ -194,13 +177,19 @@ bool ossimGeoAnnotationSource::saveState(ossimKeywordlist& kwl,
 bool ossimGeoAnnotationSource::loadState(const ossimKeywordlist& kwl,
                                          const char* prefix)
 {
-   ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,"view_proj.");
-
-   if(proj)
+   m_geometry = new ossimImageGeometry;
+   
+   ossimString newPrefix = ossimString(prefix)+"view_proj.";
+   if(!m_geometry->loadState(kwl, newPrefix.c_str()))
+   {
+      m_geometry = 0;
+   }
+   else
    {
-      removeProjection();
-      theOwnsProjectionFlag = true;
-      theProjection = proj;
+      if(!m_geometry->hasProjection())
+      {
+         m_geometry = 0;
+      }
    }
    
    return ossimAnnotationSource::loadState(kwl, prefix);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoPolyCutter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoPolyCutter.cpp
index 44c1c47cf03cbeff07023b4af123a683d3955f5a..d8785618427b72868e8301162d981e6480625aa4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoPolyCutter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoPolyCutter.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks.com)
 //
 //*************************************************************************
-// $Id: ossimGeoPolyCutter.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimGeoPolyCutter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <ossim/imaging/ossimGeoPolyCutter.h>
 #include <ossim/projection/ossimProjection.h>
@@ -22,19 +22,10 @@ ossimGeoPolyCutter::ossimGeoPolyCutter()
 {
    ossimViewInterface::theObject = this;
    theGeoPolygonList.push_back(ossimGeoPolygon());
-   theViewProjection = NULL;
-   theOwnsViewFlag = false;
 }
 
 ossimGeoPolyCutter::~ossimGeoPolyCutter()
 {
-   if(theOwnsViewFlag && theViewProjection)
-   {
-      delete theViewProjection;
-      
-      theViewProjection = NULL;
-      theOwnsViewFlag = false;
-   }
 }
 
 bool ossimGeoPolyCutter::saveState(ossimKeywordlist& kwl,
@@ -63,7 +54,7 @@ bool ossimGeoPolyCutter::saveState(ossimKeywordlist& kwl,
             fillType.c_str(),
             true);   
 
-    if(theViewProjection)
+    if(theViewProjection.valid())
     {
        ossimString viewPrefix = prefix;
        viewPrefix += "view.";
@@ -119,18 +110,8 @@ bool ossimGeoPolyCutter::loadState(const ossimKeywordlist& kwl,
 
    ossimString viewPrefix = prefix;
    viewPrefix += "view.";
-   ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,
+   theViewProjection = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,
                                                                                         viewPrefix);
-   if(proj)
-   {
-      if(theViewProjection&&theOwnsViewFlag)
-      {
-         delete theViewProjection;
-      }
-      theViewProjection = proj;
-      theOwnsViewFlag = true;
-   }
-   
    transformVertices();
    return ossimImageSourceFilter::loadState(kwl, prefix);
 }
@@ -139,7 +120,7 @@ bool ossimGeoPolyCutter::loadState(const ossimKeywordlist& kwl,
 void ossimGeoPolyCutter::setPolygon(const vector<ossimDpt>& polygon,
                                  ossim_uint32 index)
 {
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       ossimPolyCutter::setPolygon(polygon);
       invertPolygon(index);
@@ -149,7 +130,7 @@ void ossimGeoPolyCutter::setPolygon(const vector<ossimDpt>& polygon,
 void ossimGeoPolyCutter::setPolygon(const vector<ossimIpt>& polygon,
                                  ossim_uint32 index)
 {
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       ossimPolyCutter::setPolygon(polygon);
       invertPolygon(index);
@@ -184,7 +165,7 @@ void ossimGeoPolyCutter::addPolygon(const vector<ossimGpt>& polygon)
    theGeoPolygonList.push_back(polygon);
    thePolygonList.push_back(ossimPolygon());
 
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       transformVertices(((int)theGeoPolygonList.size())-1);
    }
@@ -192,7 +173,7 @@ void ossimGeoPolyCutter::addPolygon(const vector<ossimGpt>& polygon)
 
 void ossimGeoPolyCutter::addPolygon(const vector<ossimIpt>& polygon)
 {
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       ossimPolyCutter::addPolygon(polygon);
       theGeoPolygonList.push_back(ossimGeoPolygon());
@@ -202,7 +183,7 @@ void ossimGeoPolyCutter::addPolygon(const vector<ossimIpt>& polygon)
 
 void ossimGeoPolyCutter::addPolygon(const vector<ossimDpt>& polygon)
 {
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       ossimPolyCutter::addPolygon(polygon);
       theGeoPolygonList.push_back(ossimGeoPolygon());
@@ -212,7 +193,7 @@ void ossimGeoPolyCutter::addPolygon(const vector<ossimDpt>& polygon)
 
 void ossimGeoPolyCutter::addPolygon(const ossimPolygon& polygon)
 {
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       ossimPolyCutter::addPolygon(polygon);
       theGeoPolygonList.push_back(ossimGeoPolygon());
@@ -225,7 +206,7 @@ void ossimGeoPolyCutter::addPolygon(const ossimGeoPolygon& polygon)
    ossimPolyCutter::addPolygon(ossimPolygon());
    theGeoPolygonList.push_back(polygon);
    
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       transformVertices(((int)theGeoPolygonList.size())-1);
    }
@@ -248,34 +229,26 @@ void ossimGeoPolyCutter::invertPolygon(int polygonNumber)
    }
 }
 
-bool ossimGeoPolyCutter::setView(ossimObject* baseObject,
-                                 bool ownsTheView)
+bool ossimGeoPolyCutter::setView(ossimObject* baseObject)
 {
-   if(PTR_CAST(ossimProjection, baseObject))
+   ossimProjection* proj = dynamic_cast<ossimProjection*>(baseObject);
+   if(proj)
    {
-      if(theViewProjection && theOwnsViewFlag)
-      {
-         delete theViewProjection;
-      }
-      theViewProjection = PTR_CAST(ossimProjection, baseObject);
-      theOwnsViewFlag   = ownsTheView;
-
+      theViewProjection = proj;
       transformVertices();
-
       return true;
    }
-
    return false;
 }
 
 ossimObject* ossimGeoPolyCutter::getView()
 {
-   return theViewProjection;
+   return theViewProjection.get();
 }
 
 const ossimObject* ossimGeoPolyCutter::getView()const
 {
-   return theViewProjection;
+   return theViewProjection.get();
 }
 
 void ossimGeoPolyCutter::transformVertices()
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeographicAnnotationGrid.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeographicAnnotationGrid.cpp
index f6e594e040fcdefd5ae826b73eed44f5605a78e3..804b84a96e36b091d911b3d44d00355a18759437 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeographicAnnotationGrid.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeographicAnnotationGrid.cpp
@@ -44,10 +44,10 @@ void ossimGeographicAnnotationGrid::draw(ossimRgbImage& anImage)const
    // the geographic grid to generate will be 0,0 is origin
    // -180lon and 90lat.
    //
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
-      ossimAnnotationLineObject *line=NULL;
-      ossimAnnotationGdBitmapFont *font=NULL;
+      ossimRefPtr<ossimAnnotationLineObject> line=NULL;
+      ossimRefPtr<ossimAnnotationGdBitmapFont> font;
       
       line = new ossimAnnotationLineObject();
       font = new ossimAnnotationGdBitmapFont();
@@ -155,10 +155,8 @@ void ossimGeographicAnnotationGrid::draw(ossimRgbImage& anImage)const
          font->draw(anImage);
       }
 
-      delete line;
-      line = NULL;
-      delete font;
-      font = NULL;
+      line = 0;
+      font = 0;
    }
 }
 
@@ -239,7 +237,7 @@ void ossimGeographicAnnotationGrid::computeBoundingRect()
 {
    static const char* MODULE = "ossimGeographicAnnotationGrid::computeBoundingRect";
    
-   if(theViewProjection)
+   if(theViewProjection.valid())
    {
       vector<ossimDpt> points(4);
 
@@ -260,10 +258,11 @@ void ossimGeographicAnnotationGrid::computeBoundingRect()
       ossimDpt lr = theBoundingRect.lr();
 
       
-      ossimAnnotationGdBitmapFont font;
-      font.setCenterText(ossimDpt(0,0),"ddd@mm'ss.ssssC");
+      ossimRefPtr<ossimAnnotationGdBitmapFont> font = new ossimAnnotationGdBitmapFont();;
+      font->setCenterText(ossimDpt(0,0),"ddd@mm'ss.ssssC");
       ossimDrect boundingRect;
-      font.getBoundingRect(boundingRect);
+      font->getBoundingRect(boundingRect);
+      font = 0;
       
       theBoundingRect = ossimDrect(ul.x - boundingRect.width(),
                                    ul.y - boundingRect.height(),
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeomFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeomFileWriter.cpp
index ced404681eca6a290b6a5eccf41a2708860f83b1..c4b408a88e228ccb2820d9d80c2e5a1dd17bb443 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeomFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeomFileWriter.cpp
@@ -6,7 +6,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimGeomFileWriter.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimGeomFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGeomFileWriter.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -37,28 +37,22 @@ ossimGeomFileWriter::~ossimGeomFileWriter()
 
 bool ossimGeomFileWriter::writeFile()
 {
-   // Get the geometry from the input.
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-
-   // Create the projection.
-   ossimRefPtr<ossimProjection> proj =
-      ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   if (!proj.valid())
+   if(!theInputConnection) return false;
+   ossimRefPtr<ossimImageGeometry> geom = theInputConnection->getImageGeometry();
+   if(geom.valid())
    {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimGeomFileWriter::writeFile DEBUG:"
-            << "\nCreate projection failed!"
-            << "\nGeometry kwl: " << kwl
-            << endl;
-      }
-
-      return false;
+      ossimKeywordlist kwl;
+      geom->saveState(kwl);
+      return kwl.write(theFilename.c_str());
    }
-   
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj.get());
+   return false;
+#if 0
+   // Get the geometry from the input.
+   const ossimMapProjection* mapProj = 0;
+   const ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
+   if (inputGeom)
+      mapProj = PTR_CAST(ossimMapProjection, inputGeom->getProjection());
+
    if (!mapProj)
    {
       if (traceDebug())
@@ -68,7 +62,6 @@ bool ossimGeomFileWriter::writeFile()
             << "\nNot a map projection!"
             << endl;
       }
-
       return false;
    }
 
@@ -77,14 +70,15 @@ bool ossimGeomFileWriter::writeFile()
       = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
    
    // Set the tie points.
+   ossimKeywordlist kwl;
    projectionInfo->getGeom(kwl);
 
    // Write it to disk.
    return kwl.write(theFilename.c_str());
+#endif
 }
 
-void ossimGeomFileWriter::getMetadatatypeList(
-   std::vector<ossimString>& metadatatypeList) const
+void ossimGeomFileWriter::getMetadatatypeList(std::vector<ossimString>& metadatatypeList) const
 {
    metadatatypeList.push_back(ossimString("ossim_geometry")); 
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGridRemapSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGridRemapSource.cpp
index a43990922da36bc3af5ee46f1695a794b20d46c0..2b8a0b69b9eaf496faf617dc21903afda66472e3 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGridRemapSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGridRemapSource.cpp
@@ -14,7 +14,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimGridRemapSource.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimGridRemapSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimGridRemapSource.h>
 
@@ -79,7 +79,7 @@ ossimGridRemapSource::ossimGridRemapSource(ossimImageSource* inputSource,
 ossimGridRemapSource::~ossimGridRemapSource()
 {
    deallocateGrids();
-   delete theRemapEngine;
+   theRemapEngine = 0;
 }
 
 //*****************************************************************************
@@ -180,7 +180,7 @@ bool ossimGridRemapSource::loadState(const ossimKeywordlist& kwl,
    // Reset object in preparation for reassignment:
    //***
    deallocateGrids();
-   delete theRemapEngine;
+   theRemapEngine = 0;
    
    //***
    // Read the remap engine type:
@@ -348,10 +348,8 @@ void ossimGridRemapSource::deallocateGrids()
 //*****************************************************************************
 void ossimGridRemapSource::setRemapEngine(ossimGridRemapEngine* engine)
 {
-   if (theRemapEngine)
-      delete theRemapEngine;
 
-   theRemapEngine = (ossimGridRemapEngine*)engine->dup();
+   theRemapEngine = engine;
    theGridIsFilled = false;
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimHistogramRemapper.cpp b/Utilities/otbossim/src/ossim/imaging/ossimHistogramRemapper.cpp
index 6cb7c85db9a6d2a2fa55cb38054198a5f3be17b5..054c4bd668c30f76738ffd541c48464d18a23b4a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimHistogramRemapper.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimHistogramRemapper.cpp
@@ -11,7 +11,7 @@
 // Remaps a tile based on mode and histogram clip points.
 //
 //*************************************************************************
-// $Id: ossimHistogramRemapper.cpp 14068 2009-03-08 21:23:24Z dburken $
+// $Id: ossimHistogramRemapper.cpp 15390 2009-09-09 13:15:31Z gpotts $
 
 #include <cstdlib>
 #include <ossim/imaging/ossimHistogramRemapper.h>
@@ -42,7 +42,7 @@ static const char STRETCH_MODE_KW[] = "stretch_mode";
 static const char HISTOGRAM_FILENAME_KW[] = "histogram_filename";
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimHistogramRemapper.cpp 14068 2009-03-08 21:23:24Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimHistogramRemapper.cpp 15390 2009-09-09 13:15:31Z gpotts $";
 #endif
 
 ossimHistogramRemapper::ossimHistogramRemapper()
@@ -1584,25 +1584,50 @@ void ossimHistogramRemapper::setupTable()
       theTable.resize(size_in_bytes);
    }
 
-   //---
-   // Last check for NaNs in key data members and set to some default if so.
-   // This could occur if someone stripped a keyword list down to a minimal
-   // set of keywords.
-   //---
-   for (ossim_uint32 band = 0; band < BANDS; ++band)
+   ossimImageSource* input = dynamic_cast<ossimImageSource*>(getInput());
+   double minPix = ossim::defaultMin(getOutputScalarType());
+   double maxPix = ossim::defaultMax(getOutputScalarType());
+   
+   if(input)
    {
-      const double MIN = getMinPixelValue(band);
-      const double MAX = getMaxPixelValue(band);
-      
-      if ( ossim::isnan(theMinOutputValue[band]) )
+      //---
+      // Last check for NaNs in key data members and set to some default if so.
+      // This could occur if someone stripped a keyword list down to a minimal
+      // set of keywords.
+      //---
+      for (ossim_uint32 band = 0; band < BANDS; ++band)
       {
-         theMinOutputValue[band] = MIN;
-      }
-      if ( ossim::isnan(theMaxOutputValue[band]) )
+         minPix = input->getMinPixelValue(band);
+         maxPix = input->getMaxPixelValue(band);
+         if ( ossim::isnan(theMinOutputValue[band]) )
+         {
+            theMinOutputValue[band] = minPix;
+         }
+         if ( ossim::isnan(theMaxOutputValue[band]) )
+         {
+            theMaxOutputValue[band] = maxPix;
+         }
+      }   
+   }
+   else
+   {
+      //---
+      // Last check for NaNs in key data members and set to some default if so.
+      // This could occur if someone stripped a keyword list down to a minimal
+      // set of keywords.
+      //---
+      for (ossim_uint32 band = 0; band < BANDS; ++band)
       {
-         theMaxOutputValue[band] = MAX;
-      }
-   }   
+         if ( ossim::isnan(theMinOutputValue[band]) )
+         {
+            theMinOutputValue[band] = minPix;
+         }
+         if ( ossim::isnan(theMaxOutputValue[band]) )
+         {
+            theMaxOutputValue[band] = maxPix;
+         }
+      }   
+   }
 }
 
 void ossimHistogramRemapper::verifyEnabled()
@@ -1715,7 +1740,7 @@ ossimHistogramRemapper& ossimHistogramRemapper::operator=(const ossimHistogramRe
 {
    return *this;
 }
-		
+
 void ossimHistogramRemapper::setBypassFlag(bool flag)
 {
    if (theBypassFlag != flag)
@@ -1731,3 +1756,22 @@ void ossimHistogramRemapper::setBypassFlag(bool flag)
       theBypassFlag = flag;
    }
 }
+
+double ossimHistogramRemapper::getMinPixelValue(ossim_uint32 band)const
+{
+   if(theEnableFlag&&!theBypassFlag &&(band < theMinOutputValue.size()))
+   {
+      return theMinOutputValue[band];
+   }
+   return ossimTableRemapper::getMinPixelValue(band);
+}
+
+double ossimHistogramRemapper::getMaxPixelValue(ossim_uint32 band)const
+{
+   if(!theBypassFlag &&(band < theMaxOutputValue.size()))
+   {
+      return theMaxOutputValue[band];
+   }
+   return ossimTableRemapper::getMaxPixelValue(band);
+}
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp b/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp
index bf1bafc85ac09bd8f5f292ebb961ed8643c6b7ff..712e7b7824ad9f84d0b7d1823a395d11c713d27d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimIgenGenerator.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimIgenGenerator.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimIgenGenerator.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/imaging/ossimImageSource.h>
@@ -221,7 +221,7 @@ void ossimIgenGenerator::generateTiledSpecList(bool outputToFileFlag)
 
 void ossimIgenGenerator::generatePixelTiledSpecList(bool outputToFileFlag)
 {
-   ossimProjection* proj = createProductProjection();
+   ossimRefPtr<ossimProjection> proj = createProductProjection();
 
    if((!proj)||(theOutputGeoPolygon.size() != 4))
    {
@@ -325,18 +325,12 @@ void ossimIgenGenerator::generatePixelTiledSpecList(bool outputToFileFlag)
          i++;
       }
    }
-   if(proj)
-   {
-      delete proj;
-      proj = NULL;
-   }
-   
 }
 
 void ossimIgenGenerator::generateGeoTiledSpecList(const ossimDpt& spacing, bool outputToFileFlag)
 {
-   ossimProjection* proj = createProductProjection();
-   if((proj)&&(theOutputGeoPolygon.size() == 4))
+   ossimRefPtr<ossimProjection> proj = createProductProjection();
+   if((proj.valid())&&(theOutputGeoPolygon.size() == 4))
    {
       ossimDrect rect;
 
@@ -456,11 +450,6 @@ void ossimIgenGenerator::generateGeoTiledSpecList(const ossimDpt& spacing, bool
          ulLat -= spacing.lat;
       }
 
-      if(proj)
-      {
-         delete proj;
-         proj = NULL;
-      }
    }   
 }
 
@@ -478,10 +467,10 @@ void ossimIgenGenerator::generateNoTiledSpecList(bool outputToFileFlag)
       long id = 0;
       if(theOutputGeoPolygon.size())
       {
-         ossimObject* obj = createInput();
-         ossimImageChain* chain = PTR_CAST(ossimImageChain,
-                                           obj);
-         if(chain)
+         ossimRefPtr<ossimObject> obj = createInput();
+         ossimRefPtr<ossimImageChain> chain = PTR_CAST(ossimImageChain,
+                                                       obj.get());
+         if(chain.valid())
          {
             ossimGeoPolyCutter* cutter = new ossimGeoPolyCutter;
             
@@ -495,11 +484,7 @@ void ossimIgenGenerator::generateNoTiledSpecList(bool outputToFileFlag)
          {
             kwl.add("object1.",theInputKwl, true);
          }
-
-         if(obj)
-         {
-            delete obj;
-         }
+         obj = 0;
       }
       else
       {
@@ -550,8 +535,8 @@ int ossimIgenGenerator::getTileId(const ossimDrect& rect,
 
 ossimIrect ossimIgenGenerator::getInputBoundingRect()const
 {
-   ossimObject* obj = createInput();
-   ossimImageSource* inter = PTR_CAST(ossimImageSource, obj);
+   ossimRefPtr<ossimObject> obj = createInput();
+   ossimImageSource* inter = PTR_CAST(ossimImageSource, obj.get());
    ossimIrect result;
 
    result.makeNan();
@@ -559,10 +544,6 @@ ossimIrect ossimIgenGenerator::getInputBoundingRect()const
    {
       result = inter->getBoundingRect();
    }
-   if(obj)
-   {
-      delete obj;
-   }
    return result;
 }
 
@@ -574,8 +555,8 @@ void ossimIgenGenerator::addPadding(ossimGeoPolygon& output,
    {
       case OSSIM_PIXEL:
       {
-         ossimProjection* proj = createProductProjection();
-         if(proj)
+         ossimRefPtr<ossimProjection> proj = createProductProjection();
+         if(proj.valid())
          {
             ossimDpt ul;
             ossimDpt ur;
@@ -612,7 +593,6 @@ void ossimIgenGenerator::addPadding(ossimGeoPolygon& output,
 
             output.setOrdering(OSSIM_CLOCKWISE_ORDER);
          
-            delete proj;
          }
          break;
       }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp
index c9e6f0494e51818efbbb8e0df971f0d40ec29289..6e0dd2cc3d1e8cc7aa85aee3f8bae7e784ae85db 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageChain.cpp 13481 2008-08-22 16:23:15Z gpotts $
+// $Id: ossimImageChain.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <iostream>
 #include <iterator>
@@ -55,11 +55,11 @@ void ossimImageChainChildListener::processEvent(ossimEvent& event)
    {
       if(event.isPropagatingToOutputs())
       {
-         std::vector<ossimConnectableObject*>& outputList = theChain->getOutputList();
+         ossimConnectableObject::ConnectableObjectList& outputList = theChain->getOutputList();
          ossim_uint32 idx = 0;
          for(idx = 0; idx < outputList.size();++idx)
          {
-            if(outputList[idx])
+            if(outputList[idx].valid())
             {
                outputList[idx]->fireEvent(event);
                outputList[idx]->propagateEventToOutputs(event);
@@ -146,11 +146,11 @@ bool ossimImageChain::addLast(ossimConnectableObject* obj)
 {
    if(theImageChainList.size() > 0)
    {
-      ossimConnectableObject* lastSource = theImageChainList[ theImageChainList.size() -1];
-      if(PTR_CAST(ossimImageSource, obj)&&lastSource)
+      ossimConnectableObject* lastSource = theImageChainList[ theImageChainList.size() -1].get();
+      if(dynamic_cast<ossimImageSource*>(obj)&&lastSource)
       {
          obj->disconnect();
-         vector<ossimConnectableObject*> tempIn = getInputList();
+         ossimConnectableObject::ConnectableObjectList tempIn = getInputList();
          lastSource->disconnectAllInputs();
          lastSource->connectMyInputTo(obj);
          obj->changeOwner(this);
@@ -177,30 +177,27 @@ ossimImageSource* ossimImageChain::getFirstSource()
 {
    if(theImageChainList.size()>0)
    {
-      return PTR_CAST(ossimImageSource,
-                      theImageChainList[0]);
+      return dynamic_cast<ossimImageSource*>(theImageChainList[0].get());
    }
 
-   return NULL;
+   return 0;
 }
 
 ossimObject* ossimImageChain::getFirstObject()
 {
    if(theImageChainList.size()>0)
    {
-      return PTR_CAST(ossimObject,
-                      theImageChainList[0]);
+      return dynamic_cast<ossimImageSource*>(theImageChainList[0].get());
    }
 
-   return NULL;
+   return 0;
 }
 
 ossimImageSource* ossimImageChain::getLastSource()
 {
    if(theImageChainList.size()>0)
    {
-      return PTR_CAST(ossimImageSource,
-                      *(theImageChainList.end()-1));
+      return dynamic_cast<ossimImageSource*>((*(theImageChainList.end()-1)).get());
    }
 
    return NULL;
@@ -210,37 +207,36 @@ ossimObject* ossimImageChain::getLastObject()
 {
    if(theImageChainList.size()>0)
    {
-      return PTR_CAST(ossimObject,
-                      *(theImageChainList.end()-1));
+      return dynamic_cast<ossimImageSource*>((*(theImageChainList.end()-1)).get());
    }
 
-   return NULL;
+   return 0;
 }
 
 ossimConnectableObject* ossimImageChain::findObject(const ossimId& id,
                                                     bool recurse)
 {
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   std::vector<ossimRefPtr<ossimConnectableObject> >::iterator current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      if((*current))
+      if((*current).get())
       {
-	 if(id == (*current)->getId())
+         if(id == (*current)->getId())
          {
-            return (*current);
+            return (*current).get();
          }
       }
-
+      
       ++current;
    }
-
+   
    current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
       ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface,
-                                                         (*current));
+                                                         (*current).get());
       
       if(child)
       {
@@ -257,26 +253,26 @@ ossimConnectableObject* ossimImageChain::findObject(const ossimId& id,
 ossimConnectableObject* ossimImageChain::findObject(const ossimConnectableObject* obj,
                                                     bool recurse)
 {
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   std::vector<ossimRefPtr<ossimConnectableObject> >::iterator current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      if(*current)
+      if((*current).valid())
       {
-	 if(obj == (*current))
+         if(obj == (*current).get())
          {
-            return (*current);
+            return (*current).get();
          }
       }
-
+      
       ++current;
    }
-
+   
    current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current));
+      ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).get());
       
       if(child)
       {
@@ -287,91 +283,20 @@ ossimConnectableObject* ossimImageChain::findObject(const ossimConnectableObject
       ++current;
    }
    
-   return NULL;
+   return 0;
 }
 
-// ossimImageSource* ossimImageChain::findSource(const ossimId& id)
-// {
-//    ossimImageSource* result = NULL;
-//    for(unsigned long index = 0; index < theImageChainList.size();++index)
-//    {
-//      ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject, theImageChainList[index]);
-//      if(obj)
-//        {
-// 	 if(id == obj->getId())
-// 	   {
-//               return PTR_CAST(ossimImageSource,
-//                               theImageChainList[index];
-// 	   }
-//        }
-//    }
-//    // now lets search children of type ossimImageChain
-//    for(unsigned long index = 0; index < theImageChainList.size();++index)
-//    {
-//       ossimImageChain* child=PTR_CAST(ossimImageChain, theImageChainList[index]->getObject());
-//       if(child)
-//       {
-//          result = child->findSource(id);
-//          if(result)
-//          {
-//             return result;
-//          }
-//       }
-//    }
-   
-//    return result;
-// }
-
-// ossimImageSource* ossimImageChain::findFirstSourceOfType(const RTTItypeid& typeInfo)
-// {
-//    ossimImageSource* result = NULL;
-//    long index = 0;
-   
-//    for(index = 0; index < (long)theImageChainList.size();++index)
-//    {
-//       if(typeInfo.can_cast(TYPE_INFO(theImageChainList[index])))
-//       {
-//          return PTR_CAST(ossimImageSource,
-//                          theImageChainList[index]);
-//       }
-//    }
-
-//    // if still not found then search children.  It will
-//    // see if one of its children is another container of
-//    // type ossimImageChain.  If so, then it will call
-//    // its method.
-//    if(!result)
-//    {
-//       for(index = 0; index < (long)theImageChainList.size();++index)
-//       {
-//          ossimImageChain* child=PTR_CAST(ossimImageChain,
-//                                          theImageChainList[index]);
-         
-//          if(child)
-//          {
-//             result = child->findFirstSourceOfType(typeInfo);
-//             if(result)
-//             {
-//                return result;
-//             }
-//          }
-//       }
-//    }
-   
-//    return result;
-// }
-
 ossimConnectableObject* ossimImageChain::findFirstObjectOfType(const RTTItypeid& typeInfo,
                                                                bool recurse)
 {
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   vector<ossimRefPtr<ossimConnectableObject> >::iterator current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      if((*current)&&
+      if((*current).valid()&&
          (*current)->canCastTo(typeInfo))
       {
-         return (*current);
+         return (*current).get();
       }
       ++current;
    }
@@ -381,7 +306,8 @@ ossimConnectableObject* ossimImageChain::findFirstObjectOfType(const RTTItypeid&
       current =  theImageChainList.begin();
       while(current != theImageChainList.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current));
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, 
+                                                            (*current).get());
          
          if(child)
          {
@@ -401,14 +327,14 @@ ossimConnectableObject* ossimImageChain::findFirstObjectOfType(const RTTItypeid&
 ossimConnectableObject* ossimImageChain::findFirstObjectOfType(const ossimString& className,
                                                                bool recurse)
 {
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   vector<ossimRefPtr<ossimConnectableObject> >::iterator current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      if((*current)&&
+      if((*current).valid()&&
          (*current)->canCastTo(className) )
       {
-         return (*current);
+         return (*current).get();
       }
       ++current;
    }
@@ -418,7 +344,7 @@ ossimConnectableObject* ossimImageChain::findFirstObjectOfType(const ossimString
       current =  theImageChainList.begin();
       while(current != theImageChainList.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, *current);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).get());
          
          if(child)
          {
@@ -432,24 +358,26 @@ ossimConnectableObject* ossimImageChain::findFirstObjectOfType(const ossimString
       }
    }
    
-   return (ossimConnectableObject*)NULL;   
+   return (ossimConnectableObject*)0;   
 }
 
-std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const RTTItypeid& typeInfo,
+ossimConnectableObject::ConnectableObjectList ossimImageChain::findAllObjectsOfType(const RTTItypeid& typeInfo,
                                                                            bool recurse)
 {
-   std::vector<ossimConnectableObject*> result;
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   ossimConnectableObject::ConnectableObjectList result;
+   ossimConnectableObject::ConnectableObjectList::iterator current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      if((*current)&&
+      if((*current).valid()&&
          (*current)->canCastTo(typeInfo))
       {
-         vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), *current);
+         ossimConnectableObject::ConnectableObjectList::iterator iter = std::find(result.begin(), 
+                                                                                      result.end(), 
+                                                                                      (*current).get());
          if(iter == result.end())
          {
-            result.push_back(*current);
+            result.push_back((*current).get());
          }
       }
       ++current;
@@ -460,15 +388,15 @@ std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const
       current =  theImageChainList.begin();
       while(current != theImageChainList.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current));
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).get());
          
          if(child)
          {
-            vector<ossimConnectableObject*> temp;
+            ossimConnectableObject::ConnectableObjectList temp;
             temp = child->findAllObjectsOfType(typeInfo, recurse);
             for(long index=0; index < (long)temp.size();++index)
             {
-               std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), temp[index]);
+               ossimConnectableObject::ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), temp[index]);
                if(iter == result.end())
                {
                   result.push_back(temp[index]);
@@ -483,21 +411,23 @@ std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const
    
 }
 
-std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const ossimString& className,
+ossimConnectableObject::ConnectableObjectList ossimImageChain::findAllObjectsOfType(const ossimString& className,
                                                                            bool recurse)
 {
-   std::vector<ossimConnectableObject*> result;
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   ossimConnectableObject::ConnectableObjectList result;
+   ossimConnectableObject::ConnectableObjectList::iterator current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      if((*current)&&
+      if((*current).valid()&&
          (*current)->canCastTo(className))
       {
-         std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), (*current));
+         ossimConnectableObject::ConnectableObjectList::iterator iter = std::find(result.begin(), 
+                                                                         result.end(), 
+                                                                         (*current).get());
          if(iter == result.end())
          {
-            result.push_back(*current);
+            result.push_back((*current).get());
          }
       }
       ++current;
@@ -508,15 +438,15 @@ std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const
       current =  theImageChainList.begin();
       while(current != theImageChainList.end())
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, *current);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).get());
          
          if(child)
          {
-            vector<ossimConnectableObject*> temp;
+            ossimConnectableObject::ConnectableObjectList temp;
             temp = child->findAllObjectsOfType(className, recurse);
             for(long index=0; index < (long)temp.size();++index)
             {
-               std::vector<ossimConnectableObject*>::iterator iter = std::find(result.begin(), result.end(), temp[index]);
+               ossimConnectableObject::ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), temp[index]);
                if(iter == result.end())
                {
                   result.push_back(temp[index]);
@@ -531,52 +461,20 @@ std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const
    
 }
 
-// vector<ossimImageSource*> ossimImageChain::findAllSourcesOfType(const RTTItypeid& typeInfo)
-// {
-//    vector<ossimImageSource*> result;
-//    long index = 0;
-
-//    for(index = 0; index < (long)theImageChainList.size();++index)
-//    {
-//       if(typeInfo.can_cast(TYPE_INFO(theImageChainList[index]->getObject())))
-//       {
-//          result.push_back( theImageChainList[index]);
-//       }
-//    }
-//    // go through other image chains.
-//    for(index = 0; index < (long)theImageChainList.size();++index)
-//    {
-//       ossimImageChain* child=PTR_CAST(ossimImageChain, theImageChainList[index]->getObject());
-      
-//       if(child)
-//       {
-//          vector<ossimImageSource*> temp;
-         
-//          temp =  child->findAllSourcesOfType(typeInfo);
-//          for(long index2=0; index2 < (long)temp.size();index2++)
-//          {
-//             result.push_back(temp[index2]);
-//          }
-//       }
-//    }   
-   
-//    return result;
-// }
-
 void ossimImageChain::makeUniqueIds()
 {
    setId(ossimIdManager::instance()->generateId());
    for(long index = 0; index < (long)theImageChainList.size(); ++index)
    {
       ossimConnectableContainerInterface* container = PTR_CAST(ossimConnectableContainerInterface,
-                                                               theImageChainList[index]);
+                                                               theImageChainList[index].get());
       if(container)
       {
          container->makeUniqueIds();
       }
       else
       {
-         if(theImageChainList[index])
+         if(theImageChainList[index].valid())
          {
             theImageChainList[index]->setId(ossimIdManager::instance()->generateId());
          }
@@ -592,7 +490,7 @@ ossim_uint32 ossimImageChain::getNumberOfObjects(bool recurse)const
    {
       for(ossim_uint32 i = 0; i < theImageChainList.size(); ++i)
       {
-         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, theImageChainList[i]);
+         ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, theImageChainList[i].get());
          if(child)
          {
             result += child->getNumberOfObjects(true);
@@ -619,13 +517,13 @@ bool ossimImageChain::addChild(ossimConnectableObject* object)
 
 bool ossimImageChain::removeChild(ossimConnectableObject* object)
 {
-   vector<ossimConnectableObject*>::iterator current =  theImageChainList.begin();
+   vector<ossimRefPtr<ossimConnectableObject> >::iterator current =  theImageChainList.begin();
    ossim_uint32 i = 0;
    while(current != theImageChainList.end())
    {
-      if(*current)
+      if((*current).valid())
       {
-	 if(object == (*current))
+         if(object == (*current).get())
          {
             // Send an event to any listeners.
             ossimContainerEvent event((ossimObject*)this,
@@ -633,13 +531,13 @@ bool ossimImageChain::removeChild(ossimConnectableObject* object)
                                       OSSIM_EVENT_REMOVE_OBJECT_ID);
             fireEvent(event);
             object->changeOwner(NULL);
-
+            
             object->removeListener((ossimConnectableObjectListener*)this);
             object->removeListener((ossimConnectableObjectListener*)theChildListener);
-
-            std::vector<ossimConnectableObject*> input  = object->getInputList();
-            std::vector<ossimConnectableObject*> output = object->getOutputList();
-
+            
+            ossimConnectableObject::ConnectableObjectList input  = object->getInputList();
+            ossimConnectableObject::ConnectableObjectList output = object->getOutputList();
+            
             // remember the old size before removing
             ossim_uint32 chainSize = theImageChainList.size();
             current = theImageChainList.erase(current);
@@ -647,8 +545,8 @@ bool ossimImageChain::removeChild(ossimConnectableObject* object)
             // Clear connections between this object and child.
             object->disconnect();
             
-//              object->disconnect(this);
-//             object->disconnectAllInputs();
+            //              object->disconnect(this);
+            //             object->disconnectAllInputs();
             if(i == 0) // is it the first in the chain
             {
                theImageChainList[0]->removeListener(theChildListener);
@@ -658,7 +556,7 @@ bool ossimImageChain::removeChild(ossimConnectableObject* object)
             {
                if(chainSize > 1)
                {
-                  ossimConnectableObject* tempObj = theImageChainList[theImageChainList.size()-1];
+                  ossimConnectableObject* tempObj = theImageChainList[theImageChainList.size()-1].get();
                   if(tempObj)
                   {
                      tempObj->connectInputList(input);
@@ -668,29 +566,29 @@ bool ossimImageChain::removeChild(ossimConnectableObject* object)
             else // must be an interior
             {
                ossim_uint32 inIndex  = 0;
-
+               
                for(inIndex = 0; inIndex < input.size(); ++inIndex)
                {
-                  if(input[inIndex])
+                  if(input[inIndex].valid())
                   {
                      input[inIndex]->disconnectAllOutputs();
                      input[inIndex]->connectOutputList(output);
                   }
                }
             }
-
+            
             return true;
          }
       }
       ++current;
       ++i;
    }
-
+   
    current =  theImageChainList.begin();
    
    while(current != theImageChainList.end())
    {
-      ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, *current);
+      ossimConnectableContainerInterface* child=PTR_CAST(ossimConnectableContainerInterface, (*current).get());
       
       if(child)
       {
@@ -723,7 +621,7 @@ void ossimImageChain::getChildren(vector<ossimConnectableObject*>& children,
    vector<ossimConnectableObject*> temp;
    for(i = 0; i < theImageChainList.size();++i)
    {
-      temp.push_back(theImageChainList[i]);
+      temp.push_back(theImageChainList[i].get());
    }
 
    for(i = 0; i < temp.size();++i)
@@ -768,7 +666,7 @@ bool ossimImageChain::add(ossimConnectableObject* source)
         theImageChainList.insert(theImageChainList.begin(), source);
         theImageChainList[0]->addListener(theChildListener);
         source->addListener((ossimConnectableObjectListener*)this);
-        theImageChainList[0]->connectMyInputTo(theImageChainList[1]);
+        theImageChainList[0]->connectMyInputTo(theImageChainList[1].get());
         result = true;
      }
      else
@@ -827,7 +725,7 @@ bool ossimImageChain::insertRight(ossimConnectableObject* newObj,
    
    if(findObject(rightOfThisObj, false))
    {
-      vector<ossimConnectableObject*>::iterator iter = theImageChainList.begin();
+      std::vector<ossimRefPtr<ossimConnectableObject> >::iterator iter = theImageChainList.begin();
       while(iter != theImageChainList.end())
       {
          if( (*iter) == rightOfThisObj)
@@ -836,13 +734,13 @@ bool ossimImageChain::insertRight(ossimConnectableObject* newObj,
          }
          ++iter;
       }
-      if(rightOfThisObj == theImageChainList[0])
+      if(rightOfThisObj == theImageChainList[0].get())
       {
          return add(newObj);
       }
       else if(PTR_CAST(ossimImageSource, newObj))
       {
-         vector<ossimConnectableObject*> outputList = rightOfThisObj->getOutputList();
+         ossimConnectableObject::ConnectableObjectList outputList = rightOfThisObj->getOutputList();
          rightOfThisObj->disconnectAllOutputs();
 
          // Core dump fix.  Connect input prior to outputs. (drb)
@@ -886,7 +784,7 @@ bool ossimImageChain::insertLeft(ossimConnectableObject* newObj,
    
    if(findObject(leftOfThisObj, false))
    {
-      vector<ossimConnectableObject*>::iterator iter = theImageChainList.begin();
+      std::vector<ossimRefPtr<ossimConnectableObject> >::iterator iter = theImageChainList.begin();
 
       while(iter != theImageChainList.end())
       {
@@ -896,13 +794,13 @@ bool ossimImageChain::insertLeft(ossimConnectableObject* newObj,
          }
          ++iter;
       }
-      if(leftOfThisObj==theImageChainList[theImageChainList.size()-1])
+      if(leftOfThisObj==theImageChainList[theImageChainList.size()-1].get())
       {
          return addLast(newObj);
       }
       else if(PTR_CAST(ossimImageSource, newObj))
       {
-         vector<ossimConnectableObject*> inputList = leftOfThisObj->getInputList();
+         ossimConnectableObject::ConnectableObjectList inputList = leftOfThisObj->getInputList();
          leftOfThisObj->disconnectAllInputs();
          newObj->connectInputList(inputList);
          leftOfThisObj->connectMyInputTo(newObj);
@@ -940,8 +838,8 @@ bool ossimImageChain::replace(ossimConnectableObject* newObj,
    ossim_int32 idx = indexOf(oldObj);
    if(idx >= 0)
    {
-      std::vector<ossimConnectableObject*>& inputList = getInputList();
-      std::vector<ossimConnectableObject*>& outputList = oldObj->getOutputList();
+      ossimConnectableObject::ConnectableObjectList& inputList = getInputList();
+      ossimConnectableObject::ConnectableObjectList& outputList = oldObj->getOutputList();
       oldObj->removeListener((ossimConnectableObjectListener*)this);
       oldObj->removeListener(theChildListener);
       theImageChainList[idx] = newObj;
@@ -965,7 +863,7 @@ ossimRefPtr<ossimImageData> ossimImageChain::getTile(
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
          ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                         theImageChainList[0]);
+                                                         theImageChainList[0].get());
 
          if(interface)
          {
@@ -1005,7 +903,7 @@ ossim_uint32 ossimImageChain::getNumberOfInputBands() const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
       if(interface)
       {
          return interface->getNumberOfOutputBands();
@@ -1032,7 +930,7 @@ double ossimImageChain::getNullPixelValue(ossim_uint32 band)const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
       if(interface)
       {
          return interface->getNullPixelValue(band);
@@ -1059,7 +957,7 @@ double ossimImageChain::getMinPixelValue(ossim_uint32 band)const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
       if(interface)
       {
          return interface->getMinPixelValue(band);
@@ -1086,7 +984,7 @@ double ossimImageChain::getMaxPixelValue(ossim_uint32 band)const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* inter = PTR_CAST(ossimImageSource,
-                                                  theImageChainList[0]);
+                                                  theImageChainList[0].get());
       if(inter)
       {
          return inter->getMaxPixelValue(band);
@@ -1113,7 +1011,7 @@ void ossimImageChain::getOutputBandList(std::vector<ossim_uint32>& bandList) con
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* inter = PTR_CAST(ossimImageSource,
-                                                  theImageChainList[0]);
+                                                  theImageChainList[0].get());
       if(inter)
       {
          return inter->getOutputBandList(bandList);
@@ -1126,7 +1024,7 @@ ossimScalarType ossimImageChain::getOutputScalarType() const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
       if(interface)
       {
          return interface->getOutputScalarType();
@@ -1153,7 +1051,7 @@ ossim_uint32 ossimImageChain::getTileWidth()const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
          ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                         theImageChainList[0]);
+                                                         theImageChainList[0].get());
          if(interface)
          {
             return interface->getTileWidth();;
@@ -1180,7 +1078,7 @@ ossim_uint32 ossimImageChain::getTileHeight()const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
          ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                         theImageChainList[0]);
+                                                         theImageChainList[0].get());
          if(interface)
          {
             return interface->getTileHeight();
@@ -1208,7 +1106,7 @@ ossimIrect ossimImageChain::getBoundingRect(ossim_uint32 resLevel)const
    {
 
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
 
       if(interface)
       {
@@ -1241,7 +1139,7 @@ void ossimImageChain::getValidImageVertices(vector<ossimIpt>& validVertices,
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface =PTR_CAST(ossimImageSource,
-                                                     theImageChainList[0]);
+                                                     theImageChainList[0].get());
 
       if(interface)
       {
@@ -1266,34 +1164,29 @@ void ossimImageChain::getValidImageVertices(vector<ossimIpt>& validVertices,
    }
 }
 
-bool ossimImageChain::getImageGeometry(ossimKeywordlist& kwl,
-                                       const char* prefix)
+ossimImageGeometry*  ossimImageChain::getImageGeometry()
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+      ossimImageSource* interface = PTR_CAST(ossimImageSource, theImageChainList[0].get());
       if(interface)
       {
-         return interface->getImageGeometry(kwl,
-                                            prefix);
+         return interface->getImageGeometry();
       }
    }
    else
    {
       if(getInput(0))
       {
-         ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                         getInput(0));
+         ossimImageSource* interface = PTR_CAST(ossimImageSource, getInput(0));
          if(interface)
          {
-            return interface->getImageGeometry(kwl,
-                                               prefix);
+            return interface->getImageGeometry();
          }
       }
       
    }
-   return false;
+   return 0;
 }
 
 void ossimImageChain::getDecimationFactor(ossim_uint32 resLevel,
@@ -1302,7 +1195,7 @@ void ossimImageChain::getDecimationFactor(ossim_uint32 resLevel,
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
       if(interface)
       {
          interface->getDecimationFactor(resLevel,
@@ -1332,7 +1225,7 @@ void ossimImageChain::getDecimationFactors(vector<ossimDpt>& decimations) const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
       if(interface)
       {
          interface->getDecimationFactors(decimations);
@@ -1358,7 +1251,7 @@ ossim_uint32 ossimImageChain::getNumberOfDecimationLevels()const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      theImageChainList[0]);
+                                                      theImageChainList[0].get());
 
       if(interface)
       {
@@ -1425,9 +1318,9 @@ bool ossimImageChain::addAllSources(map<ossimId, vector<ossimId> >& idMapping,
          CLOG << "trying to create source with prefix: " << newPrefix
               << std::endl;
       }
-      ossimObject* object = ossimObjectFactoryRegistry::instance()->createObject(kwl,
+      ossimRefPtr<ossimObject> object = ossimObjectFactoryRegistry::instance()->createObject(kwl,
                                                                                  newPrefix.c_str());
-      ossimConnectableObject* source = PTR_CAST(ossimConnectableObject, object);
+      ossimConnectableObject* source = PTR_CAST(ossimConnectableObject, object.get());
       
       if(source)
       {
@@ -1456,7 +1349,7 @@ bool ossimImageChain::addAllSources(map<ossimId, vector<ossimId> >& idMapping,
                      CLOG << "connecting " << source->getClassName() << " to "
                           << theImageChainList[0]->getClassName() << std::endl;
                   }
-                  source->connectMyInputTo(0, theImageChainList[0]);
+                  source->connectMyInputTo(0, theImageChainList[0].get());
                }
             }
             else
@@ -1471,22 +1364,20 @@ bool ossimImageChain::addAllSources(map<ossimId, vector<ossimId> >& idMapping,
          }
          else
          {
-            delete source;
-            source = NULL;
+            source = 0;
          }
       }
       else
       {
-         delete object;
-         object = NULL;
-         source = NULL;
+         object = 0;
+         source = 0;
       }
       
       ++index;
    }
    if(theImageChainList.size())
    {
-     ossimConnectableObject* obj = theImageChainList[(long)theImageChainList.size()-1];
+     ossimConnectableObject* obj = theImageChainList[(ossim_int32)theImageChainList.size()-1].get();
      if(obj)
      {
         setNumberOfInputs(obj->getNumberOfInputs());
@@ -1645,10 +1536,10 @@ void ossimImageChain::initialize()
               << theImageChainList[index]->getClassName()
               << std::endl;
       }
-      if(theImageChainList[index])
+      if(theImageChainList[index].valid())
       {
          ossimImageSource* interface =
-            PTR_CAST(ossimImageSource, theImageChainList[index]);
+            PTR_CAST(ossimImageSource, theImageChainList[index].get());
 
          if(interface)
          {
@@ -1664,14 +1555,14 @@ void ossimImageChain::initialize()
 
 void ossimImageChain::enableSource()
 {
-   long upper = theImageChainList.size();
-   
-   for(long index = upper - 1; index >= 0; --index)
+   ossim_int32 upper = static_cast<ossim_int32>(theImageChainList.size());
+   ossim_int32 index = 0;
+   for(index = upper - 1; index >= 0; --index)
    {
       // make sure we initialize in reverse order.
       // some source may depend on the initialization of
       // its inputs
-     ossimSource* source = PTR_CAST(ossimSource, theImageChainList[index]);
+     ossimSource* source = PTR_CAST(ossimSource, theImageChainList[index].get());
      if(source)
      {
         source->enableSource();
@@ -1690,7 +1581,7 @@ void ossimImageChain::disableSource()
       // make sure we initialize in reverse order.
       // some source may depend on the initialization of
       // its inputs
-     ossimSource* source = PTR_CAST(ossimSource, theImageChainList[index]);
+     ossimSource* source = PTR_CAST(ossimSource, theImageChainList[index].get());
      if(source)
      {
         source->disableSource();
@@ -1700,12 +1591,6 @@ void ossimImageChain::disableSource()
    theEnableFlag = false;
 }
 
-
-vector<ossimConnectableObject*>& ossimImageChain::getChildren()
-{
-   return theImageChainList;
-}
-
 bool ossimImageChain::deleteFirst()
 {
    if (theImageChainList.size() == 0) return false;
@@ -1716,10 +1601,10 @@ bool ossimImageChain::deleteFirst()
       removeListener((ossimConnectableObjectListener*)this);
    theImageChainList[index]->removeListener(theChildListener);
    theImageChainList[index]->changeOwner(NULL);
-   delete theImageChainList[index];
+   theImageChainList[index] = 0;
    
    // Remove from the vector.
-   vector<ossimConnectableObject*>::iterator i = theImageChainList.begin();
+   std::vector<ossimRefPtr<ossimConnectableObject> >::iterator i = theImageChainList.begin();
    theImageChainList.erase(i);
    return true;
 }
@@ -1734,7 +1619,7 @@ bool ossimImageChain::deleteLast()
       removeListener((ossimConnectableObjectListener*)this);
    theImageChainList[index]->removeListener(theChildListener);
    theImageChainList[index]->changeOwner(NULL);
-   delete theImageChainList[index];
+   theImageChainList[index] = 0;
    
    // Remove from the vector.
    theImageChainList.pop_back();
@@ -1744,16 +1629,13 @@ bool ossimImageChain::deleteLast()
 void ossimImageChain::deleteList()
 {
    long upper = theImageChainList.size();
-
-   
    for(long index = 0; index < upper; ++index)
    {
       theImageChainList[index]->removeListener((ossimConnectableObjectListener*)this);
       theImageChainList[index]->removeListener(theChildListener);
-      theImageChainList[index]->changeOwner(NULL);
-      delete theImageChainList[index];
+      theImageChainList[index]->disconnect();
    }
-
+   
    theImageChainList.clear();
 }
 
@@ -1763,7 +1645,7 @@ void ossimImageChain::disconnectInputEvent(ossimConnectionEvent& event)
    {
       if(event.getObject()==this)
       {
-         if(theImageChainList[theImageChainList.size()-1])
+         if(theImageChainList[theImageChainList.size()-1].valid())
          {
             for(ossim_uint32 i = 0; i < event.getNumberOfOldObjects(); ++i)
             {
@@ -1784,7 +1666,7 @@ void ossimImageChain::connectInputEvent(ossimConnectionEvent& event)
    {
       if(event.getObject()==this)
       {
-         if(theImageChainList[theImageChainList.size()-1])
+         if(theImageChainList[theImageChainList.size()-1].valid())
          {
             for(ossim_uint32 i = 0; i < event.getNumberOfNewObjects(); ++i)
             {
@@ -1795,7 +1677,7 @@ void ossimImageChain::connectInputEvent(ossimConnectionEvent& event)
             }
          }
       }
-      else if(event.getObject() == theImageChainList[0])
+      else if(event.getObject() == theImageChainList[0].get())
       {
          if(!theLoadStateFlag)
          {
@@ -1851,7 +1733,7 @@ void ossimImageChain::propagateEventToOutputs(ossimEvent& event)
    //thePropagateEventFlag = true;
    if(theImageChainList.size())
    {
-      if(theImageChainList[theImageChainList.size()-1])
+      if(theImageChainList[theImageChainList.size()-1].valid())
       {
          theImageChainList[theImageChainList.size()-1]->fireEvent(event);
          theImageChainList[theImageChainList.size()-1]->propagateEventToOutputs(event);
@@ -1867,7 +1749,7 @@ void ossimImageChain::propagateEventToInputs(ossimEvent& event)
 //   thePropagateEventFlag = true;
    if(theImageChainList.size())
    {
-      if(theImageChainList[0])
+      if(theImageChainList[0].valid())
       {
          theImageChainList[0]->fireEvent(event);
          theImageChainList[0]->propagateEventToInputs(event);
@@ -1886,10 +1768,10 @@ ossimConnectableObject* ossimImageChain::getConnectableObject(
 {
    if(theImageChainList.size() && (index < theImageChainList.size()))
    {
-      return theImageChainList[index];
+      return theImageChainList[index].get();
    }
    
-   return (ossimConnectableObject*)NULL; 
+   return 0; 
 }
 
 ossim_int32 ossimImageChain::indexOf(ossimConnectableObject* obj)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageCombiner.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageCombiner.cpp
index 0a6f38ff324ca338b86b704eb2563cce79fd6e7b..bae8c9315666886d6c224a035e4f6d19d4d345aa 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageCombiner.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageCombiner.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageCombiner.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimImageCombiner.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimImageCombiner.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimIrect.h>
@@ -54,7 +54,7 @@ ossimImageCombiner::ossimImageCombiner(ossimObject* owner,
    theComputeFullResBoundsFlag = true;
 }
 
-ossimImageCombiner::ossimImageCombiner(const std::vector<ossimImageSource*>& inputSources)
+ossimImageCombiner::ossimImageCombiner(ossimConnectableObject::ConnectableObjectList& inputSources)
    :ossimImageSource(NULL,
                      inputSources.size(),
                      0,
@@ -69,7 +69,7 @@ ossimImageCombiner::ossimImageCombiner(const std::vector<ossimImageSource*>& inp
 	theComputeFullResBoundsFlag = true;
    for(ossim_uint32 index = 0; index < inputSources.size(); ++index)
    {
-      connectMyInputTo(index, inputSources[index]);
+      connectMyInputTo(index, inputSources[index].get());
    }
    addListener((ossimConnectableObjectListener*)this);
    initialize();
@@ -650,17 +650,13 @@ bool ossimImageCombiner::hasDifferentInputs()const
    return theHasDifferentInputs;
 }
 
-bool ossimImageCombiner::getImageGeometry(ossimKeywordlist& kwl,
-                                          const char* prefix)
+ossimImageGeometry* ossimImageCombiner::getImageGeometry()
 {
    if(getInput(0))
    {
-      ossimImageSource* inter = PTR_CAST(ossimImageSource,
-                                                  getInput(0));
+      ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput(0));
       if(inter)
-      {
-         return inter->getImageGeometry(kwl, prefix);
-      }
+         return inter->getImageGeometry();
    }
    
    return false;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp
index 389030b07f8d9fdd6300759d8124d22f81c2e02f..8a69bbb4b56ccee2ffe390f3251e115f85e446fe 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageData.cpp 14529 2009-05-16 23:55:18Z dburken $
+// $Id: ossimImageData.cpp 15792 2009-10-22 18:03:13Z dburken $
 
 #include <iterator>
 
@@ -77,9 +77,29 @@ ossimImageData::ossimImageData(ossimSource* owner,
    initializeDefaults();
 }
 
-ossimImageData::ossimImageData(const ossimImageData &rhs) : ossimRectilinearDataObject(rhs)
+ossimImageData::ossimImageData(const ossimImageData &rhs)
+   : ossimRectilinearDataObject(rhs),
+     theNullPixelValue(rhs.theNullPixelValue),
+     theMinPixelValue(rhs.theMinPixelValue),
+     theMaxPixelValue(rhs.theMaxPixelValue),
+     theOrigin(rhs.theOrigin)
 {
-   *this = rhs;
+}
+
+const ossimImageData& ossimImageData::operator=(const ossimImageData& rhs)
+{
+   if (this != &rhs)
+   {
+      // ossimRectilinearDataObject initialization:
+      ossimRectilinearDataObject::operator=(rhs);
+      
+      // ossimImageData (this) members:
+      theNullPixelValue = rhs.theNullPixelValue;
+      theMinPixelValue  = rhs.theMinPixelValue;
+      theMaxPixelValue  = rhs.theMaxPixelValue;
+      theOrigin         = rhs.theOrigin;      
+   }
+   return *this;
 }
 
 ossimImageData::~ossimImageData()
@@ -1069,7 +1089,7 @@ ossimDataObjectStatus ossimImageData::validate() const
 template <class T>
 ossimDataObjectStatus ossimImageData::validate(T /* dummyTemplate */ ) const
 {
-   if (getBuf() == 0)
+   if (theDataBuffer.size() == 0)
    {
       setDataObjectStatus(OSSIM_NULL);
       return OSSIM_NULL;
@@ -1172,10 +1192,7 @@ Invalid scalar type:  %d",
 
 template <class T> void ossimImageData::makeBlank(T /* dummyTemplate */ )
 {
-   if ( (getBuf() == 0) || (getDataObjectStatus() == OSSIM_EMPTY) )
-   {
-      return; // nothing to do...
-   }
+   // Note: Empty buffer or already OSSIM_EMPTY checked in public method.
    
    const ossim_uint32 BANDS = getNumberOfBands();
    const ossim_uint32 SPB   = getSizePerBand();
@@ -1912,8 +1929,8 @@ bool ossimImageData::isNull(const ossimIpt& pt)const
 {
    ossim_int32 xNew = (pt.x - theOrigin.x);
    ossim_int32 yNew = (pt.y - theOrigin.y);
-   if(xNew < 0 || xNew >= (int)theSpatialExtents[0] ||
-      yNew < 0 || yNew >= (int)theSpatialExtents[1])
+   if(xNew < 0 || xNew >= static_cast<ossim_int32>(theSpatialExtents[0]) ||
+      yNew < 0 || yNew >= static_cast<ossim_int32>(theSpatialExtents[1]) )
    {
       return true;
    }
@@ -1926,8 +1943,8 @@ bool ossimImageData::isNull(const ossimIpt& pt, ossim_uint32 band)const
 {
    ossim_int32 xNew = (pt.x - theOrigin.x);
    ossim_int32 yNew = (pt.y - theOrigin.y);
-   if(xNew < 0 || xNew >= (int)theSpatialExtents[0] ||
-      yNew < 0 || yNew >= (int)theSpatialExtents[1])
+   if(xNew < 0 || xNew >= static_cast<ossim_int32>(theSpatialExtents[0]) ||
+      yNew < 0 || yNew >= static_cast<ossim_int32>(theSpatialExtents[1]) )
    {
       return true;
    }
@@ -3741,16 +3758,16 @@ bool ossimImageData::isPointWithin(const ossimIpt& point)const
 {
    return ((point.x >= theOrigin.x)&&
            (point.y >= theOrigin.y)&&
-           ((point.x - theOrigin.x)<static_cast<long>(theSpatialExtents[0]))&&
-           ((point.y - theOrigin.y)<static_cast<long>(theSpatialExtents[1])));
+           ((point.x - theOrigin.x)<static_cast<ossim_int32>(theSpatialExtents[0]))&&
+           ((point.y - theOrigin.y)<static_cast<ossim_int32>(theSpatialExtents[1])));
 }
 
 bool ossimImageData::isPointWithin(ossim_int32 x, ossim_int32 y)const
 {
    return ((x >= theOrigin.x)&&
            (y >= theOrigin.y)&&
-           ((x - theOrigin.x) < static_cast<long>(theSpatialExtents[0]))&&
-           ((y - theOrigin.y) < static_cast<long>(theSpatialExtents[1])));
+           ((x - theOrigin.x) < static_cast<ossim_int32>(theSpatialExtents[0]))&&
+           ((y - theOrigin.y) < static_cast<ossim_int32>(theSpatialExtents[1])));
 }
 
 void ossimImageData::unloadTile(void* dest,
@@ -3784,7 +3801,7 @@ File %s line %d\nUnknown scalar type!",
                        __FILE__,
                        __LINE__);      
          return;
-   } // End of "switch (getScalarType())"
+   }
 }
 
 void ossimImageData::unloadTileToBip(void* dest,
@@ -4008,8 +4025,97 @@ File %s line %d\nUnsupported scalar type for method!",
    }
 }
 
+void ossimImageData::unloadBand( void* dest,
+                                 ossim_uint32 src_band,
+                                 ossim_uint32 dest_band,
+                                 const ossimIrect& dest_rect,
+                                 ossimInterleaveType il_type,
+                                 OverwriteBandRule ow_type ) const
+{
+   unloadBand( dest, src_band, dest_band, dest_rect, getImageRectangle(), il_type, ow_type );
+}
+
+void ossimImageData::unloadBand( void* dest,
+                                 ossim_uint32 src_band,
+                                 ossim_uint32 dest_band,
+                                 const ossimIrect& dest_rect,
+                                 const ossimIrect& clip_rect,
+                                 ossimInterleaveType il_type,
+                                 OverwriteBandRule ow_type ) const
+{
+   static const char  MODULE[] = "ossimImageData::unloadBand";
+
+   if ( il_type == OSSIM_BSQ )
+   {
+      unloadBandToBsq( dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+   }
+   else
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+         << MODULE << " NOTICE:"
+         << "\nUnsupported interleave type:  " << il_type << "  Returning..."
+         << std::endl;
+   }
+}
+
+void ossimImageData::unloadBandToBsq( void* dest,
+                                      ossim_uint32 src_band,
+                                      ossim_uint32 dest_band,
+                                      const ossimIrect& dest_rect,
+                                      const ossimIrect& clip_rect,
+                                      OverwriteBandRule ow_type ) const
+{
+   switch (getScalarType())
+   {
+      case OSSIM_UINT8:
+         unloadBandToBsqTemplate(ossim_uint8(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_SINT8:
+         unloadBandToBsqTemplate(ossim_sint8(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_UINT16:
+      case OSSIM_USHORT11:
+         unloadBandToBsqTemplate(ossim_uint16(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_SINT16:
+         unloadBandToBsqTemplate(ossim_sint16(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_UINT32:
+         unloadBandToBsqTemplate(ossim_uint32(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_SINT32:
+         unloadBandToBsqTemplate(ossim_sint32(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_NORMALIZED_FLOAT:
+      case OSSIM_FLOAT32:
+         unloadBandToBsqTemplate(ossim_float32(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_NORMALIZED_DOUBLE:
+      case OSSIM_FLOAT64:
+         unloadBandToBsqTemplate(ossim_float64(0), dest, src_band, dest_band, dest_rect, clip_rect, ow_type );
+         return;
+
+      case OSSIM_SCALAR_UNKNOWN:
+      default:
+         ossimSetError(getClassName(),
+            ossimErrorCodes::OSSIM_ERROR,
+            "ossimImageData::unloadBandToBsq\n\
+            File %s line %d\nUnsupported scalar type for method!",
+            __FILE__,
+            __LINE__);      
+         return;
+   }
+}
+
 template <class T>
-void ossimImageData::unloadBandTemplate(T, // dummy tmeplate variable
+void ossimImageData::unloadBandTemplate(T, // dummy template variable
                                         void* dest,
                                         const ossimIrect& dest_rect,
                                         const ossimIrect& clip_rect,
@@ -4356,11 +4462,12 @@ ossimImageData::unloadTileToBilTemplate(T,  // dummy template arg...
    }
 }
 
-template <class T> void ossimImageData::nullTileAlphaTemplate(T,
-                                                              const ossim_uint8* src,
-                                                              const ossimIrect& src_rect,
-                                                              const ossimIrect& clip_rect,
-                                                              bool multiplyAlphaFlag)
+template <class T> void ossimImageData::nullTileAlphaTemplate(
+   T,
+   const ossim_uint8* src,
+   const ossimIrect& src_rect,
+   const ossimIrect& clip_rect,
+   bool multiplyAlphaFlag)
 {
    static const char  MODULE[] = "ossimImageData::nullTileAlphaTemplate";
    
@@ -4521,37 +4628,36 @@ ossimImageData::unloadTileToBsqTemplate(T,  // dummy template arg...
       return;
    }
 
-   ossim_uint32 num_bands     = getNumberOfBands();
-   ossim_uint32 band          = 0;
+   ossim_uint32 num_bands = getNumberOfBands();
+   ossim_uint32 band      = 0;
    if(!dataIsNull)
    {
-      ossim_uint32 num_bands     = getNumberOfBands();
       ossim_uint32 d_width       = dest_rect.lr().x - dest_rect.ul().x + 1;
       ossim_uint32 d_band_offset = d_width * (dest_rect.lr().y-dest_rect.ul().y+1);
       ossim_uint32 s_width       = getWidth();
       ossim_uint32 s_offset      = (output_clip_rect.ul().y - img_rect.ul().y) *
-                             s_width + (output_clip_rect.ul().x - img_rect.ul().x);
-      
+                                   s_width + (output_clip_rect.ul().x - img_rect.ul().x);
+
       T* d        = static_cast<T*>(dest);
       const T** s = new const T*[num_bands];
-      
+
       // Grab a pointers to each one.
       for (band=0; band<num_bands; ++band)
       {
          s[band] = reinterpret_cast<const T*>(getBuf(band));
-         
+
          // Move to first valid pixel.
          s[band] += s_offset;
       }
-      
+
       // Move to first valid pixel.
       d += (output_clip_rect.ul().y - dest_rect.ul().y) * d_width +
            (output_clip_rect.ul().x - dest_rect.ul().x);
-      
+
       for (band=0; band<num_bands; ++band)
       {
          ossim_uint32 d_buf_offset = 0;
-         
+
          for (ossim_int32 line=output_clip_rect.ul().y;
               line<=output_clip_rect.lr().y; ++line)
          {
@@ -4562,7 +4668,7 @@ ossimImageData::unloadTileToBsqTemplate(T,  // dummy template arg...
                d[d_buf_offset+i] = s[band][i];
                ++i;
             }
-         
+
             d_buf_offset += d_width;
             s[band]      += s_width;
          }
@@ -4606,6 +4712,164 @@ ossimImageData::unloadTileToBsqTemplate(T,  // dummy template arg...
    }
 }
 
+template <class T> void
+ossimImageData::unloadBandToBsqTemplate(T,  // dummy template arg...
+                                        void* dest,
+                                        ossim_uint32 src_band,
+                                        ossim_uint32 dest_band,
+                                        const ossimIrect& dest_rect,
+                                        const ossimIrect& clip_rect,
+                                        OverwriteBandRule ow_type) const
+{
+   static const char  MODULE[] = "ossimImageData::unloadBandToBsq";
+
+   // Check the pointers.
+   if (!dest)
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+         << MODULE << " ERROR:"
+         << "\nNULL pointer passed to method!  Returning..." << std::endl;
+      return;
+   }
+
+   bool dataIsNull = false;
+   if (getDataObjectStatus() == OSSIM_NULL)
+   {
+      dataIsNull = true;
+   }
+
+   ossimIrect img_rect = getImageRectangle();
+
+   // Clip the clip_rect to the tile rect.
+   ossimIrect output_clip_rect = clip_rect.clipToRect(img_rect);
+
+   // Clip it again to the destination rect.
+   output_clip_rect = dest_rect.clipToRect(output_clip_rect);
+
+   // Check the output clip rect for intersection.
+   if (output_clip_rect.hasNans())
+   {
+      return;
+   }
+   if ( !(output_clip_rect.intersects(dest_rect)) )
+   {
+      return;
+   }
+
+   ossim_uint32 num_bands = getNumberOfBands();
+   ossim_uint32 band      = 0;
+   if(!dataIsNull)
+   {
+      ossim_uint32 d_width       = dest_rect.lr().x - dest_rect.ul().x + 1;
+      ossim_uint32 d_band_offset = d_width * (dest_rect.lr().y-dest_rect.ul().y+1);
+      ossim_uint32 s_width  = getWidth();
+      ossim_uint32 s_offset = (output_clip_rect.ul().y - img_rect.ul().y) *
+         s_width + (output_clip_rect.ul().x - img_rect.ul().x);
+
+      T* d        = static_cast<T*>(dest);
+      const T** s = new const T*[num_bands];
+
+      // Grab a pointers to each one.
+      for (band=0; band<num_bands; ++band)
+      {
+         s[band] = reinterpret_cast<const T*>(getBuf(band));
+
+         // Move to first valid pixel.
+         s[band] += s_offset;
+      }
+
+      // Move to first valid pixel.
+      d += (output_clip_rect.ul().y - dest_rect.ul().y) * d_width +
+           (output_clip_rect.ul().x - dest_rect.ul().x);
+
+      ossim_uint32 d_dest_band_offset = dest_band * d_band_offset;
+      ossim_uint32 d_buf_offset = 0;
+
+      for (ossim_int32 line=output_clip_rect.ul().y;
+         line<=output_clip_rect.lr().y; ++line)
+      {
+         ossim_int32 i=0;
+         for (ossim_int32 samp=output_clip_rect.ul().x;
+            samp<=output_clip_rect.lr().x; ++samp)
+         {
+            ossim_uint32 d_pixel_offset = d_buf_offset+i;
+            ossim_uint32 d_dest_band_pixel_offset = d_pixel_offset + d_dest_band_offset;
+
+            switch( ow_type )
+            {
+               case COLOR_DISCREPANCY:
+               {
+                  T d_dest_band = d[d_dest_band_pixel_offset];
+
+                  for ( band=0; band<num_bands; ++band )
+                  {
+                     if (band!=dest_band)
+                     {
+                        T d_other_band = d[d_pixel_offset + (band * d_band_offset)];
+                        
+                        // test for the color discrepancy
+                        if ( d_other_band != d_dest_band )
+                        {
+                           d[d_dest_band_pixel_offset] = s[src_band][i];
+                           break;
+                        }
+                     }
+                  }
+               }
+               break;
+
+               case NULL_RULE:
+               default:
+               {
+                  d[d_dest_band_pixel_offset] = s[src_band][i];
+               }
+               break;
+            }
+
+            ++i;
+         }
+
+         d_buf_offset += d_width;
+         s[src_band]  += s_width;
+      }
+
+      // Free up memory allocated for pointers.
+      delete [] s;
+   }
+   else
+   {
+      ossim_uint32 d_width       = dest_rect.lr().x - dest_rect.ul().x + 1;
+      ossim_uint32 d_band_offset = d_width * (dest_rect.lr().y-dest_rect.ul().y+1);
+
+      ossim_uint8* d = static_cast<ossim_uint8*>(dest);
+
+      // Move to first valid pixel.
+      d += (output_clip_rect.ul().y - dest_rect.ul().y) * d_width +
+         (output_clip_rect.ul().x - dest_rect.ul().x);
+
+      for (band=0; band<num_bands; ++band)
+      {
+         ossim_uint8 np = static_cast<ossim_uint8>(theNullPixelValue[band]);
+         ossim_uint32 d_buf_offset = 0;
+
+         for (ossim_int32 line=output_clip_rect.ul().y;
+            line<=output_clip_rect.lr().y; ++line)
+         {
+            ossim_int32 i=0;
+            for (ossim_int32 samp=output_clip_rect.ul().x;
+               samp<=output_clip_rect.lr().x; ++samp)
+            {
+               d[d_buf_offset+i] = np;
+               ++i;
+            }
+
+            d_buf_offset += d_width;
+         }
+         d += d_band_offset;
+      }
+   }
+}
+
 ossimObject* ossimImageData::dup() const
 {
    return new ossimImageData(*this);
@@ -5660,50 +5924,153 @@ std::ostream& ossimImageData::print(std::ostream& out) const
    return ossimRectilinearDataObject::print(out);
 }
 
+void ossimImageData::stretchMinMax()
+{
+   if ( (getDataObjectStatus() != OSSIM_NULL) &&
+        (getDataObjectStatus() != OSSIM_EMPTY) )
+   {
+      switch (getScalarType())
+      {
+         case OSSIM_UINT8:
+         {
+            stretchMinMax(ossim_uint8(0));
+            return;
+         }  
+         case OSSIM_SINT8:
+         {
+            stretchMinMax(ossim_sint8(0));
+            return;
+         }  
+         case OSSIM_UINT16:
+         case OSSIM_USHORT11:
+         {
+            stretchMinMax(ossim_uint16(0));
+            return;
+         }  
+         case OSSIM_SINT16:
+         {
+            stretchMinMax(ossim_sint16(0));
+            return;
+         }  
+         case OSSIM_UINT32:
+         {
+            stretchMinMax(ossim_uint32(0));
+            return;
+         }
+         case OSSIM_SINT32:
+         {
+            stretchMinMax(ossim_sint32(0));
+            return;
+         }  
+         case OSSIM_FLOAT32:
+         case OSSIM_NORMALIZED_FLOAT:
+         {
+            stretchMinMax(ossim_float32(0.0));
+            return;
+         }  
+         case OSSIM_NORMALIZED_DOUBLE:
+         case OSSIM_FLOAT64:
+         {
+            stretchMinMax(ossim_float64(0.0));
+            return;
+         }  
+         case OSSIM_SCALAR_UNKNOWN:
+         default:
+         {
+            setDataObjectStatus(OSSIM_STATUS_UNKNOWN);
+            ossimSetError(getClassName(),
+                          ossimErrorCodes::OSSIM_ERROR,
+                          "ossimImageData::stretchMinMax File %s line %d\n\
+Invalid scalar type:  %d",
+                          __FILE__,
+                          __LINE__,
+                          getScalarType());
+            break;
+         }
+      }
+   }
+}
+
+template <class T> void ossimImageData::stretchMinMax(T dummyTemplate)
+{
+   const ossim_uint32 BANDS  = getNumberOfBands();
+   const ossim_uint32 SPB    = getSizePerBand();
+
+   // scalar min
+   const ossim_float64 S_MIN = ossim::defaultMin(getScalarType());
+
+   // scalar max
+   const ossim_float64 S_MAX = ossim::defaultMax(getScalarType());
+
+   // scalar range
+   const ossim_float64 S_RNG = S_MAX-S_MIN+1.0;
+
+   for(ossim_uint32 band = 0; band < BANDS; ++band)
+   {
+      T* s = static_cast<T*>(getBuf(band));
+
+      if (s)
+      {
+         const ossim_float64 T_NUL = theNullPixelValue[band]; // tile null
+         const ossim_float64 T_MIN = theMinPixelValue[band];  // tile min
+         const ossim_float64 T_MAX = theMaxPixelValue[band];  // tile max
+         const ossim_float64 T_RNG = T_MAX-T_MIN+1;           // tile range
+         const ossim_float64 SPP = S_RNG / T_RNG; // stretch per pixel
+         
+         for(ossim_uint32 i = 0; i < SPB; ++i)
+         {
+            if (s[i] != T_NUL)
+            {
+               ossim_float64 p = s[i];
+               if (p <= T_MIN)
+               {
+                  p = S_MIN;
+               }
+               else if (p >= T_MAX)
+               {
+                  p = S_MAX;
+               }
+               else
+               {
+                  p = (p - T_MIN + 1.0) * SPP + S_MIN - 1.0;
+               }
+               s[i] = ossim::round<T>(p);
+            }
+         }
+      }
+   } 
+}
+
 ossim_uint32 ossimImageData::getWidth()const
 {
-   if(theSpatialExtents) return theSpatialExtents[0];
-   return 0;
+   return theSpatialExtents[0];
 }
 
 ossim_uint32 ossimImageData::getHeight()const
 {
-   if(theSpatialExtents) return theSpatialExtents[1];
-   return 0;
+   return theSpatialExtents[1];
 }
 
 void ossimImageData::getWidthHeight(ossim_uint32& w, ossim_uint32& h)
 {
-   if(theSpatialExtents)
-   {
-      w = theSpatialExtents[0];
-      h = theSpatialExtents[1];
-   }
+   w = theSpatialExtents[0];
+   h = theSpatialExtents[1];
 }
 
 void ossimImageData::setWidth(ossim_uint32 width)
 {
-   if(theSpatialExtents)
-   {
-      theSpatialExtents[0] = width;
-   }
+   theSpatialExtents[0] = width;
 }
 
 void ossimImageData::setHeight(ossim_uint32 height)
 {
-   if(theSpatialExtents)
-   {
-      theSpatialExtents[1] = height;
-   }
+   theSpatialExtents[1] = height;
 }
 
 void ossimImageData::setWidthHeight(ossim_uint32 w, ossim_uint32 h)
 {
-   if(theSpatialExtents)
-   {
-      theSpatialExtents[0] = w;
-      theSpatialExtents[1] = h;
-   }
+   theSpatialExtents[0] = w;
+   theSpatialExtents[1] = h;
 }
 
 void ossimImageData::setOrigin(const ossimIpt& origin)
@@ -5715,15 +6082,3 @@ ossim_uint32 ossimImageData::getDataSizeInBytes()const
 {
    return getSizeInBytes();
 }
-
-const ossimImageData& ossimImageData::operator=(const ossimImageData& rhs)
-{
-   theOrigin = rhs.theOrigin;
-
-   // let STL do the copying
-   theNullPixelValue = rhs.theNullPixelValue;
-   theMinPixelValue = rhs.theMinPixelValue;
-   theMaxPixelValue = rhs.theMaxPixelValue;
-
-   return *this;
-}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp
index a20e56932706981d72b8b5ede5b7b541e25b15c8..ec4502de2cc37fd7dac66254ea2515d34bdd0802 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp
@@ -1,12 +1,15 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Garrett Potts
 // Contributor: David A. Horner (DAH) - http://dave.thehorners.com
 // 
 //*************************************************************************
-// $Id: ossimImageDataFactory.cpp 13474 2008-08-22 14:20:42Z gpotts $
+// $Id: ossimImageDataFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
+
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimU8ImageData.h>
 #include <ossim/imaging/ossimU11ImageData.h>
@@ -14,6 +17,7 @@
 #include <ossim/imaging/ossimS16ImageData.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageSource.h>
+#include <ossim/base/ossimNotify.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimScalarTypeLut.h>
 
@@ -22,7 +26,7 @@ static ossimTrace traceDebug("ossimImageDataFactory:debug");
 
 ossimImageDataFactory* ossimImageDataFactory::theInstance = 0;
 OpenThreads::Mutex ossimImageDataFactory::theInstanceMutex;
-ossimImageDataFactory::ossimImageDataFactory()
+ossimImageDataFactory::ossimImageDataFactory() 
 {
    theInstance = 0;
 }
@@ -82,30 +86,21 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
          result = new ossimU8ImageData(owner, bands, width, height);
          break;
       }
-
       case OSSIM_USHORT11:
       {
          result = new ossimU11ImageData(owner, bands, width, height);
          break;
       }
-      
-      // ther are bugs in the 16 bit that I don't have time to find.
-      // The default image data object works good though.
-      //
-      // So for now I will comment these out.  I think it has something to
-      // do with the normalization it makes everything black
-      //
-      //
-//       case OSSIM_USHORT16:
-//       {
-//          result = new ossimU16ImageData(owner, bands, width, height);
-//          break;
-//       }
-//       case OSSIM_SSHORT16:
-//       {
-//          result = new ossimS16ImageData(owner, bands, width, height);
-//          break;
-//       }
+      case OSSIM_UINT16:
+      {
+         result = new ossimU16ImageData(owner, bands, width, height);
+         break;
+      }
+      case OSSIM_SINT16:
+      {
+         result = new ossimS16ImageData(owner, bands, width, height);
+         break;
+      }
       default:
       {
          // create a generic image data implementation.
@@ -113,7 +108,7 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
          break;
       }
    }
-   
+
    return result;
 }
 
@@ -153,30 +148,21 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
          result = new ossimU8ImageData(owner, bands, width, height);
          break;
       }
-
       case OSSIM_USHORT11:
       {
          result = new ossimU11ImageData(owner, bands, width, height);
          break;
       }
-      
-      // ther are bugs in the 16 bit that I don't have time to find.
-      // The default image data object works good though.
-      //
-      // So for now I will comment these out.  I think it has something to
-      // do with the normalization it makes everything black
-      //
-      //
-//       case OSSIM_USHORT16:
-//       {
-//          result = new ossimU16ImageData(owner, bands, width, height);
-//          break;
-//       }
-//       case OSSIM_SSHORT16:
-//       {
-//          result = new ossimS16ImageData(owner, bands, width, height);
-//          break;
-//       }
+      case OSSIM_UINT16:
+      {
+         result = new ossimU16ImageData(owner, bands, width, height);
+         break;
+      }
+      case OSSIM_SINT16:
+      {
+         result = new ossimS16ImageData(owner, bands, width, height);
+         break;
+      }
       default:
       {
          // create a generic image data implementation.
@@ -184,7 +170,7 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
          break;
       }
    }
-   
+
    return result;
 }
 
@@ -212,8 +198,9 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
    }
    else
    {
-      cerr << "ossimImageDataFactory::create ERROR:"
-           << "\nNULL input source!" << endl;
+      ossimNotify(ossimNotifyLevel_WARN)
+         << "ossimImageDataFactory::create ERROR:"
+         << "\nNULL input source!" << std::endl;
    }
    
    return result;
@@ -244,8 +231,9 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
    }
    else
    {
-      cerr << "ossimImageDataFactory::create ERROR:"
-           << "\nNULL input source!" << endl;
+      ossimNotify(ossimNotifyLevel_WARN)
+         << "ossimImageDataFactory::create ERROR:"
+         << "\nNULL input source!" << std::endl;
    }
 
    return result;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp
index 61da88552a0d9d0e82118f7320e70b41b9ca534c..9a7f98fabc46df6cd94c98121db5aeb88079ea53 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp
@@ -8,7 +8,7 @@
 //
 // Contains class declaration for ossimImageFileWriter.
 //*******************************************************************
-//  $Id: ossimImageFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimImageFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 
 #include <tiff.h> /* for tiff compression defines */
@@ -50,7 +50,7 @@
 static ossimTrace traceDebug("ossimImageFileWriter:debug");
 
 #if OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimImageFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimImageFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 RTTI_DEF3(ossimImageFileWriter,
@@ -118,18 +118,14 @@ ossimImageFileWriter::ossimImageFileWriter(const ossimFilename& file,
 
 ossimImageFileWriter::~ossimImageFileWriter()
 {
-   if(theInputConnection)
-   {
-      delete theInputConnection;
-      theInputConnection = NULL;
-   }
+   theInputConnection = 0;
    theProgressListener = NULL;
    removeListener((ossimConnectableObjectListener*)this);
 }
 
 void ossimImageFileWriter::initialize()
 {
-   if(theInputConnection)
+   if(theInputConnection.valid())
    {
       theInputConnection->initialize();
       setAreaOfInterest(theInputConnection->getBoundingRect());
@@ -139,15 +135,11 @@ void ossimImageFileWriter::initialize()
 void ossimImageFileWriter::changeSequencer(ossimImageSourceSequencer* sequencer)
 {
    if(!sequencer) return;
-   if(theInputConnection)
+   if(theInputConnection.valid())
    {
       sequencer->setAreaOfInterest(theInputConnection->getAreaOfInterest());
    }
 
-   if(theInputConnection)
-   {
-      delete theInputConnection;
-   }
    theInputConnection = sequencer;
    theInputConnection->connectMyInputTo(0, getInput(0));
 }
@@ -420,7 +412,7 @@ bool ossimImageFileWriter::loadState(const ossimKeywordlist& kwl,
 }
 
 bool ossimImageFileWriter::writeOverviewFile(ossim_uint16 tiff_compress_type,
-                                             ossim_int32 jpeg_compress_quality) const
+                                             ossim_int32 jpeg_compress_quality) 
 {
    if(theFilename == "") return false;
 
@@ -436,7 +428,7 @@ bool ossimImageFileWriter::writeOverviewFile(ossim_uint16 tiff_compress_type,
 
    ossimRefPtr<ossimTiffOverviewBuilder> ob = new ossimTiffOverviewBuilder();
    
-   if ( ob->setInputSource( ih.get(), false ) )
+   if ( ob->setInputSource(ih.get()) )
    {
       // Give the listener to the overview builder if set.
       if (theProgressListener)
@@ -462,7 +454,7 @@ bool ossimImageFileWriter::writeOverviewFile(ossim_uint16 tiff_compress_type,
    return true;
 }
 
-bool ossimImageFileWriter::writeEnviHeaderFile() const
+bool ossimImageFileWriter::writeEnviHeaderFile() 
 {
    if( (theFilename == "") || !theInputConnection ||
        theAreaOfInterest.hasNans())
@@ -479,7 +471,7 @@ bool ossimImageFileWriter::writeEnviHeaderFile() const
       new ossimEnviHeaderFileWriter();
    
    // Set things up.
-   writer->connectMyInputTo(0, theInputConnection);
+   writer->connectMyInputTo(0, theInputConnection.get());
    writer->initialize();
    writer->setFilename(outputFile);
    writer->setPixelType(thePixelType);
@@ -489,7 +481,7 @@ bool ossimImageFileWriter::writeEnviHeaderFile() const
    return writer->execute();
 }
 
-bool ossimImageFileWriter::writeErsHeaderFile() const
+bool ossimImageFileWriter::writeErsHeaderFile() 
 {
    if( (theFilename == "") || !theInputConnection ||
        theAreaOfInterest.hasNans())
@@ -506,7 +498,7 @@ bool ossimImageFileWriter::writeErsHeaderFile() const
 	   new ossimERSFileWriter();
    
    // Set things up.
-   writer->connectMyInputTo(0, theInputConnection);
+   writer->connectMyInputTo(0, theInputConnection.get());
    writer->initialize();
    writer->setFilename(outputFile);
    writer->setPixelType(thePixelType);
@@ -516,7 +508,7 @@ bool ossimImageFileWriter::writeErsHeaderFile() const
    return writer->execute();
 }
 
-bool ossimImageFileWriter::writeExternalGeometryFile() const
+bool ossimImageFileWriter::writeExternalGeometryFile() 
 {
    if( (theFilename == "") || !theInputConnection ||
        theAreaOfInterest.hasNans())
@@ -532,9 +524,10 @@ bool ossimImageFileWriter::writeExternalGeometryFile() const
    ossimRefPtr<ossimMetadataFileWriter> writer = new ossimGeomFileWriter();
 
    // Set things up.
-   writer->connectMyInputTo(0, theInputConnection);
-   writer->initialize();
+//   writer->connectMyInputTo(0, theInputConnection.get());
+   writer->connectMyInputTo(0, theInputConnection.get());
    writer->setFilename(geomFile);
+   writer->initialize();
    writer->setPixelType(thePixelType);
    writer->setAreaOfInterest(theAreaOfInterest);
 
@@ -542,7 +535,7 @@ bool ossimImageFileWriter::writeExternalGeometryFile() const
    return writer->execute();
 }
 
-bool ossimImageFileWriter::writeFgdcFile() const
+bool ossimImageFileWriter::writeFgdcFile() 
 {
    if( (theFilename == "") || !theInputConnection ||
        theAreaOfInterest.hasNans())
@@ -558,7 +551,7 @@ bool ossimImageFileWriter::writeFgdcFile() const
    ossimRefPtr<ossimMetadataFileWriter> writer = new ossimFgdcFileWriter();
    
    // Set things up.
-   writer->connectMyInputTo(0, theInputConnection);
+   writer->connectMyInputTo(0, theInputConnection.get());
    writer->initialize();
    writer->setFilename(outputFile);
    writer->setPixelType(thePixelType);
@@ -568,7 +561,7 @@ bool ossimImageFileWriter::writeFgdcFile() const
    return writer->execute();
 }
 
-bool ossimImageFileWriter::writeJpegWorldFile() const
+bool ossimImageFileWriter::writeJpegWorldFile() 
 {
    if(theFilename == "")
    {
@@ -582,7 +575,7 @@ bool ossimImageFileWriter::writeJpegWorldFile() const
    return writeWorldFile(file);
 }
 
-bool ossimImageFileWriter::writeReadmeFile() const
+bool ossimImageFileWriter::writeReadmeFile() 
 {
    if( (theFilename == "") || !theInputConnection ||
        theAreaOfInterest.hasNans())
@@ -600,7 +593,7 @@ bool ossimImageFileWriter::writeReadmeFile() const
       new ossimReadmeFileWriter();
    
    // Set things up.
-   writer->connectMyInputTo(0, theInputConnection);
+   writer->connectMyInputTo(0, theInputConnection.get());
    writer->initialize();
    writer->setFilename(outputFile);
    writer->setPixelType(thePixelType);
@@ -610,7 +603,7 @@ bool ossimImageFileWriter::writeReadmeFile() const
    return writer->execute();
 }
 
-bool ossimImageFileWriter::writeTiffWorldFile() const
+bool ossimImageFileWriter::writeTiffWorldFile() 
 {
    if(theFilename == "")
    {
@@ -624,7 +617,7 @@ bool ossimImageFileWriter::writeTiffWorldFile() const
    return writeWorldFile(file);
 }
 
-bool ossimImageFileWriter::writeMetaDataFiles() const
+bool ossimImageFileWriter::writeMetaDataFiles() 
 {
    bool status = true;
    
@@ -728,14 +721,14 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
    return status;
 }
 
-bool ossimImageFileWriter::writeHistogramFile() const
+bool ossimImageFileWriter::writeHistogramFile() 
 {
    if(theFilename == "") return false;
 
    ossimFilename histogram_file = theFilename;
    histogram_file.setExtension(ossimString("his"));
 
-   ossimImageHandler* handler = ossimImageHandlerRegistry::instance()->
+   ossimRefPtr<ossimImageHandler> handler = ossimImageHandlerRegistry::instance()->
       open(theFilename);
 
    if (!handler)
@@ -743,20 +736,20 @@ bool ossimImageFileWriter::writeHistogramFile() const
       return false;
    }
 
-   ossimImageHistogramSource* histoSource = new ossimImageHistogramSource;
+   ossimRefPtr<ossimImageHistogramSource> histoSource = new ossimImageHistogramSource;
 
-   ossimHistogramWriter* writer = new ossimHistogramWriter;
+   ossimRefPtr<ossimHistogramWriter> writer = new ossimHistogramWriter;
    histoSource->setMaxNumberOfRLevels(1); // Only compute for r0.
-   histoSource->connectMyInputTo(0, handler);
+   histoSource->connectMyInputTo(0, handler.get());
    histoSource->enableSource();
-   writer->connectMyInputTo(0, histoSource);
+   writer->connectMyInputTo(0, histoSource.get());
    writer->setFilename(histogram_file);
    writer->addListener(&theStdOutProgress);
    writer->execute();
-
-   delete handler;
-   delete writer;
-
+   writer->disconnect();
+   histoSource->disconnect();
+   handler->disconnect();
+   writer = 0; histoSource = 0; handler = 0;
    return true;
 }
 
@@ -933,7 +926,7 @@ const ossimObject* ossimImageFileWriter::getObject() const
 void ossimImageFileWriter::setAreaOfInterest(const ossimIrect& inputRect)
 {
    ossimImageWriter::setAreaOfInterest(inputRect);
-   if(theInputConnection)
+   if(theInputConnection.valid())
    {
       theInputConnection->setAreaOfInterest(inputRect);
    }
@@ -941,7 +934,7 @@ void ossimImageFileWriter::setAreaOfInterest(const ossimIrect& inputRect)
 
 ossimImageSourceSequencer* ossimImageFileWriter::getSequencer()
 {
-   return theInputConnection;
+   return theInputConnection.get();
 }
 
 bool ossimImageFileWriter::execute()
@@ -1000,17 +993,16 @@ bool ossimImageFileWriter::execute()
          << "Area of interest:  " << theAreaOfInterest << endl;
    }
    
-   bool needToDeleteInput = false;
+   ossimRefPtr<ossimImageSource> savedInput;
    if (theScaleToEightBitFlag)
    {
       if(theInputConnection->getOutputScalarType() != OSSIM_UINT8)
       {
-         ossimImageSource* inputSource=new ossimScalarRemapper;
+         savedInput = new ossimScalarRemapper;
          
-         inputSource->connectMyInputTo(0, theInputConnection->getInput(0));
-         theInputConnection->connectMyInputTo(0, inputSource);
+         savedInput->connectMyInputTo(0, theInputConnection->getInput(0));
+         theInputConnection->connectMyInputTo(0, savedInput.get());
          theInputConnection->initialize();
-         needToDeleteInput = true;
       }
    }
 
@@ -1067,17 +1059,15 @@ bool ossimImageFileWriter::execute()
       } // End of "if (getSequencer() && getSequencer()->isMaster()))
    }
 
-   if(needToDeleteInput)
+   if(savedInput.valid())
    {
       ossimConnectableObject* obj = theInputConnection->getInput(0);
       if(obj)
       {
          theInputConnection->connectMyInputTo(0, obj->getInput(0));
-         delete obj;
-         obj = NULL;
       }
    }
-   
+   savedInput = 0;
    return result;
 }
 
@@ -1440,13 +1430,13 @@ void ossimImageFileWriter::getPixelTypeString(ossimString& type) const
 
 void ossimImageFileWriter::setTileSize(const ossimIpt& tileSize)
 {
-   if (theInputConnection)
+   if (theInputConnection.valid())
    {
       theInputConnection->setTileSize(tileSize);
    }
 }
 
-bool ossimImageFileWriter::writeWorldFile(const ossimFilename& file) const
+bool ossimImageFileWriter::writeWorldFile(const ossimFilename& file) 
 {
    if( !theInputConnection || theAreaOfInterest.hasNans())
    {
@@ -1457,7 +1447,7 @@ bool ossimImageFileWriter::writeWorldFile(const ossimFilename& file) const
    ossimRefPtr<ossimWorldFileWriter> writer = new ossimWorldFileWriter();
    
    // Set things up.
-   writer->connectMyInputTo(0, theInputConnection);
+   writer->connectMyInputTo(0, theInputConnection.get());
    writer->initialize();
    writer->setFilename(file);
    writer->setAreaOfInterest(theAreaOfInterest);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageGaussianFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageGaussianFilter.cpp
index da8cee63be22416471fed3ca6b1ddbebcd53080b..797ad1fbf84bd110cf12487d505659ebe3e3b0fb 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageGaussianFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageGaussianFilter.cpp
@@ -4,7 +4,7 @@
 // See LICENSE.txt file in the top level directory for more details.
 // class ossimImageGaussianFilter : tile source
 //*******************************************************************
-// $Id: ossimImageGaussianFilter.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageGaussianFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <cmath>
 #include <ossim/imaging/ossimImageGaussianFilter.h>
 #include <ossim/base/ossimNumericProperty.h>
@@ -36,13 +36,21 @@ ossimImageGaussianFilter::ossimImageGaussianFilter()
    theVF->setStrictNoData(theStrictNoData);
 
    //tie them up
-   theVF->connectMyInputTo(0,theHF);
+   theVF->connectMyInputTo(0,theHF.get());
 }
 
 ossimImageGaussianFilter::~ossimImageGaussianFilter()
 {
-   delete theHF;
-   delete theVF;
+   if(theHF.valid())
+   {
+      theHF->disconnect();
+      theHF = 0;
+   }
+   if(theVF.valid())
+   {
+      theVF->disconnect();
+      theVF = 0;
+   }
 }
 
 void ossimImageGaussianFilter::setProperty(ossimRefPtr<ossimProperty> property)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageGeometry.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageGeometry.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..acd2841b935697a58b6b15420bdfd3de184bdf3f
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageGeometry.cpp
@@ -0,0 +1,510 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  Oscar Kramer
+//
+// Description: Class implementation of ossimImageGeometry. See .h file for class documentation.
+//
+//**************************************************************************************************
+// $Id$
+
+#include <ossim/imaging/ossimImageGeometry.h>
+#include <ossim/projection/ossimProjection.h>
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossim2dTo2dTransformRegistry.h>
+#include <ossim/elevation/ossimElevManager.h>
+
+RTTI_DEF1(ossimImageGeometry, "ossimImageGeometry", ossimObject);
+
+//**************************************************************************************************
+// Default constructor defaults to unity transform with no projection  
+//**************************************************************************************************
+ossimImageGeometry::ossimImageGeometry()
+:   
+m_transform (0),
+m_projection(0)
+{
+   m_gsd.makeNan();
+}
+
+//**************************************************************************************************
+// Copy constructor -- performs a deep copy. This is needed when an imageSource in the chain
+// needs to modify the image geometry at that point in the chain. The image geometry to the left
+// of that imageSource must remain unchanged. This constructor permits that imageSource to 
+// maintain its own geometry based on the input geometry. All objects in the chain and to the right
+// would see this alternate geometry. See ossimScaleFilter for an example of this case.
+//**************************************************************************************************
+ossimImageGeometry::ossimImageGeometry(const ossimImageGeometry& copy_this)
+:ossimObject(copy_this)   
+{
+   *this = copy_this;
+}
+
+//**************************************************************************************************
+//! Constructs with projection and transform objects available for referencing. Either pointer
+//! can be NULL -- the associated mapping would be identity.
+//**************************************************************************************************
+ossimImageGeometry::ossimImageGeometry(ossim2dTo2dTransform* transform, ossimProjection* proj)
+:  ossimObject(),
+   m_transform(transform),
+   m_projection(proj)
+{
+   m_gsd.makeNan();
+   if(m_projection.valid())
+   {
+      // If the transform is NULL (identity), then we can simply copy the input projection's GSD.
+      // Otherwise we'll need to compute a GSD specific to this geometry.
+      m_gsd = m_projection->getMetersPerPixel();
+   }
+}
+
+//**************************************************************************************************
+// Destructor is hidden. Only accessible via ossimRefPtr centrally managed
+//**************************************************************************************************
+ossimImageGeometry::~ossimImageGeometry()
+{
+   // Nothing to do
+}
+
+
+void ossimImageGeometry::rnToLocal(const ossimDpt& rnPt, ossim_uint32 resolutionLevel, ossimDpt& localPt)
+{
+   if(resolutionLevel != 0)
+   {
+      ossimDpt decimation = decimationFactor(resolutionLevel);
+      localPt.makeNan();
+      if(!decimation.hasNans())
+      {
+         localPt.x = rnPt.x*(1.0/decimation.x);
+         localPt.y = rnPt.y*(1.0/decimation.y);
+      }
+   }
+   else
+   {
+      localPt = rnPt;
+   }
+}
+
+void ossimImageGeometry::rnToFull(const ossimDpt& rnPt, ossim_uint32 resolutionLevel, ossimDpt& fullPt)
+{
+   ossimDpt localPt;
+   rnToLocal(rnPt, resolutionLevel, localPt);
+   localToFullImage(localPt, fullPt);
+}
+
+void ossimImageGeometry::rnToWorld(const ossimDpt& rnPt, ossim_uint32 resolutionLevel, ossimGpt& wpt)
+{
+   ossimDpt localPt;
+   rnToLocal(rnPt, resolutionLevel, localPt);
+   localToWorld(localPt, wpt);
+}
+
+void ossimImageGeometry::worldToRn(const ossimGpt& wpt, ossim_uint32 resolutionLevel, ossimDpt& rnPt)
+{   
+   ossimDpt localPt;
+   worldToLocal(wpt, localPt);
+   
+   if(resolutionLevel != 0)
+   {
+      ossimDpt decimation = decimationFactor(resolutionLevel);
+      if(!decimation.hasNans())
+      {
+         rnPt.x = localPt.x*decimation.x;
+         rnPt.y = localPt.y*decimation.y;
+      }
+   }
+   else
+   {
+      rnPt = localPt;
+   }
+}
+
+//**************************************************************************************************
+//! Exposes the 2D functionality that transforms from local (file) x,y pixel to full-image
+//! X,Y coordinates
+//**************************************************************************************************
+void ossimImageGeometry::localToFullImage(const ossimDpt& local_pt, ossimDpt& full_pt) const
+{
+    // Perform forward transform if available, otherwise assume identity:
+    if (m_transform.valid())
+        m_transform->forward(local_pt, full_pt);
+    else
+        full_pt = local_pt;
+}
+
+//**************************************************************************************************
+//! Exposes the 2D functionality that transforms from full-image X,Y coordinates to 
+//! local (file) x,y pixel coordinates
+//**************************************************************************************************
+void ossimImageGeometry::fullToLocalImage(const ossimDpt& full_pt, ossimDpt& local_pt) const
+{
+    // Perform inverse transform if available, otherwise assume identity:
+    if (m_transform.valid())
+        m_transform->inverse(full_pt, local_pt);
+    else
+        local_pt = full_pt;
+}
+
+//**************************************************************************************************
+//! Exposes the 3D projection from image to world coordinates. The caller should verify that
+//! a valid projection exists before calling this method. Returns TRUE if a valid ground point
+//! is available in the ground_pt argument. This method depends on the existence of elevation
+//! information. If no DEM is available, the results will be incorrect or inaccurate.
+//**************************************************************************************************
+bool ossimImageGeometry::localToWorld(const ossimDpt& local_pt, ossimGpt& world_pt) const
+{
+    //! Return a NAN point of no projection is defined:
+    if (!m_projection.valid())
+    {
+        world_pt.makeNan();
+        return false;
+    }
+
+    // First transform local pixel to full-image pixel:
+    ossimDpt full_image_pt (local_pt);
+    if (m_transform.valid())
+        m_transform->forward(local_pt, full_image_pt);
+
+    // Perform projection to world coordinates:
+    m_projection->lineSampleToWorld(full_image_pt, world_pt);
+    return true;
+}
+
+//**************************************************************************************************
+//! Exposes the 3D world-to-local image coordinate reverse projection. The caller should verify 
+//! that a valid projection exists before calling this method. Returns TRUE if a valid image 
+//! point is available in the local_pt argument.
+//**************************************************************************************************
+bool ossimImageGeometry::worldToLocal(const ossimGpt& world_pt, ossimDpt& local_pt) const
+{
+    //! Return a NAN point of no projection is defined:
+    if (!m_projection.valid())
+    {
+        local_pt.makeNan();
+        return false;
+    }
+
+   ossimGpt copyPt(world_pt);
+   if(isAffectedByElevation())
+   {
+      if(world_pt.isHgtNan())
+      {
+         copyPt.hgt = ossimElevManager::instance()->getHeightAboveEllipsoid(copyPt);
+      }
+   }
+    // First Perform projection from world coordinates to full-image space:
+    ossimDpt full_image_pt;
+    m_projection->worldToLineSample(copyPt, full_image_pt);
+
+    // Then transform to local space:
+    if (m_transform.valid())
+        m_transform->inverse(full_image_pt, local_pt);
+    else
+        local_pt = full_image_pt;
+
+    return true;
+}
+
+//**************************************************************************************************
+//! Sets the transform to be used for local-to-full-image coordinate transformation
+//**************************************************************************************************
+void ossimImageGeometry::setTransform(ossim2dTo2dTransform* transform) 
+{ 
+   m_transform = transform; 
+   if (m_projection.valid())
+   {
+      m_gsd.makeNan();
+   }
+}
+
+//**************************************************************************************************
+//! Sets the projection to be used for local-to-world coordinate transformation
+//**************************************************************************************************
+void ossimImageGeometry::setProjection(ossimProjection* projection) 
+{ 
+   m_projection = projection; 
+   if (m_projection.valid())
+   {
+      m_gsd.makeNan();
+   }
+}
+
+//**************************************************************************************************
+//! Returns TRUE if this geometry is sensitive to elevation
+//**************************************************************************************************
+bool ossimImageGeometry::isAffectedByElevation() const
+{
+    if (m_projection.valid())
+        return m_projection->isAffectedByElevation();
+    return false;
+}
+
+const ossimDpt& ossimImageGeometry::getMetersPerPixel() const
+{
+   if(m_gsd.hasNans())
+   {
+      if(m_projection.valid())
+      {
+         computeGsd();
+      }
+   }
+   
+   return m_gsd;
+}
+
+//**************************************************************************************************
+//! When either the projection or the transform changes, this method recomputes the GSD.
+//**************************************************************************************************
+void ossimImageGeometry::computeGsd()const
+{
+   if (!m_projection.valid())
+   {
+      m_gsd.makeNan();
+      return;
+   }
+   ossimDpt pL0 (0,0);
+   if (m_transform.valid())
+      pL0 = m_transform->getOrigin();
+
+   ossimDpt pLx (pL0.x+1.0, pL0.y    );
+   ossimDpt pLy (pL0.x    , pL0.y+1.0);
+
+   // We need to do the local-to-world but eliminating elevation effects, hence the complication:
+   ossimGpt g0, gx, gy;
+   ossimDpt pFx, pFy;
+   localToWorld(pL0, g0);
+   localToFullImage(pLx, pFx);
+   localToFullImage(pLy, pFy);
+   m_projection->lineSampleHeightToWorld(pFx, g0.height(), gx);
+   m_projection->lineSampleHeightToWorld(pFy, g0.height(), gy);
+
+   // Compute horizontal distance for one pixel:
+   m_gsd.x = g0.distanceTo(gx);
+   m_gsd.y = g0.distanceTo(gy);
+}
+
+//**************************************************************************************************
+//! Prints contents to output stream.
+//**************************************************************************************************
+std::ostream& ossimImageGeometry::print(std::ostream& out) const
+{
+   out << "type: ossimImageGeometry" << std::endl;
+    if(m_transform.valid())
+    {
+        out << "  m_transform: ";
+        m_transform->print(out);
+    }
+    else
+    {
+        out << "  No transform defined. Using identity transform.\n";
+    }
+
+    if(m_projection.valid())
+    {
+        out << "  m_projection: ";
+        m_projection->print(out);
+    }
+    else
+    {
+        out << "  No projection defined. ";
+    }
+    return out;
+}
+
+//**************************************************************************************************
+//! Returns TRUE if argument geometry has exactly the same instances for transform and 
+//! m_projection. This may need to be expanded to permit different instances of same transforms
+//**************************************************************************************************
+bool ossimImageGeometry::operator==(const ossimImageGeometry& other) const
+{
+    return ((m_transform == other.m_transform) && (m_projection == other.m_projection));
+}
+
+//**************************************************************************************************
+//! Returns the decimation factor from R0 for the resolution level specified. For r_index=0, the 
+//! decimation factor is by definition 1.0. For the non-discrete case, r_index=1 returns a 
+//! decimation of 0.5. If the vector of discrete decimation factors (m_decimationFactors) is 
+//! empty, the factor will be computed as f=1/2^n
+//**************************************************************************************************
+ossimDpt ossimImageGeometry::decimationFactor(ossim_uint32 r_index) const
+{
+   ossim_uint32 size = (ossim_uint32)m_decimationFactors.size();
+   if (size)
+   {
+      if (r_index < size)
+      {
+         return m_decimationFactors[r_index];
+      }
+      
+      // Return the last defined decimation if the index requested exceeds list size:
+      return m_decimationFactors[size-1];
+   }
+
+   // Compute the decimation factor:
+   ossim_float64 factor = 1.0/(ossim_float64)(1 << r_index);
+   
+   return ossimDpt(factor, factor);
+}
+
+void ossimImageGeometry::decimationFactor(ossim_uint32 r_index,
+                                          ossimDpt& result) const
+{
+   const ossim_uint32 SIZE = (ossim_uint32)m_decimationFactors.size();
+   if (SIZE)
+   {
+      if (r_index < SIZE)
+      {
+         result = m_decimationFactors[r_index];
+      }
+      else
+      {
+         //---
+         // Return the last defined decimation if the index requested
+         // exceeds list size:
+         //---
+         result = m_decimationFactors[SIZE-1];
+      }
+   }
+   else
+   {
+      // Compute the decimation factor:
+      ossim_float64 factor = 1.0/(ossim_float64)(1 << r_index);
+      result.x = factor;
+      result.y = factor;
+   }
+}
+
+void ossimImageGeometry::decimationFactors(
+   std::vector<ossimDpt>& decimations) const
+{
+   decimations = m_decimationFactors;
+}
+
+//*****************************************************************************
+//! Attempts to initialize a transform and a projection given the KWL.
+//! Returns TRUE if no error encountered.
+//*****************************************************************************
+bool ossimImageGeometry::loadState(const ossimKeywordlist& kwl,
+                                   const char* prefix)
+{
+   const char* lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   if (lookup)
+   {
+      ossimString decimations   = kwl.find(prefix, "decimations");
+      ossimString gsd           = kwl.find(prefix, "gsd");
+      if ( ossimString(lookup) == STATIC_TYPE_NAME(ossimImageGeometry) )
+      {
+         ossimObject::loadState(kwl, prefix);
+
+         // First try to create a transform
+         ossim2dTo2dTransform* transform = 0;
+         ossimString transformPrefix = ossimString(prefix) + "transform.";
+         ossimString projectionPrefix = ossimString(prefix) + "projection.";
+         transform = ossim2dTo2dTransformRegistry::instance()->
+            createNativeObjectFromRegistry(kwl, transformPrefix.c_str());
+         
+         // Now look for projection spec:
+         ossimProjection* projection =
+            ossimProjectionFactoryRegistry::instance()->
+               createProjection(kwl, projectionPrefix.c_str());
+         if(projection)
+         {
+            m_projection = projection;
+         }
+         if(transform)
+         {
+            m_transform = transform;
+         }
+      }
+      else
+      {
+         // Now look for projection spec (for backwards compatibility):
+         ossimProjection* projection = 
+            ossimProjectionFactoryRegistry::instance()->
+            createProjection(kwl, prefix);
+         if (projection)
+         {
+            setProjection(projection);
+         }
+      }
+      
+      if(!decimations.empty())
+      {
+         m_decimationFactors.clear();
+         ossim::toVector(m_decimationFactors, decimations);
+      }
+      if(!gsd.empty())
+      {
+         m_gsd.toPoint(gsd);
+      }
+   }
+
+   return true;
+}
+
+//**************************************************************************************************
+//! Saves the transform (if any) and projection (if any) states to the KWL.
+//**************************************************************************************************
+bool ossimImageGeometry::saveState(ossimKeywordlist& kwl, const char* prefix) const
+{
+   bool good_save = true;
+   ossimString transformPrefix = ossimString(prefix) + "transform.";
+   ossimString projectionPrefix = ossimString(prefix) + "projection.";
+   // Save transform if present:
+   if (m_transform.valid())
+   {
+      good_save = m_transform->saveState(kwl, transformPrefix.c_str());
+   }
+
+   // Save projection if present:
+   if (m_projection.valid())
+   {
+      good_save &= m_projection->saveState(kwl, projectionPrefix.c_str());
+   }
+   good_save &= ossimObject::saveState(kwl, prefix);
+
+   ossimString deimations;
+   if(m_decimationFactors.size())
+   {
+      ossimString resultPoints;
+      ossim::toStringList(resultPoints,
+                          m_decimationFactors);
+      
+      if(!resultPoints.empty())
+      {
+         kwl.add(prefix, "decimations", resultPoints, true);
+      }
+   }
+   kwl.add(prefix, "gsd", m_gsd.toString(), true);
+   
+   return good_save;
+}
+
+//**************************************************************************************************
+//! Replaces any existing transform and projection with those in the copy_this object
+//**************************************************************************************************
+const ossimImageGeometry& ossimImageGeometry::operator=(const ossimImageGeometry& copy_this)
+{
+   if (this != &copy_this)
+   {
+      // Get deep copy of 2D transform if one exists:
+      if (copy_this.m_transform.valid())
+      {
+         m_transform = (ossim2dTo2dTransform*) copy_this.m_transform->dup();
+      }
+      
+      // Now establish a deep copy of the projection, if any:
+      if (copy_this.m_projection.valid())
+      {
+         m_projection = (ossimProjection*) copy_this.m_projection->dup();
+      }
+       // the Gsd should already be solved from the source we are copying from
+      m_gsd = copy_this.m_gsd;
+   }
+   return *this;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageGeometryFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageGeometryFactory.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a87cec8c0fde4c3bc672bd2ca4ec2d70385f0463
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageGeometryFactory.cpp
@@ -0,0 +1,217 @@
+//*****************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class implementation of ossimImageGeometryFactory.
+// See .h file for class documentation.
+//
+//*****************************************************************************
+// $Id$
+#include <ossim/imaging/ossimImageGeometryFactory.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossim2dTo2dShiftTransform.h>
+#include <ossim/imaging/ossimNitfTileSource.h>
+#include <ossim/imaging/ossimTiffTileSource.h>
+#include <ossim/support_data/ossimNitfRegisteredTag.h>
+#include <ossim/support_data/ossimNitfIchipbTag.h>
+#include <ossim/support_data/ossimNitfStdidcTag.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/base/ossim2dTo2dTransformRegistry.h>
+
+ossimImageGeometryFactory* ossimImageGeometryFactory::m_instance = 0;
+
+ossimImageGeometryFactory::ossimImageGeometryFactory()
+{
+   m_instance = this;
+}
+
+ossimImageGeometryFactory* ossimImageGeometryFactory::instance()
+{
+   if(!m_instance)
+   {
+      m_instance = new ossimImageGeometryFactory();
+   }
+   
+   return m_instance;
+}
+
+ossimImageGeometry* ossimImageGeometryFactory::createGeometry(
+   const ossimString& typeName)const
+{
+   if(typeName == "ossimImageGeometry")
+   {
+      return new ossimImageGeometry();
+   }
+   
+   return 0;
+}
+
+ossimImageGeometry* ossimImageGeometryFactory::createGeometry(
+   const ossimKeywordlist& kwl, const char* prefix)const
+{
+   ossimRefPtr<ossimImageGeometry> result = 0;
+   ossimString type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   if(!type.empty())
+   {
+      result = createGeometry(type);
+      if(result.valid()&&!result->loadState(kwl, prefix))
+      {
+         result = 0;
+      }
+   }
+   
+   return result.release();
+}
+
+ossimImageGeometry* ossimImageGeometryFactory::createGeometry(
+   const ossimFilename& filename, ossim_uint32 entryIdx)const
+{
+   // currently don't support this option just yet by this factory
+   return 0;
+}
+
+bool ossimImageGeometryFactory::extendGeometry(ossimImageHandler* handler)const
+{
+   bool result = true;
+   if (handler)
+   {
+      ossimRefPtr<ossimImageGeometry> geom = handler->getImageGeometry();
+      if(geom.valid())
+      {
+         if(!geom->getProjection())
+         {
+            geom->setProjection(createProjection(handler));
+            result&=geom->hasProjection();
+         }
+         if(!geom->getTransform())
+         {
+            geom->setTransform(createTransform(handler));
+            result&=geom->hasTransform();
+        }
+      }
+   }
+   
+   return result;
+}
+
+void ossimImageGeometryFactory::getTypeNameList(
+   std::vector<ossimString>& typeList)const
+{
+   typeList.push_back("ossimImageGeometry");
+}
+
+ossim2dTo2dTransform* ossimImageGeometryFactory::createTransform(
+   ossimImageHandler* handler)const
+{
+   // Currently nothing to do...
+   
+   ossimRefPtr<ossim2dTo2dTransform> result = 0;
+   
+   ossimNitfTileSource* nitf = dynamic_cast<ossimNitfTileSource*> (handler);
+   
+   if(nitf)
+   {
+      result = createTransformFromNitf(nitf);
+   }
+   
+   return result.release();
+}
+
+ossimProjection* ossimImageGeometryFactory::createProjection(
+   ossimImageHandler* handler) const
+{
+   ossimRefPtr<ossimProjection> result =
+      ossimProjectionFactoryRegistry::instance()->createProjection(handler);
+
+   return result.release();
+}
+
+ossim2dTo2dTransform* ossimImageGeometryFactory::createTransformFromNitf(ossimNitfTileSource* nitf)const
+{
+   ossim2dTo2dTransform* result = 0;
+   
+   ossimRefPtr<ossimNitfImageHeader> hdr = nitf->getCurrentImageHeader();
+   if (!hdr)
+   {
+      return result;
+   }
+   
+   //---
+   // Test for the ichipb tag and set the sub image if needed.
+   // 
+   // NOTE # 1:
+   // 
+   // There are nitf writers that set the ichipb offsets and only have
+   // IGEOLO field present.  For these it has been determined
+   // (but still in question) that we should not apply the sub image offset.
+   //
+   // See trac # 1578
+   // http://trac.osgeo.org/ossim/ticket/1578
+   //
+   // NOTE # 2:
+   //
+   // Let the ICHIPB have precedence over the STDIDC tag as we could have a
+   // chip of a segment.
+   //---
+   ossimRefPtr<ossimNitfRegisteredTag> tag =
+   hdr->getTagData(ossimString("ICHIPB"));
+   if (tag.valid())
+   {
+      ossimNitfIchipbTag* ichipb = PTR_CAST(ossimNitfIchipbTag, tag.get());
+      if (ichipb)
+      {
+         const ossimRefPtr<ossimNitfRegisteredTag> blocka =
+         hdr->getTagData(ossimString("BLOCKA"));
+         const ossimRefPtr<ossimNitfRegisteredTag> rpc00a =
+         hdr->getTagData(ossimString("RPC00A"));              
+         const ossimRefPtr<ossimNitfRegisteredTag> rpc00b =
+         hdr->getTagData(ossimString("RPC00B"));
+         
+         //---
+         // If any of these tags are present we will use the sub image from
+         // the ichipb tag.
+         //---
+         if ( blocka.get() || rpc00a.get() || rpc00b.get() )
+         {
+            result = ichipb->newTransform();
+         }
+      }
+   }
+   
+   if ( !result)
+   {
+      //---
+      // Look for the STDIDC tag for a sub image (segment) offset.
+      //
+      // See: STDI-002 Table 7.3 for documentation.
+      //---
+      tag = hdr->getTagData(ossimString("STDIDC"));
+      if (tag.valid() && (hdr->getIMode() == "B") )
+      {
+         ossimDpt shift;
+         ossimNitfStdidcTag* stdidc = PTR_CAST(ossimNitfStdidcTag, tag.get());
+         if (stdidc)
+         {
+            ossim_int32 startCol = stdidc->getStartColumn().toInt32();
+            ossim_int32 startRow = stdidc->getStartRow().toInt32();
+            if ( (startCol > 0) && (startRow > 0) )
+            {
+               
+               // field are one based; hence, the - 1.
+               shift.x = (startCol-1) * hdr->getNumberOfPixelsPerBlockHoriz();
+               shift.y = (startRow-1) * hdr->getNumberOfPixelsPerBlockVert();
+            }
+            if(shift.x > 0 ||
+               shift.y > 0)
+            {
+               result = new ossim2dTo2dShiftTransform(shift);
+            }
+         }
+      }
+   }
+   
+   return result;
+}
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageGeometryRegistry.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageGeometryRegistry.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0a50b1cd27ba217fdc14b16811274cdd9682db87
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageGeometryRegistry.cpp
@@ -0,0 +1,38 @@
+//**************************************************************************************************
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class implementation of ossimImageGeometryRegistry. See .h file for class documentation.
+//
+//**************************************************************************************************
+// $Id$
+#include <ossim/imaging/ossimImageGeometryRegistry.h>
+#include <ossim/imaging/ossimImageGeometryFactory.h>
+#include <ossim/base/ossimObjectFactoryRegistry.h>
+ossimImageGeometryRegistry* ossimImageGeometryRegistry::m_instance = 0;
+RTTI_DEF1(ossimImageGeometryRegistry, "ossimImageGeometryRegistry", ossimObjectFactory);
+ossimImageGeometryRegistry* ossimImageGeometryRegistry::instance()
+{
+   if(!m_instance)
+   {
+      m_instance = new ossimImageGeometryRegistry();
+      m_instance->registerFactory(ossimImageGeometryFactory::instance());
+      ossimObjectFactoryRegistry::instance()->registerFactory(m_instance);
+   }
+   
+   return m_instance;
+}
+
+bool ossimImageGeometryRegistry::extendGeometry(ossimImageHandler* handler)const
+{
+   bool result = false;
+   ossim_uint32 idx = 0;
+   for(;((idx < m_factoryList.size())&&!result); ++idx)
+   {
+      result = m_factoryList[idx]->extendGeometry(handler);
+   }
+   
+   return result;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHandler.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHandler.cpp
index 8e7ec55195f822e8952f09b32460b6c00150eb1c..0ba911847a9fce81afade87baaf9bc7ff950cf29 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageHandler.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHandler.cpp
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See LICENSE.txt file in the top level directory.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
@@ -10,29 +12,33 @@
 // derive from.
 //
 //*******************************************************************
-//  $Id: ossimImageHandler.cpp 14268 2009-04-10 15:40:01Z dburken $
+//  $Id: ossimImageHandler.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <algorithm>
 
 #include <ossim/imaging/ossimImageHandler.h>
-#include <ossim/base/ossimStringProperty.h>
-#include <ossim/base/ossimKeywordNames.h>
-#include <ossim/base/ossimTrace.h>
-#include <ossim/base/ossimEventIds.h>
+
 #include <ossim/base/ossimContainerEvent.h>
-#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimEventIds.h>
 #include <ossim/base/ossimFilename.h>
-#include <ossim/imaging/ossimTiffTileSource.h>
-#include <ossim/imaging/ossimTiffOverviewBuilder.h>
+#include <ossim/base/ossimFilenameProperty.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimPolygon.h>
+#include <ossim/base/ossimStdOutProgress.h>
+#include <ossim/base/ossimStringProperty.h>
+#include <ossim/base/ossimTrace.h>
+
 #include <ossim/imaging/ossimHistogramWriter.h>
+#include <ossim/imaging/ossimImageHandlerRegistry.h>
 #include <ossim/imaging/ossimImageHistogramSource.h>
-#include <ossim/base/ossimStdOutProgress.h>
-#include <ossim/base/ossimPolygon.h>
+#include <ossim/imaging/ossimTiffTileSource.h>
+#include <ossim/imaging/ossimTiffOverviewBuilder.h>
+
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
-#include <ossim/base/ossimFilenameProperty.h>
-#include <ossim/imaging/ossimImageHandlerRegistry.h>
-
+#include <ossim/imaging/ossimImageGeometryRegistry.h>
 RTTI_DEF1(ossimImageHandler, "ossimImageHandler", ossimImageSource)
 
 //***
@@ -41,23 +47,26 @@ RTTI_DEF1(ossimImageHandler, "ossimImageHandler", ossimImageSource)
 static ossimTrace traceDebug("ossimImageHandler:debug");
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimImageHandler.cpp 14268 2009-04-10 15:40:01Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimImageHandler.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
+// GARRETT! All of the decimation factors are scattered throughout. We want to fold that into 
+// the image geometry object. The code is ready in ossimImageGeometry for this (more or less), but
+// the ossimImageGeometry::m_decimationFactors is not being set nor referenced. Can you do this?
+// I'm a little foggy on how we want to incorporate R-level scaling into the geometry object.
    
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimImageHandler::ossimImageHandler()
-      :
-      ossimImageSource(0,
-                       0,
-                       0,
-                       true,
-                       false),// output list is not fixed
-      theImageFile(ossimFilename::NIL),
-      theOverview(0),
-      theSubImageOffset(0, 0),
-      theValidImageVertices(0),
-      theMetaData(),
-      theGeometryKwl()
+:
+ossimImageSource(0, 0, 0, true, false /* output list is not fixed */ ),
+theImageFile(ossimFilename::NIL),
+theOverview(0),
+//theSubImageOffset(0, 0),
+theValidImageVertices(0),
+theMetaData(),
+theStartingResLevel(0)
 {
    if (traceDebug())
    {
@@ -72,15 +81,17 @@ ossimImageHandler::ossimImageHandler()
    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimImageHandler::~ossimImageHandler()
 {
-   if (theOverview)
-   {
-      delete theOverview;
-      theOverview = 0;
-   }
+   theOverview = 0;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageHandler::initialize()
 {
 }
@@ -111,6 +122,8 @@ bool ossimImageHandler::saveState(ossimKeywordlist& kwl,
            ossimKeywordNames::OVERVIEW_FILE_KW,
            theOverviewFile.c_str(),
            true);
+
+   kwl.add(prefix, "start_res_level", true);
    
    return true;
 }
@@ -172,14 +185,15 @@ bool ossimImageHandler::loadState(const ossimKeywordlist& kwl,
          << "filename = " << theImageFile << std::endl;
    }
    
-   // Check for an external geometry file.
+   // Check for an external geometry file to initialize our image geometry object:
    lookup = kwl.find(prefix, ossimKeywordNames::GEOM_FILE_KW);
    if (lookup)
    {
       ossimKeywordlist geomKwl;
       if (geomKwl.addFile(lookup) == true)
       {
-         theGeometryKwl = geomKwl;
+         theGeometry = new ossimImageGeometry;
+         theGeometry->loadState(geomKwl);
          if(traceDebug())
          {
             ossimNotify(ossimNotifyLevel_DEBUG)
@@ -198,6 +212,13 @@ bool ossimImageHandler::loadState(const ossimKeywordlist& kwl,
       initVertices(lookup);
    }
 
+   // Starting resolution level.
+   lookup = kwl.find(prefix, "start_res_level");
+   if (lookup)
+   {
+      theStartingResLevel = ossimString(lookup).toUInt32();
+   }
+
    if(getNumberOfInputs())
    {
       theInputObjectList.clear();
@@ -304,7 +325,12 @@ bool ossimImageHandler::initVertices(const char* file)
 
 ossim_uint32 ossimImageHandler::getNumberOfDecimationLevels() const
 {
-   return (theOverview?theOverview->getNumberOfDecimationLevels():1);
+   ossim_uint32 result = 1; // Add r0
+   if (theOverview.valid())
+   {
+      result += theOverview->getNumberOfDecimationLevels();
+   }
+   return result;
 }
 
 ossim_uint32 ossimImageHandler::getNumberOfReducedResSets() const
@@ -316,13 +342,7 @@ ossimIrect ossimImageHandler::getImageRectangle(ossim_uint32 resLevel) const
 {
    ossimIrect result;
    
-   if( !isOpen() )
-   {
-      result.makeNan();
-      return result;
-   }
-   
-   if( isValidRLevel(resLevel) )
+   if( isOpen() && isValidRLevel(resLevel) )
    {
       ossim_int32 lines   = getNumberOfLines(resLevel);
       ossim_int32 samples = getNumberOfSamples(resLevel);
@@ -335,41 +355,17 @@ ossimIrect ossimImageHandler::getImageRectangle(ossim_uint32 resLevel) const
          result = ossimIrect(0, 0, samples-1, lines-1);
       }
    }
-   
-   //---
-   // Special case to handle overviews with no R0.
-   //---
-   else if( isValidRLevel(resLevel+1) )
+   else
    {
-      ossim_int32 lines   = getNumberOfLines(resLevel+1);
-      ossim_int32 samples = getNumberOfSamples(resLevel+1);
-      if( lines && samples )
-      {
-         result = ossimIrect(0, 0, samples*2-1, lines*2-1);
-      }
-      else
-      {
-         result.makeNan();
-      }
+      result.makeNan();
    }
-   
+
    return result;
 }
 
 ossimIrect ossimImageHandler::getBoundingRect(ossim_uint32 resLevel) const
 {
-   ossimIrect result = getImageRectangle(resLevel);
-
-   if (result.isNan() == false)
-   {
-      ossimIpt offset = getSubImageOffset(resLevel);
-      if (offset.isNan() == false)
-      {
-         result = result + offset;
-      }
-   }
-
-   return result;
+   return getImageRectangle(resLevel);
 }
 
 
@@ -383,7 +379,7 @@ void ossimImageHandler::getDecimationFactor(ossim_uint32 resLevel,
    }
    else
    {
-      result.x = 1.0 / pow((double)2, (double)resLevel);
+      result.x = 1.0 / ((ossim_float64)(1<<resLevel));
       result.y = result.x;
    }
 }
@@ -405,8 +401,8 @@ bool ossimImageHandler::buildHistogram(int numberOfRLevels)
       ossimFilename file =
          getFilenameWithThisExtension(ossimString(".his"));
       
-      ossimImageHistogramSource* histoSource = new ossimImageHistogramSource;
-      ossimHistogramWriter* writer = new ossimHistogramWriter;
+      ossimRefPtr<ossimImageHistogramSource> histoSource = new ossimImageHistogramSource;
+      ossimRefPtr<ossimHistogramWriter> writer = new ossimHistogramWriter;
       
       if(numberOfRLevels)
       {
@@ -418,13 +414,14 @@ bool ossimImageHandler::buildHistogram(int numberOfRLevels)
       }
       histoSource->connectMyInputTo(0, this);
       histoSource->enableSource();
-      writer->connectMyInputTo(0, histoSource);
+      writer->connectMyInputTo(0, histoSource.get());
       writer->setFilename(file);
       writer->addListener(&theStdOutProgress);
       writer->execute();
-      
-      delete histoSource;
-      delete writer;
+      histoSource->disconnect();
+      writer->disconnect();
+      histoSource = 0;
+      writer = 0;
    }
    else
    {
@@ -508,7 +505,7 @@ bool ossimImageHandler::buildOverview(const ossimFilename& filename,
 
    theOverviewFile = filename;
    ossimTiffOverviewBuilder tiffBuilder;
-   if ( tiffBuilder.setInputSource(this, false) == false )
+   if ( tiffBuilder.setInputSource(this) == false )
    {
       return false;
    }
@@ -551,136 +548,167 @@ bool ossimImageHandler::buildOverview(const ossimFilename& filename,
    return true;
 }
 
-//*******************************************************************
-// Public method:
-//*******************************************************************
-bool ossimImageHandler::getImageGeometry(ossimKeywordlist& kwl,
-                                         const char* prefix)
+//*****************************************************************************
+//! Returns the image geometry object associated with this tile source or
+//! NULL if non defined.
+//! The geometry contains full-to-local image transform as well as projection
+//! (image-to-world).
+//*****************************************************************************
+ossimImageGeometry* ossimImageHandler::getImageGeometry()
 {
-   if (traceDebug())
+   if (theGeometry.valid())
    {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimImageHandler::getImageGeometry DEBUG: entered..."
-         << std::endl;
+      if(getNumberOfDecimationLevels() !=
+         theGeometry->getNumberOfDecimations())
+      {
+         std::vector<ossimDpt> decimationList;
+         getDecimationFactors(decimationList);
+         theGeometry->setDiscreteDecimation(decimationList);
+      }
+      return theGeometry.get();
+   }
+   
+   //---
+   // Check factory for external geom:
+   //---
+   getExternalImageGeometry();
+   if (theGeometry.valid())
+   {
+      return theGeometry.get();  // We should return here.
    }
+   // ok,  now let's start with an empty geometry and then call the extension plugins.
+   //
+   theGeometry = new ossimImageGeometry();
    
-   if (theGeometryKwl.getSize())
+   //---
+   // And finally allow factories to extend the internal geometry.
+   // This allows plugins for tagged formats with tags not know in the base
+   // to extend the internal geometry.
+   //
+   // Plugins can do handler->getImageGeometry() then modify/extend.
+   //---
+   if(!ossimImageGeometryRegistry::instance()->extendGeometry( this ))
    {
-      kwl.add(prefix, theGeometryKwl);
-      //kwl = theGeometryKwl;
-      return true;
+      // Check for internal, for geotiff, nitf and so on as last resort for getting some kind of geometry
+      // loaded
+      //
+      getInternalImageGeometry();
    }
    
-   bool result = false;
-   ossimRefPtr<ossimProjection> proj = 0;
-   ossimFilename filename = getFilenameWithThisExtension(ossimString(".geom"));
+   return theGeometry.get();
+}
+
+ossimImageGeometry* ossimImageHandler::getExternalImageGeometry()
+{
+   // If already defined, return it:
+   if (theGeometry.valid())
+   {
+      return theGeometry.get();
+   }
+   
+   //---
+   // No geometry object has been set up yet. Check for external geometry file.
+   //---
+   // Try "foo.geom" if image is "foo.tif":
+   //
+   ossimFilename filename = getFilenameWithThisExtension(ossimString(".geom"), false);
+   
    if(!filename.exists())
    {
-      // Try tacking on the entry like "foo_e0.hdf".
+      // Try "foo_e0.tif" if image is "foo.tif" where "e0" is entry index.
       filename = getFilenameWithThisExtension(ossimString(".geom"), true);
    }
+   
+   ossimRefPtr<ossimImageGeometry> geom = 0;
+   
    if(filename.exists())
    {
-      if(kwl.addFile(filename))
+      // Open the geom file as a KWL and initialize our geometry object:
+      ossimKeywordlist geomKwl(filename);
+      
+      ossimString prefix = "";
+      
+      // Try loadState with no prefix.
+      const char* lookup = geomKwl.find(prefix.c_str(),
+                                        ossimKeywordNames::TYPE_KW);
+      if (lookup)
       {
-         ossimString tempPrefix =
-            "image"+ossimString::toString(getCurrentEntry())+".";
-         kwl.stripPrefixFromAll(tempPrefix);
+         ossimString type = lookup;
          
-         if(kwl.find(ossimKeywordNames::TYPE_KW))
+         if(type == "ossimImageGeometry")
          {
-            ossimKeywordlist kwlTemp(kwl);
-            
-            kwlTemp.add(ossimKeywordNames::GEOM_FILE_KW,
-                        filename.c_str(),
-                        true);
-
-            proj = ossimProjectionFactoryRegistry::instance()->
-               createProjection(kwlTemp);
-            if(proj.valid())
+            // Try it with no prefix.
+            geom = new ossimImageGeometry;
+            if(!geom->loadState(geomKwl, prefix.c_str()))
             {
-               result = true;
-               kwl.add(prefix, kwlTemp);//kwl = kwlTemp;
+               geom = 0;
             }
          }
-      }
-   }
-
-   
-   if(!result)
-   {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimImageHandler::getImageGeometry DEBUG:"
-            << "\nCalling createProjection"
-            << "\ngetFilename():      " << getFilename()
-            << "\ngetCurrentEntry():  " << getCurrentEntry()
-            << std::endl;
-      }
-      
-      proj = ossimProjectionFactoryRegistry::instance()->
-         createProjection(getFilename(),
-                          getCurrentEntry());
-      if(proj.valid())
-      {
-         result = proj->saveState(kwl, prefix);
          
-         result = true;
+         if (!geom)
+         {
+            // Try with "image0 type prefix.
+            prefix = "image"+ossimString::toString(getCurrentEntry()) + ".";
+            
+            lookup = geomKwl.find(prefix.c_str(), ossimKeywordNames::TYPE_KW);
+            if(lookup)
+            {
+               type = lookup;
+               if(type == "ossimImageGeometry")
+               {
+                  geom = new ossimImageGeometry;
+                  if(!geom->loadState(geomKwl, prefix.c_str()))
+                  {
+                     geom = 0;
+                  }
+               }
+            }
+         }
       }
    }
    
-   if (result == true)
-   {
-      theGeometryKwl.clear();
-      // Capture the geometry for next time.
-//      theGeometryKwl = kwl;
-      theGeometryKwl.add(kwl, prefix, true);
-   }
+   theGeometry = geom.get();
+   return theGeometry.get();
+}
 
-   if (traceDebug())
+ossimImageGeometry* ossimImageHandler::getInternalImageGeometry()
+{
+   // Default, derived classes should override.
+   if ( !theGeometry )
    {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimImageHandler::getImageGeometry DEBUG:"
-         << "boolean return:  " << result
-         << std::endl;
+      // allocate an empty geometry if nothing present
+      theGeometry = new ossimImageGeometry();
    }
    
-   return result;
+   return theGeometry.get();
 }
 
-void ossimImageHandler::setImageGeometry(const ossimKeywordlist& kwl)
+void ossimImageHandler::setImageGeometry( ossimImageGeometry* geom)
 {
-   theGeometryKwl = kwl;
+   theGeometry = geom;
 }
 
 void ossimImageHandler::saveImageGeometry() const
 {
-   ossimFilename geometryFile =
-      getFilenameWithThisExtension(ossimString(".geom"));
+   ossimFilename geometryFile = getFilenameWithThisExtension(ossimString(".geom"));
    saveImageGeometry(geometryFile);
 }
 
-void ossimImageHandler::saveImageGeometry(
-   const ossimFilename& geometry_file) const
+void ossimImageHandler::saveImageGeometry(const ossimFilename& geometry_file) const
 {
-   theGeometryKwl.write(geometry_file.c_str());
+   if (theGeometry.valid())
+   {
+      ossimKeywordlist kwl;
+      theGeometry->saveState(kwl);
+      kwl.write(geometry_file.chars());
+   }
 }
 
 void ossimImageHandler::closeOverview()
 {
-   if(theOverview)
-   {
-      delete theOverview;
-      theOverview = 0;
-   }
+   theOverview = 0;
 }
 
-// const ossimFilename& ossimImageHandler::getOverviewFile()const
-// {
-//    return theOverviewFile;
-// }
-
 bool ossimImageHandler::hasOverviews() const
 {
    return (getNumberOfDecimationLevels() > 1);
@@ -688,28 +716,55 @@ bool ossimImageHandler::hasOverviews() const
 
 bool ossimImageHandler::openOverview(const ossimFilename& overview_file)
 {
-   closeOverview();
-   
-   theOverviewFile = overview_file;
-   // make sure we don't open ourselves.
-   if(theImageFile == theOverviewFile) return false;
+   bool result = false;
    
-   theOverview = new ossimTiffTileSource;
+   closeOverview();
 
-   if ( theOverview->open(theOverviewFile) )
+   if (overview_file != theImageFile) // Make sure we don't open ourselves.
    {
+      result = true;
+      
       //---
-      // This is not really a container event; however, using for now.
+      // Get the number of level before the call to opening the overview so
+      // the overview can be told what it's starting res level is.
       //---
-      ossimContainerEvent event(this, theOverview, OSSIM_EVENT_ADD_OBJECT_ID);
-      fireEvent(event);
+      ossim_uint32 overviewStartingResLevel =
+         getNumberOfDecimationLevels();
+      
+      // Try to open:
+      theOverview = ossimImageHandlerRegistry::instance()->open(overview_file);
+      
+      if (theOverview.valid())
+      {
+         // Set the starting res level of the overview.
+         theOverview->setStartingResLevel(overviewStartingResLevel);
+         
+         // Capture the file name.
+         theOverviewFile = overview_file;
 
-      return true;
-   }
+         if (traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << "overview starting res level: " << overviewStartingResLevel
+               << "\noverview levels: "
+               << theOverview->getNumberOfDecimationLevels()
+               << "\nlevels: " << getNumberOfDecimationLevels()
+               << endl;
+         }
+         
+         //---
+         // This is not really a container event; however, using for now.
+         //---
+         ossimContainerEvent event(this,
+                                   theOverview.get(),
+                                   OSSIM_EVENT_ADD_OBJECT_ID);
+         fireEvent(event);
+         
 
-   delete theOverview;
-   theOverview = 0;
-   return false;
+      }
+   }
+   
+   return result;
 }
 
 bool ossimImageHandler::openOverview()
@@ -871,12 +926,27 @@ bool ossimImageHandler::open(const ossimFilename& imageFile,
 
 bool ossimImageHandler::isValidRLevel(ossim_uint32 resLevel) const
 {
-   if (resLevel < getNumberOfDecimationLevels())
+   bool result = false;
+   
+   const ossim_uint32 LEVELS = getNumberOfDecimationLevels();
+   
+   if ( !theStartingResLevel) // Not an overview.
    {
-      return true;
+      result = (resLevel < LEVELS);
    }
-
-   return false;
+   else  // Used as overview.
+   {
+      if (resLevel >= theStartingResLevel)
+      {
+         //---
+         // Adjust the res level to be zero based for this overview before
+         // checking.
+         //---
+         result = ( (resLevel - theStartingResLevel) < LEVELS);
+      }
+   }
+   
+   return result;
 }
 
 void ossimImageHandler::getValidImageVertices(vector<ossimIpt>& validVertices,
@@ -913,12 +983,8 @@ void ossimImageHandler::getValidImageVertices(vector<ossimIpt>& validVertices,
 
 void ossimImageHandler::close()
 {
-   if (theOverview)
-   {
-      delete theOverview;
-      theOverview = 0;
-   }
-
+   theOverview = 0;
+   theGeometry = 0;
    theValidImageVertices.clear();
 }
 
@@ -1032,9 +1098,9 @@ ossim_uint32 ossimImageHandler::getNumberOfEntries()const
 
 void ossimImageHandler::completeOpen()
 {
-  loadMetaData();
-  openOverview();
-  openValidVertices();
+   loadMetaData();
+   openOverview();
+   openValidVertices();
 }
 
 bool ossimImageHandler::canConnectMyInputTo(ossim_int32 inputIndex,
@@ -1048,33 +1114,6 @@ bool ossimImageHandler::hasMetaData()const
    return theMetaData.isValid();
 }
 
-ossimIpt ossimImageHandler::getSubImageOffset(ossim_uint32 resLevel) const
-{
-   if (resLevel == 0)
-   {
-      return theSubImageOffset;
-   }
-
-   ossimIpt offset;
-   offset.makeNan();
-   if (isValidRLevel(resLevel))
-   {
-      ossimDpt decimation;
-      getDecimationFactor(resLevel, decimation);
-      if(!decimation.hasNans()) // Should never have nans...
-      {
-         offset.x = ossim::round<int>(theSubImageOffset.x*decimation.x);
-         offset.y = ossim::round<int>(theSubImageOffset.y*decimation.y);
-      }
-   }
-   return offset;
-}
-
-void ossimImageHandler::setSubImageOffset(const ossimIpt& p)
-{
-   theSubImageOffset = p;
-}
-
 void ossimImageHandler::setFilename(const ossimFilename& filename)
 {
    theImageFile = filename;
@@ -1216,6 +1255,23 @@ ossimFilename ossimImageHandler::getFilenameWithThisExtension(
    return f;
 }
 
+bool ossimImageHandler::getOverviewTile(ossim_uint32 resLevel,
+                                        ossimImageData* result)
+{
+   bool status = false;
+   
+   if (theOverview.valid())
+   {
+      if (theOverview->isValidRLevel(resLevel) && result &&
+          (result->getNumberOfBands() == getNumberOfOutputBands()) )
+      {
+         status = theOverview->getTile(result, resLevel);
+      }
+   }
+   
+   return status;
+}
+
 ossimRefPtr<ossimNBandLutDataObject> ossimImageHandler::getLut()const
 {
    return theLut;
@@ -1257,3 +1313,15 @@ ossimFilename ossimImageHandler::createDefaultValidVerticesFilename() const
    
    return result;
 }
+
+ossim_uint32 ossimImageHandler::getStartingResLevel() const
+{
+   return theStartingResLevel;
+}
+
+void ossimImageHandler::setStartingResLevel(ossim_uint32 level)
+{
+   theStartingResLevel = level;
+}
+
+   
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp
index e82f030be2e54101771aec93490fcd1eec55c010..21a53e76e8889718dc05dde771d1a191d33e0dbc 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp
@@ -1,9 +1,11 @@
 //----------------------------------------------------------------------------
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimImageHandlerFactory.cpp 14056 2009-03-04 20:32:58Z gpotts $
+// $Id: ossimImageHandlerFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimImageHandlerFactory.h>
 #include <ossim/imaging/ossimAdrgTileSource.h>
 #include <ossim/imaging/ossimCcfTileSource.h>
@@ -18,7 +20,7 @@
 #include <ossim/imaging/ossimUsgsDemTileSource.h>
 #include <ossim/imaging/ossimLandsatTileSource.h>
 #include <ossim/imaging/ossimGeneralRasterTileSource.h>
-// #include <ossim/imaging/ossimERSTileSource.h>
+#include <ossim/imaging/ossimERSTileSource.h>
 #include <ossim/imaging/ossimVpfTileSource.h>
 #include <ossim/imaging/ossimTileMapTileSource.h>
 #include <ossim/base/ossimTrace.h>
@@ -35,7 +37,7 @@ RTTI_DEF1(ossimImageHandlerFactory, "ossimImageHandlerFactory", ossimImageHandle
 ossimImageHandlerFactory* ossimImageHandlerFactory::theInstance = 0;
 ossimImageHandlerFactory::~ossimImageHandlerFactory()
 {
-   theInstance = (ossimImageHandlerFactory*)NULL;
+   theInstance = (ossimImageHandlerFactory*)0;
 }
 
 ossimImageHandlerFactory* ossimImageHandlerFactory::instance()
@@ -52,9 +54,9 @@ ossimImageHandlerFactory* ossimImageHandlerFactory::instance()
    return theInstance;
 }
 
-ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)const
+ossimImageHandler* ossimImageHandlerFactory::open(
+   const ossimFilename& fileName)const
 {
-
    ossimFilename copyFilename = fileName;
 
    if(traceDebug())
@@ -64,13 +66,13 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
          << std::endl
          << "Attempting to open file " << copyFilename << std::endl;
    }
-   ossimImageHandler* result = NULL;
+   ossimRefPtr<ossimImageHandler> result = 0;
 
    // Check for empty file.
    copyFilename.trim();
    if (copyFilename.empty())
    {
-      return result;
+      return result.release();
    }
 
    // for all of our imagehandlers the filename must exist.
@@ -78,10 +80,27 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    // we need to move this.
    if(!copyFilename.exists()) return 0;
 
-   if(copyFilename.ext() == "gz")
+   ossimString ext = copyFilename.ext().downcase();
+
+   if(ext == "gz")
    {
       copyFilename = copyFilename.setExtension("");
    }
+
+   // Try opening from extension logic first.
+   result = openFromExtension(copyFilename);
+   {
+      if (result.valid())
+      {
+         return result.release();
+      }
+   }
+
+   //---
+   // If here do it the brute force way by going down the list of available
+   // readers...
+   //---
+
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -90,9 +109,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimJpegTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
 
    // test if TileMap
@@ -105,9 +124,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimTileMapTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
       // test if Radarsat
    if(traceDebug())
@@ -119,9 +138,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimRadarSatTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
     // test if Radarsat2
 //    if(traceDebug())
@@ -133,9 +152,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
 //    result = new ossimRadarSat2TileSource;
 //    if(result->open(copyFilename))
 //    {
-//       return result;
+//       return result.release();
 //    }
-//    delete result;
+//    result = 0;
 
       // test if TerraSAR
 //    if(traceDebug())
@@ -147,9 +166,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
 //    result = new ossimTerraSarTileSource;
 //    if(result->open(copyFilename))
 //    {
-//       return result;
+//       return result.release();
 //    }
-//    delete result;
+//    result = 0;
 
    // this must be checked first before the TIFF handler
    if(traceDebug())
@@ -161,9 +180,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimQuickbirdTiffTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -174,9 +193,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimTiffTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -187,9 +206,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimCibCadrgTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -199,9 +218,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimDoqqTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -211,10 +230,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimDtedTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
 
-   delete result;
+   result = 0;
 
    // this must be checked first before the NITF raw handler
 
@@ -227,9 +246,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimQuickbirdNitfTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -239,9 +258,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimNitfTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -252,9 +271,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimUsgsDemTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -265,9 +284,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimLandsatTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -277,21 +296,21 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimVpfTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
-//    if(traceDebug())
-//    {
-//       ossimNotify(ossimNotifyLevel_DEBUG)
-//          << "trying ERS" << std::endl;
-//    }
-//    result = new ossimERSTileSource;
-//    if(result->open(copyFilename))
-//    {
-//       return result;
-//    }
-//    delete result;
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "trying ERS" << std::endl;
+   }
+   result = new ossimERSTileSource;
+   if(result->open(copyFilename))
+   {
+      return result.release();
+   }
+   result = 0;
 
    // Note:  SRTM should be in front of general raster...
    if(traceDebug())
@@ -303,9 +322,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimSrtmTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -316,9 +335,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimGeneralRasterTileSource;
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -331,9 +350,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
 
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -344,10 +363,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
    result = new ossimCcfTileSource();
    if(result->open(copyFilename))
    {
-      return result;
+      return result.release();
    }
 
-   delete result;
+   result = 0;
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -365,7 +384,7 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
          << "ossimImageHandlerFactory::open(kwl, prefix) DEBUG: entered..."
          << std::endl;
    }
-   ossimImageHandler* result = NULL;
+   ossimRefPtr<ossimImageHandler> result = 0;
 
    if(traceDebug())
    {
@@ -376,9 +395,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
 
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -388,9 +407,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimCcfTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -401,9 +420,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimCibCadrgTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -413,9 +432,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimDoqqTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -425,9 +444,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimDtedTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -437,9 +456,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimJpegTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -450,10 +469,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result = new ossimQuickbirdNitfTileSource;
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-
-   delete result;
+   result = 0;
 
 
    if(traceDebug())
@@ -464,9 +482,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimNitfTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    // TileMap
    if(traceDebug())
@@ -478,10 +496,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result = new ossimTileMapTileSource;
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
 
-   delete result;
+   result = 0;
 
       // RadarSat
    if(traceDebug())
@@ -493,10 +511,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result = new ossimRadarSatTileSource;
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
 
-   delete result;
+   result = 0;
 
   // RadarSat2
 //    if(traceDebug())
@@ -508,10 +526,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
 //    result = new ossimRadarSat2TileSource;
 //    if(result->loadState(kwl, prefix))
 //    {
-//       return result;
+//       return result.release();
 //    }
 //
-//    delete result;
+//    result = 0;
 
       // TerraSAR
 //    if(traceDebug())
@@ -523,10 +541,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
 //    result = new ossimTerraSarTileSource;
 //    if(result->loadState(kwl, prefix))
 //    {
-//       return result;
+//       return result.release();
 //    }
 //
-//    delete result;
+//    result = 0;
 
    // Must be before tiff...
    if(traceDebug())
@@ -538,10 +556,10 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result = new ossimQuickbirdTiffTileSource;
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
 
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -551,9 +569,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimTiffTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -564,9 +582,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimUsgsDemTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -576,9 +594,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimLandsatTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -588,22 +606,22 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result = new ossimVpfTileSource;
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
-//    if(traceDebug())
-//    {
-//       ossimNotify(ossimNotifyLevel_DEBUG)
-//          << "trying ERS" << std::endl;
-//    }
-//    result = new ossimERSTileSource;
-//    if(result->loadState(kwl, prefix))
-//    {
-//       return result;
-//    }
-//    delete result;
-   // Note:  SRTM should be in front of general raster...
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "trying ERS" << std::endl;
+   }
+   result = new ossimERSTileSource;
+   if(result->loadState(kwl, prefix))
+   {
+      return result.release();
+   }
+   result = 0;
+  // Note:  SRTM should be in front of general raster...
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -613,9 +631,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimSrtmTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -626,9 +644,9 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    result  = new ossimGeneralRasterTileSource();
    if(result->loadState(kwl, prefix))
    {
-      return result;
+      return result.release();
    }
-   delete result;
+   result = 0;
 
    if(traceDebug())
    {
@@ -636,7 +654,168 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
          << "ossimImageHandlerFactory::open(kwl, prefix) DEBUG: returning..."
          << std::endl;
    }
-   return (ossimImageHandler*)NULL;
+   return (ossimImageHandler*)0;
+}
+
+ossimImageHandler* ossimImageHandlerFactory::openFromExtension(
+   const ossimFilename& fileName) const
+{
+   ossimString ext = fileName.ext().downcase();
+
+   ossimRefPtr<ossimImageHandler> result = 0;
+
+   //---
+   // Ovr can be combined with "tif" once we get rid of
+   // ossimQuickbirdTiffTileSource
+   //---
+   if (ext == "ovr")
+   {
+      result = new ossimTiffTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (ext == "tif") || (ext == "tiff") )
+   {
+      // this must be checked first before the TIFF handler
+      result = new ossimQuickbirdTiffTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+
+      result = new ossimTiffTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (ext == "ntf") || (ext == "nitf") )
+   {
+      // this must be checked first before the NITF raw handler
+      result = new ossimQuickbirdNitfTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+
+      result = new ossimNitfTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (fileName == "a.toc") || (ext == "toc") )
+   {
+      result = new ossimCibCadrgTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (ext == "jpg") || (ext == "jpeg") )
+   {
+      result = new ossimJpegTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (ext == "doq") || (ext == "doqq") )
+   {
+      result = new ossimDoqqTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (ext == "dt2") || (ext == "dt1") || (ext == "dt3") ||
+        (ext == "dt4") || (ext == "dt5") || (ext == "dt0") )
+   {
+      result = new ossimDtedTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if (ext == "hgt")
+   {
+      result = new ossimSrtmTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if (ext == "dem")
+   {
+      result = new ossimUsgsDemTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if (ext == "fst")
+   {
+      result = new ossimLandsatTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if ( (ext == "ras") || (ext == "raw") )
+   {
+      result = new ossimGeneralRasterTileSource;
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if (ext == "img")
+   {
+      result  = new ossimAdrgTileSource();
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   if (ext == "ccf")
+   {
+      result = new ossimCcfTileSource();
+      if(result->open(fileName))
+      {
+         return result.release();
+      }
+      result = 0;
+   }
+
+   return result.release();
 }
 
 ossimObject* ossimImageHandlerFactory::createObject(const ossimString& typeName)const
@@ -681,10 +860,10 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimString& typeName)
    {
       return new ossimLandsatTileSource();
    }
-//    if(STATIC_TYPE_NAME(ossimERSTileSource) == typeName)
-//    {
-//       return new ossimERSTileSource();
-//    }
+   if(STATIC_TYPE_NAME(ossimERSTileSource) == typeName)
+   {
+      return new ossimERSTileSource();
+   }
    if(STATIC_TYPE_NAME(ossimSrtmTileSource) == typeName)
    {
       return new ossimSrtmTileSource();
@@ -699,7 +878,7 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimString& typeName)
       return new ossimTileMapTileSource();
    }
 
-   return (ossimObject*)NULL;
+   return (ossimObject*)0;
 }
 
 void ossimImageHandlerFactory::getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList& extensionList)const
@@ -736,7 +915,7 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimKeywordlist& kwl,
          << "ossimImageHandlerFactory::createObject(kwl, prefix) DEBUG:"
          << " entering ..." << std::endl;
    }
-   ossimObject* result = (ossimObject*)NULL;
+   ossimObject* result = (ossimObject*)0;
    const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
 
    if(type)
@@ -784,7 +963,7 @@ void ossimImageHandlerFactory::getTypeNameList(std::vector<ossimString>& typeLis
    typeList.push_back(STATIC_TYPE_NAME(ossimTiffTileSource));
    typeList.push_back(STATIC_TYPE_NAME(ossimUsgsDemTileSource));
    typeList.push_back(STATIC_TYPE_NAME(ossimLandsatTileSource));
-//    typeList.push_back(STATIC_TYPE_NAME(ossimERSTileSource));
+   typeList.push_back(STATIC_TYPE_NAME(ossimERSTileSource));
    typeList.push_back(STATIC_TYPE_NAME(ossimSrtmTileSource));
    typeList.push_back(STATIC_TYPE_NAME(ossimGeneralRasterTileSource));
    typeList.push_back(STATIC_TYPE_NAME(ossimTileMapTileSource));
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp
index 7f899cdf7dee791f7331194d315f3b39ba8d2f5d..975d7e7fa0a200a9d439d63d774d918057ada235 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp
@@ -2,14 +2,14 @@
 //
 // License:  See top level LICENSE.txt file.
 // 
-// Author:  Garrett Potts (gpotts@imagelinks.com)
+// Author:  Garrett Potts
 //
 // Description:
 //
 // Contains class definition for ImageHandlerRegistry.
 //
 //*******************************************************************
-//  $Id: ossimImageHandlerRegistry.cpp 14053 2009-03-04 12:25:51Z gpotts $
+//  $Id: ossimImageHandlerRegistry.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
 #include <ossim/imaging/ossimImageHandlerFactory.h>
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHistogramSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHistogramSource.cpp
index 6325fcee417bcb1941a849cf818d8df16185e787..2898f157914c0e016cbf542b4f74a4d132763c4a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageHistogramSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHistogramSource.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageHistogramSource.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimImageHistogramSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimImageHistogramSource.h>
 #include <ossim/base/ossimMultiResLevelHistogram.h>
 #include <ossim/base/ossimMultiBandHistogram.h>
@@ -293,7 +293,7 @@ void ossimImageHistogramSource::computeNormalModeHistogram()
       ossim_float64 maxValue     = 0;
       getBinInformation(numberOfBins, minValue, maxValue);
 		
-      ossimImageSourceSequencer* sequencer = new ossimImageSourceSequencer;
+      ossimRefPtr<ossimImageSourceSequencer> sequencer = new ossimImageSourceSequencer;
       sequencer->connectMyInputTo(0, getInput(0));
       sequencer->initialize();
       
@@ -365,7 +365,7 @@ void ossimImageHistogramSource::computeNormalModeHistogram()
             }
          }
       }
-      delete sequencer;
+      sequencer->disconnect();
       sequencer = 0;
    }
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp
index edbf2ad9444440cb6c506dfb4ba9d281e9e08ec3..c766b81e645786d5f8f2a7cf7c848ca6e337fe69 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp
@@ -36,7 +36,7 @@ ossimImageModel::~ossimImageModel()
 
 void ossimImageModel::initialize(const ossimImageHandler& ih)
 {
-   theSubImageOffset = ih.getSubImageOffset(0);
+   theSubImageOffset = ossimDpt();
    theLines          = ih.getNumberOfLines(0);
    theSamples        = ih.getNumberOfSamples(0);
    ih.getDecimationFactors(theDecimationFactors);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageMosaic.cpp
index 6606a629177605f7c98da1df6c9741cf30b1c3b2..51eab66d068878f412fb4c7bd3021275e3adecf6 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageMosaic.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageMosaic.cpp
@@ -7,7 +7,7 @@
 // Description: implementation for image mosaic
 //
 //*************************************************************************
-// $Id: ossimImageMosaic.cpp 12745 2008-04-27 03:38:04Z gpotts $
+// $Id: ossimImageMosaic.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimImageMosaic.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -25,7 +25,7 @@ ossimImageMosaic::ossimImageMosaic()
 
 }
 
-ossimImageMosaic::ossimImageMosaic(const vector<ossimImageSource*>& inputSources)
+ossimImageMosaic::ossimImageMosaic(ossimConnectableObject::ConnectableObjectList& inputSources)
     : ossimImageCombiner(inputSources),
       theTile(NULL)
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp
index 3c5cb44a8a2b6dd9f15fa0de6dc735a25900289f..94c0587b22db4a6c3aa058824bbd38fa39e12de7 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp
@@ -1,11 +1,13 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimImageRenderer.cpp 13905 2008-12-02 14:37:12Z gpotts $
+//  $Id: ossimImageRenderer.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 using namespace std;
@@ -39,13 +41,16 @@ using namespace std;
 #include <ossim/projection/ossimEquDistCylProjection.h>
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimImageRenderer.cpp 13905 2008-12-02 14:37:12Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimImageRenderer.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 static ossimTrace traceDebug("ossimImageRenderer:debug");
 
 RTTI_DEF2(ossimImageRenderer, "ossimImageRenderer", ossimImageSourceFilter, ossimViewInterface);
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::ossimRendererSubRectInfo::splitView(ossimImageViewTransform* transform,
                                                              ossimRendererSubRectInfo& ulRect,
                                                              ossimRendererSubRectInfo& urRect,
@@ -60,10 +65,10 @@ void ossimImageRenderer::ossimRendererSubRectInfo::splitView(ossimImageViewTrans
       << "\nllRect = " << llRect << endl;
 #endif
    
-   ossimIrect vrect(theVul,
-                    theVur,
-                    theVlr,
-                    theVll);
+   ossimIrect vrect(m_Vul,
+                    m_Vur,
+                    m_Vlr,
+                    m_Vll);
    
    ossimIrect tempUlRect;
    ossimIrect tempUrRect;
@@ -89,95 +94,95 @@ void ossimImageRenderer::ossimRendererSubRectInfo::splitView(ossimImageViewTrans
       {
          if((h%2) == 0) // if even
          {
-            tempUlRect = ossimIrect(theVul.x,
-                                    theVul.y,
-                                    theVul.x + (w2 - 1),
-                                    theVul.y + (h2 - 1));
+            tempUlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y,
+                                    m_Vul.x + (w2 - 1),
+                                    m_Vul.y + (h2 - 1));
             
-            tempUrRect = ossimIrect(theVul.x + w2,
-                                    theVul.y,
-                                    theVul.x + w2 + (w2 - 1),
-                                    theVul.y + (h2 - 1));
+            tempUrRect = ossimIrect(m_Vul.x + w2,
+                                    m_Vul.y,
+                                    m_Vul.x + w2 + (w2 - 1),
+                                    m_Vul.y + (h2 - 1));
             
-            tempLrRect = ossimIrect(theVul.x + w2,
-                                    theVul.y + h2,
-                                    theVul.x + w2 + (w2 - 1),
-                                    theVul.y + h2 + (h2 - 1));
+            tempLrRect = ossimIrect(m_Vul.x + w2,
+                                    m_Vul.y + h2,
+                                    m_Vul.x + w2 + (w2 - 1),
+                                    m_Vul.y + h2 + (h2 - 1));
             
-            tempLlRect = ossimIrect(theVul.x,
-                                    theVul.y + h2,
-                                    theVul.x + (w2 - 1),
-                                    theVul.y + h2 + (h2 - 1));
+            tempLlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y + h2,
+                                    m_Vul.x + (w2 - 1),
+                                    m_Vul.y + h2 + (h2 - 1));
          }
          else // odd
          {
-            tempUlRect = ossimIrect(theVul.x,
-                                    theVul.y,
-                                    theVul.x + (w2 - 1),
-                                    theVul.y + (h2));
+            tempUlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y,
+                                    m_Vul.x + (w2 - 1),
+                                    m_Vul.y + (h2));
             
-            tempUrRect = ossimIrect(theVul.x + w2,
-                                    theVul.y,
-                                    theVul.x + w2 + (w2 - 1),
-                                    theVul.y + (h2));
+            tempUrRect = ossimIrect(m_Vul.x + w2,
+                                    m_Vul.y,
+                                    m_Vul.x + w2 + (w2 - 1),
+                                    m_Vul.y + (h2));
             
-            tempLrRect = ossimIrect(theVul.x + w2,
-                                    theVul.y + h2 + 1,
-                                    theVul.x + w2 + (w2 - 1),
-                                    theVul.y + h2 + (h2));
+            tempLrRect = ossimIrect(m_Vul.x + w2,
+                                    m_Vul.y + h2 + 1,
+                                    m_Vul.x + w2 + (w2 - 1),
+                                    m_Vul.y + h2 + (h2));
             
-            tempLlRect = ossimIrect(theVul.x,
-                                    theVul.y + h2 + 1,
-                                    theVul.x + (w2 - 1),
-                                    theVul.y + h2 + (h2));
+            tempLlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y + h2 + 1,
+                                    m_Vul.x + (w2 - 1),
+                                    m_Vul.y + h2 + (h2));
          }
       }
       else // odd
       {
          if((h%2) == 0) // if even
          {
-            tempUlRect = ossimIrect(theVul.x,
-                                    theVul.y,
-                                    theVul.x + (w2),
-                                    theVul.y + (h2 - 1));
+            tempUlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y,
+                                    m_Vul.x + (w2),
+                                    m_Vul.y + (h2 - 1));
             
-            tempUrRect = ossimIrect(theVul.x + w2 + 1,
-                                    theVul.y,
-                                    theVul.x + w2 + (w2),
-                                    theVul.y + (h2 - 1));
+            tempUrRect = ossimIrect(m_Vul.x + w2 + 1,
+                                    m_Vul.y,
+                                    m_Vul.x + w2 + (w2),
+                                    m_Vul.y + (h2 - 1));
             
-            tempLrRect = ossimIrect(theVul.x + w2+1,
-                                    theVul.y + h2,
-                                    theVul.x + w2 + (w2),
-                                    theVul.y + h2 + (h2 - 1));
+            tempLrRect = ossimIrect(m_Vul.x + w2+1,
+                                    m_Vul.y + h2,
+                                    m_Vul.x + w2 + (w2),
+                                    m_Vul.y + h2 + (h2 - 1));
             
-            tempLlRect = ossimIrect(theVul.x,
-                                    theVul.y + h2,
-                                    theVul.x + (w2),
-                                    theVul.y + h2 + (h2 - 1));
+            tempLlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y + h2,
+                                    m_Vul.x + (w2),
+                                    m_Vul.y + h2 + (h2 - 1));
             
          }
          else // odd
          {
-            tempUlRect = ossimIrect(theVul.x,
-                                    theVul.y,
-                                    theVul.x + (w2),
-                                    theVul.y + (h2));
+            tempUlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y,
+                                    m_Vul.x + (w2),
+                                    m_Vul.y + (h2));
             
-            tempUrRect = ossimIrect(theVul.x + w2+1,
-                                    theVul.y,
-                                    theVul.x + w2 + (w2),
-                                    theVul.y + (h2));
+            tempUrRect = ossimIrect(m_Vul.x + w2+1,
+                                    m_Vul.y,
+                                    m_Vul.x + w2 + (w2),
+                                    m_Vul.y + (h2));
             
-            tempLrRect = ossimIrect(theVul.x + w2+1,
-                                    theVul.y + h2+1,
-                                    theVul.x + w2 + (w2),
-                                    theVul.y + h2 + (h2));
+            tempLrRect = ossimIrect(m_Vul.x + w2+1,
+                                    m_Vul.y + h2+1,
+                                    m_Vul.x + w2 + (w2),
+                                    m_Vul.y + h2 + (h2));
             
-            tempLlRect = ossimIrect(theVul.x,
-                                    theVul.y + h2+1,
-                                    theVul.x + (w2),
-                                    theVul.y + h2 + (h2));
+            tempLlRect = ossimIrect(m_Vul.x,
+                                    m_Vul.y + h2+1,
+                                    m_Vul.x + (w2),
+                                    m_Vul.y + h2 + (h2));
          }
       }
    }
@@ -191,25 +196,25 @@ void ossimImageRenderer::ossimRendererSubRectInfo::splitView(ossimImageViewTrans
       << "ll      = " << tempLlRect << endl;
 #endif
 
-   ulRect.theVul = tempUlRect.ul();
-   ulRect.theVur = tempUlRect.ur();
-   ulRect.theVlr = tempUlRect.lr();
-   ulRect.theVll = tempUlRect.ll();
+   ulRect.m_Vul = tempUlRect.ul();
+   ulRect.m_Vur = tempUlRect.ur();
+   ulRect.m_Vlr = tempUlRect.lr();
+   ulRect.m_Vll = tempUlRect.ll();
    
-   urRect.theVul = tempUrRect.ul();
-   urRect.theVur = tempUrRect.ur();
-   urRect.theVlr = tempUrRect.lr();
-   urRect.theVll = tempUrRect.ll();
+   urRect.m_Vul = tempUrRect.ul();
+   urRect.m_Vur = tempUrRect.ur();
+   urRect.m_Vlr = tempUrRect.lr();
+   urRect.m_Vll = tempUrRect.ll();
    
-   lrRect.theVul = tempLrRect.ul();
-   lrRect.theVur = tempLrRect.ur();
-   lrRect.theVlr = tempLrRect.lr();
-   lrRect.theVll = tempLrRect.ll();
-
-   llRect.theVul = tempLlRect.ul();
-   llRect.theVur = tempLlRect.ur();
-   llRect.theVlr = tempLlRect.lr();
-   llRect.theVll = tempLlRect.ll();
+   lrRect.m_Vul = tempLrRect.ul();
+   lrRect.m_Vur = tempLrRect.ur();
+   lrRect.m_Vlr = tempLrRect.lr();
+   lrRect.m_Vll = tempLrRect.ll();
+
+   llRect.m_Vul = tempLlRect.ul();
+   llRect.m_Vur = tempLlRect.ur();
+   llRect.m_Vlr = tempLlRect.lr();
+   llRect.m_Vll = tempLlRect.ll();
    
    ulRect.transformViewToImage(transform);
    urRect.transformViewToImage(transform);
@@ -217,58 +222,64 @@ void ossimImageRenderer::ossimRendererSubRectInfo::splitView(ossimImageViewTrans
    llRect.transformViewToImage(transform);
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::ossimRendererSubRectInfo::transformImageToView(ossimImageViewTransform* transform)
 {
    ossimDpt vul;
    ossimDpt vur;
    ossimDpt vlr;
    ossimDpt vll;
-   transform->imageToView(theIul,
+   transform->imageToView(m_Iul,
                           vul);
-   transform->imageToView(theIur,
+   transform->imageToView(m_Iur,
                           vur);
-   transform->imageToView(theIlr,
+   transform->imageToView(m_Ilr,
                           vlr);
-   transform->imageToView(theIll,
+   transform->imageToView(m_Ill,
                           vll);
    
-   theVul = vul;
-   theVur = vur;
-   theVlr = vlr;
-   theVll = vll;
+   m_Vul = vul;
+   m_Vur = vur;
+   m_Vlr = vlr;
+   m_Vll = vll;
    
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::ossimRendererSubRectInfo::transformViewToImage(ossimImageViewTransform* transform)
 {
    
    
-   ossimDpt nvul = theVul;
-   ossimDpt nvur = theVur;;
-   ossimDpt nvlr = theVlr;
-   ossimDpt nvll = theVll;
+   ossimDpt nvul = m_Vul;
+   ossimDpt nvur = m_Vur;;
+   ossimDpt nvlr = m_Vlr;
+   ossimDpt nvll = m_Vll;
 
    transform->viewToImage(nvul,
-                          theIul);
+                          m_Iul);
    transform->viewToImage(nvur,
-                          theIur);
+                          m_Iur);
    transform->viewToImage(nvlr,
-                          theIlr);
+                          m_Ilr);
    transform->viewToImage(nvll,
-                          theIll);
+                          m_Ill);
 
    if(imageHasNans())
    {
-      theViewToImageScale.makeNan();
+      m_ViewToImageScale.makeNan();
    }
    else
    {
-      theViewToImageScale = ossimDpt(1.0, 1.0);
+      m_ViewToImageScale = ossimDpt(1.0, 1.0);
       
-      ossimDpt topDelta    = theIur - theIul;
-      ossimDpt rightDelta  = theIlr - theIur;
-      ossimDpt bottomDelta = theIll - theIlr;
-      ossimDpt leftDelta   = theIul - theIll;
+      ossimDpt topDelta    = m_Iur - m_Iul;
+      ossimDpt rightDelta  = m_Ilr - m_Iur;
+      ossimDpt bottomDelta = m_Ill - m_Ilr;
+      ossimDpt leftDelta   = m_Iul - m_Ill;
       double topLen    = topDelta.length();
       double bottomLen = bottomDelta.length();
       double rightLen  = rightDelta.length();
@@ -280,80 +291,86 @@ void ossimImageRenderer::ossimRendererSubRectInfo::transformViewToImage(ossimIma
       double averageVert  = ((leftLen) + (rightLen))*.5;
       
       
-      ossimDpt deltaViewP1P2 = theVul - theVur;
-      ossimDpt deltaViewP1P3 = theVul - theVll;
+      ossimDpt deltaViewP1P2 = m_Vul - m_Vur;
+      ossimDpt deltaViewP1P3 = m_Vul - m_Vll;
       
       double lengthViewP1P2 = deltaViewP1P2.length();//+1;
       double lengthViewP1P3 = deltaViewP1P3.length();//+1;
 
       if(lengthViewP1P2 > FLT_EPSILON)
       {
-         theViewToImageScale.x = averageHoriz/lengthViewP1P2;
+         m_ViewToImageScale.x = averageHoriz/lengthViewP1P2;
       }
       else
       {
-         theViewToImageScale.makeNan();
+         m_ViewToImageScale.makeNan();
       }
       if(lengthViewP1P3 > FLT_EPSILON)
       {
-         theViewToImageScale.y = averageVert/lengthViewP1P3;
+         m_ViewToImageScale.y = averageVert/lengthViewP1P3;
           
       }
       else
       {
-         theViewToImageScale.makeNan();
+         m_ViewToImageScale.makeNan();
       }
 
-      if(!theViewToImageScale.hasNans())
+      if(!m_ViewToImageScale.hasNans())
       {
-         theImageToViewScale.x = 1.0/theViewToImageScale.x;
-         theImageToViewScale.y = 1.0/theViewToImageScale.y;
+         m_ImageToViewScale.x = 1.0/m_ViewToImageScale.x;
+         m_ImageToViewScale.y = 1.0/m_ViewToImageScale.y;
       }
       else
       {
-         theImageToViewScale.makeNan();
+         m_ImageToViewScale.makeNan();
       }
   }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::ossimRendererSubRectInfo::stretchImageOut(bool enableRound)
 {
-   ossimDpt topDelta    = theIur - theIul;
-   ossimDpt rightDelta  = theIlr - theIur;
-   ossimDpt bottomDelta = theIll - theIlr;
-   ossimDpt leftDelta   = theIul - theIll;
+   ossimDpt topDelta    = m_Iur - m_Iul;
+   ossimDpt rightDelta  = m_Ilr - m_Iur;
+   ossimDpt bottomDelta = m_Ill - m_Ilr;
+   ossimDpt leftDelta   = m_Iul - m_Ill;
 
    topDelta = topDelta*(1.0/topDelta.length());
    rightDelta = rightDelta*(1.0/rightDelta.length());
    bottomDelta = bottomDelta*(1.0/bottomDelta.length());
    leftDelta = leftDelta*(1.0/leftDelta.length());
 
-   theIul = theIul + ((leftDelta - topDelta)*.5);
-   theIur = theIur + ((topDelta - rightDelta)*.5);
-   theIlr = theIlr + ((rightDelta - bottomDelta)*.5);
-   theIll = theIll + ((bottomDelta - leftDelta)*.5);
+   m_Iul = m_Iul + ((leftDelta - topDelta)*.5);
+   m_Iur = m_Iur + ((topDelta - rightDelta)*.5);
+   m_Ilr = m_Ilr + ((rightDelta - bottomDelta)*.5);
+   m_Ill = m_Ill + ((bottomDelta - leftDelta)*.5);
 
    if(enableRound)
    {
-      theIul = ossimIpt(ossim::round<int>(theIul.x),
-                        ossim::round<int>(theIul.y));
-      theIur = ossimIpt(ossim::round<int>(theIur.x),
-                        ossim::round<int>(theIur.y));
-      theIlr = ossimIpt(ossim::round<int>(theIlr.x),
-                        ossim::round<int>(theIlr.y));
-      theIll = ossimIpt(ossim::round<int>(theIll.x),
-                        ossim::round<int>(theIll.y));
+      m_Iul = ossimIpt(ossim::round<int>(m_Iul.x),
+                        ossim::round<int>(m_Iul.y));
+      m_Iur = ossimIpt(ossim::round<int>(m_Iur.x),
+                        ossim::round<int>(m_Iur.y));
+      m_Ilr = ossimIpt(ossim::round<int>(m_Ilr.x),
+                        ossim::round<int>(m_Ilr.y));
+      m_Ill = ossimIpt(ossim::round<int>(m_Ill.x),
+                        ossim::round<int>(m_Ill.y));
    }
 }
 
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 bool ossimImageRenderer::ossimRendererSubRectInfo::isIdentity()const
 {
-//    ossimDpt deltaP1P2 = theIul - theIur;
-//    ossimDpt deltaP1P3 = theIul - theIll;
+//    ossimDpt deltaP1P2 = m_Iul - m_Iur;
+//    ossimDpt deltaP1P3 = m_Iul - m_Ill;
    
-//    ossimDpt deltaViewP1P2 = theVul - theVur;
-//    ossimDpt deltaViewP1P3 = theVul - theVll;
+//    ossimDpt deltaViewP1P2 = m_Vul - m_Vur;
+//    ossimDpt deltaViewP1P3 = m_Vul - m_Vll;
    
 //    bool horizontalSigns = ossimGetSign(deltaP1P2.x)==ossimGetSign(deltaViewP1P2.x);
 //    bool verticalSigns   = ossimGetSign(deltaP1P3.y)==ossimGetSign(deltaViewP1P3.y);
@@ -363,17 +380,17 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::isIdentity()const
 //    if(horizontalSigns && verticalSigns)
 //    {
 //       // check scales to see if they are 1
-//       if(fabs(1-theViewToImageScale.x) <= FLT_EPSILON &&
-//          fabs(1-theViewToImageScale.y) <= FLT_EPSILON)
+//       if(fabs(1-m_ViewToImageScale.x) <= FLT_EPSILON &&
+//          fabs(1-m_ViewToImageScale.y) <= FLT_EPSILON)
 //       {
 //          return true;
 //       }
 //    }
 
-    double iulDelta = (theIul-theVul).length();
-    double iurDelta = (theIur-theVur).length();
-    double ilrDelta = (theIlr-theVlr).length();
-    double illDelta = (theIll-theVll).length();
+    double iulDelta = (m_Iul-m_Vul).length();
+    double iurDelta = (m_Iur-m_Vur).length();
+    double ilrDelta = (m_Ilr-m_Vlr).length();
+    double illDelta = (m_Ill-m_Vll).length();
 
     return ((iulDelta <= FLT_EPSILON)&&
             (iurDelta <= FLT_EPSILON)&&
@@ -381,6 +398,9 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::isIdentity()const
             (illDelta <= FLT_EPSILON));
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate(ossimImageViewTransform* transform,
 									  double error)const
 {
@@ -477,6 +497,9 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate(ossimI
 }
 
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::ossimRendererSubRectInfo::getViewMids(ossimDpt& upperMid,
 				     ossimDpt& rightMid,
 				     ossimDpt& bottomMid,
@@ -484,13 +507,16 @@ void ossimImageRenderer::ossimRendererSubRectInfo::getViewMids(ossimDpt& upperMi
 				     ossimDpt& center)const
 {
   
-  upperMid  = (theVul + theVur)*.5;
-  rightMid  = (theVur + theVlr)*.5;
-  bottomMid = (theVlr + theVll)*.5;
-  leftMid   = (theVul + theVll)*.5;
-  center    = (theVul + theVur + theVlr + theVll)*.25;
+  upperMid  = (m_Vul + m_Vur)*.5;
+  rightMid  = (m_Vur + m_Vlr)*.5;
+  bottomMid = (m_Vlr + m_Vll)*.5;
+  leftMid   = (m_Vul + m_Vll)*.5;
+  center    = (m_Vul + m_Vur + m_Vlr + m_Vll)*.25;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::ossimRendererSubRectInfo::getImageMids(ossimDpt& upperMid,
 				      ossimDpt& rightMid,
 				      ossimDpt& bottomMid,
@@ -507,14 +533,17 @@ void ossimImageRenderer::ossimRendererSubRectInfo::getImageMids(ossimDpt& upperM
     }
   else
     {
-      upperMid  = (theIul + theIur)*.5;
-      rightMid  = (theIur + theIlr)*.5;
-      bottomMid = (theIlr + theIll)*.5;
-      leftMid   = (theIul + theIll)*.5;
-      center    = (theIul + theIur + theIlr + theIll)*.25;
+      upperMid  = (m_Iul + m_Iur)*.5;
+      rightMid  = (m_Iur + m_Ilr)*.5;
+      bottomMid = (m_Ilr + m_Ill)*.5;
+      leftMid   = (m_Iul + m_Ill)*.5;
+      center    = (m_Iul + m_Iur + m_Ilr + m_Ill)*.25;
     }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimDpt ossimImageRenderer::ossimRendererSubRectInfo::getParametricCenter(const ossimDpt& ul, const ossimDpt& ur, 
 									   const ossimDpt& lr, const ossimDpt& ll)const
 {
@@ -527,65 +556,77 @@ ossimDpt ossimImageRenderer::ossimRendererSubRectInfo::getParametricCenter(const
   return centerBottom + (centerBottom - centerTop)*.5;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimImageRenderer::ossimImageRenderer()
-   :
-      ossimImageSourceFilter(),
-      ossimViewInterface(NULL),
-      theResampler(NULL),
-      theBlankTile(NULL),
-      theTile(NULL),
-      theTemporaryBuffer(NULL),
-      theStartingResLevel(0),
-      theImageViewTransform(NULL),
-      theMaxRecursionLevel(5),
-      theAutoUpdateInputTransform(true),
-      theMaxLevelsToCompute(999999) // something large so it will always compute
+:
+ossimImageSourceFilter(),
+ossimViewInterface(NULL),
+m_Resampler(NULL),
+m_BlankTile(NULL),
+m_Tile(NULL),
+m_TemporaryBuffer(NULL),
+m_StartingResLevel(0),
+m_ImageViewTransform(NULL),
+m_MaxRecursionLevel(5),
+m_AutoUpdateInputTransform(true),
+m_MaxLevelsToCompute(999999) // something large so it will always compute
 {
-   ossimViewInterface::theObject = this;
-   theResampler = new ossimFilterResampler();
-   theImageViewTransform = new ossimImageViewProjectionTransform;
-   theBoundingRect.makeNan();
-//    theInputRect.makeNan();
-//    theOutputRect.makeNan();
+    ossimViewInterface::theObject = this;
+    m_Resampler = new ossimFilterResampler();
+    m_ImageViewTransform = new ossimImageViewProjectionTransform;
+    m_BoundingRect.makeNan();
+    //    m_InputRect.makeNan();
+    //    theOutputRect.makeNan();
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimImageRenderer::ossimImageRenderer(ossimImageSource* inputSource,
                                        ossimImageViewTransform* imageViewTrans)
    : ossimImageSourceFilter(inputSource),
      ossimViewInterface(NULL),
-     theResampler(NULL),
-     theBlankTile(NULL),
-     theTile(NULL),
-     theTemporaryBuffer(NULL),
-     theStartingResLevel(0),
-     theImageViewTransform(imageViewTrans),
-     theMaxRecursionLevel(5),
-     theAutoUpdateInputTransform(true),
-     theMaxLevelsToCompute(999999) // something large so it will always compute
+     m_Resampler(NULL),
+     m_BlankTile(NULL),
+     m_Tile(NULL),
+     m_TemporaryBuffer(NULL),
+     m_StartingResLevel(0),
+     m_ImageViewTransform(imageViewTrans),
+     m_MaxRecursionLevel(5),
+     m_AutoUpdateInputTransform(true),
+     m_MaxLevelsToCompute(999999) // something large so it will always compute
 {
    ossimViewInterface::theObject = this;
-   theResampler = new ossimFilterResampler();
-   if(!theImageViewTransform)
+   m_Resampler = new ossimFilterResampler();
+   if(!m_ImageViewTransform)
    {
-      theImageViewTransform = new ossimImageViewProjectionTransform;
+      m_ImageViewTransform = new ossimImageViewProjectionTransform;
    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimImageRenderer::~ossimImageRenderer()
 {
-   if (theImageViewTransform)
+   if (m_ImageViewTransform)
    {
-      delete theImageViewTransform;
-      theImageViewTransform = NULL;
+      delete m_ImageViewTransform;
+      m_ImageViewTransform = NULL;
    }
    
-   if(theResampler)
+   if(m_Resampler)
    {
-      delete theResampler;
-      theResampler = NULL;
+      delete m_Resampler;
+      m_Resampler = NULL;
    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimRefPtr<ossimImageData> ossimImageRenderer::getTile(
    const  ossimIrect& tileRect,
    ossim_uint32 resLevel)
@@ -602,12 +643,12 @@ ossimRefPtr<ossimImageData> ossimImageRenderer::getTile(
    // long h = tileRect.height();
    // ossimIpt origin = tileRect.ul();
    
-   if(!theBlankTile.valid() || !theTile.valid())
+   if(!m_BlankTile.valid() || !m_Tile.valid())
    {
       allocate();
    }
 
-   if(!theTile.valid())
+   if(!m_Tile.valid())
    {
       if(traceDebug())
       {
@@ -618,33 +659,33 @@ ossimRefPtr<ossimImageData> ossimImageRenderer::getTile(
       return ossimImageSourceFilter::getTile(tileRect, resLevel);
    }
 
-   if(theBlankTile.valid())
+   if(m_BlankTile.valid())
    {
-      theBlankTile->setImageRectangle(tileRect);
+      m_BlankTile->setImageRectangle(tileRect);
    }
 
    if(!theInputConnection)
    {
-      return theBlankTile;
+      return m_BlankTile;
    }
    
-   if ( !isSourceEnabled()||(!theImageViewTransform)||
-        (!theImageViewTransform->isValid()) )
+   if ( !isSourceEnabled()||(!m_ImageViewTransform)||
+        (!m_ImageViewTransform->isValid()) )
    {
       // This tile source bypassed, return the input tile source.
       return theInputConnection->getTile(tileRect, resLevel);  
    }
 
-   if(theBoundingViewRect.hasNans())
+   if(m_BoundingViewRect.hasNans())
    {
-      theBoundingViewRect = getBoundingRect();
+      m_BoundingViewRect = getBoundingRect();
    }
-   if(theBoundingViewRect.width() < 4 &&
-      theBoundingViewRect.height() < 4)
+   if(m_BoundingViewRect.width() < 4 &&
+      m_BoundingViewRect.height() < 4)
    {
-      return theBlankTile;
+      return m_BlankTile;
    }
-   ossimIrect rect = theBoundingViewRect;
+   ossimIrect rect = m_BoundingViewRect;
    if( !theInputConnection || !rect.intersects(tileRect) )
    {
       if(traceDebug())
@@ -652,46 +693,63 @@ ossimRefPtr<ossimImageData> ossimImageRenderer::getTile(
          ossimNotify(ossimNotifyLevel_DEBUG)
             << MODULE << "No intersection, Returning...." << endl;
       }
-      return theBlankTile;
+      return m_BlankTile;
    }
    
-   if(!theTile)
+   if(!m_Tile)
    {
       return theInputConnection->getTile(tileRect, resLevel);
    }
    
-   // long tw = theTile->getWidth();
-   // long th = theTile->getHeight();
+   // long tw = m_Tile->getWidth();
+   // long th = m_Tile->getHeight();
    
-   theTile->setImageRectangle(tileRect);
-   theTile->makeBlank();
-
+   m_Tile->setImageRectangle(tileRect);
+   m_Tile->makeBlank();
+ 
+#if 1
+   // expand a small patch just to alleviate errors in the size of the rect when resampling
+      ossimIrect viewRectClip = tileRect.clipToRect(ossimIrect(m_BoundingViewRect.ul() + ossimIpt(-8,-8),
+                                                               m_BoundingViewRect.lr() + ossimIpt(8,8)));
+  // ossimIrect viewRectClip = tileRect.clipToRect(m_BoundingViewRect);
+//   std::cout << "_____________________" << std::endl;
+//   std::cout << "viewRectClip = " <<  viewRectClip << std::endl;
+//   std::cout << "tileRect = " <<  tileRect << std::endl;
+//   std::cout << "m_BoundingViewRect = " <<  m_BoundingViewRect << std::endl;
+   ossimRendererSubRectInfo subRectInfo(viewRectClip.ul(),
+                                        viewRectClip.ur(),
+                                        viewRectClip.lr(),
+                                        viewRectClip.ll());
+#else
    ossimRendererSubRectInfo subRectInfo(tileRect.ul(),
                                         tileRect.ur(),
                                         tileRect.lr(),
                                         tileRect.ll());
-   
-   subRectInfo.transformViewToImage(theImageViewTransform);
+#endif
+   subRectInfo.transformViewToImage(m_ImageViewTransform);
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE << " image rect = " << subRectInfo.getImageRect() << std::endl;
    }
    
-   recursiveResample(theTile, subRectInfo, 1);
+   recursiveResample(m_Tile, subRectInfo, 1);
    
-   if(theTile.valid())
+   if(m_Tile.valid())
    {
-      theTile->validate();
+      m_Tile->validate();
    }
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE << "Returning...." << endl;
    }
-   return theTile;
+   return m_Tile;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::recursiveResample(ossimRefPtr<ossimImageData> outputData,
                                            const ossimRendererSubRectInfo& rectInfo,
                                            ossim_uint32 level)
@@ -713,7 +771,7 @@ void ossimImageRenderer::recursiveResample(ossimRefPtr<ossimImageData> outputDat
       return;
    }
    const double error = 1;
-   if(rectInfo.canBilinearInterpolate(theImageViewTransform, error))
+   if(rectInfo.canBilinearInterpolate(m_ImageViewTransform, error))
    {                                // then draw the tile
       fillTile(outputData,
 	       rectInfo);
@@ -727,7 +785,7 @@ void ossimImageRenderer::recursiveResample(ossimRefPtr<ossimImageData> outputDat
       ossimRendererSubRectInfo lrRectInfo;
       ossimRendererSubRectInfo llRectInfo;
       
-      rectInfo.splitView(theImageViewTransform,
+      rectInfo.splitView(m_ImageViewTransform,
 			 ulRectInfo,
 			 urRectInfo,
 			 lrRectInfo,
@@ -742,13 +800,13 @@ void ossimImageRenderer::recursiveResample(ossimRefPtr<ossimImageData> outputDat
          << "\nheight = " << vrect.height()
          << "\nlevel  = " << level << endl;
 #endif
-      bool scaleUlNeedsSplit = ((!ulRectInfo.canBilinearInterpolate(theImageViewTransform, error))||
+      bool scaleUlNeedsSplit = ((!ulRectInfo.canBilinearInterpolate(m_ImageViewTransform, error))||
 				ulRectInfo.imageHasNans());
-      bool scaleUrNeedsSplit = ((!urRectInfo.canBilinearInterpolate(theImageViewTransform, error))||
+      bool scaleUrNeedsSplit = ((!urRectInfo.canBilinearInterpolate(m_ImageViewTransform, error))||
 				urRectInfo.imageHasNans());
-      bool scaleLrNeedsSplit = ((!lrRectInfo.canBilinearInterpolate(theImageViewTransform, error))||
+      bool scaleLrNeedsSplit = ((!lrRectInfo.canBilinearInterpolate(m_ImageViewTransform, error))||
 				lrRectInfo.imageHasNans());
-      bool scaleLlNeedsSplit = ((!llRectInfo.canBilinearInterpolate(theImageViewTransform, error))||
+      bool scaleLlNeedsSplit = ((!llRectInfo.canBilinearInterpolate(m_ImageViewTransform, error))||
 				llRectInfo.imageHasNans());
       
       bool tooSmall = (vrect.width() < 4) && (vrect.height()<4);
@@ -819,6 +877,9 @@ void ossimImageRenderer::recursiveResample(ossimRefPtr<ossimImageData> outputDat
 
 #define RSET_SEARCH_THRESHHOLD 0.1
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
                                   const ossimRendererSubRectInfo& rectInfo)
 {
@@ -844,7 +905,18 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
    //long closestFitResLevel = (long)floor( log( 1.0 / averageScale )/ log( 2.0 ) );
    
    ossim_uint32 resLevel = closestFitResLevel<0 ? 0:closestFitResLevel;
-   resLevel += theStartingResLevel;
+   resLevel += m_StartingResLevel;
+
+   //---
+   // ESH 02/2009: If requested resLevel is too high, let's lower it to one
+   // that is ok.
+   //---
+   const ossim_uint32 NUM_LEVELS =
+      theInputConnection->getNumberOfDecimationLevels();
+   if ( (NUM_LEVELS > 0) && (resLevel >=  NUM_LEVELS) )
+   {
+      resLevel = NUM_LEVELS - 1;
+   }
 
    //---
    // ESH 11/2008: Check the rset at the calculated resLevel to see
@@ -856,7 +928,7 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
    theInputConnection->getDecimationFactor(resLevel, decimation);
    double requestScale = 1.0 / pow( (double)2.0, (double)resLevel );
    double closestScale = decimation.hasNans() ? requestScale : decimation.x;
-   
+
    double differenceTest = 0.0;
    if (closestScale != 0.0)
    {
@@ -875,16 +947,16 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
         ((fabs(differenceTest) < RSET_SEARCH_THRESHHOLD) &&
          (differenceTest < 0.0) ) )
    {
+      //---
       // ESH 11/2008: We test for the best rset. We assume 
       // that decimation level always decreases as resLevel increases, so 
       // the search can end before testing all rsets.
+      //---
       ossim_uint32 savedResLevel = resLevel;
       closestScale = 1.0; // resLevel 0
       resLevel = 0;
-      ossim_uint32 numLevels =
-         theInputConnection->getNumberOfDecimationLevels();
       ossim_uint32 i;
-      for( i=1; i<numLevels; ++i )
+      for( i=1; i<NUM_LEVELS; ++i )
       {
          theInputConnection->getDecimationFactor(i, decimation);
          if(decimation.hasNans() == false )
@@ -909,16 +981,16 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
       }
    }
    
-   ossimDpt nul(rectInfo.theIul.x*closestScale,
-                rectInfo.theIul.y*closestScale);
-   ossimDpt nll(rectInfo.theIll.x*closestScale,
-                rectInfo.theIll.y*closestScale);
-   ossimDpt nlr(rectInfo.theIlr.x*closestScale,
-                rectInfo.theIlr.y*closestScale);
-   ossimDpt nur(rectInfo.theIur.x*closestScale,
-                rectInfo.theIur.y*closestScale);
+   ossimDpt nul(rectInfo.m_Iul.x*closestScale,
+                rectInfo.m_Iul.y*closestScale);
+   ossimDpt nll(rectInfo.m_Ill.x*closestScale,
+                rectInfo.m_Ill.y*closestScale);
+   ossimDpt nlr(rectInfo.m_Ilr.x*closestScale,
+                rectInfo.m_Ilr.y*closestScale);
+   ossimDpt nur(rectInfo.m_Iur.x*closestScale,
+                rectInfo.m_Iur.y*closestScale);
    
-   theResampler->getKernelSupport( kernelSupportX, kernelSupportY );
+   m_Resampler->getKernelSupport( kernelSupportX, kernelSupportY );
    
    ossimDrect boundingRect = ossimDrect( nul, nll, nlr, nur );
    
@@ -942,10 +1014,10 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
       return;
    }
    
-   ossimDrect bounds = theBoundingRect;
+   ossimDrect bounds = m_BoundingRect;
    
    bounds = bounds*ossimDpt(closestScale, closestScale);
-   theResampler->setBoundingInputRect(bounds);
+   m_Resampler->setBoundingInputRect(bounds);
    
    double denominatorY = 1.0;
    if(tile_size.y > 2)
@@ -955,9 +1027,9 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
    
    ossimDpt newScale( imageToViewScale.x / closestScale,
                      imageToViewScale.y / closestScale );
-   theResampler->setScaleFactor(newScale);
+   m_Resampler->setScaleFactor(newScale);
    
-   theResampler->resample(data,
+   m_Resampler->resample(data,
                           outputData,
                           vrect,
                           nul,
@@ -970,6 +1042,9 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
    
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 long ossimImageRenderer::computeClosestResLevel(const std::vector<ossimDpt>& decimationFactors,
                                                 double scale)const
 {
@@ -1001,6 +1076,9 @@ long ossimImageRenderer::computeClosestResLevel(const std::vector<ossimDpt>& dec
    return result;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimIrect ossimImageRenderer::getBoundingRect(ossim_uint32 resLevel)const
 {
 #if 0
@@ -1017,9 +1095,9 @@ ossimIrect ossimImageRenderer::getBoundingRect(ossim_uint32 resLevel)const
       return theInputConnection->getBoundingRect(resLevel);
    }
    
-   if(!theBoundingViewRect.hasNans())
+   if(!m_BoundingViewRect.hasNans())
    {
-      return theBoundingViewRect;
+      return m_BoundingViewRect;
    }
    
    vector<ossimDpt> points(4);
@@ -1031,33 +1109,33 @@ ossimIrect ossimImageRenderer::getBoundingRect(ossim_uint32 resLevel)const
    inputRect.makeNan();
    outputRect.makeNan();
 
-   if(theInputConnection&&theImageViewTransform)
+   if(theInputConnection&&m_ImageViewTransform)
    {
       inputRect = theInputConnection->getBoundingRect(resLevel);
       
-      if(isSourceEnabled()&&theImageViewTransform->isValid())
+      if(isSourceEnabled()&&m_ImageViewTransform->isValid())
       {
 //          inputRect = ossimDrect(inputRect.ul().x,
 //                                 inputRect.ul().y,
 //                                 inputRect.lr().x,
 //                                 inputRect.lr().y); 
          
-// 	 theImageViewTransform->imageToView(inputRect.ul(), points[0]);
-//          theImageViewTransform->imageToView(inputRect.ur(), points[1]);
-//          theImageViewTransform->imageToView(inputRect.lr(), points[2]);
-//          theImageViewTransform->imageToView(inputRect.ll(), points[3]);
+// 	 m_ImageViewTransform->imageToView(inputRect.ul(), points[0]);
+//          m_ImageViewTransform->imageToView(inputRect.ur(), points[1]);
+//          m_ImageViewTransform->imageToView(inputRect.lr(), points[2]);
+//          m_ImageViewTransform->imageToView(inputRect.ll(), points[3]);
 
          
-         ossimDrect tempRect = theImageViewTransform->getImageToViewBounds(inputRect);
+         ossimDrect tempRect = m_ImageViewTransform->getImageToViewBounds(inputRect);
          
-         theBoundingViewRect = ossimIrect(static_cast<int>(floor(tempRect.ul().x + 0.5)),
+         m_BoundingViewRect = ossimIrect(static_cast<int>(floor(tempRect.ul().x + 0.5)),
                                           static_cast<int>(floor(tempRect.ul().y + 0.5)),
                                           static_cast<int>(floor(tempRect.lr().x + 0.5)),
                                           static_cast<int>(floor(tempRect.lr().y + 0.5)));
       }
       else
       {
-         theBoundingViewRect = inputRect;
+         m_BoundingViewRect = inputRect;
       }
    }
    
@@ -1073,53 +1151,39 @@ ossimIrect ossimImageRenderer::getBoundingRect(ossim_uint32 resLevel)const
    }
 #endif
    
-   return theBoundingViewRect;
+   return m_BoundingViewRect;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::initialize()
 {
-   //---
    // Call the base class initialize.
    // Note:  This will reset "theInputConnection" if it changed...
-   //---
    ossimImageSourceFilter::initialize();
 
-   theBoundingViewRect.makeNan();
-   theBoundingRect.makeNan();
+   m_BoundingViewRect.makeNan();
+   m_BoundingRect.makeNan();
 
    if (theInputConnection)
-   {
-      theBoundingRect = theInputConnection->getBoundingRect();
-   }
+      m_BoundingRect = theInputConnection->getBoundingRect();
 
-   if (theImageViewTransform)
-   {
-      ossimImageViewProjectionTransform* trans
-         = PTR_CAST(ossimImageViewProjectionTransform,
-                    theImageViewTransform);
-      if(trans)
-      {
-         if(PTR_CAST(ossimMapProjection, trans->getImageProjection()) ||
-            (!trans->getImageProjection())||
-            (!trans->getViewProjection()))
-         {
-            checkTransform();
-         }
-      }
-   }
+   if (m_ImageViewTransform && !m_ImageViewTransform->isValid())
+      checkIVT();
 
-   if (theResampler)
+   if (m_Resampler)
    {
-      theResampler->setBoundingInputRect(theBoundingRect);
+      m_Resampler->setBoundingInputRect(m_BoundingRect);
    }
    
-   theInputDecimationFactors.clear();
+   m_InputDecimationFactors.clear();
 
    deallocate();
-//    if (theInputConnection && theTile.valid())
+//    if (theInputConnection && m_Tile.valid())
 //    {
 //       if ( theInputConnection->getNumberOfOutputBands() !=
-//            theTile->getNumberOfBands())
+//            m_Tile->getNumberOfBands())
 //       {
 //          //---
 //          // This will wide things slick and force an allocate() call on first
@@ -1130,48 +1194,60 @@ void ossimImageRenderer::initialize()
 //    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::deallocate()
 {
-   theTile            = NULL;
-   theBlankTile       = NULL;
-   theTemporaryBuffer = NULL;
+   m_Tile            = NULL;
+   m_BlankTile       = NULL;
+   m_TemporaryBuffer = NULL;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::allocate()
 {
    deallocate();
 
    if(theInputConnection)
    {
-      theTile = ossimImageDataFactory::instance()->create(this, this);
-      theBlankTile  = ossimImageDataFactory::instance()->create(this, this);
+      m_Tile = ossimImageDataFactory::instance()->create(this, this);
+      m_BlankTile  = ossimImageDataFactory::instance()->create(this, this);
       
-      theTile->initialize();
-      theBoundingRect = theInputConnection->getBoundingRect();
+      m_Tile->initialize();
+      m_BoundingRect = theInputConnection->getBoundingRect();
    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 bool ossimImageRenderer::saveState(ossimKeywordlist& kwl,
                                    const char* prefix)const
 {
-   if(theImageViewTransform)
+   if(m_ImageViewTransform)
    {
       ossimString newPrefix = ossimString(prefix) + ossimString("image_view_trans.");
       
-      theImageViewTransform->saveState(kwl, newPrefix.c_str());
+      m_ImageViewTransform->saveState(kwl, newPrefix.c_str());
    }
-   if(theResampler)
+   if(m_Resampler)
    {
-      theResampler->saveState(kwl,
+      m_Resampler->saveState(kwl,
                               (ossimString(prefix)+"resampler.").c_str());
    }
    kwl.add(prefix,
            "max_levels_to_compute",
-           theMaxLevelsToCompute);
+           m_MaxLevelsToCompute);
    
    return ossimImageSource::saveState(kwl, prefix);
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 bool ossimImageRenderer::loadState(const ossimKeywordlist& kwl,
                                    const char* prefix)
 {
@@ -1188,90 +1264,95 @@ bool ossimImageRenderer::loadState(const ossimKeywordlist& kwl,
    
    ossimString newPrefix = ossimString(prefix) + ossimString("image_view_trans.");
    bool result = ossimImageSourceFilter::loadState(kwl, prefix);
-   theInputDecimationFactors.clear();
+   m_InputDecimationFactors.clear();
    
-   if(theResampler)
+   if(m_Resampler)
    {
-      theResampler->loadState(kwl,
+      m_Resampler->loadState(kwl,
                               (ossimString(prefix)+"resampler.").c_str());
    }
-   if(theImageViewTransform)
+   if(m_ImageViewTransform)
    {
-      delete theImageViewTransform;
-      theImageViewTransform = NULL;
+      delete m_ImageViewTransform;
+      m_ImageViewTransform = NULL;
    }
-   theImageViewTransform = ossimImageViewTransformFactory::instance()->createTransform(kwl, newPrefix.c_str());
-   if(!theImageViewTransform)
+   m_ImageViewTransform = ossimImageViewTransformFactory::instance()->createTransform(kwl, newPrefix.c_str());
+   if(!m_ImageViewTransform)
    {
-      theImageViewTransform = new ossimImageViewProjectionTransform;
+      m_ImageViewTransform = new ossimImageViewProjectionTransform;
    }
    const char* maxLevelsToCompute = kwl.find(prefix,
                                              "max_levels_to_compute");
    if(maxLevelsToCompute)
    {
-      theMaxLevelsToCompute = ossimString(maxLevelsToCompute).toUInt32();
+      m_MaxLevelsToCompute = ossimString(maxLevelsToCompute).toUInt32();
    }
    
    return result;
 }
 
-void ossimImageRenderer::setImageViewTransform(ossimImageViewTransform* transform)
+//**************************************************************************************************
+// 
+//**************************************************************************************************
+void ossimImageRenderer::setImageViewTransform(ossimImageViewTransform* ivt)
 {
-   if(theImageViewTransform)
-   {
-      delete theImageViewTransform;
-   }
-   theImageViewTransform = transform;
+   if(m_ImageViewTransform)
+      delete m_ImageViewTransform;
 
-   ossimImageViewProjectionTransform* trans = PTR_CAST(ossimImageViewProjectionTransform,
-                                                       theImageViewTransform);
-   if(trans)
-   {
-      if(!trans->getImageProjection())
-      {
-         checkTransform();
-      }
-   }
-   theBoundingViewRect.makeNan();
+   m_ImageViewTransform = ivt;
+   if (!m_ImageViewTransform || !m_ImageViewTransform->isValid())
+      checkIVT();
+
+   m_BoundingViewRect.makeNan();
 }
 
-bool ossimImageRenderer::setView(ossimObject* baseObject,
-                                 bool ownsTheView)
+//**************************************************************************************************
+// 
+//**************************************************************************************************
+bool ossimImageRenderer::setView(ossimObject* baseObject)
 {
    bool result = false;
-   theBoundingViewRect.makeNan();
-   if(theImageViewTransform)
+   m_BoundingViewRect.makeNan();
+   if(m_ImageViewTransform)
    {
-      result = theImageViewTransform->setView(baseObject,
-                                              ownsTheView);
+      result = m_ImageViewTransform->setView(baseObject);
    }
 
    return result;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimObject* ossimImageRenderer::getView()
 {
-   if(theImageViewTransform)
+   if(m_ImageViewTransform)
    {
-      return theImageViewTransform->getView();
+      return m_ImageViewTransform->getView();
    }
    return NULL;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 const ossimObject* ossimImageRenderer::getView()const
 {
-   if(theImageViewTransform)
+   if(m_ImageViewTransform)
    {
-      return theImageViewTransform->getView();
+      return m_ImageViewTransform->getView();
    }
    return NULL;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::getValidImageVertices(vector<ossimIpt>& validVertices,
                                                ossimVertexOrdering ordering,
                                                ossim_uint32 resLevel)const
 {
-   if(theInputConnection&&theImageViewTransform&&theImageViewTransform->isValid())
+   if(theInputConnection&&m_ImageViewTransform&&m_ImageViewTransform->isValid())
    {
       theInputConnection->getValidImageVertices(validVertices, ordering, resLevel);
       if(isSourceEnabled())
@@ -1284,7 +1365,7 @@ void ossimImageRenderer::getValidImageVertices(vector<ossimIpt>& validVertices,
             // transform each point to the view
             for(idx = 0; idx < inputSize; ++idx)
             {
-               theImageViewTransform->imageToView(validVertices[idx], viewPt);
+               m_ImageViewTransform->imageToView(validVertices[idx], viewPt);
                
                // round it to the nearest pixel
                //
@@ -1295,82 +1376,84 @@ void ossimImageRenderer::getValidImageVertices(vector<ossimIpt>& validVertices,
    }
 }
 
-bool ossimImageRenderer::getImageGeometry(ossimKeywordlist& kwl,
-                                          const char* prefix)
+//**************************************************************************************************
+// Returns the geometry associated with the image being served out of the renderer. This corresponds
+// To the view geometry defined in theIVT.
+//**************************************************************************************************
+ossimImageGeometry* ossimImageRenderer::getImageGeometry()
 {
-   if(isSourceEnabled()&&getView())
-   {
-      const ossimObject* view = getView();
-      
-      bool result = view->saveState(kwl, prefix);
+   // Make sure the IVT was properly initialized
+   if (m_ImageViewTransform && !m_ImageViewTransform->isValid())
+      checkIVT();
 
-      return result;
-   }
-   else
+   ossimImageViewProjectionTransform* ivpt = PTR_CAST(ossimImageViewProjectionTransform, 
+                                                      m_ImageViewTransform);
+   if (ivpt)
    {
-      if(theInputConnection)
-      {
-         return theInputConnection->getImageGeometry(kwl, prefix);
-      }
+      // we need to return the right side since the geometry changed to a view geometry
+      return ivpt->getViewGeometry();
    }
 
-   return false;
+   return 0;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::connectInputEvent(ossimConnectionEvent& event)
 {
    theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
-   // All this code in here will change after the demo.  For now we need a
-   // way to bring every one up with a projection.  Later we will have to
-   // tie to a projection source.
-   //
-   if(!theImageViewTransform)
-   {
-      theImageViewTransform  = new ossimImageViewProjectionTransform;
-   }
+   if(!m_ImageViewTransform)
+      m_ImageViewTransform  = new ossimImageViewProjectionTransform;
    
-   checkTransform();
-
+   checkIVT();
    initialize();
    
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::disconnectInputEvent(ossimConnectionEvent& event)
 {
-   ossimImageViewProjectionTransform* transform = PTR_CAST(ossimImageViewProjectionTransform,
-                                                           theImageViewTransform);
-   if(transform)
-   {
-      transform->setImageProjection(NULL, true);
-   }
+   ossimImageViewProjectionTransform* ivpt = PTR_CAST(ossimImageViewProjectionTransform,
+                                                      m_ImageViewTransform);
+   if(ivpt)
+      ivpt->setImageGeometry(NULL);
    
    theInputConnection = NULL;
-   theInputDecimationFactors.clear();
+   m_InputDecimationFactors.clear();
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::propertyEvent(ossimPropertyEvent& event)
 {
-   checkTransform();
+   checkIVT();
    initialize();
 }
 
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::setProperty(ossimRefPtr<ossimProperty> property)
 {
   ossimString tempName = property->getName();
   
   if(tempName == "Filter type")
     {
-      if(theResampler)
+      if(m_Resampler)
 	{
-	  theResampler->setFilterType(property->valueToString());
+	  m_Resampler->setFilterType(property->valueToString());
 	}
     }
 //   else if(tempName == "Blur factor")
 //     {
-//       if(theResampler)
+//       if(m_Resampler)
 // 	{
-// 	  theResampler->setBlurFactor(property->valueToString().toDouble());
+// 	  m_Resampler->setBlurFactor(property->valueToString().toDouble());
 // 	}
 //     }
   else
@@ -1379,6 +1462,9 @@ void ossimImageRenderer::setProperty(ossimRefPtr<ossimProperty> property)
     }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimRefPtr<ossimProperty> ossimImageRenderer::getProperty(const ossimString& name)const
 {
   ossimString tempName = name;
@@ -1386,10 +1472,10 @@ ossimRefPtr<ossimProperty> ossimImageRenderer::getProperty(const ossimString& na
   if(tempName == "Filter type")
     {
       std::vector<ossimString> filterNames;
-      theResampler->getFilterTypes(filterNames);
+      m_Resampler->getFilterTypes(filterNames);
       
       ossimStringProperty* stringProp = new ossimStringProperty("Filter type",
-								theResampler->getMinifyFilterTypeAsString(),
+								m_Resampler->getMinifyFilterTypeAsString(),
 								false,
 								filterNames);
       stringProp->clearChangeType();
@@ -1401,7 +1487,7 @@ ossimRefPtr<ossimProperty> ossimImageRenderer::getProperty(const ossimString& na
 //   else if(tempName == "Blur factor")
 //   {
 //      ossimNumericProperty* numericProperty = new ossimNumericProperty("Blur factor",
-//                                                                       ossimString::toString((double)theResampler->getBlurFactor()));
+//                                                                       ossimString::toString((double)m_Resampler->getBlurFactor()));
      
 //      numericProperty->setConstraints(0.0, 50.0);
 //      numericProperty->setNumericType(ossimNumericProperty::ossimNumericPropertyType_FLOAT64);
@@ -1413,6 +1499,9 @@ ossimRefPtr<ossimProperty> ossimImageRenderer::getProperty(const ossimString& na
   return ossimImageSourceFilter::getProperty(name);
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::getPropertyNames(std::vector<ossimString>& propertyNames)const
 {
   ossimImageSourceFilter::getPropertyNames(propertyNames);
@@ -1422,103 +1511,91 @@ void ossimImageRenderer::getPropertyNames(std::vector<ossimString>& propertyName
 }
 
 
-void ossimImageRenderer::checkTransform()
+//**************************************************************************************************
+// Insures that a proper IVT is established.
+//**************************************************************************************************
+void ossimImageRenderer::checkIVT()
 {
-  theBoundingViewRect.makeNan();
+   m_BoundingViewRect.makeNan();
    if(!isSourceEnabled())
-   {
       return;
-   }
 
-   
-      
-   // All this code in here might change after the demo.  For now we need a
-   // way to bring every one up with a projection.  Later we will have to
-   // tie to a projection source.
-   ossimImageViewProjectionTransform* transform = PTR_CAST(ossimImageViewProjectionTransform,
-                                                           theImageViewTransform);
-   ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput(0));
-
-   // we will only check for projection transforms
-   if(!transform||!inter) return;
+   // Check validity of the IVT:
+   if (m_ImageViewTransform->isValid())
+      return;
 
-   ossimProjection* proj = NULL;
-   
-//   if(theAutoUpdateInputTransform)//||
-//      (!transform->getImageProjection()))
-//    {
-   if(!transform->getImageProjection()||
-      PTR_CAST(ossimMapProjection, transform->getImageProjection()))
-   {
-      ossimKeywordlist kwl;
-      inter->getImageGeometry(kwl);
-      
-      proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-      transform->setImageProjection(proj, true);
-   }
-   else
-   {
-      proj = transform->getImageProjection();
-   }
-//    }
-   
-   if(proj)
-   {
-      //---
-      // Set the view or output projection.  This will be the same as input
-      // if already map projected; else, the default is geographic
-      // (EquDistCyl).
-      //---
-      if(!transform->getView()) // check to see if we found a view controller and the view was set
-      {                         // if not then we will create a default output projection
-         ossimProjection* newProj = (ossimProjection*)NULL;
-         ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);
-         if(mapProj&&!mapProj->hasModelTransform())
-         {
-            newProj = (ossimProjection*)proj->dup(); // Make a copy...
-         }
-         else
+   // Detected uninitialized IVT. We are only concerned with projection IVTs (IVPTs) so 
+   // make sure that's what we're working with:
+   ossimImageViewProjectionTransform* ivpt = 
+      PTR_CAST(ossimImageViewProjectionTransform, m_ImageViewTransform);
+   ossimImageSource* inputSrc = PTR_CAST(ossimImageSource, getInput(0));
+   if(!ivpt || !inputSrc) 
+      return; // nothing to do here yet.
+
+   // Fetch the input image geometry from the IVPT to see if one needs to be established:
+   ossimImageGeometry* inputGeom = ivpt->getImageGeometry();
+   if (!inputGeom)
+   {
+      // Ask the input source for a geometry:
+      inputGeom = inputSrc->getImageGeometry();
+      if (!inputGeom)
+      {
+         if(traceDebug())
          {
-            newProj = new ossimEquDistCylProjection;
-
-            mapProj = PTR_CAST(ossimMapProjection, newProj);
-            if(mapProj) 
-            {
-               ossimDpt meters = proj->getMetersPerPixel();
-               
-               double GSD = (meters.x + meters.y)/2.0;
-               meters.x = GSD;
-               meters.y = GSD;
-               mapProj->setUlGpt(proj->origin());
-               mapProj->setOrigin(proj->origin());
-               mapProj->setMetersPerPixel(meters);
-            }            
+            ossimNotify(ossimNotifyLevel_WARN)<<"ossimImageRenderer::checkTransform() -- "
+            "No input image geometry could be established for this renderer."<<endl;
          }
-
-         // drb only do below if using default projection... See above.
-//          mapProj = PTR_CAST(ossimMapProjection, newProj);
-//          if(mapProj) 
-//          {
-//             ossimDpt meters = proj->getMetersPerPixel();
-	    
-//             double GSD = (meters.x + meters.y)/2.0;
-//             meters.x = GSD;
-//             meters.y = GSD;
-//             mapProj->setUlGpt(proj->origin());
-//             mapProj->setOrigin(proj->origin());
-//             mapProj->setMetersPerPixel(meters);
-//          }
-
-         transform->setViewProjection(newProj, true);
+         return;
       }
+      ivpt->setImageGeometry(inputGeom);
    }
-   else
+
+   // Now check the output view geometry:
+   ossimImageGeometry* outputGeom = ivpt->getViewGeometry();
+   if (!outputGeom)
    {
-      transform->setImageProjection(NULL, true);
+      ossimImageGeometry* myOutGeom = new ossimImageGeometry;
+
+      // If the input geometry sports a map projection instead of a 3D projector, use the same
+      // map projection for the view:
+      const ossimProjection*  inputProj = inputGeom->getProjection();
+      const ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, inputProj);
+      if (mapProj)
+      {
+         // Legacy code dies hard -- should have a copy-projection method defined:
+         ossimKeywordlist kwl;
+         mapProj->saveState(kwl);
+         ossimProjection* my_proj = 
+            ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+         myOutGeom->setProjection(my_proj);
+      }
+      else 
+      {
+         // The input geometry uses a 3D projection, so let's default here to a
+         // ossimEquDistCylProjection for the view:
+         ossimMapProjection* myMapProj = new ossimEquDistCylProjection;
+         ossimDpt meters = inputGeom->getMetersPerPixel();
+         double GSD = (meters.x + meters.y)/2.0;
+         meters.x = GSD;
+         meters.y = GSD;
+         if(inputProj)
+         {
+            myMapProj->setUlGpt(inputProj->origin());
+            myMapProj->setOrigin(inputProj->origin());
+         }
+         myMapProj->setMetersPerPixel(meters);
+         myOutGeom->setProjection(myMapProj);
+      }
+      
+      // Set up our IVT with the new output geometry:
+      ivpt->setViewGeometry(myOutGeom);
    }
 }
 
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::getDecimationFactor(ossim_uint32 resLevel,
 					     ossimDpt& result)const
 {
@@ -1533,6 +1610,9 @@ void ossimImageRenderer::getDecimationFactor(ossim_uint32 resLevel,
     }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::getDecimationFactors(vector<ossimDpt>& decimations)const
 {
   if(isSourceEnabled())
@@ -1545,6 +1625,9 @@ void ossimImageRenderer::getDecimationFactors(vector<ossimDpt>& decimations)cons
     }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossim_uint32 ossimImageRenderer::getNumberOfDecimationLevels()const
 {
   if(isSourceEnabled())
@@ -1554,6 +1637,10 @@ ossim_uint32 ossimImageRenderer::getNumberOfDecimationLevels()const
 
   return ossimImageSourceFilter::getNumberOfDecimationLevels();
 }
+
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::stretchQuadOut(const ossimDpt& amount,
                                         ossimDpt& ul,
                                         ossimDpt& ur,
@@ -1585,20 +1672,23 @@ void ossimImageRenderer::stretchQuadOut(const ossimDpt& amount,
       ll = ll - left + bottom;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIrect& boundingRect,
                                                        ossim_uint32 resLevel)
 {
    if(!theInputConnection)
    {
-      theBlankTile->setImageRectangle(boundingRect);
+      m_BlankTile->setImageRectangle(boundingRect);
       
-      return theBlankTile;
+      return m_BlankTile;
    }
    
    ossim_uint32 levels = theInputConnection->getNumberOfDecimationLevels();
    
-   // ossim_uint32 maxValue = (ossim_uint32)ossim::max((ossim_uint32)theBoundingRect.width(),
-   //                                            (ossim_uint32)theBoundingRect.height());
+   // ossim_uint32 maxValue = (ossim_uint32)ossim::max((ossim_uint32)m_BoundingRect.width(),
+   //                                            (ossim_uint32)m_BoundingRect.height());
    
    if(resLevel == 0)
    {
@@ -1613,10 +1703,10 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
       }
       else
       {
-         return theBlankTile;
+         return m_BlankTile;
       }
    }
-   else if((resLevel - levels) < theMaxLevelsToCompute)
+   else if((resLevel - levels) < m_MaxLevelsToCompute)
    {
       // check to see how many decimations we must achiev for the
       // request
@@ -1650,16 +1740,16 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
       ossimIrect mappedRequestedRect = requestedRectAtValidRLevel;
       requestedRectAtValidRLevel  = requestedRectAtValidRLevel*((double)multiplier);
       
-      if(!theTemporaryBuffer)
+      if(!m_TemporaryBuffer)
       {
-         theTemporaryBuffer = (ossimImageData*)theBlankTile->dup();
-         theTemporaryBuffer->setImageRectangle(mappedRequestedRect);
-         theTemporaryBuffer->initialize();
+         m_TemporaryBuffer = (ossimImageData*)m_BlankTile->dup();
+         m_TemporaryBuffer->setImageRectangle(mappedRequestedRect);
+         m_TemporaryBuffer->initialize();
       }
       else
       {
-         theTemporaryBuffer->setImageRectangle(mappedRequestedRect);
-         theTemporaryBuffer->makeBlank();
+         m_TemporaryBuffer->setImageRectangle(mappedRequestedRect);
+         m_TemporaryBuffer->makeBlank();
       }
       
      // ossim_uint32 totalCount   = ((requestedRectAtValidRLevel.lr().y-requestedRectAtValidRLevel.ul().y)*
@@ -1685,7 +1775,7 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
                   case OSSIM_UINT8:
                   {
                      resampleTileToDecimation((ossim_uint8)0,
-                                              theTemporaryBuffer,
+                                              m_TemporaryBuffer,
                                               data,
                                               multiplier);
                      break;
@@ -1693,7 +1783,7 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
                   case OSSIM_SINT16:
                   {
                      resampleTileToDecimation((ossim_sint16)0,
-                                              theTemporaryBuffer,
+                                              m_TemporaryBuffer,
                                               data,
                                               multiplier);
                      break;
@@ -1702,7 +1792,7 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
                   case OSSIM_USHORT11:
                   {
                      resampleTileToDecimation((ossim_uint16)0,
-                                              theTemporaryBuffer,
+                                              m_TemporaryBuffer,
                                               data,
                                               multiplier);
                      break;
@@ -1711,7 +1801,7 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
                   case OSSIM_NORMALIZED_FLOAT:
                   {
                      resampleTileToDecimation((ossim_float32)0,
-                                              theTemporaryBuffer,
+                                              m_TemporaryBuffer,
                                               data,
                                               multiplier);
                      break;
@@ -1720,7 +1810,7 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
                   case OSSIM_NORMALIZED_DOUBLE:
                   {
                      resampleTileToDecimation((ossim_float64)0,
-                                              theTemporaryBuffer,
+                                              m_TemporaryBuffer,
                                               data,
                                               multiplier);
                      break;
@@ -1738,23 +1828,32 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
             
          }
       }
-      theTemporaryBuffer->validate();
-      return theTemporaryBuffer;
+      m_TemporaryBuffer->validate();
+      return m_TemporaryBuffer;
    }
 
    return 0;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::setMaxLevelsToCompute(ossim_uint32 maxLevels)
 {
-   theMaxLevelsToCompute = maxLevels;
+   m_MaxLevelsToCompute = maxLevels;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossim_uint32 ossimImageRenderer::getMaxLevelsToCompute()const
 {
-   return theMaxLevelsToCompute;
+   return m_MaxLevelsToCompute;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 template <class T>
 void ossimImageRenderer::resampleTileToDecimation(T dummyVariable,
 						  ossimRefPtr<ossimImageData> result,
@@ -1897,23 +1996,35 @@ void ossimImageRenderer::resampleTileToDecimation(T dummyVariable,
   delete [] offsetY;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimString ossimImageRenderer::getLongName() const
 {
    return ossimString("Image Renderer");
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimString ossimImageRenderer::getShortName() const
 {
    return ossimString("Image Renderer"); 
 }
 
- void ossimImageRenderer::enableSource()
+//**************************************************************************************************
+// 
+//**************************************************************************************************
+void ossimImageRenderer::enableSource()
 {
    ossimImageSourceFilter::enableSource();
-   checkTransform();
+   checkIVT();
    initialize();
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimImageRenderer::fireProgressEvent(double percentComplete)
 {
    ossimProcessProgressEvent event(this, percentComplete);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSharpenFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSharpenFilter.cpp
index 85548475e09b0a025e7d47d4dac68ad3b927039b..35f2489a647f3a595f22f1adedfc20dc26c48fe7 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSharpenFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSharpenFilter.cpp
@@ -8,24 +8,38 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSharpenFilter.cpp 12981 2008-06-04 01:05:54Z dburken $
+// $Id: ossimImageSharpenFilter.cpp 15446 2009-09-21 17:35:42Z gpotts $
 #include <cstdlib> /* for abs() */
 #include <ossim/imaging/ossimImageSharpenFilter.h>
 #include <ossim/base/ossimIrect.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
+#include <ossim/base/ossimNumericProperty.h>
 
 RTTI_DEF1(ossimImageSharpenFilter, "ossimImageSharpenFilter", ossimImageSourceFilter);
 
+static const char* KERNEL_WIDTH_KW = "kernel_width";
+static const char* KERNEL_SIGMA_KW = "kernel_sigma";
+
 ossimImageSharpenFilter::ossimImageSharpenFilter(ossimObject* owner)
    :ossimImageSourceFilter(owner),
-    theTile(NULL)
+   theWidth(3),
+   theSigma(.5)
 {
+   theConvolutionSource = new ossimConvolutionSource;
 }
 
 ossimImageSharpenFilter::~ossimImageSharpenFilter()
 {
 }
 
+void ossimImageSharpenFilter::setWidthAndSigma(ossim_uint32 w, ossim_float64 sigma)
+{
+   theWidth = w;
+   theWidth |= 1;
+   if(theWidth < 3) theWidth = 3;
+   theSigma = sigma;
+}
+
 ossimRefPtr<ossimImageData> ossimImageSharpenFilter::getTile(
    const ossimIrect& tileRect,
    ossim_uint32 resLevel)
@@ -34,336 +48,176 @@ ossimRefPtr<ossimImageData> ossimImageSharpenFilter::getTile(
    {
       return NULL;
    }
-
    if(!isSourceEnabled())
    {
       return theInputConnection->getTile(tileRect, resLevel);
    }
-   
-   // we have a 3x3 matrix so stretch the rect out to cover
-   // the required pixels
-   //
-   ossimIrect newRect(ossimIpt(tileRect.ul().x - 1,
-                               tileRect.ul().y - 1),
-                      ossimIpt(tileRect.lr().x + 1,
-                               tileRect.lr().y + 1));
-   
-   ossimRefPtr<ossimImageData> data =
-      theInputConnection->getTile(newRect, resLevel);
+   return theConvolutionSource->getTile(tileRect, resLevel);   
+}
 
-   if ( !data.valid() ||
-        ( data->getDataObjectStatus() == OSSIM_NULL ) ||
-        ( data->getDataObjectStatus() == OSSIM_EMPTY ) )
+void ossimImageSharpenFilter::initialize()
+{
+   ossimImageSourceFilter::initialize();
+   if(theConvolutionSource->getInput()!=getInput())
    {
-      // Caller wants tileRect, not newRect so don't return "data".
-      return theInputConnection->getTile(tileRect, resLevel);
+      theConvolutionSource->disconnectAllInputs();
+      theConvolutionSource->connectMyInputTo(0, getInput());
    }
+   buildConvolutionMatrix();   
+}
 
-   if (!theTile)
-   {
-      allocate(); // First time through...
-   }
-   
-   long w     = tileRect.width();
-   long h     = tileRect.height();
-   long tileW = theTile->getWidth();
-   long tileH = theTile->getHeight();
-   if((w != tileW)||
-      (h != tileH))
-   {
-      theTile->setWidth(w);
-      theTile->setHeight(h);
-      if((w*h)!=(tileW*tileH))
-      {
-         theTile->initialize();
-      }
-      else
+void ossimImageSharpenFilter::buildConvolutionMatrix()
+{
+   std::vector<double> theKernel(theWidth*theWidth);
+   double* kernel = &theKernel.front();
+   //width = findWidth(sigma);
+   ossim_int32 i = 0 ;
+   ossim_int32 u = 0 ;
+   ossim_int32 v = 0 ;
+   double normalize = 0.0 ;
+   ossim_int32 w2 = theWidth>>1;
+   for (v = -w2; v <= w2; ++v)
+   {
+      for (u = -w2; u <= w2; ++u)
       {
-         theTile->makeBlank();
+         double value = laplacianOfGaussian(u, v, theSigma);
+         kernel[i] = value;
+         normalize += kernel[i] ;
+         ++i ;
       }
    }
-   else
+   if (fabs(normalize) <= 1e-6)
    {
-      theTile->makeBlank();
+      normalize = 1.0;
    }
-   theTile->setOrigin(tileRect.ul());
-   
-   switch(data->getScalarType())
+   normalize=(1.0/normalize);
+   ossim_int32 size = static_cast<ossim_int32>(theWidth*theWidth);
+   for (i = 0; i < size; ++i)
    {
-   case OSSIM_UCHAR:
+      kernel[i]=kernel[i]*normalize;
+   } 
+      
+#if 0
+   // print the kernel
+   for (i = 0; i < width*width; ++i)
    {
-      if(data->getDataObjectStatus() == OSSIM_FULL)
-      {
-         sharpenFull(static_cast<ossim_uint8>(0),
-                     data,
-                     theTile);
-      }
-      else
+      if((i%width)==0)
       {
-         sharpenPartial(static_cast<ossim_uint8>(0),
-                        data,
-                        theTile);
+         std::cout << std::endl;
       }
-      break;
-   }
-   case OSSIM_FLOAT: 
-   case OSSIM_NORMALIZED_FLOAT:
+      std::cout << kernel[i] <<", ";
+   } 
+   std::cout << std::endl;
+#endif
+   theConvolutionSource->setConvolution(kernel, theWidth, theWidth, false);
+}
+
+void ossimImageSharpenFilter::connectInputEvent(ossimConnectionEvent &event)
+{
+   ossimImageSourceFilter::connectInputEvent(event);
+   theConvolutionSource->connectMyInputTo(0, getInput());
+   buildConvolutionMatrix();
+}
+
+void ossimImageSharpenFilter::disconnectInputEvent(ossimConnectionEvent &event)
+{
+   ossimImageSourceFilter::disconnectInputEvent(event);
+   theConvolutionSource->connectMyInputTo(0, getInput());
+}
+
+ossimString ossimImageSharpenFilter::getShortName() const
+{
+   return ossimString("Sharpen");
+}
+
+ossimString ossimImageSharpenFilter::getLongName() const
+{
+   return ossimString("Sharpens the input");
+}
+
+void ossimImageSharpenFilter::setProperty(ossimRefPtr<ossimProperty> property)
+{
+   if(!property) return;
+   if(property->getName() == KERNEL_WIDTH_KW)
    {
-      if(data->getDataObjectStatus() == OSSIM_FULL)
-      {
-         sharpenFull(static_cast<float>(0),
-                     data,
-                     theTile);
-      }
-      else
-      {
-         sharpenPartial(static_cast<float>(0),
-                        data,
-                        theTile);
-      }
-      break;
+      theWidth = property->valueToString().toDouble();
+      theWidth |=1;
+      if(theWidth < 3) theWidth = 3;
+      initialize();
    }
-   case OSSIM_USHORT16:
-   case OSSIM_USHORT11:
+   else if(property->getName() == KERNEL_SIGMA_KW)
    {
-      if(data->getDataObjectStatus() == OSSIM_FULL)
-      {
-         sharpenFull(static_cast<ossim_uint16>(0),
-                     data,
-                     theTile);
-      }
-      else
-      {
-         sharpenPartial(static_cast<ossim_uint16>(0),
-                        data,
-                        theTile);
-      }
-      break;
+      theSigma = property->valueToString().toDouble();
+      if(theWidth < .1) theWidth = .5;
+      initialize();
    }
-   case OSSIM_SSHORT16:
+   else
    {
-      if(data->getDataObjectStatus() == OSSIM_FULL)
-      {
-         sharpenFull(static_cast<ossim_sint16>(0),
-                     data,
-                     theTile);
-      }
-      else
-      {
-         sharpenPartial(static_cast<ossim_sint16>(0),
-                        data,
-                        theTile);
-      }
-      break;
+      ossimImageSourceFilter::setProperty(property.get());
    }
-   case OSSIM_DOUBLE:
-   case OSSIM_NORMALIZED_DOUBLE:
-   {
-      if(data->getDataObjectStatus() == OSSIM_FULL)
-      {
-         sharpenFull(static_cast<double>(0),
-                     data,
-                     theTile);
-      }
-      else
-      {
-         sharpenPartial(static_cast<double>(0),
-                        data,
-                        theTile);
-      }
-      break;
+}
+
+ossimRefPtr<ossimProperty> ossimImageSharpenFilter::getProperty(const ossimString& name)const
+{
+   ossimRefPtr<ossimProperty> property = 0;
+   if(name == KERNEL_WIDTH_KW)
+   {
+      property = new ossimNumericProperty("Kernel width",
+                                          ossimString::toString(theWidth),
+                                          3.0,
+                                          64.0);
+      property->setCacheRefreshBit();
+      
    }
-   default:
+   else if(name == KERNEL_SIGMA_KW)
    {
-      ossimNotify(ossimNotifyLevel_WARN) << "ossimImageSharpenFilter::getTile WARNING: Scalar type = " << theTile->getScalarType() << " Not supported!" << std::endl;
-      break;
+      property = new ossimNumericProperty("Kernel sigma",
+                                          ossimString::toString(theSigma),
+                                          .1,
+                                          32);
+      property->setCacheRefreshBit();
    }
+   else 
+   {
+      property = ossimImageSourceFilter::getProperty(name);
    }
-   theTile->validate();
    
-   return theTile;
+   return property.get();
 }
 
-
-template<class T> void ossimImageSharpenFilter::sharpenPartial(
-   T,
-   const ossimRefPtr<ossimImageData>& inputData,
-   ossimRefPtr<ossimImageData>& outputData)
+void ossimImageSharpenFilter::getPropertyNames(std::vector<ossimString>& propertyNames)const
 {
-   double sum = 0.0;
-   ossim_int32 inputW        = (ossim_int32)inputData->getWidth();
-   ossim_int32 outputW       = (ossim_int32)outputData->getWidth();
-   ossim_int32 outputH       = (ossim_int32)outputData->getHeight();
-   ossim_int32 numberOfBands = (ossim_int32)inputData->getNumberOfBands();
-   ossimIpt outputOrigin = outputData->getOrigin();
-   ossimIpt inputOrigin  = inputData->getOrigin();
-   
-   ossim_int32 startInputOffset = std::abs(outputOrigin.y - inputOrigin.y)*
-      inputW + std::abs(outputOrigin.x - inputOrigin.x);
-   ossim_int32 ulKernelStart    = -inputW - 1;
-   ossim_int32 leftKernelStart  = -1;
-   ossim_int32 llKernelStart    = inputW  - 1;
-   
-   const T* ulKernelStartBuf   = NULL;
-   const T* leftKernelStartBuf = NULL;
-   const T* llKernelStartBuf   = NULL;
-   
-   for(ossim_int32 band = 0; band < numberOfBands; ++band)
-   {
-      const T* inputBuf  = static_cast<const T*>(inputData->getBuf(band)) +
-         startInputOffset;
-      T* outputBuf = static_cast<T*>(outputData->getBuf(band));
-      T maxPix     = static_cast<T>(inputData->getMaxPix(band));
-      T minPix     = static_cast<T>(inputData->getMinPix(band));
-      T nullPix    = static_cast<T>(inputData->getNullPix(band));
-      
-      if(inputBuf&&outputBuf)
-      {
-         for(ossim_int32 row = 0; row < outputW; ++row)
-         {
-            ossim_int32 rowOffset    = inputW*row;
-            ulKernelStartBuf   = inputBuf + (rowOffset + ulKernelStart);
-            leftKernelStartBuf = inputBuf + (rowOffset + leftKernelStart);
-            llKernelStartBuf   = inputBuf + (rowOffset + llKernelStart);
-            for(ossim_int32 col = 0; col < outputH; ++col)
-            {
-               if((ulKernelStartBuf[0]   != nullPix)&&
-                  (ulKernelStartBuf[1]   != nullPix)&&
-                  (ulKernelStartBuf[2]   != nullPix)&&
-                  (leftKernelStartBuf[0] != nullPix)&&
-                  (leftKernelStartBuf[1] != nullPix)&&
-                  (leftKernelStartBuf[2] != nullPix)&&
-                  (llKernelStartBuf[0]   != nullPix)&&
-                  (llKernelStartBuf[1]   != nullPix)&&
-                  (llKernelStartBuf[2]   != nullPix))
-               {
-                  sum = -1.0*(double)ulKernelStartBuf[0]  + -2.0*(double)ulKernelStartBuf[1] + -1.0*(double)ulKernelStartBuf[2] +
-                        -2.0*(double)leftKernelStartBuf[0]  + 16.0*(double)leftKernelStartBuf[1] + -2.0*(double)leftKernelStartBuf[2] +
-                        -1.0*(double)llKernelStartBuf[0]  + -2.0*(double)llKernelStartBuf[1] + -1.0*(double)llKernelStartBuf[2];
-                  sum /= 4.0;
-                  
-                  if(sum > maxPix)
-                  {
-                     *outputBuf = maxPix;
-                  }
-                  else if(sum < minPix || ((T)sum == nullPix))
-                  {
-                     *outputBuf = minPix;
-                  }
-                  else
-                  {
-                     *outputBuf = static_cast<T>(sum);
-                  }
-               }
-               else
-               {
-                  *outputBuf = nullPix;
-               }
-               
-               ++ulKernelStartBuf;
-               ++leftKernelStartBuf;
-               ++llKernelStartBuf;
-               ++outputBuf;
-            }
-         }
-      }
-   }
+   ossimImageSourceFilter::getPropertyNames(propertyNames);
+   propertyNames.push_back(KERNEL_WIDTH_KW);
+   propertyNames.push_back(KERNEL_SIGMA_KW);
 }
 
-template<class T> void ossimImageSharpenFilter::sharpenFull(
-   T,
-   const ossimRefPtr<ossimImageData>& inputData,
-   ossimRefPtr<ossimImageData>& outputData)
+bool ossimImageSharpenFilter::loadState(const ossimKeywordlist& kwl,
+                                        const char* prefix)
 {
-   double sum = 0.0;
-   ossim_int32 inputW        = (ossim_int32)inputData->getWidth();
-   ossim_int32 outputW       = (ossim_int32)outputData->getWidth();
-   ossim_int32 outputH       = (ossim_int32)outputData->getHeight();
-   ossim_int32 numberOfBands = (ossim_int32)inputData->getNumberOfBands();
-   ossimIpt outputOrigin = outputData->getOrigin();
-   ossimIpt inputOrigin  = inputData->getOrigin();
-   
-   ossim_int32 startInputOffset = std::abs(outputOrigin.y - inputOrigin.y)*
-      inputW + std::abs(outputOrigin.x - inputOrigin.x);
-   ossim_int32 ulKernelStart    = -inputW - 1;
-   ossim_int32 leftKernelStart  = -1;
-   ossim_int32 llKernelStart    = inputW  - 1;
-   
-   const T* ulKernelStartBuf   = NULL;
-   const T* leftKernelStartBuf = NULL;
-   const T* llKernelStartBuf   = NULL;
-   
-   for(ossim_int32 band = 0; band < numberOfBands; ++band)
+   bool result = ossimImageSourceFilter::loadState(kwl, prefix);
+   ossimString kernelWidth = kwl.find(prefix, KERNEL_WIDTH_KW);
+   ossimString kernelSigma = kwl.find(prefix, KERNEL_SIGMA_KW);
+   kernelWidth = kernelWidth.trim();
+   kernelSigma = kernelSigma.trim();
+   if(!kernelWidth.empty())
    {
-      const T* inputBuf  = static_cast<const T*>(inputData->getBuf(band)) +
-         startInputOffset;
-      T* outputBuf = static_cast<T*>(outputData->getBuf(band));
-      T maxPix     = static_cast<T>(inputData->getMaxPix(band));
-      T minPix     = static_cast<T>(inputData->getMinPix(band));
-      T nullPix    = static_cast<T>(inputData->getNullPix(band));
-      
-      if(inputBuf&&outputBuf)
-      {
-         for(ossim_int32 row = 0; row < outputW; ++row)
-         {
-            ossim_int32 rowOffset    = inputW*row;
-            ulKernelStartBuf   = inputBuf + (rowOffset + ulKernelStart);
-            leftKernelStartBuf = inputBuf + (rowOffset + leftKernelStart);
-            llKernelStartBuf   = inputBuf + (rowOffset + llKernelStart);
-            for(ossim_int32 col = 0; col < outputH; ++col)
-            {
-               sum = -1.0*(double)ulKernelStartBuf[0]  + -2.0*(double)ulKernelStartBuf[1] + -1.0*(double)ulKernelStartBuf[2] +
-                     -2.0*(double)leftKernelStartBuf[0]  + 16.0*(double)leftKernelStartBuf[1] + -2.0*(double)leftKernelStartBuf[2] +
-                     -1.0*(double)llKernelStartBuf[0]  + -2.0*(double)llKernelStartBuf[1] + -1.0*(double)llKernelStartBuf[2];
-               sum /= 4.0;
-               
-               if(sum > maxPix)
-               {
-                  *outputBuf = maxPix;
-               }
-               else if((sum < minPix) || (sum == nullPix))
-               {
-                  *outputBuf = minPix;
-               }
-               else
-               {
-                  *outputBuf = static_cast<T>(sum);
-               }
-               
-               ++ulKernelStartBuf
-                  ;
-               ++leftKernelStartBuf;
-               ++llKernelStartBuf;
-               ++outputBuf;
-            }
-         }
-      }
+      theWidth = kernelWidth.toUInt32();
+      theWidth |= 1; // make it odd and check for size
+      if(theWidth < 3) theWidth = 3;
    }
-}
-
-void ossimImageSharpenFilter::initialize()
-{
-   // Hmmm... (drb)
-}
-
-void ossimImageSharpenFilter::allocate()
-{   
-   theTile = NULL;
-   if(theInputConnection)
+   if(!kernelSigma.empty())
    {
-      ossimImageDataFactory* idf = ossimImageDataFactory::instance();
-      theTile = idf->create(this, this);
-      theTile->initialize();
+      theSigma = kernelSigma.toFloat64();
    }
+   buildConvolutionMatrix();
+   return result;
 }
 
-ossimString ossimImageSharpenFilter::getShortName() const
+bool ossimImageSharpenFilter::saveState(ossimKeywordlist& kwl,
+                                        const char* prefix)const
 {
-   return ossimString("Sharpen");
+   kwl.add(prefix, KERNEL_WIDTH_KW, theWidth, true);
+   kwl.add(prefix, KERNEL_SIGMA_KW, theSigma, true);
+   return ossimImageSourceFilter::saveState(kwl, prefix);
 }
-
-ossimString ossimImageSharpenFilter::getLongName() const
-{
-   return ossimString("Sharpens the input input");
-}
-
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp
index 15c238985a351046aeef5569faaa2fcf04bd85ea..a89f135c0da03c87e2a3bbb07cb3391326502580 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp
@@ -1,5 +1,4 @@
 //*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
 //
 // License:  LGPL
 // 
@@ -8,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSource.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimImageSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimImageSource.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -42,19 +41,19 @@ ossimImageSource::~ossimImageSource()
 ossimRefPtr<ossimImageData> ossimImageSource::getTile(const ossimIpt& origin,
                                                       ossim_uint32 resLevel)
 {
-   ossimIrect tile_rect(origin.x,
-                        origin.y,
-                        origin.x + getTileWidth()  - 1,
-                        origin.y + getTileHeight() - 1);
+   ossimIrect tileRect(origin.x,
+                       origin.y,
+                       origin.x + getTileWidth()  - 1,
+                       origin.y + getTileHeight() - 1);
    
-   return getTile(tile_rect, resLevel);
+   return getTile(tileRect, resLevel);
 }
 
 ossimRefPtr<ossimImageData> ossimImageSource::getTile(const ossimIrect& rect,
                                                       ossim_uint32 resLevel)
 {
    ossimImageSource* inter = PTR_CAST(ossimImageSource,
-                                               getInput(0));
+                                      getInput(0));
    if(inter)
    {
       return inter->getTile(rect, resLevel);
@@ -62,6 +61,31 @@ ossimRefPtr<ossimImageData> ossimImageSource::getTile(const ossimIrect& rect,
    return NULL;
 }
 
+bool ossimImageSource::getTile(ossimImageData* result, ossim_uint32 resLevel)
+{
+   bool status = true;
+   
+   if (result)
+   {
+      result->ref();
+      
+      ossimIrect tileRect = result->getImageRectangle();
+      
+      ossimRefPtr<ossimImageData> id = getTile(tileRect, resLevel);
+      if (id.valid())
+      {
+         *result = *(id.get());
+      }
+      else
+      {
+         status = false;
+      }
+      result->unref();
+   }
+
+   return status;
+}
+
 void ossimImageSource::getDecimationFactor(ossim_uint32 resLevel,
                                            ossimDpt& result)const
 {
@@ -138,7 +162,7 @@ ossim_uint32 ossimImageSource::getTileHeight() const
 ossimIrect ossimImageSource::getBoundingRect(ossim_uint32 resLevel)const
 {
    ossimImageSource* inter = PTR_CAST(ossimImageSource,
-                                               getInput(0));
+                                      getInput(0));
    if(inter)
    {
       return inter->getBoundingRect(resLevel);
@@ -229,32 +253,29 @@ double ossimImageSource::getMaxPixelValue(ossim_uint32 band)const
    return ossim::defaultMax(getOutputScalarType());
 }
 
-
-bool ossimImageSource::getImageGeometry(ossimKeywordlist& kwl,
-                                        const char* prefix)
+//**************************************************************************************************
+// Default implementation returns the image geometry object associated with the first input source 
+// (if any) connected to this source, or NULL.
+//**************************************************************************************************
+ossimImageGeometry*  ossimImageSource::getImageGeometry()
 {
-   int i = 0;
-   for(i = 0; i < (int)getNumberOfInputs(); ++i)
+   if (getNumberOfInputs())
    {
-      ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                      getInput(i));
+      ossimImageSource* interface = PTR_CAST(ossimImageSource, getInput(0));
       if(interface)
-      {
-         return interface->getImageGeometry(kwl, prefix);
-      }
+         return interface->getImageGeometry();
    }
-   
-   return false;
+   return 0;
 }
 
-void ossimImageSource::setImageGeometry(const ossimKeywordlist& kwl)
+//**************************************************************************************************
+//! Default implementation sets geometry of the first input to the geometry specified.
+//**************************************************************************************************
+void ossimImageSource::setImageGeometry(const ossimImageGeometry* geom)
 {
-   ossimImageSource* inter = PTR_CAST(ossimImageSource,
-                                               getInput(0));
+   ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput(0));
    if (inter)
-   {
-      setImageGeometry(kwl);
-   }
+      setImageGeometry(geom);
 }
 
 void ossimImageSource::saveImageGeometry() const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactoryBase.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactoryBase.cpp
index b62f2872762ff7c36d4aa96b0fcce0e7369b0be4..13f9b5ab3236c513c7ffcb52f0b317e4a4ba7caa 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactoryBase.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactoryBase.cpp
@@ -5,7 +5,7 @@
 // Author: David Burken <dburken@imagelinks.com>
 //
 //*************************************************************************
-// $Id: ossimImageSourceFactoryBase.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimImageSourceFactoryBase.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimImageSourceFactoryBase.h>
 #include <ossim/imaging/ossimImageSource.h>
@@ -24,37 +24,27 @@ const ossimImageSourceFactoryBase& ossimImageSourceFactoryBase::operator=(const
 
 ossimImageSource* ossimImageSourceFactoryBase::createImageSource(const ossimString& name)const
 {
-   ossimObject* result =createObject(name);
+   ossimRefPtr<ossimObject> result =createObject(name);
    
-   if(PTR_CAST(ossimImageSource, result))
+   if(PTR_CAST(ossimImageSource, result.get()))
    {
-      return (ossimImageSource*)result;
+      return (ossimImageSource*)result.release();
    }
+   result = 0;
 
-   if(result)
-   {
-      delete result;
-      result = NULL;
-   }
-
-   return (ossimImageSource*)NULL;
+   return 0;
 }
 
 ossimImageSource* ossimImageSourceFactoryBase::createImageSource(const ossimKeywordlist& kwl,
                                                                  const char* prefix)const
 {
-   ossimObject* result =createObject(kwl, prefix);
+   ossimRefPtr<ossimObject> result =createObject(kwl, prefix);
    
-   if(PTR_CAST(ossimImageSource, result))
-   {
-      return (ossimImageSource*)result;
-   }
-
-   if(result)
+   if(PTR_CAST(ossimImageSource, result.get()))
    {
-      delete result;
-      result = NULL;
+      return (ossimImageSource*)result.release();
    }
-
-   return (ossimImageSource*)NULL;
+   result = 0;
+   
+   return (ossimImageSource*)0;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp
index d6636b93811ef34a13a0fb904b8e1c0151b55a63..6ee78206c06c6a0a0b3031b207900f711c9d60ee 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp
@@ -10,7 +10,7 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimImageSourceSequencer.cpp 13374 2008-08-04 13:02:22Z gpotts $
+//  $Id: ossimImageSourceSequencer.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimImageSourceSequencer.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/base/ossimIrect.h>
@@ -26,11 +26,11 @@ static ossimTrace traceDebug("ossimImageSourceSequencer:debug");
    
 ossimImageSourceSequencer::ossimImageSourceSequencer(ossimImageSource* inputSource,
                                                      ossimObject* owner)
-   :ossimImageSource(owner,
-                     1,
-                     1,
-                     true,
-                     true),
+:ossimImageSource(owner,
+                  1,
+                  1,
+                  true,
+                  false),
     theBlankTile(NULL),
     theAreaOfInterest(0,0,0,0),
     theTileSize(OSSIM_DEFAULT_TILE_WIDTH, OSSIM_DEFAULT_TILE_HEIGHT),
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp
index 17904ed3c1a67f48efc2980836323d358c77eedc..6a81236f2871e401820a0b32b9f3ba777b039f08 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp
@@ -83,7 +83,7 @@ bool ossimImageStatisticsSource::canConnectMyInputTo(ossim_int32 inputIndex,
 template <class T>
 void ossimImageStatisticsSource::computeStatisticsTemplate(T dummyVariable)
 {
-   ossimImageSourceSequencer* sequencer = new ossimImageSourceSequencer;
+   ossimRefPtr<ossimImageSourceSequencer> sequencer = new ossimImageSourceSequencer;
 
    sequencer->connectMyInputTo(getInput());
    sequencer->setToStartOfSequence();
@@ -136,7 +136,6 @@ void ossimImageStatisticsSource::computeStatisticsTemplate(T dummyVariable)
    }
    
    sequencer->disconnect();
-   delete sequencer;
    sequencer = 0;
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp
index 19f7ebde3bd7d5c82dd555e2bd996e01d089efc4..73056595c7f5ea432da784220a07c216d09b3fb0 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageToPlaneNormalFilter.cpp 13382 2008-08-04 18:53:26Z gpotts $
+// $Id: ossimImageToPlaneNormalFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimImageToPlaneNormalFilter.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -113,19 +113,12 @@ void ossimImageToPlaneNormalFilter::initialize()
       theBlankTile = (ossimImageData*)(theTile->dup());
       theTile->initialize();
 
-
       if(theTrackScaleFlag)
       {
-         ossimKeywordlist kwl;
-         theInputConnection->getImageGeometry(kwl);
-
-         ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->
-            createProjection(kwl);
-
-         if(proj)
+         const ossimImageGeometry* geom = theInputConnection->getImageGeometry();
+         if(geom)
          {
-            ossimDpt pt = proj->getMetersPerPixel();
-
+            ossimDpt pt = geom->getMetersPerPixel();
             if(!pt.hasNans())
             {
                theXScale = pt.x;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageWriterFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageWriterFactory.cpp
index 0ea98563193536a8a05d3fc707bc6fa5649fafa4..98b7c11bc89e5a952f7999db024d81ade19eb156 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageWriterFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageWriterFactory.cpp
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimImageWriterFactory.cpp 13619 2008-09-29 19:10:31Z gpotts $
+//  $Id: ossimImageWriterFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimImageWriterFactory.h>
 #include <ossim/imaging/ossimImageWriterFactoryRegistry.h>
@@ -104,18 +104,18 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
 	mimeType = mimeType.downcase();
 	
    // Check for tiff writer.
-   ossimImageFileWriter* writer = createFromMimeType(mimeType);
+   ossimRefPtr<ossimImageFileWriter> writer = createFromMimeType(mimeType);
 	
-	if(writer)
+	if(writer.valid())
 	{
-		return writer;
+		return writer.release();
 	}
  
    writer = new ossimTiffWriter;
 	
    if (STATIC_TYPE_NAME(ossimTiffWriter) == typeName )
    {
-      return writer;
+      return writer.release();
    }
    else
    {
@@ -123,16 +123,16 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
       if ( writer->hasImageType(typeName) )
       {
          writer->setOutputImageType(typeName);
-         return writer;
+         return writer.release();
       }
    }
-   delete writer; // Not a tiff writer.   
+   writer = 0;
 
    // Check for jpeg writer.
    writer = new ossimJpegWriter;
    if ( writer->getClassName() == typeName )
    {
-      return new ossimJpegWriter;
+      return writer.release();
    }
    else
    {
@@ -140,16 +140,16 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
       if ( writer->hasImageType(typeName) )
       {
          writer->setOutputImageType(typeName);
-         return writer;
+         return writer.release();
       }
    }
-	delete writer; // not a jpeg writer
+	writer = 0; // not a jpeg writer
 	
    // Check for general raster writer.
    writer = new ossimGeneralRasterWriter;
    if ( writer->getClassName() == typeName )
    {
-      return writer;
+      return writer.release();
    }
    else
    {
@@ -157,16 +157,16 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
       if ( writer->hasImageType(typeName) )
       {
          writer->setOutputImageType(typeName);
-         return writer;
+         return writer.release();
       }
    }
-   delete writer; // Not a general raster writer.   
+   writer = 0; // Not a general raster writer.   
 
    // Check for nitf writer.
    writer = new ossimNitfWriter;
    if ( writer->getClassName() == typeName )
    {
-      return writer;
+      return writer.release();
    }
    else
    {
@@ -174,15 +174,15 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
       if ( writer->hasImageType(typeName) )
       {
          writer->setOutputImageType(typeName);
-         return writer;
+         return writer.release();
       }
    }
-   delete writer; // Not a nitf writer.   
+   writer = 0; // Not a nitf writer.   
    // Check for nitf writer.
    writer = new ossimNitf20Writer;
    if ( writer->getClassName() == typeName )
    {
-      return writer;
+      return writer.release();
    }
    else
    {
@@ -190,14 +190,13 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
       if ( writer->hasImageType(typeName) )
       {
          writer->setOutputImageType(typeName);
-         return writer;
+         return writer.release();
       }
    }
-   delete writer; // Not a nitf writer.   
+   writer = 0; // Not a nitf writer.   
    
-   writer = 0;
 
-   return writer; // Return a null writer.
+   return writer.release(); // Return a null writer.
 }
 
 ossimImageFileWriter* ossimImageWriterFactory::createFromMimeType(const ossimString& mimeType)const
@@ -266,29 +265,23 @@ void ossimImageWriterFactory::getTypeNameList(std::vector<ossimString>& typeList
 void ossimImageWriterFactory::getImageTypeList(std::vector<ossimString>& imageTypeList)const
 {
    // Add the tiff writer types.
-   ossimImageFileWriter* writer = new ossimTiffWriter;
+   ossimRefPtr<ossimImageFileWriter> writer = new ossimTiffWriter;
    writer->getImageTypeList(imageTypeList);
-   delete writer;
 
    // Add the jpeg writer types.
    writer = new ossimJpegWriter;
    writer->getImageTypeList(imageTypeList);
-   delete writer;
 
    // Add the general raster writer types.
    writer = new ossimGeneralRasterWriter;
    writer->getImageTypeList(imageTypeList);
-   delete writer;
-   writer = NULL;
 
    // Add the nitf writer types.
    writer = new ossimNitfWriter;
    writer->getImageTypeList(imageTypeList);
-   delete writer;
-   writer = NULL;
    // Add the nitf writer types.
    writer = new ossimNitf20Writer;
    writer->getImageTypeList(imageTypeList);
-   delete writer;
-   writer = NULL;
+   
+   writer = 0;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
index 7ae004eb31b6b0094f37e73915d3ad48e29d5ddf..639d56cad169448f3a7d46aea584666d122401d2 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimIndexToRgbLutFilter.cpp 11411 2007-07-27 13:53:51Z dburken $
+// $Id: ossimIndexToRgbLutFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimIndexToRgbLutFilter.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/base/ossimRgbVector.h>
@@ -28,6 +28,7 @@ static const char* INTERPOLATION_TYPE_KW = "interpolation_type";
 
 ossimIndexToRgbLutFilter::ossimIndexToRgbLutFilter()
    :ossimImageSourceFilter(),
+    theLut(new ossimRgbLutDataObject()),
     theMinValue(ossim::nan()),
     theMaxValue(ossim::nan()),
     theMinMaxDeltaLength(ossim::nan()),
@@ -45,7 +46,7 @@ ossimIndexToRgbLutFilter::ossimIndexToRgbLutFilter(ossimImageSource* inputSource
                                                  double maxValue,
                                                  ossimIndexToRgbLutFilterInterpolationType interpolationType)
    :ossimImageSourceFilter(inputSource),
-    theLut(lut),
+    theLut((ossimRgbLutDataObject*)lut.dup()),
     theMinValue(minValue),
     theMaxValue(maxValue),
     theMinValueOverride(false),
@@ -118,7 +119,7 @@ ossimRefPtr<ossimImageData> ossimIndexToRgbLutFilter::convertInputTile(const oss
    outBuf[0] = (ossim_uint8*)(theTile->getBuf(0));
    outBuf[1] = (ossim_uint8*)(theTile->getBuf(1));
    outBuf[2] = (ossim_uint8*)(theTile->getBuf(2));
-   long numberOfEntries = (long)theLut.getNumberOfEntries();
+   long numberOfEntries = (long)theLut->getNumberOfEntries();
 
    if(!numberOfEntries)
    {
@@ -378,7 +379,7 @@ void ossimIndexToRgbLutFilter::normalizeValue(double value,
 void ossimIndexToRgbLutFilter::getColorNormIndex(double index,
                                                  ossimRgbVector& result)
 {
-   long numberOfEntries = theLut.getNumberOfEntries();
+   long numberOfEntries = theLut->getNumberOfEntries();
    index*=numberOfEntries;
    if(theInterpolationType == ossimIndexToRgbLutFilter_LINEAR)
    {
@@ -389,8 +390,8 @@ void ossimIndexToRgbLutFilter::getColorNormIndex(double index,
       int lutIndex2 = lutIndex+1;
       if(lutIndex2>=numberOfEntries) lutIndex2 = numberOfEntries-1;
       
-      result = theLut[lutIndex]*(1.0-lutT) +
-               theLut[lutIndex2]*(lutT);
+      result = (*theLut)[lutIndex]*(1.0-lutT) +
+               (*theLut)[lutIndex2]*(lutT);
       
    }
    else
@@ -398,7 +399,7 @@ void ossimIndexToRgbLutFilter::getColorNormIndex(double index,
       int i = ossim::round<int>(index);
       i = i < 0?0:i;
       i = i >numberOfEntries?numberOfEntries:i;
-      result = theLut[i];
+      result = (*theLut)[i];
    }
 }
 
@@ -407,7 +408,7 @@ void ossimIndexToRgbLutFilter::getColor(double index,
 {
    if(theInterpolationType == ossimIndexToRgbLutFilter_LINEAR)
    {
-      long numberOfEntries = theLut.getNumberOfEntries();
+      long numberOfEntries = theLut->getNumberOfEntries();
       int lutIndex = (int)index;
       
       double lutT   = index - lutIndex;
@@ -415,12 +416,12 @@ void ossimIndexToRgbLutFilter::getColor(double index,
       
       if(lutIndex2>=numberOfEntries) lutIndex2 = numberOfEntries-1;
       
-      result = theLut[lutIndex]*(1.0-lutT) +
-               theLut[lutIndex2]*(lutT);
+      result = (*theLut)[lutIndex]*(1.0-lutT) +
+               (*theLut)[lutIndex2]*(lutT);
    }
    else
    {
-      result = theLut[ossim::round<int>(index)];
+      result = (*theLut)[ossim::round<int>(index)];
    }
 }
 
@@ -457,11 +458,11 @@ bool ossimIndexToRgbLutFilter::saveState(ossimKeywordlist& kwl,
    {
       kwl.add(newPrefix.c_str(), "lut_file", theLutFile.c_str(), true);
       ossimKeywordlist kwl2;
-      theLut.saveState(kwl2);
+      theLut->saveState(kwl2);
    }
    else
    {
-      theLut.saveState(kwl, newPrefix.c_str());
+      theLut->saveState(kwl, newPrefix.c_str());
    }
 
    return ossimImageSourceFilter::saveState(kwl, prefix);
@@ -533,7 +534,7 @@ bool ossimIndexToRgbLutFilter::loadState(const ossimKeywordlist& kwl,
    {
       theLutFile = "";
    }
-   theLut.loadState(kwl, newPrefix.c_str());
+   theLut->loadState(kwl, newPrefix.c_str());
 
    bool result = ossimImageSourceFilter::loadState(kwl, prefix);
 
@@ -561,7 +562,7 @@ ossimScalarType ossimIndexToRgbLutFilter::getOutputScalarType() const
 
 void ossimIndexToRgbLutFilter::setLut(ossimRgbLutDataObject& lut)
 {
-   theLut = lut;
+   theLut = new ossimRgbLutDataObject(lut);
 }
 
 void ossimIndexToRgbLutFilter::setLut(const ossimFilename& file)
@@ -570,7 +571,7 @@ void ossimIndexToRgbLutFilter::setLut(const ossimFilename& file)
    if(file.exists())
    {
       ossimKeywordlist kwl(file.c_str());
-      theLut.loadState(kwl);
+      theLut->loadState(kwl);
    }
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp
index 315c5f69a74eea091f704d6bb27fed616903d76d..3439d0335956a678c8a9fb1580c277f391803ece 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp
@@ -8,7 +8,7 @@
 //
 // Contains class definition for JpegTileSource.
 //*******************************************************************
-//  $Id: ossimJpegTileSource.cpp 13054 2008-06-23 13:55:13Z gpotts $
+//  $Id: ossimJpegTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #if defined(__BORLANDC__)
 #include <iostream>
 using std::size_t;
@@ -212,46 +212,75 @@ void ossimJpegTileSource::allocate()
 }
 
 ossimRefPtr<ossimImageData> ossimJpegTileSource::getTile(
-   const ossimIrect& tile_rect, ossim_uint32 resLevel)
+   const ossimIrect& rect, ossim_uint32 resLevel)
 {
-   if(!isSourceEnabled()||!isOpen()||!isValidRLevel(resLevel))
+   if (theTile.valid())
    {
-      return ossimRefPtr<ossimImageData>();
-   }
-   
-   if (theOverview)
-   {
-      if (theOverview->hasR0() || resLevel)
+      // Image rectangle must be set prior to calling getTile.
+      theTile->setImageRectangle(rect);
+      
+      if ( getTile( theTile.get(), resLevel ) == false )
       {
-         return theOverview->getTile(tile_rect, resLevel);
+         if (theTile->getDataObjectStatus() != OSSIM_NULL)
+         {
+            theTile->makeBlank();
+         }
       }
    }
+   
+   return theTile;
+}
 
-   if (!theTile.valid())
+bool ossimJpegTileSource::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()) )
    {
-      return ossimRefPtr<ossimImageData>();
-   }
+      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();       
 
-   theTile->setImageRectangle(tile_rect);
-   if (getImageRectangle(0).intersects(tile_rect))
-   {
-      // Make a clip rect.
-      ossimIrect clip_rect = tile_rect.clipToRect(getImageRectangle(0));
+         if (getImageRectangle(0).intersects(tile_rect))
+         {
+            // Make a clip rect.
+            ossimIrect clip_rect = tile_rect.clipToRect(getImageRectangle(0));
+            
+            fillTile(clip_rect, result);
+         }
+         else // No intersection...
+         {
+            result->makeBlank();
+         }
+      }
 
-      fillTile(clip_rect);
-   }
-   else
-   {
-      // No point in requested tile within the image rectangle.
-      return ossimRefPtr<ossimImageData>();
+      result->unref();  // Decrement ref count.
    }
 
-   return theTile;
+   return status;
 }
 
-void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
+void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect,
+                                   ossimImageData* tile)
 {
-   if (!theTile || !theFilePtr) return;
+   if (!theFilePtr) return;
 
    ossimIrect buffer_rect = clip_rect;
    buffer_rect.stretchToTileBoundary(theCacheSize);
@@ -259,9 +288,9 @@ void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
    buffer_rect.set_lrx(getImageRectangle(0).lr().x);
 
    // Check for a partial tile.
-   if ( ! theTile->getImageRectangle().completely_within(buffer_rect) )
+   if ( ! tile->getImageRectangle().completely_within(buffer_rect) )
    {
-      theTile->makeBlank();
+      tile->makeBlank();
    }
 
    ossim_int32 number_of_cache_tiles = buffer_rect.height()/theCacheSize.y;
@@ -277,7 +306,7 @@ void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
 
    ossimIpt origin = buffer_rect.ul();
    
-   for (int tile = 0; tile < number_of_cache_tiles; ++tile)
+   for (int tileIdx = 0; tileIdx < number_of_cache_tiles; ++tileIdx)
    {
       // See if it's in the cache already.
       ossimRefPtr<ossimImageData> tempTile;
@@ -285,7 +314,7 @@ void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
          getTile(theCacheId, origin);
       if (tempTile.valid())
       {
-         theTile->loadTile(tempTile.get());
+         tile->loadTile(tempTile.get());
       }
       else
       {
@@ -357,21 +386,18 @@ void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
          }
          theCacheTile->validate();
          
-         theTile->loadTile(theCacheTile.get());
+         tile->loadTile(theCacheTile.get());
          
          // Add it to the cache for the next time.
          ossimAppFixedTileCache::instance()->addTile(theCacheId, theCacheTile);
          
-
-//         delete[] buf;
-
       } // End of reading for jpeg file.
       
       origin.y += theCacheSize.y;
       
    } // for (int tile = 0; tile < number_of_cache_tiles; ++tile)
 
-   theTile->validate();
+   tile->validate();
 }
 
 //*******************************************************************
@@ -550,7 +576,7 @@ bool ossimJpegTileSource::isValidRLevel(ossim_uint32 reduced_res_level) const
    {
       return true;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->isValidRLevel(reduced_res_level);
    }
@@ -559,8 +585,8 @@ bool ossimJpegTileSource::isValidRLevel(ossim_uint32 reduced_res_level) const
       cerr << MODULE << " Invalid reduced_res_level:  " << reduced_res_level
            << "\nHighest available:  " << (getNumberOfDecimationLevels() - 1)
            << endl;
-      return false;
    }
+   return false;
 }
 
 //*******************************************************************
@@ -572,7 +598,7 @@ ossim_uint32 ossimJpegTileSource::getNumberOfLines(ossim_uint32 reduced_res_leve
    {
       return theImageRect.lr().y - theImageRect.ul().y + 1;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfLines(reduced_res_level);
    }
@@ -589,7 +615,7 @@ ossim_uint32 ossimJpegTileSource::getNumberOfSamples(ossim_uint32 reduced_res_le
    {
       return theImageRect.lr().x - theImageRect.ul().x + 1;;
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfSamples(reduced_res_level);
    }
@@ -617,7 +643,7 @@ ossimString ossimJpegTileSource::getLongName()const
    return ossimString("jpg reader");
 }
 
-ossimString  ossimJpegTileSource::className()const
+ossimString  ossimJpegTileSource::getClassName()const
 {
    return ossimString("ossimJpegTileSource");
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimJpegWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimJpegWriter.cpp
index 0dedb34836f2e0a84b2a865989fc77854923c925..99094ca6bcc9b07e5040ab883063afa2d821eec8 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimJpegWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimJpegWriter.cpp
@@ -5,7 +5,7 @@
 // Author:  David Burken
 //
 //*******************************************************************
-//  $Id: ossimJpegWriter.cpp 13134 2008-07-04 02:11:35Z gpotts $
+//  $Id: ossimJpegWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <cstdio>
@@ -105,17 +105,15 @@ bool ossimJpegWriter::writeFile()
          return false;
       }
    }
-   
-   bool needToDeleteInput = false;
+   ossimRefPtr<ossimImageSource> savedInput;
    
    if(theInputConnection->getOutputScalarType() != OSSIM_UINT8)
    {
-      ossimImageSource* inputSource=new ossimScalarRemapper;
+      savedInput = new ossimScalarRemapper;
       
-      inputSource->connectMyInputTo(0, theInputConnection->getInput(0));
-      theInputConnection->connectMyInputTo(0, inputSource);
+      savedInput->connectMyInputTo(0, theInputConnection->getInput(0));
+      theInputConnection->connectMyInputTo(0, savedInput.get());
       theInputConnection->initialize();
-      needToDeleteInput = true;
    }
    
    if(theInputConnection->isMaster())
@@ -306,17 +304,15 @@ bool ossimJpegWriter::writeFile()
    {
       theInputConnection->slaveProcessTiles();
    }
-   if(needToDeleteInput)
+   if(savedInput.valid())
    {
       ossimConnectableObject* obj = theInputConnection->getInput(0);
       if(obj)
       {
          theInputConnection->connectMyInputTo(0, obj->getInput(0));
-         delete obj;
-         obj = NULL;
       }
    }
-   
+   savedInput = 0;   
    return true;
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimLandsatTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimLandsatTileSource.cpp
index 5a06beef29272b4692c291577cf0d35986610953..735572c7d8ac52b84fdebb2d6ddb8434345f6bcf 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimLandsatTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimLandsatTileSource.cpp
@@ -9,7 +9,7 @@
 // Contains class implementaiton for the class "ossim LandsatTileSource".
 //
 //*******************************************************************
-//  $Id: ossimLandsatTileSource.cpp 13468 2008-08-20 18:25:57Z gpotts $
+//  $Id: ossimLandsatTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimLandsatTileSource.h>
 #include <ossim/base/ossimDirectory.h>
@@ -59,11 +59,7 @@ ossimLandsatTileSource::ossimLandsatTileSource(const ossimKeywordlist& kwl,
 //*******************************************************************
 ossimLandsatTileSource::~ossimLandsatTileSource()
 {
-   if (theFfHdr)
-   {
-      delete theFfHdr;
-      theFfHdr = NULL;
-   }
+   theFfHdr = NULL;
 }
 
 bool ossimLandsatTileSource::open()
@@ -212,11 +208,7 @@ void ossimLandsatTileSource::openHeader(const ossimFilename& file)
    //***
    ossimFilename hdr = file.file();
    hdr.downcase();
-   if(theFfHdr)
-   {
-      delete theFfHdr;
-      theFfHdr = 0;
-   }
+   theFfHdr = 0;
    if ( hdr.contains("hpn") || hdr.contains("hrf") || hdr.contains("htm") )
    {
       theFfHdr = new ossimFfL7(file.c_str());      
@@ -227,13 +219,12 @@ void ossimLandsatTileSource::openHeader(const ossimFilename& file)
    } 
 	else 
 	{
-      theFfHdr = NULL;
+      theFfHdr = 0;
       return;
    }
    if (theFfHdr->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
    {
-      delete theFfHdr;
-      theFfHdr = NULL;
+      theFfHdr = 0;
    }
    return;
 
@@ -324,32 +315,22 @@ void ossimLandsatTileSource::openHeader(const ossimFilename& file)
 #endif
 }
    
-bool ossimLandsatTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                              const char* prefix)
+ossimImageGeometry*  ossimLandsatTileSource::getImageGeometry()
 {
-   // Check for override for an external geometry file, or a previous save.
-   if(ossimImageHandler::getImageGeometry(kwl, prefix))
-   {
-      return true;
-   }
-   
-   if (!theFfHdr) return false;
+   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
+   if (result->getProjection())
+      return theGeometry.get();
+
+   if (!theFfHdr) return result;
 
    // Make a model
-   ossimLandSatModel model(*theFfHdr);
+   ossimLandSatModel* model = new ossimLandSatModel (*theFfHdr);
 
-   if (model.getErrorStatus() != ossimErrorCodes::OSSIM_OK)
-   {
-   
+   if (model->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
       return false;
-   }
 
-   bool result = model.saveState(kwl, prefix);
-   if (result)
-   {
-      // Capture for next time...
-      setImageGeometry(kwl);
-   }
+   //initialize the image geometry object with the model
+   result->setProjection(model);
    return result;
 }
 
@@ -394,7 +375,7 @@ ossimRefPtr<ossimProperty> ossimLandsatTileSource::getProperty(
 			return (new ossimStringProperty(name, "landsat7"));
 		}
 	}
-   else if (theFfHdr)
+   else if (theFfHdr.valid())
    {
       result = theFfHdr->getProperty(name);
    }
@@ -411,7 +392,7 @@ void ossimLandsatTileSource::getPropertyNames(
    std::vector<ossimString>& propertyNames)const
 {
 	propertyNames.push_back("file_type");
-   if (theFfHdr)
+   if (theFfHdr.valid())
    {
       theFfHdr->getPropertyNames(propertyNames);
    }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimLandsatTopoCorrectionFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimLandsatTopoCorrectionFilter.cpp
index a7f03b9d7ca625da424095519db864aea83e9d4f..b62ff6be5ba9f62a1451713a678038024f4ce097 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimLandsatTopoCorrectionFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimLandsatTopoCorrectionFilter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimLandsatTopoCorrectionFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+// $Id: ossimLandsatTopoCorrectionFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimLandsatTopoCorrectionFilter.h>
 #include <ossim/imaging/ossimImageToPlaneNormalFilter.h>
 #include <ossim/support_data/ossimFfL7.h>
@@ -59,13 +59,13 @@ void ossimLandsatTopoCorrectionFilter::setLandsatHeader(const ossimFilename& hea
    if(header != "")
    {
       theLandsatHeader = header;
-      ossimFfL7 headerL7(header.c_str());
-      headerL7.getGain(theGain);
-      headerL7.getBias(theBias);
-      headerL7.getSunElevation(theLightSourceElevationAngle);
-      headerL7.getSunAzimuth(theLightSourceAzimuthAngle);
+      ossimRefPtr<ossimFfL7> headerL7 = new ossimFfL7(header.c_str());
+      headerL7->getGain(theGain);
+      headerL7->getBias(theBias);
+      headerL7->getSunElevation(theLightSourceElevationAngle);
+      headerL7->getSunAzimuth(theLightSourceAzimuthAngle);
       computeLightDirection();
-      theJulianDay = headerL7.getJulianDay();
+      theJulianDay = headerL7->getJulianDay();
    }
 }
 
@@ -77,7 +77,7 @@ ossimFilename ossimLandsatTopoCorrectionFilter::findLandsatHeader()
    {
       return result;
    }
-   vector<ossimConnectableObject*> handlerList;
+   ossimConnectableObject::ConnectableObjectList handlerList;
 
    getInput(0)->findAllInputsOfType(handlerList,
                                     STATIC_TYPE_INFO(ossimImageHandler),
@@ -88,7 +88,7 @@ ossimFilename ossimLandsatTopoCorrectionFilter::findLandsatHeader()
 
    if(handlerList.size())
    {
-      handler = (ossimImageHandler*)handlerList[0];
+      handler = (ossimImageHandler*)handlerList[0].get();
    }
 
    if(handler)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMapCompositionSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMapCompositionSource.cpp
index 343957b6130bffe3ae428bc791697a85edc012b2..5437760974e106c9cb3dec9a350f5c9dba49e574 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimMapCompositionSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimMapCompositionSource.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimMapCompositionSource.cpp 13966 2009-01-14 16:31:17Z gpotts $
+// $Id: ossimMapCompositionSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimMapCompositionSource.h>
 #include <ossim/imaging/ossimU8ImageData.h>
@@ -28,14 +28,11 @@
 #include <ossim/base/ossimTextProperty.h>
 #include <ossim/base/ossimNumericProperty.h>
 #include <ossim/base/ossimStringProperty.h>
-
 #include <sstream>
-using namespace std;
 
-static const char* GRID_TYPE_ENUM_NAMES[] = {"none",
-                                             "line",
-                                             "reseaux"};
+using namespace std;
 
+static const char* GRID_TYPE_ENUM_NAMES[]     = {"none", "line", "reseaux"};
 static const char* VIEW_WIDTH_KW              = "view_width";
 static const char* VIEW_HEIGHT_KW             = "view_height";
 static const char* METER_GRID_SPACING_X_KW    = "meter_grid_spacing_x";
@@ -64,7 +61,6 @@ static const char* BOTTOM_METER_LABEL_COLOR_KW  = "bottom_meter_label_color";
 static const char* LEFT_METER_LABEL_COLOR_KW    = "left_meter_label_color";
 static const char* RIGHT_METER_LABEL_COLOR_KW   = "right_meter_label_color";
 
-
 static const char* TOP_GEO_LABEL_FORMAT_KW    = "top_geo_label_format";
 static const char* BOTTOM_GEO_LABEL_FORMAT_KW = "bottom_geo_label_format";
 static const char* LEFT_GEO_LABEL_FORMAT_KW   = "left_geo_label_format";
@@ -144,8 +140,7 @@ ossimMapCompositionSource::ossimMapCompositionSource()
     theLeftMeterTickFlag(false),
     theRightMeterTickFlag(false),
     theGeographicSpacing(1.0, 1.0),
-    theMeterSpacing(3600*30, 3600*30),
-    theInputProjection(NULL)
+    theMeterSpacing(3600*30, 3600*30)
 {
    theViewWidthHeight = ossimIpt(-1,-1);
    vector<ossimFontInformation> info;
@@ -157,7 +152,7 @@ ossimMapCompositionSource::ossimMapCompositionSource()
       theGeographicTopLabelFontInfo = info[0];
       theGeographicTopLabelFontInfo.thePointSize = ossimIpt(12,12);
 
-      if(theGeographicTopLabelFont)
+      if(theGeographicTopLabelFont.valid())
       {
          theGeographicBottomLabelFont     = (ossimFont*)theGeographicTopLabelFont->dup();
          theGeographicBottomLabelFontInfo = theGeographicTopLabelFontInfo;
@@ -184,62 +179,16 @@ ossimMapCompositionSource::ossimMapCompositionSource()
 
 ossimMapCompositionSource::~ossimMapCompositionSource()
 {
-   if(theInputProjection)
-   {
-      delete theInputProjection;
-      theInputProjection = NULL;
-   }
-   
-   if(theGeographicTopLabelFont)
-   {
-      delete theGeographicTopLabelFont;
-      theGeographicTopLabelFont = NULL;
-   }
-   if(theGeographicBottomLabelFont)
-   {
-      delete theGeographicBottomLabelFont;
-      theGeographicBottomLabelFont = NULL;
-   }
-   if(theGeographicLeftLabelFont)
-   {
-      delete theGeographicLeftLabelFont;
-      theGeographicLeftLabelFont = NULL;
-   }
-   if(theGeographicRightLabelFont)
-   {
-      delete theGeographicRightLabelFont;
-      theGeographicRightLabelFont = NULL;
-   }
-
-   if(theMeterTopLabelFont)
-   {
-      delete theMeterTopLabelFont;
-      theMeterTopLabelFont = NULL;
-   }
-   
-   if(theMeterBottomLabelFont)
-   {
-      delete theMeterBottomLabelFont;
-      theMeterBottomLabelFont = NULL;
-   }
+   theGeographicTopLabelFont = 0;
+   theGeographicBottomLabelFont = 0;
+   theGeographicLeftLabelFont = 0;
+   theGeographicRightLabelFont = 0;
+   theMeterTopLabelFont = 0;
+   theMeterBottomLabelFont = 0;
+   theMeterLeftLabelFont = 0;
 
-   if(theMeterLeftLabelFont)
-   {
-      delete theMeterLeftLabelFont;
-      theMeterLeftLabelFont = NULL;
-   }
-
-   if(theMeterRightLabelFont)
-   {
-      delete theMeterRightLabelFont;
-      theMeterRightLabelFont = NULL;
-   }
-   
-   if(theTitleFont)
-   {
-      delete theTitleFont;
-      theTitleFont = NULL;
-   }
+   theMeterRightLabelFont = 0;
+   theTitleFont = 0;
    deleteFixedAnnotations();
 }
 
@@ -374,12 +323,7 @@ void ossimMapCompositionSource::setTitleFont(const ossimFontInformation& fontInf
    ossimFont* font = ossimFontFactoryRegistry::instance()->createFont(fontInfo);
    if(font)
    {
-      if(theTitleFont)
-      {
-         delete theTitleFont;
-         theTitleFont = NULL;
-      }
-
+ 
       theTitleFont     = font;
       theTitleFontInfo = fontInfo;      
    }
@@ -407,16 +351,10 @@ void ossimMapCompositionSource::setGeographicTopLabelFont(const ossimFontInforma
 
    if(font)
    {
-      if(theGeographicTopLabelFont)
-      {
-         delete theGeographicTopLabelFont;
-         theGeographicTopLabelFont = NULL;
-      }
-      
       if(traceDebug())
       {
          CLOG << "Previous font info " <<endl
-              << theGeographicTopLabelFont << endl;
+              << theGeographicTopLabelFont.get() << endl;
       }
       theGeographicTopLabelFont = font;
       theGeographicTopLabelFontInfo = fontInfo;
@@ -424,7 +362,7 @@ void ossimMapCompositionSource::setGeographicTopLabelFont(const ossimFontInforma
       if(traceDebug())
       {
          CLOG << "New font info " <<endl
-              << theGeographicTopLabelFont << endl;
+              << theGeographicTopLabelFont.get() << endl;
       }      
    }
 }
@@ -439,12 +377,6 @@ void ossimMapCompositionSource::setGeographicBottomLabelFont(const ossimFontInfo
 
    if(font)
    {
-      if(theGeographicBottomLabelFont)
-      {
-         delete theGeographicBottomLabelFont;
-         theGeographicBottomLabelFont = NULL;
-      }
-      
       theGeographicBottomLabelFont     = font;
       theGeographicBottomLabelFontInfo = fontInfo;
 
@@ -461,12 +393,6 @@ void ossimMapCompositionSource::setGeographicLeftLabelFont(const ossimFontInform
 
    if(font)
    {
-      if(theGeographicLeftLabelFont)
-      {
-         delete theGeographicLeftLabelFont;
-         theGeographicLeftLabelFont = NULL;
-      }
-      
       theGeographicLeftLabelFont     = font;
       theGeographicLeftLabelFontInfo = fontInfo;
 
@@ -484,12 +410,6 @@ void ossimMapCompositionSource::setGeographicRightLabelFont(const ossimFontInfor
 
    if(font)
    {
-      if(theGeographicRightLabelFont)
-      {
-         delete theGeographicRightLabelFont;
-         theGeographicRightLabelFont = NULL;
-      }
-      
       theGeographicRightLabelFont = font;
       theGeographicRightLabelFontInfo = fontInfo;
    }
@@ -506,12 +426,6 @@ void ossimMapCompositionSource::setMeterTopLabelFont(const ossimFontInformation&
 
    if(font)
    {
-      if(theMeterTopLabelFont)
-      {
-         delete theMeterTopLabelFont;
-         theMeterTopLabelFont = NULL;
-      }
-      
       theMeterTopLabelFont     = font;
       theMeterTopLabelFontInfo = fontInfo;
    }
@@ -527,12 +441,6 @@ void ossimMapCompositionSource::setMeterBottomLabelFont(const ossimFontInformati
 
    if(font)
    {
-      if(theMeterBottomLabelFont)
-      {
-         delete theMeterBottomLabelFont;
-         theMeterBottomLabelFont = NULL;
-      }
-      
       theMeterBottomLabelFont     = font;
       theMeterBottomLabelFontInfo = fontInfo;
    }
@@ -548,12 +456,6 @@ void ossimMapCompositionSource::setMeterLeftLabelFont(const ossimFontInformation
 
    if(font)
    {
-      if(theMeterLeftLabelFont)
-      {
-         delete theMeterLeftLabelFont;
-         theMeterLeftLabelFont = NULL;
-      }
-      
       theMeterLeftLabelFont     = font;
       theMeterLeftLabelFontInfo = fontInfo;
    }
@@ -569,12 +471,6 @@ void ossimMapCompositionSource::setMeterRightLabelFont(const ossimFontInformatio
 
    if(font)
    {
-      if(theMeterRightLabelFont)
-      {
-         delete theMeterRightLabelFont;
-         theMeterRightLabelFont = NULL;
-      }
-      
       theMeterRightLabelFont     = font;
       theMeterRightLabelFontInfo = fontInfo;
    }
@@ -655,26 +551,7 @@ void ossimMapCompositionSource::initialize()
    theTile = 0;
    if(theInputConnection)
    {
-      if(theInputProjection)
-      {
-         delete theInputProjection;
-         theInputProjection = NULL;
-      }
-      
       computeBorderRects();
-
-      ossimKeywordlist kwl;
-      
-      theInputConnection->getImageGeometry(kwl);
-      ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-      
-      theInputProjection = PTR_CAST(ossimMapProjection, proj);
-      if(!theInputProjection&&proj)
-      {
-         delete proj;
-         proj = NULL;
-      }
-
       layoutAnnotations();
    }
    else 
@@ -794,26 +671,20 @@ void ossimMapCompositionSource::addGeographicTopGridLabels()
       }
       return;
    }
-   if(theInputConnection&&theInputProjection)
+   
+   if(theInputConnection)
    { 
+      const ossimMapProjection* mapProj = inputMapProjection();
       ossimGpt gpt[4];
       ossimDrect rect = getViewingRect();
 
       if(rect.hasNans()) return;
-      theInputProjection->lineSampleToWorld(rect.ul(),
-                                            gpt[0]);
-      theInputProjection->lineSampleToWorld(rect.ur(),
-                                            gpt[1]);
-      theInputProjection->lineSampleToWorld(rect.lr(),
-                                            gpt[2]);
-      theInputProjection->lineSampleToWorld(rect.ll(),
-                                            gpt[3]);
+      mapProj->lineSampleToWorld(rect.ul(), gpt[0]);
+      mapProj->lineSampleToWorld(rect.ur(), gpt[1]);
+      mapProj->lineSampleToWorld(rect.lr(), gpt[2]);
+      mapProj->lineSampleToWorld(rect.ll(), gpt[3]);
       
-      ossimDrect grect(gpt[0],
-                       gpt[1],
-                       gpt[2],
-                       gpt[3],
-                       OSSIM_RIGHT_HANDED);
+      ossimDrect grect(gpt[0], gpt[1], gpt[2], gpt[3], OSSIM_RIGHT_HANDED);
 
       if(grect.hasNans()) return;
       ossimDpt ulLatLon(((int)((grect.ul().x-theGeographicSpacing.x)/theGeographicSpacing.x))*theGeographicSpacing.x,
@@ -863,16 +734,11 @@ void ossimMapCompositionSource::addGeographicTopGridLabels()
                        0.0,
                        gpt[0].datum());
          
-         theInputProjection->worldToLineSample(tgpt,
-                                               tipt);
-         
-         theInputProjection->worldToLineSample(bgpt,
-                                               bipt);
+         mapProj->worldToLineSample(tgpt, tipt);
+         mapProj->worldToLineSample(bgpt, bipt);
 
          
-         if((!tipt.hasNans()&&
-             !bipt.hasNans()) &&
-            rect.clip(tipt, bipt))
+         if((!tipt.hasNans()&& !bipt.hasNans()) && rect.clip(tipt, bipt))
          {
             ossimIpt rounded(tipt);
             if( (rounded.x >= rect.ul().x)&&
@@ -883,17 +749,15 @@ void ossimMapCompositionSource::addGeographicTopGridLabels()
                   ossimDms dms(tgpt.lond(), false);
                
                   ossimString dmsString = dms.toString(theTopGeographicFormat.c_str());
-                  ossimAnnotationFontObject* lonLabel = new ossimAnnotationFontObject(ossimIpt(0,0),
-                                                                                      dmsString);
-                  lonLabel->setFont(theGeographicTopLabelFont, false);
-
+                  ossimAnnotationFontObject* lonLabel = 
+                     new ossimAnnotationFontObject(ossimIpt(0,0), dmsString);
+                  lonLabel->setFont(theGeographicTopLabelFont.get());
                   lonLabel->setGeometryInformation(theGeographicTopLabelFontInfo);
                   lonLabel->computeBoundingRect();
                   ossimDrect boundsD;
                   lonLabel->getBoundingRect(boundsD);
                   
-                  ossimIpt center( rounded.x,
-                                   ossim::round<int>(rect.ul().y-(boundsD.height()/2)));
+                  ossimIpt center( rounded.x, ossim::round<int>(rect.ul().y-(boundsD.height()/2)));
                
                   lonLabel->setColor(theTopGeographicLabelColor.getR(), theTopGeographicLabelColor.getG(), theTopGeographicLabelColor.getB());
                   lonLabel->setCenterPosition(center);
@@ -916,10 +780,9 @@ void ossimMapCompositionSource::addGeographicTopGridLabels()
                }
                if(theTopGeographicTickFlag)
                {
-                  ossimAnnotationLineObject* lineLabel = new ossimAnnotationLineObject(ossimIpt(rounded.x,
-                                                                                                ossim::round<int>(rect.ul().y-24)),
-                                                                                       ossimIpt(rounded.x,
-                                                                                                ossim::round<int>(rect.ul().y)));
+                  ossimAnnotationLineObject* lineLabel = new ossimAnnotationLineObject
+                     (ossimIpt(rounded.x,ossim::round<int>(rect.ul().y-24)),
+                      ossimIpt(rounded.x, ossim::round<int>(rect.ul().y)));
                   lineLabel->setColor(theTopGeographicLabelColor.getR(), theTopGeographicLabelColor.getG(), theTopGeographicLabelColor.getB());
                   addFixedAnnotation(lineLabel);
                }
@@ -939,26 +802,20 @@ void ossimMapCompositionSource::addGeographicBottomGridLabels()
    {
       return;
    }
-   if(theInputConnection&&theInputProjection)
+
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimGpt gpt[4];
       ossimDrect rect = getViewingRect();
 
       if(rect.hasNans()) return;
-      theInputProjection->lineSampleToWorld(rect.ul(),
-                                            gpt[0]);
-      theInputProjection->lineSampleToWorld(rect.ur(),
-                                            gpt[1]);
-      theInputProjection->lineSampleToWorld(rect.lr(),
-                                            gpt[2]);
-      theInputProjection->lineSampleToWorld(rect.ll(),
-                                            gpt[3]);
+      mapProj->lineSampleToWorld(rect.ul(), gpt[0]);
+      mapProj->lineSampleToWorld(rect.ur(), gpt[1]);
+      mapProj->lineSampleToWorld(rect.lr(), gpt[2]);
+      mapProj->lineSampleToWorld(rect.ll(), gpt[3]);
       
-      ossimDrect grect(gpt[0],
-                       gpt[1],
-                       gpt[2],
-                       gpt[3],
-                       OSSIM_RIGHT_HANDED);
+      ossimDrect grect(gpt[0], gpt[1], gpt[2], gpt[3], OSSIM_RIGHT_HANDED);
 
       if(grect.hasNans()) return;
       ossimDpt ulLatLon(((int)((grect.ul().x-theGeographicSpacing.x)/theGeographicSpacing.x))*theGeographicSpacing.x,
@@ -1004,11 +861,8 @@ void ossimMapCompositionSource::addGeographicBottomGridLabels()
                        0.0,
                        gpt[0].datum());
          
-         theInputProjection->worldToLineSample(tgpt,
-                                               tipt);
-         
-         theInputProjection->worldToLineSample(bgpt,
-                                               bipt);
+         mapProj->worldToLineSample(tgpt, tipt);
+         mapProj->worldToLineSample(bgpt, bipt);
 
          if(rect.clip(tipt, bipt))
          {
@@ -1024,7 +878,7 @@ void ossimMapCompositionSource::addGeographicBottomGridLabels()
                   ossimAnnotationFontObject* lonLabel = new ossimAnnotationFontObject(ossimIpt(0,0),
                                                                                       dmsString);
                   lonLabel->setGeometryInformation(theGeographicBottomLabelFontInfo);
-                  lonLabel->setFont(theGeographicBottomLabelFont, false);
+                  lonLabel->setFont(theGeographicBottomLabelFont.get());
 //                  lonLabel->setFont(theGeographicBottomLabelFont->dup());
                   
                   lonLabel->computeBoundingRect();
@@ -1078,20 +932,18 @@ void ossimMapCompositionSource::addGeographicLeftGridLabels()
    {
       return;
    }
-   if(theInputConnection&&theInputProjection)
+   
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimGpt gpt[4];
       ossimDrect rect = getViewingRect();
 
       if(rect.hasNans()) return;
-      theInputProjection->lineSampleToWorld(rect.ul(),
-                                            gpt[0]);
-      theInputProjection->lineSampleToWorld(rect.ur(),
-                                            gpt[1]);
-      theInputProjection->lineSampleToWorld(rect.lr(),
-                                            gpt[2]);
-      theInputProjection->lineSampleToWorld(rect.ll(),
-                                            gpt[3]);
+      mapProj->lineSampleToWorld(rect.ul(), gpt[0]);
+      mapProj->lineSampleToWorld(rect.ur(), gpt[1]);
+      mapProj->lineSampleToWorld(rect.lr(), gpt[2]);
+      mapProj->lineSampleToWorld(rect.ll(), gpt[3]);
       
       ossimDrect grect(gpt[0],
                        gpt[1],
@@ -1141,11 +993,8 @@ void ossimMapCompositionSource::addGeographicLeftGridLabels()
                        gpt[0].datum());
 
          
-         theInputProjection->worldToLineSample(lgpt,
-                                               lipt);
-
-         theInputProjection->worldToLineSample(rgpt,
-                                               ript);
+         mapProj->worldToLineSample(lgpt, lipt);
+         mapProj->worldToLineSample(rgpt, ript);
          if(rect.clip(lipt, ript))
          {
             ossimIpt rounded(lipt);
@@ -1160,7 +1009,7 @@ void ossimMapCompositionSource::addGeographicLeftGridLabels()
                   ossimAnnotationFontObject* latLabel = new ossimAnnotationFontObject(ossimIpt(0,0),
                                                                                       dmsString);
                   latLabel->setGeometryInformation(theGeographicLeftLabelFontInfo);
-                  latLabel->setFont(theGeographicLeftLabelFont, false);
+                  latLabel->setFont(theGeographicLeftLabelFont.get());
 //                  latLabel->setFont(theGeographicLeftLabelFont->dup());
                   
                   latLabel->computeBoundingRect();
@@ -1216,20 +1065,18 @@ void ossimMapCompositionSource::addGeographicRightGridLabels()
    {
       return;
    }
-   if(theInputConnection&&theInputProjection)
+
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimGpt gpt[4];
       ossimDrect rect = getViewingRect();
 
       if(rect.hasNans()) return;
-      theInputProjection->lineSampleToWorld(rect.ul(),
-                                            gpt[0]);
-      theInputProjection->lineSampleToWorld(rect.ur(),
-                                            gpt[1]);
-      theInputProjection->lineSampleToWorld(rect.lr(),
-                                            gpt[2]);
-      theInputProjection->lineSampleToWorld(rect.ll(),
-                                            gpt[3]);
+      mapProj->lineSampleToWorld(rect.ul(), gpt[0]);
+      mapProj->lineSampleToWorld(rect.ur(), gpt[1]);
+      mapProj->lineSampleToWorld(rect.lr(), gpt[2]);
+      mapProj->lineSampleToWorld(rect.ll(), gpt[3]);
       
       ossimDrect grect(gpt[0],
                        gpt[1],
@@ -1279,11 +1126,8 @@ void ossimMapCompositionSource::addGeographicRightGridLabels()
                        gpt[0].datum());
          
          
-         theInputProjection->worldToLineSample(lgpt,
-                                               lipt);
-         
-         theInputProjection->worldToLineSample(rgpt,
-                                               ript);
+         mapProj->worldToLineSample(lgpt, lipt);
+         mapProj->worldToLineSample(rgpt, ript);
          
          if(rect.clip(lipt, ript))
          {
@@ -1299,7 +1143,7 @@ void ossimMapCompositionSource::addGeographicRightGridLabels()
                   ossimAnnotationFontObject* latLabel = new ossimAnnotationFontObject(ossimIpt(0,0),
                                                                                       dmsString);
                   latLabel->setGeometryInformation(theGeographicRightLabelFontInfo);
-                  latLabel->setFont(theGeographicRightLabelFont, false);
+                  latLabel->setFont(theGeographicRightLabelFont.get());
 //                  latLabel->setFont(theGeographicRightLabelFont->dup());
                   latLabel->computeBoundingRect();
                   ossimDrect boundsD;
@@ -1350,20 +1194,17 @@ void ossimMapCompositionSource::addGeographicRightGridLabels()
 
 void ossimMapCompositionSource::addGeographicGridLines()
 {
-   if(theInputConnection&&theInputProjection)
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimGpt gpt[4];
       ossimDrect rect = getViewingRect();
 
       if(rect.hasNans()) return;
-      theInputProjection->lineSampleToWorld(rect.ul(),
-                                            gpt[0]);
-      theInputProjection->lineSampleToWorld(rect.ur(),
-                                            gpt[1]);
-      theInputProjection->lineSampleToWorld(rect.lr(),
-                                            gpt[2]);
-      theInputProjection->lineSampleToWorld(rect.ll(),
-                                            gpt[3]);
+      mapProj->lineSampleToWorld(rect.ul(), gpt[0]);
+      mapProj->lineSampleToWorld(rect.ur(), gpt[1]);
+      mapProj->lineSampleToWorld(rect.lr(), gpt[2]);
+      mapProj->lineSampleToWorld(rect.ll(), gpt[3]);
       
       ossimDrect grect(gpt[0],
                        gpt[1],
@@ -1415,11 +1256,8 @@ void ossimMapCompositionSource::addGeographicGridLines()
                        0.0,
                        gpt[0].datum());
          
-         theInputProjection->worldToLineSample(tgpt,
-                                               tipt);
-         
-         theInputProjection->worldToLineSample(bgpt,
-                                               bipt);
+         mapProj->worldToLineSample(tgpt, tipt);
+         mapProj->worldToLineSample(bgpt, bipt);
 
          if(rect.clip(tipt, bipt))
          {
@@ -1444,10 +1282,8 @@ void ossimMapCompositionSource::addGeographicGridLines()
                        0.0,
                        gpt[0].datum());
 
-         theInputProjection->worldToLineSample(lgpt,
-                                               lipt);
-         theInputProjection->worldToLineSample(rgpt,
-                                               ript);
+         mapProj->worldToLineSample(lgpt, lipt);
+         mapProj->worldToLineSample(rgpt, ript);
          
          if(rect.clip(lipt, ript))
          {
@@ -1466,19 +1302,16 @@ void ossimMapCompositionSource::addGeographicGridLines()
 
 void ossimMapCompositionSource::addGeographicGridReseaux()
 {
-   if(theInputConnection&&theInputProjection)
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimGpt gptArray[4];
       ossimDrect rect = getViewingRect();
       
-      theInputProjection->lineSampleToWorld(rect.ul(),
-                                            gptArray[0]);
-      theInputProjection->lineSampleToWorld(rect.ur(),
-                                            gptArray[1]);
-      theInputProjection->lineSampleToWorld(rect.lr(),
-                                            gptArray[2]);
-      theInputProjection->lineSampleToWorld(rect.ll(),
-                                            gptArray[3]);
+      mapProj->lineSampleToWorld(rect.ul(), gptArray[0]);
+      mapProj->lineSampleToWorld(rect.ur(), gptArray[1]);
+      mapProj->lineSampleToWorld(rect.lr(), gptArray[2]);
+      mapProj->lineSampleToWorld(rect.ll(), gptArray[3]);
       
       ossimDrect grect(gptArray[0],
                        gptArray[1],
@@ -1507,9 +1340,7 @@ void ossimMapCompositionSource::addGeographicGridReseaux()
                          0.0,
                          gptArray[0].datum());
             
-            
-            theInputProjection->worldToLineSample(gpt,
-                                                  ipt);
+            mapProj->worldToLineSample(gpt, ipt);
 
             ossimIpt rounded(ipt);
             if(rect.pointWithin(ossimDpt(rounded)))
@@ -1539,26 +1370,18 @@ void ossimMapCompositionSource::addGeographicGridReseaux()
 
 void ossimMapCompositionSource::addMeterGridLines()
 {
-   if(theInputConnection&&theInputProjection)
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimDpt dptArray[4];
       ossimDrect rect = getViewingRect();
       
-      theInputProjection->lineSampleToEastingNorthing(rect.ul(),
-                                                      dptArray[0]);
-      theInputProjection->lineSampleToEastingNorthing(rect.ur(),
-                                                      dptArray[1]);
-      theInputProjection->lineSampleToEastingNorthing(rect.lr(),
-                                                      dptArray[2]);
-      theInputProjection->lineSampleToEastingNorthing(rect.ll(),
-                                                      dptArray[3]);
+      mapProj->lineSampleToEastingNorthing(rect.ul(), dptArray[0]);
+      mapProj->lineSampleToEastingNorthing(rect.ur(), dptArray[1]);
+      mapProj->lineSampleToEastingNorthing(rect.lr(), dptArray[2]);
+      mapProj->lineSampleToEastingNorthing(rect.ll(), dptArray[3]);
       
-      
-      ossimDrect drect(dptArray[0],
-                       dptArray[1],
-                       dptArray[2],
-                       dptArray[3],
-                       OSSIM_RIGHT_HANDED);
+      ossimDrect drect(dptArray[0], dptArray[1], dptArray[2], dptArray[3], OSSIM_RIGHT_HANDED);
       
       ossimDpt ulMeter(((int)((drect.ul().x-theMeterSpacing.x)/theMeterSpacing.x))*theMeterSpacing.x,
                        ((int)((drect.ul().y+theMeterSpacing.y)/theMeterSpacing.y))*theMeterSpacing.y);
@@ -1577,17 +1400,12 @@ void ossimMapCompositionSource::addMeterGridLines()
          ossimDpt tipt; // top
          ossimDpt bipt; // bottom
 
-         ossimDpt tdpt(horizontal,
-                       meterSpacing.ul().y);
+         ossimDpt tdpt(horizontal, meterSpacing.ul().y);
 
-         ossimDpt bdpt(horizontal,
-                       meterSpacing.lr().y);
-         
-         theInputProjection->eastingNorthingToLineSample(tdpt,
-                                                         tipt);
+         ossimDpt bdpt(horizontal, meterSpacing.lr().y);
          
-         theInputProjection->eastingNorthingToLineSample(bdpt,
-                                                         bipt);
+         mapProj->eastingNorthingToLineSample(tdpt, tipt);
+         mapProj->eastingNorthingToLineSample(bdpt, bipt);
          
          if(rect.clip(tipt, bipt))
          {
@@ -1605,20 +1423,15 @@ void ossimMapCompositionSource::addMeterGridLines()
       {
          ossimDpt lipt;
          ossimDpt ript;
-         ossimDpt ldpt(meterSpacing.ul().x,
-                       vertical);
-         ossimDpt rdpt(meterSpacing.ur().x,
-                       vertical);
-
-         theInputProjection->eastingNorthingToLineSample(ldpt,
-                                                         lipt);
-         theInputProjection->eastingNorthingToLineSample(rdpt,
-                                                         ript);
+         ossimDpt ldpt(meterSpacing.ul().x, vertical);
+         ossimDpt rdpt(meterSpacing.ur().x, vertical);
+
+         mapProj->eastingNorthingToLineSample(ldpt,  lipt);
+         mapProj->eastingNorthingToLineSample(rdpt,  ript);
          
          if(rect.clip(lipt, ript))
          {
-            ossimAnnotationLineObject* line = new ossimAnnotationLineObject(lipt,
-                                                                            ript);
+            ossimAnnotationLineObject* line = new ossimAnnotationLineObject(lipt, ript);
          
             line->setColor(theMeterGridColor.getR(),
                            theMeterGridColor.getG(),
@@ -1632,19 +1445,16 @@ void ossimMapCompositionSource::addMeterGridLines()
 
 void ossimMapCompositionSource::addMeterGridLabels()
 {
-   if(theInputConnection&&theInputProjection)
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    {
       ossimDpt dptArray[4];
       ossimDrect rect = getViewingRect();
       
-      theInputProjection->lineSampleToEastingNorthing(rect.ul(),
-                                                      dptArray[0]);
-      theInputProjection->lineSampleToEastingNorthing(rect.ur(),
-                                                      dptArray[1]);
-      theInputProjection->lineSampleToEastingNorthing(rect.lr(),
-                                                      dptArray[2]);
-      theInputProjection->lineSampleToEastingNorthing(rect.ll(),
-                                                      dptArray[3]);
+      mapProj->lineSampleToEastingNorthing(rect.ul(), dptArray[0]);
+      mapProj->lineSampleToEastingNorthing(rect.ur(), dptArray[1]);
+      mapProj->lineSampleToEastingNorthing(rect.lr(), dptArray[2]);
+      mapProj->lineSampleToEastingNorthing(rect.ll(), dptArray[3]);
       
       ossimDrect drect(dptArray[0],
                        dptArray[1],
@@ -1675,7 +1485,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
       long extraLeftDelta    = 0;
       long extraRightDelta   = 0;
          
-      if(theTopGeographicLabelFlag&&theGeographicTopLabelFont)
+      if(theTopGeographicLabelFlag&&theGeographicTopLabelFont.valid())
       {  
          ossimDms dms(180, false);
          ossimString dmsString = dms.toString(theTopGeographicFormat.c_str());
@@ -1686,7 +1496,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
          theGeographicTopLabelFont->getBoundingBox(box);
          extraTopDelta = box.height();
       }
-      if(theBottomGeographicLabelFlag&&theGeographicBottomLabelFont)
+      if(theBottomGeographicLabelFlag&&theGeographicBottomLabelFont.valid())
       {  
          ossimDms dms(180, false);
          ossimString dmsString = dms.toString(theBottomGeographicFormat.c_str());
@@ -1696,7 +1506,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
          theGeographicBottomLabelFont->getBoundingBox(box);
          extraBottomDelta = box.height();
       }
-      if(theLeftGeographicLabelFlag&&theGeographicLeftLabelFont)
+      if(theLeftGeographicLabelFlag&&theGeographicLeftLabelFont.valid())
       {  
          ossimDms dms(90.0, true);
          ossimString dmsString = dms.toString(theLeftGeographicFormat.c_str());
@@ -1706,7 +1516,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
          theGeographicLeftLabelFont->getBoundingBox(box);
          extraLeftDelta = box.width();
       }
-      if(theRightGeographicLabelFlag&&theGeographicRightLabelFont)
+      if(theRightGeographicLabelFlag&&theGeographicRightLabelFont.valid())
       {  
          ossimDms dms(90.0, true);
          ossimString dmsString = dms.toString(theRightGeographicFormat.c_str());
@@ -1733,11 +1543,8 @@ void ossimMapCompositionSource::addMeterGridLabels()
             ossimDpt bdpt(horizontal,
                           meterSpacing.lr().y);
             
-            theInputProjection->eastingNorthingToLineSample(tdpt,
-                                                            tipt);
-            
-            theInputProjection->eastingNorthingToLineSample(bdpt,
-                                                            bipt);
+            mapProj->eastingNorthingToLineSample(tdpt, tipt);
+            mapProj->eastingNorthingToLineSample(bdpt, bipt);
             
             rect.clip(tipt, bipt);
             
@@ -1750,7 +1557,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                                                                    ossimString::toString(horizontal).c_str());
                
                
-               topLabel->setFont(theMeterTopLabelFont, false);
+               topLabel->setFont(theMeterTopLabelFont.get());
                
                topLabel->setGeometryInformation(theMeterTopLabelFontInfo);
                topLabel->computeBoundingRect();
@@ -1800,7 +1607,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                                                                       ossimString::toString(horizontal).c_str());
                
                
-               bottomLabel->setFont(theMeterBottomLabelFont, false);
+               bottomLabel->setFont(theMeterBottomLabelFont.get());
                
                bottomLabel->setGeometryInformation(theMeterBottomLabelFontInfo);
                bottomLabel->computeBoundingRect();
@@ -1856,10 +1663,8 @@ void ossimMapCompositionSource::addMeterGridLabels()
             ossimDpt rdpt(meterSpacing.ur().x,
                           vertical);
             
-            theInputProjection->eastingNorthingToLineSample(ldpt,
-                                                            lipt);
-            theInputProjection->eastingNorthingToLineSample(rdpt,
-                                                            ript);
+            mapProj->eastingNorthingToLineSample(ldpt, lipt);
+            mapProj->eastingNorthingToLineSample(rdpt, ript);
             
             if(rect.clip(lipt, ript))
             {
@@ -1868,7 +1673,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                                                                     ossimString::toString(vertical).c_str());
                
                
-               leftLabel->setFont(theMeterLeftLabelFont, false);
+               leftLabel->setFont(theMeterLeftLabelFont.get());
                
                leftLabel->setGeometryInformation(theMeterLeftLabelFontInfo);
                leftLabel->computeBoundingRect();
@@ -1916,7 +1721,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                                                                      ossimString::toString(vertical).c_str());
                
                
-               rightLabel->setFont(theMeterRightLabelFont, false);
+               rightLabel->setFont(theMeterRightLabelFont.get());
                
                rightLabel->setGeometryInformation(theMeterRightLabelFontInfo);
                rightLabel->computeBoundingRect();
@@ -1966,19 +1771,16 @@ void ossimMapCompositionSource::addMeterGridLabels()
 
 void ossimMapCompositionSource::addMeterGridReseaux()
 {
-   if(theInputConnection&&theInputProjection)
+   const ossimMapProjection* mapProj = inputMapProjection();
+   if(mapProj)
    { 
       ossimDpt dpt[4];
       ossimDrect rect = getViewingRect();
       
-      theInputProjection->lineSampleToEastingNorthing(rect.ul(),
-                                                      dpt[0]);
-      theInputProjection->lineSampleToEastingNorthing(rect.ur(),
-                                                      dpt[1]);
-      theInputProjection->lineSampleToEastingNorthing(rect.lr(),
-                                                      dpt[2]);
-      theInputProjection->lineSampleToEastingNorthing(rect.ll(),
-                                                      dpt[3]);
+      mapProj->lineSampleToEastingNorthing(rect.ul(), dpt[0]);
+      mapProj->lineSampleToEastingNorthing(rect.ur(), dpt[1]);
+      mapProj->lineSampleToEastingNorthing(rect.lr(), dpt[2]);
+      mapProj->lineSampleToEastingNorthing(rect.ll(), dpt[3]);
       
       ossimDrect drect(dpt[0],
                        dpt[1],
@@ -2005,8 +1807,7 @@ void ossimMapCompositionSource::addMeterGridReseaux()
             ossimDpt dpt(horizontal,
                          vertical);
             
-            theInputProjection->eastingNorthingToLineSample(dpt,
-                                                            ipt);
+            mapProj->eastingNorthingToLineSample(dpt, ipt);
 
             ossimIpt rounded(ipt);
             if(rect.pointWithin(ossimDpt(rounded)))
@@ -2040,7 +1841,7 @@ void ossimMapCompositionSource::addTitle()
    ossimAnnotationFontObject* title = new ossimAnnotationFontObject(ossimIpt(0,0),
                                                                     theTitleString);
    title->setGeometryInformation(theTitleFontInfo);
-   title->setFont(theTitleFont, false);
+   title->setFont(theTitleFont.get());
    title->setColor(theTitleColor.getR(),
                    theTitleColor.getG(),
                    theTitleColor.getB());
@@ -2098,10 +1899,10 @@ void ossimMapCompositionSource::drawAnnotations(
    
    if(theImage->getImageData().valid())
    {
-      vector<ossimAnnotationObject*>::iterator object = theFixedAnnotationList.begin();
+      ossimAnnotationSource::AnnotationObjectListType::iterator object = theFixedAnnotationList.begin();
       while(object != theFixedAnnotationList.end())
       {
-         if(*object)
+         if((*object).valid())
          {
             (*object)->draw(*theImage);
          }
@@ -2114,14 +1915,6 @@ void ossimMapCompositionSource::drawAnnotations(
 
 void ossimMapCompositionSource::deleteFixedAnnotations()
 {
-   for(int i = 0; i < (int)theFixedAnnotationList.size();++i)
-   {
-      if(theFixedAnnotationList[i])
-      {
-         delete theFixedAnnotationList[i];
-      }
-   }
-
    theFixedAnnotationList.clear();
 }
 
@@ -3369,53 +3162,6 @@ bool ossimMapCompositionSource::loadState(const ossimKeywordlist& kwl,
    theMeterRightLabelFontInfo.loadState(kwl, (ossimString(prefix) + ossimString(RIGHT_METER_LABEL_FONT_KW) + ".").c_str());
    
    theTitleFontInfo.loadState(kwl, (ossimString(prefix) + ossimString(TITLE_FONT_KW) + ".").c_str());
-   if(theTitleFont)
-   {
-      delete theTitleFont;
-      theTitleFont = NULL;
-   }
-   if(theGeographicTopLabelFont)
-   {
-      delete theGeographicTopLabelFont;
-      theGeographicTopLabelFont = NULL;
-   }
-   if(theGeographicBottomLabelFont)
-   {
-      delete theGeographicBottomLabelFont;
-      theGeographicBottomLabelFont = NULL;
-   }
-   if(theGeographicLeftLabelFont)
-   {
-      delete theGeographicLeftLabelFont;
-      theGeographicLeftLabelFont = NULL;
-   }
-   if(theGeographicRightLabelFont)
-   {
-      delete theGeographicRightLabelFont;
-      theGeographicRightLabelFont = NULL;
-   }
-
-   if(theMeterTopLabelFont)
-   {
-      delete theMeterTopLabelFont;
-      theMeterTopLabelFont = NULL;
-   }
-   if(theMeterBottomLabelFont)
-   {
-      delete theMeterBottomLabelFont;
-      theMeterBottomLabelFont = NULL;
-   }
-   if(theMeterLeftLabelFont)
-   {
-      delete theMeterLeftLabelFont;
-      theMeterLeftLabelFont = NULL;
-   }
-   if(theMeterRightLabelFont)
-   {
-      delete theMeterRightLabelFont;
-      theMeterRightLabelFont = NULL;
-   }
-   
    theTitleFont = ossimFontFactoryRegistry::instance()->createFont(theTitleFontInfo);
    theGeographicTopLabelFont = ossimFontFactoryRegistry::instance()->createFont(theGeographicTopLabelFontInfo);
    theGeographicBottomLabelFont = ossimFontFactoryRegistry::instance()->createFont(theGeographicBottomLabelFontInfo);
@@ -4034,3 +3780,20 @@ void ossimMapCompositionSource::addFixedAnnotation(ossimAnnotationObject* obj)
       theFixedAnnotationList.push_back(obj);
    }
 }
+
+//**************************************************************************************************
+//! Fetches the input connection's image geometry and verifies that it is a map projection.
+//! Returns NULL if no valid projection found.
+//**************************************************************************************************
+const ossimMapProjection* ossimMapCompositionSource::inputMapProjection() const
+{
+   if (!theInputConnection)
+      return 0;
+
+   const ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
+   if (!inputGeom)
+      return 0;
+
+   return PTR_CAST(ossimMapProjection, inputGeom->getProjection());
+}
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMaxMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMaxMosaic.cpp
index 0260336594837f698aea68611e5cf510f91ffefb..c94b82f2a8d78d230a202143882aceef15515466 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimMaxMosaic.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimMaxMosaic.cpp
@@ -11,7 +11,7 @@
 //              of all inputs to top of the mosaic output. 
 //
 //*************************************************************************
-// $Id: ossimMaxMosaic.cpp 10777 2007-04-25 14:49:17Z gpotts $
+// $Id: ossimMaxMosaic.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimMaxMosaic.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -29,7 +29,7 @@ ossimMaxMosaic::ossimMaxMosaic()
 {
 }
 
-ossimMaxMosaic::ossimMaxMosaic(const vector<ossimImageSource*>& inputSources)
+ossimMaxMosaic::ossimMaxMosaic(ossimConnectableObject::ConnectableObjectList& inputSources)
     : ossimImageCombiner(inputSources),
       theTile(NULL)
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp
index 0b8f99cfb5d16b061f1a2fac1fad89c98e4db550..33511c88e8ab25e30c6982d1a2f96c703d83f4fe 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp
@@ -185,3 +185,8 @@ void ossimMemoryImageSource::getDecimationFactor(ossim_uint32 resLevel,
       result.y = result.x;
    }
 }
+
+void ossimMemoryImageSource::getDecimationFactors(std::vector<ossimDpt>& decimations)const
+{
+   decimations.push_back(ossimDpt(1.0,1.0));
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMetadataFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMetadataFileWriter.cpp
index bc62419052760307af28b04db060b6059f73516e..c686fffde475ae37c71fff7f73325bcfbbf0f8f6 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimMetadataFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimMetadataFileWriter.cpp
@@ -8,7 +8,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimMetadataFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimMetadataFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimMetadataFileWriter.h>
 #include <ossim/base/ossimTrace.h>
@@ -30,7 +30,7 @@ RTTI_DEF3(ossimMetadataFileWriter,
 static ossimTrace traceDebug("ossimMetadataFileWriter:degug");
 
 ossimMetadataFileWriter::ossimMetadataFileWriter()
-   :
+   :ossimConnectableObject(0),
       ossimProcessInterface(),
       ossimConnectableObjectListener(),
       theInputConnection(NULL),
@@ -38,17 +38,18 @@ ossimMetadataFileWriter::ossimMetadataFileWriter()
       thePixelType(OSSIM_PIXEL_IS_POINT),
       theAreaOfInterest()
 {
+   addListener((ossimConnectableObjectListener*)this);
    theAreaOfInterest.makeNan();
 }
 
 ossimMetadataFileWriter::~ossimMetadataFileWriter()
 {
+   removeListener((ossimConnectableObjectListener*)this);
 }
 
 void ossimMetadataFileWriter::initialize()
 {
-   theInputConnection = PTR_CAST(ossimImageSource,
-                                 getInput());
+   theInputConnection = dynamic_cast<ossimImageSource*> (getInput(0));
 }
 
 bool ossimMetadataFileWriter::loadState(const ossimKeywordlist& kwl,
@@ -99,7 +100,6 @@ void ossimMetadataFileWriter::disconnectInputEvent(ossimConnectionEvent& event)
 
 void ossimMetadataFileWriter::connectInputEvent(ossimConnectionEvent& event)
 {
-   theInputConnection = PTR_CAST(ossimImageSource, getInput());
    initialize();
 }
 
@@ -131,7 +131,6 @@ const ossimObject* ossimMetadataFileWriter::getObject() const
 bool ossimMetadataFileWriter::execute()
 {
    bool result = false;
-   
    if (!theInputConnection)
    {
       initialize();
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp
index ed3ee412a17f5c572653dc9dd97b1250664ca632..72c393092d459ca6e78ffd2acc2af26cea8dd9e2 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  Garrett Potts
 //
@@ -30,6 +32,7 @@
 #include <ossim/base/ossimStringProperty.h>
 #include <ossim/base/ossimNumericProperty.h>
 #include <ossim/base/ossimBooleanProperty.h>
+#include <ossim/support_data/ossimNitfCommon.h>
 #include <ossim/support_data/ossimNitfGeoPositioningTag.h>
 #include <ossim/support_data/ossimNitfLocalGeographicTag.h>
 #include <ossim/support_data/ossimNitfLocalCartographicTag.h>
@@ -37,16 +40,16 @@
 #include <ossim/support_data/ossimNitfNameConversionTables.h>
 #include <ossim/support_data/ossimNitfBlockaTag.h>
 
-RTTI_DEF1(ossimNitf20Writer, "ossimNitf20Writer", ossimImageFileWriter);
+RTTI_DEF1(ossimNitf20Writer, "ossimNitf20Writer", ossimNitfWriterBase);
 
 static ossimTrace traceDebug(ossimString("ossimNitfWriter:debug"));
      
 static ossimString monthConversionTable[] = {"   ", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
 
 ossimNitf20Writer::ossimNitf20Writer(const ossimFilename& filename,
-                                 ossimImageSource* inputSource)
-   : ossimImageFileWriter(filename, inputSource, NULL),
-     theOutputStream(NULL),
+                                     ossimImageSource* inputSource)
+   : ossimNitfWriterBase(filename, inputSource),
+     theOutputStream(0),
      theFileHeader(),
      theImageHeader(),
      theEnableRpcbTagFlag(false),
@@ -128,7 +131,8 @@ bool ossimNitf20Writer::writeFile()
    }
 
    // Write out the geometry info.
-   writeGeometry();
+   writeGeometry(theImageHeader.get(), theInputConnection.get());
+   
    addTags();
    
    bool result = false;
@@ -295,9 +299,10 @@ bool ossimNitf20Writer::writeBlockBandSeparate()
    ossim_uint64 headerLength = ((ossim_uint64)theOutputStream->tellp() - headerStart) /* + 1 */;
    
    ossimString representation;
-   theImageHeader->setActualBitsPerPixel(getActualBitsPerPixel());
-   theImageHeader->setBitsPerPixel(getBitsPerPixel());
-   theImageHeader->setPixelType(getNitfPixelType());
+   theImageHeader->setActualBitsPerPixel(
+      ossim::getActualBitsPerPixel(scalarType));
+   theImageHeader->setBitsPerPixel(ossim::getBitsPerPixel(scalarType));
+   theImageHeader->setPixelType(ossimNitfCommon::getNitfPixelType(scalarType));
    theImageHeader->setNumberOfBands(bands);
    theImageHeader->setImageMode('B');// blocked
 
@@ -402,15 +407,15 @@ bool ossimNitf20Writer::writeBlockBandSeparate()
       ++tileNumber;
    }
 
-   ossim_uint64 pos = theOutputStream->tellp();
+   std::streamoff pos = theOutputStream->tellp();
 
-   setComplexityLevel(pos);
+   setComplexityLevel(pos, theFileHeader.get());
 
    /*
     * Need to change the way I compute file length and header length later
     * We need to figure out a better way to compute.
     */
-   theFileHeader->setFileLength(pos);
+   theFileHeader->setFileLength(static_cast<ossim_uint64>(pos));
    theFileHeader->setHeaderLength(headerLength);
    theOutputStream->seekp(0, ios::beg);
    imageInfoRecord.setSubheaderLength(imageHeaderSize);
@@ -456,9 +461,10 @@ bool ossimNitf20Writer::writeBlockBandSequential()
    ossim_uint64 headerLength = ((ossim_uint64)theOutputStream->tellp() - headerStart) /* + 1 */;
    
    ossimString representation;
-   theImageHeader->setActualBitsPerPixel(getActualBitsPerPixel());
-   theImageHeader->setBitsPerPixel(getBitsPerPixel());
-   theImageHeader->setPixelType(getNitfPixelType());
+   theImageHeader->setActualBitsPerPixel(
+      ossim::getActualBitsPerPixel(scalarType));
+   theImageHeader->setBitsPerPixel(ossim::getBitsPerPixel(scalarType));
+   theImageHeader->setPixelType(ossimNitfCommon::getNitfPixelType(scalarType));
    theImageHeader->setNumberOfBands(bands);
    theImageHeader->setImageMode('S');// blocked
    
@@ -577,15 +583,15 @@ bool ossimNitf20Writer::writeBlockBandSequential()
       }
    }
    
-   ossim_uint64 pos = theOutputStream->tellp();
+   std::streamoff pos = theOutputStream->tellp();
 
-   setComplexityLevel(pos);
+   setComplexityLevel(pos, theFileHeader.get());
 
    /*
     * Need to change the way I compute file length and header length later
     * We need to figure out a better way to compute.
     */
-   theFileHeader->setFileLength(pos);
+   theFileHeader->setFileLength(static_cast<ossim_uint64>(pos));
    theFileHeader->setHeaderLength(headerLength);
    theOutputStream->seekp(0, ios::beg);
    imageInfoRecord.setSubheaderLength(imageHeaderSize);
@@ -604,73 +610,6 @@ void ossimNitf20Writer::addRegisteredTag(
      theImageHeader->addTag(tagInfo);
 }
 
-void ossimNitf20Writer::writeGeometry()
-{
-   if ( (theImageHeader.valid() == false) || !theInputConnection )
-   {
-      return;
-   }
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-   ossimRefPtr<ossimProjection> proj =
-      ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   
-   if(proj.valid() == false)
-   {
-      // No projection info.
-      return;
-   }
-
-   // Get the requested bounding rectangles.
-   ossimIrect rect = theInputConnection->getBoundingRect();
-
-   // See if it's a map projection; else, a sensor model.
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj.get());
-   if (mapProj)
-   {
-      // Use map info to get the corners.
-      ossimMapProjectionInfo mapInfo(mapProj, rect);
-      mapInfo.setPixelType(OSSIM_PIXEL_IS_AREA);
-      
-      // See if it's utm.
-      ossimUtmProjection* utmProj = PTR_CAST(ossimUtmProjection, proj.get());
-      if(utmProj)
-      {
-         ossimDpt ul = mapInfo.ulEastingNorthingPt();
-         ossimDpt ur = mapInfo.urEastingNorthingPt();
-         ossimDpt lr = mapInfo.lrEastingNorthingPt();
-         ossimDpt ll = mapInfo.llEastingNorthingPt();
-         
-         if(utmProj->getHemisphere() == 'N')
-         {
-            theImageHeader->setUtmNorth(utmProj->getZone(), ul, ur, lr, ll);
-         }
-         else
-         {
-            theImageHeader->setUtmSouth(utmProj->getZone(), ul, ur, lr, ll);
-         }
-      }
-      else
-      {
-         ossimGpt ul = mapInfo.ulGroundPt();
-         ossimGpt ur = mapInfo.urGroundPt();
-         ossimGpt lr = mapInfo.lrGroundPt();
-         ossimGpt ll = mapInfo.llGroundPt();
-         theImageHeader->setGeographicLocationDms(ul, ur, lr, ll);
-      }
-
-      if (theEnableBlockaTagFlag)
-      {
-         addBlockaTag(mapInfo);
-      }
-   }
-
-   if (theEnableRpcbTagFlag)
-   {
-      addRpcbTag(rect, proj);
-   }
-}
-
 void ossimNitf20Writer::addTags()
 {
    ossimDate currentDate;
@@ -860,295 +799,14 @@ void ossimNitf20Writer::addTags()
    }
 }
 
-void ossimNitf20Writer::setComplexityLevel(ossim_uint64 endPosition)
-{
-   //---
-   // See MIL-STD-2500C, Table A-10:
-   //
-   // Lots of rules here, but for now we will key off of file size.
-   //---
-
-   if (!theFileHeader)
-   {
-      return;
-   }
-
-   const ossim_uint64 MB   = 1024 * 1024;
-   const ossim_uint64 MB50 = 50   * MB;
-   const ossim_uint64 GIG  = 1000 * MB;
-   const ossim_uint64 GIG2 = 2    * GIG;
-   
-   ossimString complexity = "03"; // Less than 50 mb.
-   
-
-   if ( (endPosition >= MB50) && (endPosition < GIG) )
-   {
-      complexity = "05";
-   }
-   else if ( (endPosition >= GIG) && (endPosition < GIG2) )
-   {
-      complexity = "06";
-   }
-   else if (endPosition >= GIG2)
-   {
-      complexity = "07";
-   }
-   
-   theFileHeader->setComplexityLevel(complexity);
-}
-
-
-void ossimNitf20Writer::addBlockaTag(ossimMapProjectionInfo& mapInfo)
-{
-   if (!theImageHeader)
-   {
-      return;
-   }
-
-   // Capture the current pixel type.
-   ossimPixelType originalPixelType = mapInfo.getPixelType();
-
-   // This tag wants corners as area:
-   mapInfo.setPixelType(OSSIM_PIXEL_IS_AREA);
-   
-   // Stuff the blocka tag which has six digit precision.
-   ossimNitfBlockaTag* blockaTag = new ossimNitfBlockaTag();
-   
-   // Set the block number.
-   blockaTag->setBlockInstance(1);
-
-   // Set the number of lines.
-   blockaTag->setLLines(mapInfo.linesPerImage());
-
-   // Set first row, first column.
-   blockaTag->setFrfcLoc(ossimDpt(mapInfo.ulGroundPt()));
-   
-   // Set first row, last column.
-   blockaTag->setFrlcLoc(ossimDpt(mapInfo.urGroundPt()));
-   
-   // Set last row, last column.
-   blockaTag->setLrlcLoc(ossimDpt(mapInfo.lrGroundPt()));
-   
-   // Set last row, first column.
-   blockaTag->setLrfcLoc(ossimDpt(mapInfo.llGroundPt()));
-   
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimNitf20Writer::writeGeometry DEBUG:"
-         << "\nBLOCKA Tag:" << *((ossimObject*)(blockaTag))
-         << std::endl;
-   }
-   
-   // Add the tag to the header.
-   ossimRefPtr<ossimNitfRegisteredTag> blockaTagRp = blockaTag;
-   ossimNitfTagInformation blockaTagInfo(blockaTagRp);
-   theImageHeader->addTag(blockaTagInfo);
-
-   // Reset the pixel type to original value
-   mapInfo.setPixelType(originalPixelType);
-}
-
-void ossimNitf20Writer::addRpcbTag(const ossimIrect& rect,
-                                 ossimRefPtr<ossimProjection> proj)
-{
-   if (!proj.valid())
-   {
-      return;
-   }
-
-   bool useElevation = false;
-
-   if (PTR_CAST(ossimMapProjection, proj.get()))
-   {
-      // If we're already map projected turn the elevation off.
-      useElevation = false;
-   }
-
-   // Make an rpc solver.
-   ossimRpcSolver rs(useElevation);
-   
-   // Compute the coefficients.
-   rs.solveCoefficients(ossimDrect(rect),
-                        *proj.get(),
-                        64,
-                        64);
-   
-   // Add the tag.
-   ossimRefPtr<ossimNitfRegisteredTag> tag = rs.getNitfRpcBTag();
-   ossimNitfTagInformation tagInfo(tag);
-   theImageHeader->addTag(tagInfo);
-   
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimNitf20Writer::addRpcbTag DEBUG:"
-         << "\nRPCB Tag:" << *((ossimObject*)(tag.get()))
-         << "\nProjection:" << std::endl;
-      
-      proj->print(ossimNotify(ossimNotifyLevel_DEBUG));
-      
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "\nRect: " << rect << std::endl;
-   }
-}
-
-ossim_uint32 ossimNitf20Writer::getActualBitsPerPixel() const
-{
-   ossim_uint32 actualBitsPerPixel = 0;
-   if (theInputConnection)
-   {
-      ossimScalarType scalarType = theInputConnection->getOutputScalarType();
-      switch(scalarType)
-      {
-         case OSSIM_UCHAR:
-         {
-            actualBitsPerPixel = 8;
-            break;
-         }
-         case OSSIM_USHORT11:
-         {
-            actualBitsPerPixel = 11;
-            break;
-         }
-         case OSSIM_USHORT16:
-         case OSSIM_SSHORT16:
-         {
-            actualBitsPerPixel = 16;
-            break;
-         }
-         case OSSIM_FLOAT:
-         case OSSIM_NORMALIZED_FLOAT:
-         {
-            actualBitsPerPixel = 32;
-            break;
-         }
-         case OSSIM_DOUBLE:
-         case OSSIM_NORMALIZED_DOUBLE:
-         {
-            actualBitsPerPixel = 64;
-            break;
-         }
-         default:
-         {
-            break;
-         }
-      }
-   }
-   
-   return actualBitsPerPixel;
-}
-
-ossim_uint32 ossimNitf20Writer::getBitsPerPixel() const
-{
-   ossim_uint32 bitsPerPixel = 0;
-
-   if (theInputConnection)
-   {
-      ossimScalarType scalarType = theInputConnection->getOutputScalarType();
-      switch(scalarType)
-      {
-         case OSSIM_UCHAR:
-         {
-            bitsPerPixel = 8;
-            break;
-         }
-         case OSSIM_USHORT11:
-         {
-            bitsPerPixel = 16;
-            break;
-         }
-         case OSSIM_USHORT16:
-         case OSSIM_SSHORT16:
-         {
-            bitsPerPixel = 16;
-            break;
-         }
-         case OSSIM_FLOAT:
-         case OSSIM_NORMALIZED_FLOAT:
-         {
-            bitsPerPixel = 32;
-            break;
-         }
-         case OSSIM_DOUBLE:
-         case OSSIM_NORMALIZED_DOUBLE:
-         {
-            bitsPerPixel = 64;
-            break;
-         }
-         default:
-         {
-            break;
-         }
-      }
-   }
-   return bitsPerPixel;
-}
-
-ossimString ossimNitf20Writer::getNitfPixelType() const
-{
-   ossimString pixelType;
-   if (theInputConnection)
-   {
-      ossimScalarType scalarType = theInputConnection->getOutputScalarType();
-      switch(scalarType)
-      {
-         case OSSIM_UCHAR:
-         case OSSIM_USHORT11:
-         case OSSIM_USHORT16:
-         {
-            pixelType = "INT";
-            break;
-         }
-         case OSSIM_SSHORT16:
-         {
-            pixelType    = "SI";
-            break;
-         }
-         case OSSIM_FLOAT:
-         case OSSIM_NORMALIZED_FLOAT:
-         case OSSIM_DOUBLE:
-         case OSSIM_NORMALIZED_DOUBLE:
-         {
-            pixelType    = "R";
-            break;
-         }
-         default:
-         {
-            break;
-         }
-      }
-   }
-   return pixelType;
-}
-
 bool ossimNitf20Writer::saveState(ossimKeywordlist& kwl,
-                                const char* prefix) const
+                                  const char* prefix) const
 {
-   kwl.add(prefix, "enable_rpcb_tag", theEnableRpcbTagFlag, true);
-   kwl.add(prefix, "enable_blocka_tag", theEnableBlockaTagFlag, true);
-
-   return ossimImageFileWriter::saveState(kwl, prefix);
+   return ossimNitfWriterBase::saveState(kwl, prefix);
 }
 
 bool ossimNitf20Writer::loadState(const ossimKeywordlist& kwl,
-                                const char* prefix)
+                                  const char* prefix)
 {
-   // Look for the rpcb enable flag keyword.
-   const char* lookup = kwl.find(prefix, "enable_rpcb_tag");
-   if(lookup)
-   {
-      ossimString os = lookup;
-      theEnableRpcbTagFlag = os.toBool();
-   }
-
-   // Look for the blocka enable flag keyword.
-   lookup = kwl.find(prefix, "enable_blocka_tag");
-   if(lookup)
-   {
-      ossimString os = lookup;
-      theEnableBlockaTagFlag = os.toBool();
-   }
-
-   return ossimImageFileWriter::loadState(kwl, prefix);
+   return ossimNitfWriterBase::loadState(kwl, prefix);
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp
index 43f0a36fc9331e0b319026cd78d93b1d31e87f38..3ad59cecbd8db4b7cc5751e79f5109b89effec76 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp
@@ -9,18 +9,12 @@
 // Description:  Contains class definition for ossimNitfTileSource.
 // 
 //*******************************************************************
-//  $Id: ossimNitfTileSource.cpp 14380 2009-04-20 22:23:24Z dburken $
+//  $Id: ossimNitfTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <jerror.h>
 
-#include <ossim/imaging/ossimNitfTileSource.h>
-
-#include <ossim/base/ossimPackedBits.h>
-#include <ossim/support_data/ossimNitfIchipbTag.h>
-#include <ossim/support_data/ossimNitfImageHeaderV2_0.h>
-#include <ossim/support_data/ossimNitfImageHeaderV2_1.h>
-#include <ossim/support_data/ossimNitfStdidcTag.h>
-#include <ossim/support_data/ossimNitfVqCompressionHeader.h>
+#include <algorithm> /* for std::fill */
 
+#include <ossim/imaging/ossimNitfTileSource.h>
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimCommon.h>
 #include <ossim/base/ossimTrace.h>
@@ -31,20 +25,27 @@
 #include <ossim/base/ossimFilename.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimInterleaveTypeLut.h>
+#include <ossim/base/ossimPackedBits.h>
 #include <ossim/base/ossimScalarTypeLut.h>
 #include <ossim/base/ossimEndian.h>
 #include <ossim/base/ossimBooleanProperty.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimJpegMemSrc.h>
 #include <ossim/imaging/ossimTiffTileSource.h>
-
-
+#include <ossim/base/ossim2dTo2dShiftTransform.h>
 #include <ossim/base/ossimContainerProperty.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/support_data/ossimNitfIchipbTag.h>
+#include <ossim/support_data/ossimNitfImageHeaderV2_0.h>
+#include <ossim/support_data/ossimNitfImageHeaderV2_1.h>
+#include <ossim/support_data/ossimNitfStdidcTag.h>
+#include <ossim/support_data/ossimNitfVqCompressionHeader.h>
+
 
 RTTI_DEF1_INST(ossimNitfTileSource, "ossimNitfTileSource", ossimImageHandler)
 
 #ifdef OSSIM_ID_ENABLED
-   static const char OSSIM_ID[] = "$Id: ossimNitfTileSource.cpp 14380 2009-04-20 22:23:24Z dburken $";
+   static const char OSSIM_ID[] = "$Id: ossimNitfTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
    
 //---
@@ -95,6 +96,7 @@ ossimNitfTileSource::ossimNitfTileSource()
       thePackedBitsFlag(false),
       theCompressedBuf(0),
       theDecimationFactor(1.0),
+      theDecimationFactors(),
       theNitfBlockOffset(0),
       theNitfBlockSize(0)
 {
@@ -132,18 +134,8 @@ void ossimNitfTileSource::destroy()
 
    theCacheTile = 0;
    theTile      = 0;
-
-   if(theOverview)
-   {
-      delete theOverview;
-      theOverview = 0;
-   }
-   if(theCompressedBuf)
-   {
-      delete [] theCompressedBuf;
-      theCompressedBuf = 0;
-   }
-}
+   theOverview = 0;
+ }
 
 bool ossimNitfTileSource::isOpen()const
 {
@@ -152,18 +144,31 @@ bool ossimNitfTileSource::isOpen()const
 
 bool ossimNitfTileSource::open()
 {
+   bool result = false;
+   
    if(isOpen())
    {
       close();
    }
    
    theErrorStatus = ossimErrorCodes::OSSIM_OK;
-
-   if ( !parseFile() )
+   
+   if ( parseFile() )
    {
-      return false;
+      result = allocate();
+   }
+   if (result)
+   {
+      completeOpen();
+
+      //---
+      // computeDecimationFactors must be called after completeOpen so that the
+      // overviews are picked up.
+      //---
+      result = computeDecimationFactors();
    }
-   return allocate();
+   
+   return result;
 }
 
 void ossimNitfTileSource::close()
@@ -234,7 +239,7 @@ bool ossimNitfTileSource::parseFile()
    //---
    for (ossim_uint32 i = 0; i < theNumberOfImages; ++i)
    {
-      ossimNitfImageHeader* hdr = theNitfFile->getNewImageHeader(i);
+      ossimRefPtr<ossimNitfImageHeader> hdr = theNitfFile->getNewImageHeader(i);
       if (!hdr)
       {
          setErrorStatus();
@@ -248,7 +253,7 @@ bool ossimNitfTileSource::parseFile()
       }
       if (traceDebug())
       {
-         if(hdr)
+         if(hdr.valid())
          {
             ossimNotify(ossimNotifyLevel_DEBUG)
                << MODULE << "DEBUG:"
@@ -266,7 +271,7 @@ bool ossimNitfTileSource::parseFile()
             theNitfImageHeader.push_back(hdr);
          }
       }
-      else if ( canUncompress(hdr) )
+      else if ( canUncompress(hdr.get()) )
       {
          theEntryList.push_back(i);
          theCacheEnabledFlag = true;
@@ -288,10 +293,6 @@ bool ossimNitfTileSource::parseFile()
    {
       return false;
    }
-   if(theNitfImageHeader.size() == 1)
-   {
-      theLut = theNitfImageHeader[0]->createLut(0);
-   }
    if(theEntryList.size()>0)
    {
       theCurrentEntry = theEntryList[0];
@@ -321,7 +322,14 @@ bool ossimNitfTileSource::parseFile()
          theCurrentEntry = theEntryList[0];
       }
    }
-
+   
+   // initialize the lut to the current entry if the current entry has a lut.
+   //
+   if(theNitfImageHeader[theCurrentEntry]->getRepresentation().contains("LUT"))
+   {
+      theLut = theNitfImageHeader[theCurrentEntry]->createLut(0);
+   }
+   
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -390,12 +398,6 @@ bool ossimNitfTileSource::allocate()
 
    // Set the decimation factor.
    initializeDecimationFactor();
-
-   // Initialize the sub image offset.
-   if (initializeSubImageOffset() == false)
-   {
-      return false;
-   }
    
    // Initialize the image rectangle. before the cache size is done
    if (initializeImageRect() == false)
@@ -420,7 +422,6 @@ bool ossimNitfTileSource::allocate()
       return false;
    }
 
-
    // Initialize the cache tile interleave type.
    initializeCacheTileInterLeaveType();
    if (theCacheTileInterLeaveType == OSSIM_INTERLEAVE_UNKNOWN)
@@ -455,9 +456,6 @@ bool ossimNitfTileSource::allocate()
    //---
    initializeOutputTile();
 
-   // Call base class complete open.
-   completeOpen();
-
    return true;
 }
 
@@ -470,7 +468,20 @@ bool ossimNitfTileSource::canUncompress(const ossimNitfImageHeader* hdr) const
       
       if (code == "C3") // jpeg
       {
-         result = true;
+         if (hdr->getBitsPerPixelPerBand() == 8)
+         {
+            result = true;
+         }
+         else
+         {
+            if(traceDebug())
+            {
+               ossimNotify(ossimNotifyLevel_DEBUG)
+                  << "Entry with jpeg compression (C3) has an unsupported "
+                  << "JPEG data precision: " << hdr->getBitsPerPixelPerBand()
+                  << std::endl;
+            }
+         }
       }
       else if(isVqCompressed( code ) &&
               (hdr->getCompressionHeader().valid()) )
@@ -502,7 +513,7 @@ void ossimNitfTileSource::initializeReadMode()
    ossimString imode           = hdr->getIMode();
    ossimString compressionCode = hdr->getCompressionCode();
 
-   if ( (imode == "B") && (compressionCode == "C3") )
+   if ( (compressionCode == "C3") && ((imode == "B")||(imode == "P")) )
    {
       theReadMode = READ_JPEG_BLOCK; 
    }
@@ -640,6 +651,13 @@ void ossimNitfTileSource::initializeScalarType()
                theScalarType = OSSIM_FLOAT32;
             }
          }
+         else
+         {
+            if(bitsPerPixel<8)
+            {
+               theScalarType = OSSIM_UINT8;
+            }
+         }
          break;
       }
    }
@@ -831,126 +849,161 @@ bool ossimNitfTileSource::initializeBlockSize()
 
 void ossimNitfTileSource::initializeDecimationFactor()
 {
-   theDecimationFactor = 1.0;
-   
    const ossimNitfImageHeader* hdr = getCurrentImageHeader();
-   if (!hdr)
+   if (hdr)
    {
-      return;
+      hdr->getDecimationFactor(theDecimationFactor);
    }
 
-   //---
-   // Look for string like:
-   // "/2" = 1/2
-   // "/4  = 1/4
-   // ...
-   // "/16 = 1/16
-   // If it is full resolution it should be "1.0"
-   //---
-   ossimString os = hdr->getImageMagnification();
-   if ( os.contains("/") )
+   if ( !hdr || ossim::isnan(theDecimationFactor) )
    {
-      os = os.after("/");
-      ossim_float64 d = os.toFloat64();
-      if (d)
-      {
-         theDecimationFactor = 1.0 / d;
-      }
+      theDecimationFactor = 1.0;
    }
 }
 
-bool ossimNitfTileSource::initializeSubImageOffset()
+#if 0
+ossimImageGeometry* ossimNitfTileSource::getImageGeometry()
 {
-   // Start with nan offset.
-   theSubImageOffset.makeNan();
-   
-   const ossimNitfImageHeader* hdr = getCurrentImageHeader();
-   if (!hdr)
-   {
-      return false;
-   }
-
    //---
-   // Look for the STDIDC tag for a sub image offset.
-   //
-   // See: STDI-002 Table 7.3 for documentation.
+   // Call base class getImageGeometry which will check for external geometry
+   // or an already set geometry.
    //---
-   ossimRefPtr<ossimNitfRegisteredTag> tag =
-      hdr->getTagData(ossimString("STDIDC"));
-   if (tag.valid() && (hdr->getIMode() == "B") )
-   {
-      ossimNitfStdidcTag* stdidc = PTR_CAST(ossimNitfStdidcTag, tag.get());
-      if (stdidc)
-      {
-         ossim_int32 startCol = stdidc->getStartColumn().toInt32();
-         ossim_int32 startRow = stdidc->getStartRow().toInt32();
-         if ( (startCol > 0) && (startRow > 0) )
-         {
-            // field are one based; hence, the - 1.
-            theSubImageOffset.x =
-               (startCol-1) * hdr->getNumberOfPixelsPerBlockHoriz();
-            theSubImageOffset.y =
-               (startRow-1) * hdr->getNumberOfPixelsPerBlockVert();
-         }
-      }
-   }
+   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
 
-   if (theSubImageOffset.hasNans())
+   if (result)
    {
-      //---
-      // Test for the ichipb tag and set the sub image if needed.
-      // 
-      // NOTE:
-      // 
-      // There are nitf writers that set the ichipb offsets and only have
-      // IGEOLO field present.  For these it has been determined
-      // (but still in question) that we should not apply the sub image offset.
-      //
-      // See trac # 1578
-      // http://trac.osgeo.org/ossim/ticket/1578
-      //---
-      tag = hdr->getTagData(ossimString("ICHIPB"));
-      if (tag.valid())
+      if ( !result->getTransform() )
       {
-         ossimNitfIchipbTag* ichipb = PTR_CAST(ossimNitfIchipbTag, tag.get());
-         if (ichipb)
+         ossimRefPtr<ossim2dTo2dTransform> transform = 0;
+         
+         const ossimNitfImageHeader* hdr = getCurrentImageHeader();
+         if (hdr)
          {
-            const ossimRefPtr<ossimNitfRegisteredTag> blocka =
-               hdr->getTagData(ossimString("BLOCKA"));
-            const ossimRefPtr<ossimNitfRegisteredTag> rpc00a =
-               hdr->getTagData(ossimString("RPC00A"));              
-            const ossimRefPtr<ossimNitfRegisteredTag> rpc00b =
-               hdr->getTagData(ossimString("RPC00B"));
-            
             //---
-            // If any of these tags are present we will use the sub image from
-            // the ichipb tag.
+            // Test for the ichipb tag and set the sub image if needed.
+            // 
+            // NOTE # 1:
+            // 
+            // There are nitf writers that set the ichipb offsets and only have
+            // IGEOLO field present.  For these it has been determined
+            // (but still in question) that we should not apply the sub image
+            // offset.
+            //
+            // See trac # 1578
+            // http://trac.osgeo.org/ossim/ticket/1578
+            //
+            // NOTE # 2:
+            //
+            // Let the ICHIPB have precedence over the STDIDC tag as we could
+            // have a chip of a segment.
             //---
-            if ( blocka.get() || rpc00a.get() || rpc00b.get() )
+            ossimRefPtr<ossimNitfRegisteredTag> tag =
+               hdr->getTagData(ossimString("ICHIPB"));
+            if (tag.valid())
             {
-               ossimDpt pt;
-               ichipb->getSubImageOffset(pt);
-               theSubImageOffset = pt;
+               ossimNitfIchipbTag* ichipb =
+                  PTR_CAST(ossimNitfIchipbTag, tag.get());
+               if (ichipb)
+               {
+                  const ossimRefPtr<ossimNitfRegisteredTag> blocka =
+                     hdr->getTagData(ossimString("BLOCKA"));
+                  const ossimRefPtr<ossimNitfRegisteredTag> rpc00a =
+                     hdr->getTagData(ossimString("RPC00A"));              
+                  const ossimRefPtr<ossimNitfRegisteredTag> rpc00b =
+                     hdr->getTagData(ossimString("RPC00B"));
+                  
+                  //---
+                  // If any of these tags are present we will use the sub
+                  // image from the ichipb tag.
+                  //---
+                  if ( blocka.get() || rpc00a.get() || rpc00b.get() )
+                  {
+                     transform = ichipb->newTransform();
+                  }
+               }
             }
+   
+            if ( !transform)
+            {
+               //---
+               // Look for the STDIDC tag for a sub image (segment) offset.
+               //
+               // See: STDI-002 Table 7.3 for documentation.
+               //---
+               tag = hdr->getTagData(ossimString("STDIDC"));
+               if (tag.valid() && (hdr->getIMode() == "B") )
+               {
+                  ossimDpt shift;
+                  ossimNitfStdidcTag* stdidc =
+                     PTR_CAST(ossimNitfStdidcTag, tag.get());
+                  if (stdidc)
+                  {
+                     ossim_int32 startCol = stdidc->getStartColumn().toInt32();
+                     ossim_int32 startRow = stdidc->getStartRow().toInt32();
+                     if ( (startCol > 0) && (startRow > 0) )
+                     {
+                        
+                        // field are one based; hence, the - 1.
+                        shift.x = (startCol-1) *
+                           hdr->getNumberOfPixelsPerBlockHoriz();
+                        shift.y = (startRow-1) *
+                           hdr->getNumberOfPixelsPerBlockVert();
+                     }
+                     if(shift.x > 0 ||
+                        shift.y > 0)
+                     {
+                        transform = new ossim2dTo2dShiftTransform(shift);
+                     }
+                  }
+               }
+            }
+            
+         } // matches: if (hdr)
+
+         if ( transform.valid() )
+         {
+            result->setTransform( transform.get() );
          }
-      }
-   }
+         //else
+         //{
+         //   ossimImageGeometryRegistry::instance()->createTransform(this);
+         //}
+         
+         
+      } // matches: if ( !result->getTransform() )
 
-   // If still nan set to upper left corner (typically 0,0):
-   if (theSubImageOffset.hasNans())
-   {
-      theSubImageOffset = hdr->getImageRect().ul();
-   }
+      if ( !result->getProjection() )
+      {
+         ossimRefPtr<ossimProjection> proj =
+            ossimProjectionFactoryRegistry::instance()->
+               createProjection(this);
+         if ( proj.valid() )
+         {
+            result->setProjection( proj.get() );
+         }
+         //else
+         //{
+         //   ossimImageGeometryRegistry::instance()->createProjection(this);
+         //}
+         
+      }
+      
+   } // matches: if (result)
 
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimNitfTileSource::initializeSubImageOffset DEBUG:"
-         << "\nSub image offset:  " << theSubImageOffset
-         << endl;
+         << "ossimNitfTileSource::createImageGeometry DEBUG:\n";
+
+      if (result)
+      {
+         result->print(ossimNotify(ossimNotifyLevel_DEBUG)) << "\n";
+      }
    }
-   return true;
+
+   return result;
 }
+#endif
 
 bool ossimNitfTileSource::initializeImageRect()
 {
@@ -960,35 +1013,10 @@ bool ossimNitfTileSource::initializeImageRect()
       theImageRect.makeNan();
       return false;
    }
-
-   bool initialized = false;
-
-   const ossimRefPtr<ossimNitfRegisteredTag> tag =
-      hdr->getTagData(ossimString("ICHIPB"));
-   if (tag.valid())
-   {
-      ossimNitfIchipbTag* ichipb = PTR_CAST(ossimNitfIchipbTag, tag.get());
-      if (ichipb)
-      {
-         // This has the sub image offset applied...
-         ossimDrect rect;
-         ichipb->getFullImageRect(rect);
-         
-         theBlockImageRect = rect;
-         theImageRect      = rect;
-         initialized       = true;
-      }
-   }
-
-   if (!initialized)
-   {
-      theBlockImageRect = hdr->getBlockImageRect();
-      theImageRect      = hdr->getImageRect();
-      
-      theBlockImageRect += theSubImageOffset;
-      theImageRect      += theSubImageOffset;
-   }
-
+   
+   theBlockImageRect = hdr->getBlockImageRect();
+   theImageRect      = hdr->getImageRect();
+   
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -1061,12 +1089,12 @@ void ossimNitfTileSource::initializeCacheTileInterLeaveType()
       case READ_BIB_BLOCK:
       case READ_BSQ_BLOCK:
       case READ_BIB:
+      case READ_JPEG_BLOCK:  
          theCacheTileInterLeaveType = OSSIM_BSQ;
          break;
 
       case READ_BIP_BLOCK:
       case READ_BIP:
-      case READ_JPEG_BLOCK:
          theCacheTileInterLeaveType = OSSIM_BIP;
          break;
 
@@ -1111,17 +1139,11 @@ void ossimNitfTileSource::initializeCompressedBuf()
       return;
    }
 
-   if(theCompressedBuf)
-   {
-      delete [] theCompressedBuf;
-      theCompressedBuf = 0;
-   }
-
    if( (hdr->getRepresentation().upcase().contains("LUT")) ||
        ( isVqCompressed(hdr->getCompressionCode()) ) )
    {
-      theCompressedBuf = new ossim_uint8[theReadBlockSizeInBytes];
-      memset(theCompressedBuf, '\0', theReadBlockSizeInBytes);
+      theCompressedBuf.resize(theReadBlockSizeInBytes);
+      std::fill(theCompressedBuf.begin(), theCompressedBuf.end(), '\0');
    }
 }
 
@@ -1143,71 +1165,67 @@ ossimRefPtr<ossimImageData> ossimNitfTileSource::getTile(
       return ossimRefPtr<ossimImageData>();
    }
 
-   if (theOverview)
+   if (!theTile.valid())
    {
-      if (theOverview->hasR0() || resLevel)
-      {
-         // Subtract any offsets since the overview doesn't know about them.
-         ossimIrect rr_rect = tileRect - getSubImageOffset(resLevel);
+      return theTile;
+   }
+
+   // Rectangle must be set prior to getOverviewTile call.
+   theTile->setImageRectangle(tileRect);
 
+   if (resLevel)
+   {
+      if ( getOverviewTile(resLevel, theTile.get() ) )
+      {
+         return theTile;
+      }
+   }
+   
+   ossim_uint32 level = resLevel;
+   if (theStartingResLevel)  // Used as overview.
+   {
+      if (theStartingResLevel <= resLevel)
+      {
          //---
-         // If there is a sub image offset then we will not be requesting
-         // the same rectangle as was requested from us.  For this reason,
-         // we'll do a setOrigin, rather than just returning the getTile
-         // result.
+         // Adjust the level to be relative to the reader using this as
+         // overview.
          //---
-         ossimRefPtr<ossimImageData> tileData = theOverview->getTile(rr_rect,
-                                                                     resLevel);
-         if(tileData.valid())
-         {
-            tileData->setImageRectangle(tileRect);
-         
-            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.  
-               //---
-               tileData->setScalarType(OSSIM_USHORT11);
-            }
-         }
-         
-         return tileData;
+         level -= theStartingResLevel; 
       }
    }
 
-   if (!theTile.valid())
+   //---
+   // See if the whole tile is going to be filled, if not, start out with
+   // a blank tile so data from a previous load gets wiped out.
+   //---
+   if ( !tileRect.completely_within(theImageRect) )
    {
-      return theTile;
+      // Start with a blank tile.
+      theTile->makeBlank();
    }
    
-   theTile->setImageRectangle(tileRect);
-   
    //---
    // See if any point of the requested tile is in the image.
    //---
    if ( tileRect.intersects(theBlockImageRect) )
    {
       ossimIrect clipRect = tileRect.clipToRect(theImageRect);
-
-      //---
-      // See if the whole tile is going to be filled, if not, start out with
-      // a blank tile so data from a previous load gets wiped out.
-      //---
-      if ( !tileRect.completely_within(clipRect) )
-      {
-         // Start with a blank tile.
-         theTile->makeBlank();
-      }
             
       // See if the requested clip rect is already in the cache tile.
       if ( (clipRect.completely_within(theCacheTile->getImageRectangle()))&&
            (theCacheTile->getDataObjectStatus() != OSSIM_EMPTY)&&
            (theCacheTile->getBuf()))
       {
+         //---
+         // Note: Clip the cache tile(nitf block) to the image clipRect since
+         // there are nitf blocks that go beyond the image dimensions, i.e.,
+         // edge blocks.
+         //---        
+         ossimIrect cr =
+               theCacheTile->getImageRectangle().clipToRect(clipRect);
          theTile->loadTile(theCacheTile->getBuf(),
                            theCacheTile->getImageRectangle(),
+                           cr,
                            theCacheTileInterLeaveType);
          //---
          // Validate the tile.  This will set the status to full, partial
@@ -1229,23 +1247,21 @@ ossimRefPtr<ossimImageData> ossimNitfTileSource::getTile(
          }
          else
          {
+            ossimNotify(ossimNotifyLevel_WARN)
+               << __FILE__ << __LINE__
+               << " loadTile failed!"
+               << std::endl;
             theTile->makeBlank(); // loadTile failed...
          }
       }
    } // End of if ( tileRect.intersects(image_rect) )
-   else
-   {
-      // No part of requested tile within the image rectangle.
-      theTile->makeBlank();
-   }
 
    return theTile;   
 }
 
 bool ossimNitfTileSource::loadTile(const ossimIrect& clipRect)
 {
-   // Subtract any offsets and work in zero based image space.
-   ossimIrect zbClipRect  = clipRect - theSubImageOffset;
+   ossimIrect zbClipRect  = clipRect;
 
    const ossim_uint32 BLOCK_HEIGHT = theCacheSize.y;
    const ossim_uint32 BLOCK_WIDTH  = theCacheSize.x;
@@ -1257,8 +1273,7 @@ bool ossimNitfTileSource::loadTile(const ossimIrect& clipRect)
    // block boundry.  
    //---
    ossimIpt nitfBlockOrigin = zbClipRect.ul();
-//   adjustToStartOfBlock(nitfBlockOrigin, BLOCK_HEIGHT, BLOCK_WIDTH);
-   
+
    // Vertical block loop.
    ossim_int32 y = nitfBlockOrigin.y;
    while (y < zbClipRect.lr().y)
@@ -1267,16 +1282,28 @@ bool ossimNitfTileSource::loadTile(const ossimIrect& clipRect)
       ossim_int32 x = nitfBlockOrigin.x;
       while (x < zbClipRect.lr().x)
       {
-         if (loadBlock(x, y))
+         if ( loadBlockFromCache(x, y, clipRect) == false )
          {
-            theTile->loadTile(theCacheTile->getBuf(),
-                              theCacheTile->getImageRectangle(),
-                              theCacheTileInterLeaveType);
-         }
-         else
-         {
-            // Error loading...
-            return false;
+            if ( loadBlock(x, y) )
+            {
+               //---
+               // Note: Clip the cache tile(nitf block) to the image clipRect
+               // since there are nitf blocks that go beyond the image
+               // dimensions, i.e., edge blocks.
+               //---    
+               ossimIrect cr =
+                  theCacheTile->getImageRectangle().clipToRect(clipRect);
+               
+               theTile->loadTile(theCacheTile->getBuf(),
+                                 theCacheTile->getImageRectangle(),
+                                 cr,
+                                 theCacheTileInterLeaveType);
+            }
+            else
+            {
+               // Error loading...
+               return false;
+            }
          }
          
          x += BLOCK_WIDTH; // Go to next block.
@@ -1288,6 +1315,42 @@ bool ossimNitfTileSource::loadTile(const ossimIrect& clipRect)
    return true;
 }
 
+bool ossimNitfTileSource::loadBlockFromCache(ossim_uint32 x, ossim_uint32 y,
+                                             const ossimIrect& clipRect)
+{
+   bool result = false;
+   
+   if (theCacheEnabledFlag)
+   {
+      //---
+      // The origin set in the cache tile must have the sub image offset in it
+      // since "theTile" is relative to any sub image offset.  This is so that
+      // "theTile->loadTile(theCacheTile)" will work.
+      //---
+      ossimIpt origin(x, y);
+
+      ossimRefPtr<ossimImageData> tempTile =
+         ossimAppFixedTileCache::instance()->getTile(theCacheId, origin);
+      if (tempTile.valid())
+      {
+         //---
+         // Note: Clip the cache tile(nitf block) to the image clipRect since
+         // there are nitf blocks that go beyond the image dimensions, i.e.,
+         // edge blocks.
+         //---    
+         ossimIrect cr =
+            tempTile->getImageRectangle().clipToRect(clipRect);
+
+         theTile->loadTile(tempTile.get()->getBuf(),
+                           tempTile->getImageRectangle(),
+                           cr,
+                           theCacheTileInterLeaveType);
+         result = true;
+      }
+   }
+   return result;
+}
+
 bool ossimNitfTileSource::loadBlock(ossim_uint32 x, ossim_uint32 y)
 {
 #if 0
@@ -1305,21 +1368,7 @@ bool ossimNitfTileSource::loadBlock(ossim_uint32 x, ossim_uint32 y)
    // "theTile->loadTile(theCacheTile)" will work.
    //---
    ossimIpt origin(x, y);
-   origin = origin + theSubImageOffset;
-   
-   if (theCacheEnabledFlag)
-   {
-      // See if it's in the cache already.
-      ossimRefPtr<ossimImageData> tempTile = 0;
-      tempTile = ossimAppFixedTileCache::instance()->
-         getTile(theCacheId, origin);
-      if (tempTile.valid())
-      {
-         theTile->loadTile(tempTile.get());
-         return true;
-      }
-   }
-   
+    
    const ossimNitfImageHeader* hdr = getCurrentImageHeader();
    theCacheTile->setOrigin(origin);
    ossim_uint32 readSize = theReadBlockSizeInBytes;
@@ -1374,7 +1423,7 @@ bool ossimNitfTileSource::loadBlock(ossim_uint32 x, ossim_uint32 y)
             if(isVqCompressed(hdr->getCompressionCode())||
                hdr->getRepresentation().upcase().contains("LUT"))
             {
-               buf = theCompressedBuf;
+               buf = (ossim_uint8*)&(theCompressedBuf.front());
             }
             else
             {
@@ -1395,11 +1444,13 @@ bool ossimNitfTileSource::loadBlock(ossim_uint32 x, ossim_uint32 y)
                }
                else if(isVqCompressed(hdr->getCompressionCode()))
                {
-                  vqUncompress(theCacheTile, theCompressedBuf);
+                  vqUncompress(theCacheTile,
+                               (ossim_uint8*)&(theCompressedBuf.front()));
                }
                else if(hdr->getRepresentation().upcase().contains("LUT"))
                {
-                  lutUncompress(theCacheTile, theCompressedBuf);
+                  lutUncompress(theCacheTile,
+                                (ossim_uint8*)&(theCompressedBuf.front()));
                }
             }
          }
@@ -1532,7 +1583,7 @@ void ossimNitfTileSource::convertTransparentToNull(ossimRefPtr<ossimImageData> t
    if(!hdr||!tile) return;
 
    if(!tile->getBuf()) return;
-   ossimIpt tempOrigin = tile->getOrigin()-theSubImageOffset;
+   ossimIpt tempOrigin = tile->getOrigin();
    ossim_uint32 blockNumber = getBlockNumber(tempOrigin);
    ossim_uint32 numberOfBands = tile->getNumberOfBands();
    ossim_uint32 band = 0;
@@ -1950,61 +2001,38 @@ ossim_uint32 ossimNitfTileSource::getNumberOfOutputBands() const
 
 ossim_uint32 ossimNitfTileSource::getNumberOfLines(ossim_uint32 resLevel) const
 {
+   ossim_uint32 result = 0;
    if (resLevel == 0)
    {
       const ossimNitfImageHeader* hdr = getCurrentImageHeader();
-      if (!hdr)
+      if (hdr)
       {
-         return 0;
+         result = hdr->getNumberOfRows();
       }
-      return  hdr->getNumberOfRows();
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
-      return theOverview->getNumberOfLines(resLevel);
+      result = theOverview->getNumberOfLines(resLevel);
    }
-   return 0;
+   return result;
 }
 
 ossim_uint32 ossimNitfTileSource::getNumberOfSamples(ossim_uint32 resLevel) const
 {
+   ossim_uint32 result = 0;
    if (resLevel == 0)
    {
       const ossimNitfImageHeader* hdr = getCurrentImageHeader();
-      if (!hdr)
+      if (hdr)
       {
-         return 0;
+         result = hdr->getNumberOfCols();
       }
-      return  hdr->getNumberOfCols();
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
-      return theOverview->getNumberOfSamples(resLevel);
-   }
-   return 0;
-}
-
-void ossimNitfTileSource::adjustToStartOfBlock(ossimIpt& pt,
-                                               ossim_int32 tile_height,
-                                               ossim_int32 tile_width) const
-{
-   if (pt.x > 0)
-   {
-      pt.x = pt.x/tile_width*tile_width;
-   }
-   else if (pt.x < 0)
-   {
-      pt.x = (pt.x-tile_width)/tile_width*tile_width;
-   }
-
-   if (pt.y > 0)
-   {
-      pt.y = pt.y/tile_height*tile_height;
-   }
-   else if (pt.y < 0)
-   {
-      pt.y = (pt.y-tile_height)/tile_height*tile_height;
+      result = theOverview->getNumberOfSamples(resLevel);
    }
+   return result;
 }
 
 ossim_uint32 ossimNitfTileSource::getBlockNumber(const ossimIpt& block_origin) const
@@ -2014,7 +2042,7 @@ ossim_uint32 ossimNitfTileSource::getBlockNumber(const ossimIpt& block_origin) c
    const ossimNitfImageHeader* hdr = getCurrentImageHeader();
    if (!hdr)
    {
-      return blockNumber;
+      return blockNumber; 
    }
 
    ossim_uint32 blockY;
@@ -2137,7 +2165,7 @@ ossimString ossimNitfTileSource::getLongName()const
    return ossimString("nitf reader");
 }
 
-ossimString ossimNitfTileSource::className()const
+ossimString ossimNitfTileSource::getClassName()const
 {
    return ossimString("ossimNitfTileSource");
 }
@@ -2172,8 +2200,8 @@ bool ossimNitfTileSource::setCurrentEntry(ossim_uint32 entryIdx)
       {
          if ( entryIdx < theNumberOfImages )
          {
-            // Must clear or getImageGeometry method will use last entries.
-            theGeometryKwl.clear();
+            // Clear the geometry.
+            theGeometry = 0;
             
             // Must clear or openOverview will use last entries.
             theOverviewFile.clear();
@@ -2185,6 +2213,17 @@ bool ossimNitfTileSource::setCurrentEntry(ossim_uint32 entryIdx)
             // need to reinitialize some things.
             //---
             result = allocate();
+            if (result)
+            {
+               completeOpen();
+
+               //---
+               // computeDecimationFactors must be called after completeOpen
+               // so that the
+               // overviews are picked up.
+               //---
+               result = computeDecimationFactors();
+            }
          }
          else
          {
@@ -2200,7 +2239,15 @@ bool ossimNitfTileSource::setCurrentEntry(ossim_uint32 entryIdx)
          theCurrentEntry = entryIdx;
       }
    }
-
+   
+   if(result)
+   {
+      if(theNitfImageHeader[theCurrentEntry]->getRepresentation().contains("LUT"))
+      {
+         theLut = theNitfImageHeader[theCurrentEntry]->createLut(0);
+      }
+      
+   }
    return result;
 }
 
@@ -2238,7 +2285,17 @@ const ossimNitfFileHeader* ossimNitfTileSource::getFileHeader()const
 {
    if(theNitfFile.valid())
    {
-      return theNitfFile->getHeader().get();
+      return theNitfFile->getHeader();
+   }
+   
+   return 0;
+}
+
+ossimNitfFileHeader* ossimNitfTileSource::getFileHeader()
+{
+   if(theNitfFile.valid())
+   {
+      return theNitfFile->getHeader();
    }
    
    return 0;
@@ -2246,33 +2303,112 @@ const ossimNitfFileHeader* ossimNitfTileSource::getFileHeader()const
 
 const ossimNitfImageHeader* ossimNitfTileSource::getCurrentImageHeader() const
 {
-   return theNitfImageHeader[theCurrentEntry].get();
+   if(theNitfImageHeader.size())
+   {
+      return theNitfImageHeader[theCurrentEntry].get();
+   }
+   
+   return 0;
+}
+
+ossimNitfImageHeader* ossimNitfTileSource::getCurrentImageHeader()
+{
+   if(theNitfImageHeader.size())
+   {
+      return theNitfImageHeader[theCurrentEntry].get();
+   }
+   
+   return 0;
 }
 
 void ossimNitfTileSource::getDecimationFactor(ossim_uint32 resLevel,
                                               ossimDpt& result) const
 {
-   if (resLevel == 0)
+   if (resLevel < theDecimationFactors.size())
    {
-      result.x = theDecimationFactor;
-      result.y = theDecimationFactor;
+      result.x = theDecimationFactors[resLevel].x;
+      result.y = theDecimationFactors[resLevel].y;
    }
    else
    {
-      result.x = theDecimationFactor /
-         pow( static_cast<ossim_float64>(2.0),
-              static_cast<ossim_float64>(resLevel) );
-      result.y = result.x;
+      result.makeNan();
    }
 }
 
+bool ossimNitfTileSource::computeDecimationFactors()
+{
+   bool result = true;
+   
+   theDecimationFactors.clear();
+   
+   const ossim_uint32 LEVELS = getNumberOfDecimationLevels();
+
+   for (ossim_uint32 level = 0; level < LEVELS; ++level)
+   {
+      ossimDpt pt;
+      
+      if (level == 0)
+      {
+         pt.x = theDecimationFactor;
+         pt.y = theDecimationFactor;
+      }
+      else
+      {
+         /* 
+            ESH 02/2009 -- No longer assume powers of 2 reduction 
+            in linear size from resLevel 0 (Tickets # 467,529).
+         */
+         
+         // Get the sample decimation.
+         ossim_float64 r0 = getNumberOfSamples(0);
+         ossim_float64 rL = getNumberOfSamples(level);
+         if ( (r0 > 0.0) && (rL > 0.0) )
+         {
+            pt.x = theDecimationFactor * rL / r0;
+         }
+         else
+         {
+            result = false;
+            break;
+         }
+
+         // Get the line decimation.
+         r0 = getNumberOfLines(0);
+         rL = getNumberOfLines(level);
+         if ( (r0 > 0.0) && (rL > 0.0) )
+         {
+            pt.y = theDecimationFactor * rL / r0;
+         }
+         else
+         {
+            result = false;
+            break;
+         }
+      }
+
+      theDecimationFactors.push_back(pt);
+   }
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "ossimNitfTileSource::computeDecimationFactors DEBUG\n";
+      for (ossim_uint32 i = 0; i < theDecimationFactors.size(); ++i)
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "decimation[" << i << "]: " << theDecimationFactors[i]
+            << std::endl;
+      }
+   }
+   
+   return result;
+}
+
 void ossimNitfTileSource::setBoundingRectangle(const ossimIrect& imageRect)
 {
    theImageRect = imageRect;
-   theSubImageOffset = theImageRect.ul();
-   
    // now shift the internal block rect as well
-   theBlockImageRect = (theBlockImageRect - theBlockImageRect.ul()) + theSubImageOffset;
+   theBlockImageRect = (theBlockImageRect - theBlockImageRect.ul());
 }
 
 ossimRefPtr<ossimProperty> ossimNitfTileSource::getProperty(const ossimString& name)const
@@ -2286,7 +2422,7 @@ ossimRefPtr<ossimProperty> ossimNitfTileSource::getProperty(const ossimString& n
    {
       if(theNitfFile.valid())
       {
-         if(theNitfFile->getHeader().valid())
+         if(theNitfFile->getHeader())
          {
             ossimRefPtr<ossimProperty> p = theNitfFile->getHeader()->getProperty(name);
             if(p.valid())
@@ -2334,7 +2470,7 @@ void ossimNitfTileSource::getPropertyNames(std::vector<ossimString>& propertyNam
 {
    ossimImageHandler::getPropertyNames(propertyNames);
    propertyNames.push_back(ossimKeywordNames::ENABLE_CACHE_KW);
-   if(theNitfFile->getHeader().valid())
+   if(theNitfFile->getHeader())
    {
       theNitfFile->getHeader()->getPropertyNames(propertyNames);
    }
@@ -2552,23 +2688,32 @@ bool ossimNitfTileSource::scanForJpegBlockOffsets()
    while ( theFileStr.get(c) ) 
    {
       ++blockSize;
-      if (static_cast<ossim_uint8>(c) == 0xff)
+      if (static_cast<ossim_uint8>(c) == 0xff) // Found FF byte.
       {
-         if ( theFileStr.get(c) )
+         //---
+         // Loop to skip multiple 0xff's in cases like FF FF D8
+         //---
+         while ( theFileStr.get(c) )
          {
             ++blockSize;
-
-            if (static_cast<ossim_uint8>(c) == 0xd8) // At SOI marker...
-            {
-               std::streamoff pos = theFileStr.tellg();
-               theNitfBlockOffset.push_back(pos-2);
-            }
-            else if (static_cast<ossim_uint8>(c) == 0xd9) // At EOI marker...
+            if (static_cast<ossim_uint8>(c) != 0xff)
             {
-               theNitfBlockSize.push_back(blockSize);
-               blockSize = 0;
+               break;
             }
          }
+         
+         if (static_cast<ossim_uint8>(c) == 0xd8) 
+         {
+            // At SOI 0xFFD8 marker...
+            std::streamoff pos = theFileStr.tellg();
+            theNitfBlockOffset.push_back(pos-2);
+         }
+         else if (static_cast<ossim_uint8>(c) == 0xd9)
+         {
+            // At EOI 0xD9marker...
+            theNitfBlockSize.push_back(blockSize);
+            blockSize = 0;
+         }
       }
    }
 
@@ -2629,17 +2774,15 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
    theFileStr.seekg(theNitfBlockOffset[blockNumber], ios::beg);
    
    // Read the block into memory.
-   ossim_uint8* compressedBuf = new ossim_uint8[theNitfBlockSize[blockNumber]];
-   
-   if (!theFileStr.read((char*)compressedBuf, theNitfBlockSize[blockNumber]))
+   std::vector<ossim_uint8> compressedBuf(theNitfBlockSize[blockNumber]);
+   if (!theFileStr.read((char*)&(compressedBuf.front()),
+                        theNitfBlockSize[blockNumber]))
    {
       theFileStr.clear();
       ossimNotify(ossimNotifyLevel_FATAL)
-         << "ossimNitfTileSource::loadBlock Read Error!"
+         << "ossimNitfTileSource::uncompressJpegBlock Read Error!"
          << "\nReturning error..." << endl;
       theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
-      delete [] compressedBuf;
-      compressedBuf = 0;
       return false;
    }
 
@@ -2671,8 +2814,6 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
        * We need to clean up the JPEG object, close the input file, and return.
        */
      jpeg_destroy_decompress(&cinfo);
-     delete [] compressedBuf;
-     compressedBuf = 0;
      return false;
    }
 
@@ -2684,7 +2825,7 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
    // memory so we will use "ossimJpegMemorySrc" in place of " jpeg_stdio_src".
    //---
    ossimJpegMemorySrc (&cinfo,
-                       compressedBuf,
+                       &(compressedBuf.front()),
                        static_cast<size_t>(theReadBlockSizeInBytes));
 
    /* Step 3: read file parameters with jpeg_read_header() */
@@ -2697,8 +2838,6 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
       if (loadJpegQuantizationTables(cinfo) == false)
       {
          jpeg_destroy_decompress(&cinfo);
-         delete [] compressedBuf;
-         compressedBuf = 0;
          return false;
       }
    }
@@ -2710,8 +2849,6 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
       if (loadJpegHuffmanTables(cinfo) == false)
       {
          jpeg_destroy_decompress(&cinfo);
-         delete [] compressedBuf;
-         compressedBuf = 0;
          return false;
       }
    }
@@ -2725,8 +2862,38 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
    /* Step 5: Start decompressor */
    jpeg_start_decompress(&cinfo);
    
+   const ossim_uint32 SAMPLES = cinfo.output_width;
+
+   //---
+   // Note: Some nitf will be tagged with a given number of lines but the last
+   // jpeg block may go beyond that to a complete block.  So it you clamp to
+   // last line of the nitf you will get a libjpeg error:
+   // 
+   // "Application transferred too few scanlines"
+   //
+   // So here we will always read the full jpeg block even if it is beyond the
+   // last line of the nitf.
+   //---
+   const ossim_uint32 LINES_TO_READ =
+      min(static_cast<ossim_uint32>(theCacheSize.y), cinfo.output_height);
+
    /* JSAMPLEs per row in output buffer */
-   int row_stride = cinfo.output_width * cinfo.output_components;
+   const ossim_uint32 ROW_STRIDE = SAMPLES * cinfo.output_components;
+
+   if ( (SAMPLES < theCacheTile->getWidth() ) ||
+        (LINES_TO_READ < theCacheTile->getHeight()) )
+   {
+      theCacheTile->makeBlank();
+   }
+
+   if ( (SAMPLES > theCacheTile->getWidth()) ||
+        (LINES_TO_READ > theCacheTile->getHeight()) )
+   {
+      // Error...
+      jpeg_finish_decompress(&cinfo);
+      jpeg_destroy_decompress(&cinfo);
+      return false;
+   }
    
    // Get pointers to the cache tile buffers.
    std::vector<ossim_uint8*> destinationBuffer(theNumberOfInputBands);
@@ -2735,17 +2902,13 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
    {
       destinationBuffer[band] = theCacheTile->getUcharBuf(band);
    }
-   
+
    // Make a temp line buffer
-   ossim_uint8* lineBuffer = new ossim_uint8[row_stride];
+   std::vector<ossim_uint8> lineBuffer(ROW_STRIDE);
    JSAMPROW jbuf[1];
-   jbuf[0] = (JSAMPROW) lineBuffer;
+   jbuf[0] = (JSAMPROW) &(lineBuffer.front());
 
-   ossim_uint32 linesToRead =
-      min(static_cast<ossim_uint32>(theCacheSize.y),
-          (getNumberOfLines()-y) );
-                                 
-   while (cinfo.output_scanline < linesToRead)
+   while (cinfo.output_scanline < LINES_TO_READ)
    {
       // Read a line from the jpeg file.
       jpeg_read_scanlines(&cinfo, jbuf, 1);
@@ -2753,9 +2916,17 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
       //---
       // Copy the line which if band interleaved by pixel the the band
       // separate buffers.
+      //
+      // Note:
+      // Not sure if IMODE of 'B' is interleaved the same as image with
+      // IMODE of 'P'.
+      //
+      // This works with all samples with IMODE of B and P but I only have
+      // one band 'B' and three band 'P'.  So if we ever get a three band
+      // 'B' it could be wrong here. (drb - 20090615)
       //---
-      ossim_int32 index = 0;
-      for (ossim_int32 sample = 0; sample < row_stride; ++sample)
+      ossim_uint32 index = 0;
+      for (ossim_uint32 sample = 0; sample < SAMPLES; ++sample)         
       {
          for (band = 0; band < theNumberOfInputBands; ++band)
          {
@@ -2766,7 +2937,7 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
       
       for (band = 0; band < theNumberOfInputBands; ++band)
       {
-         destinationBuffer[band] += row_stride;
+         destinationBuffer[band] += theCacheSize.x;         
       }
    }
 
@@ -2774,12 +2945,6 @@ bool ossimNitfTileSource::uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y)
    jpeg_finish_decompress(&cinfo);
    jpeg_destroy_decompress(&cinfo);
 
-   delete [] compressedBuf;
-   compressedBuf = 0;
-   
-   // Delete the line buffer.
-   delete [] lineBuffer;
-   lineBuffer = 0;
    return true;
 }
 
@@ -3034,3 +3199,15 @@ bool ossimNitfTileSource::loadJpegHuffmanTables(
    }
    return true;
 }
+
+// Protected to disallow use...
+ossimNitfTileSource::ossimNitfTileSource(const ossimNitfTileSource& /* obj */)
+{
+}
+
+// Protected to disallow use...
+ossimNitfTileSource& ossimNitfTileSource::operator=(
+   const ossimNitfTileSource& /* rhs */)
+{
+   return *this;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNitfWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNitfWriter.cpp
index 73131d7350a25a303c5903833911d50da775aeb7..3047282df8aa44f0b8bbc8a077f0f5863b50d29b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNitfWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNitfWriter.cpp
@@ -1,11 +1,13 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimNitfWriter.cpp 11385 2007-07-25 13:56:38Z gpotts $
+//  $Id: ossimNitfWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <fstream>
 #include <algorithm>
@@ -13,22 +15,23 @@
 #include <iomanip>
 #include <tiffio.h>
 #include <ossim/imaging/ossimNitfWriter.h>
+#include <ossim/base/ossimBooleanProperty.h>
+#include <ossim/base/ossimContainerProperty.h>
 #include <ossim/base/ossimDate.h>
+#include <ossim/base/ossimEndian.h>
+#include <ossim/base/ossimNumericProperty.h>
 #include <ossim/base/ossimPreferences.h>
+#include <ossim/base/ossimProperty.h>
 #include <ossim/base/ossimRefPtr.h>
+#include <ossim/base/ossimStringProperty.h>
 #include <ossim/base/ossimTrace.h>
-#include <ossim/base/ossimEndian.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/projection/ossimRpcSolver.h>
 #include <ossim/projection/ossimUtmProjection.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/imaging/ossimRectangleCutFilter.h>
-#include <ossim/base/ossimProperty.h>
-#include <ossim/base/ossimContainerProperty.h>
-#include <ossim/base/ossimStringProperty.h>
-#include <ossim/base/ossimNumericProperty.h>
-#include <ossim/base/ossimBooleanProperty.h>
+#include <ossim/support_data/ossimNitfCommon.h>
 #include <ossim/support_data/ossimNitfGeoPositioningTag.h>
 #include <ossim/support_data/ossimNitfLocalGeographicTag.h>
 #include <ossim/support_data/ossimNitfLocalCartographicTag.h>
@@ -36,18 +39,16 @@
 #include <ossim/support_data/ossimNitfNameConversionTables.h>
 #include <ossim/support_data/ossimNitfBlockaTag.h>
 
-RTTI_DEF1(ossimNitfWriter, "ossimNitfWriter", ossimImageFileWriter);
+RTTI_DEF1(ossimNitfWriter, "ossimNitfWriter", ossimNitfWriterBase);
 
 static ossimTrace traceDebug(ossimString("ossimNitfWriter:debug"));
                              
 ossimNitfWriter::ossimNitfWriter(const ossimFilename& filename,
                                  ossimImageSource* inputSource)
-   : ossimImageFileWriter(filename, inputSource, NULL),
-     theOutputStream(NULL),
+   : ossimNitfWriterBase(filename, inputSource),
+     theOutputStream(0),
      theFileHeader(),
-     theImageHeader(),
-     theEnableRpcbTagFlag(false),
-     theEnableBlockaTagFlag(true)
+     theImageHeader()
 {
    //---
    // Since the internal nitf tags are not very accurate, write an external
@@ -122,9 +123,9 @@ bool ossimNitfWriter::writeFile()
 
       return false;
    }
-
+   
    // Write out the geometry info.
-   writeGeometry();
+   writeGeometry(theImageHeader.get(), theInputConnection.get());
 
    // addStandardTags();
    
@@ -178,27 +179,9 @@ void ossimNitfWriter::setProperty(ossimRefPtr<ossimProperty> property)
          theImageHeader->setProperties(propertyList);
       }
    }
-   else if (name == "enable_rpcb_tag")
-   {
-      ossimBooleanProperty* boolProperty = PTR_CAST(ossimBooleanProperty,
-                                                    property.get());
-      if (boolProperty)
-      {
-         theEnableRpcbTagFlag = boolProperty->getBoolean();
-      }
-   }
-   else if (name == "enable_blocka_tag")
-   {
-      ossimBooleanProperty* boolProperty = PTR_CAST(ossimBooleanProperty,
-                                                    property.get());
-      if (boolProperty)
-      {
-         theEnableBlockaTagFlag = boolProperty->getBoolean();
-      }
-   }
    else
    {
-      ossimImageFileWriter::setProperty(property);
+      ossimNitfWriterBase::setProperty(property);
    }
 }
 
@@ -226,36 +209,21 @@ ossimRefPtr<ossimProperty> ossimNitfWriter::getProperty(const ossimString& name)
       
       result = container;
    }
-   else if(name == "enable_rpcb_tag")
-   {
-      ossimBooleanProperty* boolProperty =
-         new ossimBooleanProperty(name, theEnableRpcbTagFlag);
-
-      result = boolProperty;
-   }   
-   else if(name == "enable_blocka_tag")
-   {
-      ossimBooleanProperty* boolProperty =
-         new ossimBooleanProperty(name, theEnableBlockaTagFlag);
-
-      result = boolProperty;
-   }   
    else
    {
-      return ossimImageFileWriter::getProperty(name);
+      return ossimNitfWriterBase::getProperty(name);
    }
 
    return result;
 }
 
-void ossimNitfWriter::getPropertyNames(std::vector<ossimString>& propertyNames)const
+void ossimNitfWriter::getPropertyNames(
+   std::vector<ossimString>& propertyNames)const
 {
-   ossimImageFileWriter::getPropertyNames(propertyNames);
+   ossimNitfWriterBase::getPropertyNames(propertyNames);
 
    propertyNames.push_back("file_header");
    propertyNames.push_back("image_header");
-   propertyNames.push_back("enable_rpcb_tag");
-   propertyNames.push_back("enable_blocka_tag");
 }
 
 bool ossimNitfWriter::writeBlockBandSeparate()
@@ -290,9 +258,10 @@ bool ossimNitfWriter::writeBlockBandSeparate()
    ossim_uint64 headerLength = ((ossim_uint64)theOutputStream->tellp() - headerStart) /* + 1 */;
    
    ossimString representation;
-   theImageHeader->setActualBitsPerPixel(getActualBitsPerPixel());
-   theImageHeader->setBitsPerPixel(getBitsPerPixel());
-   theImageHeader->setPixelType(getNitfPixelType());
+   theImageHeader->setActualBitsPerPixel(
+      ossim::getActualBitsPerPixel(scalarType));
+   theImageHeader->setBitsPerPixel(ossim::getBitsPerPixel(scalarType));
+   theImageHeader->setPixelType(ossimNitfCommon::getNitfPixelType(scalarType));
    theImageHeader->setNumberOfBands(bands);
    theImageHeader->setImageMode('B');// blocked
 
@@ -397,15 +366,15 @@ bool ossimNitfWriter::writeBlockBandSeparate()
       ++tileNumber;
    }
 
-   ossim_uint64 pos = theOutputStream->tellp();
+   std::streamoff pos = theOutputStream->tellp();
 
-   setComplexityLevel(pos);
+   setComplexityLevel(pos, theFileHeader.get());
 
    /*
     * Need to change the way I compute file length and header length later
     * We need to figure out a better way to compute.
     */
-   theFileHeader->setFileLength(pos);
+   theFileHeader->setFileLength(static_cast<ossim_uint64>(pos));
    theFileHeader->setHeaderLength(headerLength);
    theOutputStream->seekp(0, ios::beg);
    imageInfoRecord.setSubheaderLength(imageHeaderSize);
@@ -451,9 +420,10 @@ bool ossimNitfWriter::writeBlockBandSequential()
    ossim_uint64 headerLength = ((ossim_uint64)theOutputStream->tellp() - headerStart) /* + 1 */;
    
    ossimString representation;
-   theImageHeader->setActualBitsPerPixel(getActualBitsPerPixel());
-   theImageHeader->setBitsPerPixel(getBitsPerPixel());
-   theImageHeader->setPixelType(getNitfPixelType());
+   theImageHeader->setActualBitsPerPixel(
+      ossim::getActualBitsPerPixel(scalarType));
+   theImageHeader->setBitsPerPixel(ossim::getBitsPerPixel(scalarType));
+   theImageHeader->setPixelType(ossimNitfCommon::getNitfPixelType(scalarType));
    theImageHeader->setNumberOfBands(bands);
    theImageHeader->setImageMode('S');// blocked
    
@@ -572,15 +542,15 @@ bool ossimNitfWriter::writeBlockBandSequential()
       }
    }
    
-   ossim_uint64 pos = theOutputStream->tellp();
+   std::streamoff pos = theOutputStream->tellp();
 
-   setComplexityLevel(pos);
+   setComplexityLevel(pos, theFileHeader.get());
 
    /*
     * Need to change the way I compute file length and header length later
     * We need to figure out a better way to compute.
     */
-   theFileHeader->setFileLength(pos);
+   theFileHeader->setFileLength(static_cast<ossim_uint64>(pos));
    theFileHeader->setHeaderLength(headerLength);
    theOutputStream->seekp(0, ios::beg);
    imageInfoRecord.setSubheaderLength(imageHeaderSize);
@@ -599,111 +569,6 @@ void ossimNitfWriter::addRegisteredTag(
      theImageHeader->addTag(tagInfo);
 }
 
-void ossimNitfWriter::writeGeometry()
-{
-   if ( (theImageHeader.valid() == false) || !theInputConnection )
-   {
-      return;
-   }
-   
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-   ossimRefPtr<ossimProjection> proj =
-      ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   
-   if(proj.valid() == false)
-   {
-      // No projection info.
-      return;
-   }
-
-   // Get the requested bounding rectangles.
-   ossimIrect rect = theInputConnection->getBoundingRect();
-
-   // See if it's a map projection; else, a sensor model.
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj.get());
-   if (mapProj)
-   {
-      // Use map info to get the corners.
-      ossimMapProjectionInfo mapInfo(mapProj, rect);
-      mapInfo.setPixelType(OSSIM_PIXEL_IS_AREA);
-      
-      // See if it's utm.
-      ossimUtmProjection* utmProj = PTR_CAST(ossimUtmProjection, proj.get());
-      if(utmProj)
-      {
-         ossimDpt ul = mapInfo.ulEastingNorthingPt();
-         ossimDpt ur = mapInfo.urEastingNorthingPt();
-         ossimDpt lr = mapInfo.lrEastingNorthingPt();
-         ossimDpt ll = mapInfo.llEastingNorthingPt();
-         
-         if(utmProj->getHemisphere() == 'N')
-         {
-            theImageHeader->setUtmNorth(utmProj->getZone(), ul, ur, lr, ll);
-         }
-         else
-         {
-            theImageHeader->setUtmSouth(utmProj->getZone(), ul, ur, lr, ll);
-         }
-      }
-      else
-      {
-         ossimGpt ul = mapInfo.ulGroundPt();
-         ossimGpt ur = mapInfo.urGroundPt();
-         ossimGpt lr = mapInfo.lrGroundPt();
-         ossimGpt ll = mapInfo.llGroundPt();
-         theImageHeader->setGeographicLocationDms(ul, ur, lr, ll);
-      }
-
-      if (theEnableBlockaTagFlag)
-      {
-         addBlockaTag(mapInfo);
-      }
-   }
-
-   if (theEnableRpcbTagFlag)
-   {
-      addRpcbTag(rect, proj);
-   }
-}
-
-void ossimNitfWriter::setComplexityLevel(ossim_uint64 endPosition)
-{
-   //---
-   // See MIL-STD-2500C, Table A-10:
-   //
-   // Lots of rules here, but for now we will key off of file size.
-   //---
-
-   if (!theFileHeader)
-   {
-      return;
-   }
-
-   const ossim_uint64 MB   = 1024 * 1024;
-   const ossim_uint64 MB50 = 50   * MB;
-   const ossim_uint64 GIG  = 1000 * MB;
-   const ossim_uint64 GIG2 = 2    * GIG;
-   
-   ossimString complexity = "03"; // Less than 50 mb.
-   
-
-   if ( (endPosition >= MB50) && (endPosition < GIG) )
-   {
-      complexity = "05";
-   }
-   else if ( (endPosition >= GIG) && (endPosition < GIG2) )
-   {
-      complexity = "06";
-   }
-   else if (endPosition >= GIG2)
-   {
-      complexity = "07";
-   }
-   
-   theFileHeader->setComplexityLevel(complexity);
-}
-
 #if 0
 void ossimNitfWriter::addStandardTags()
 {
@@ -750,257 +615,14 @@ void ossimNitfWriter::addStandardTags()
 }
 #endif
 
-void ossimNitfWriter::addBlockaTag(ossimMapProjectionInfo& mapInfo)
-{
-   if (!theImageHeader)
-   {
-      return;
-   }
-
-   // Capture the current pixel type.
-   ossimPixelType originalPixelType = mapInfo.getPixelType();
-
-   // This tag wants corners as area:
-   mapInfo.setPixelType(OSSIM_PIXEL_IS_AREA);
-   
-   // Stuff the blocka tag which has six digit precision.
-   ossimNitfBlockaTag* blockaTag = new ossimNitfBlockaTag();
-   
-   // Set the block number.
-   blockaTag->setBlockInstance(1);
-
-   // Set the number of lines.
-   blockaTag->setLLines(mapInfo.linesPerImage());
-
-   // Set first row, first column.
-   blockaTag->setFrfcLoc(ossimDpt(mapInfo.ulGroundPt()));
-   
-   // Set first row, last column.
-   blockaTag->setFrlcLoc(ossimDpt(mapInfo.urGroundPt()));
-   
-   // Set last row, last column.
-   blockaTag->setLrlcLoc(ossimDpt(mapInfo.lrGroundPt()));
-   
-   // Set last row, first column.
-   blockaTag->setLrfcLoc(ossimDpt(mapInfo.llGroundPt()));
-   
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimNitfWriter::writeGeometry DEBUG:"
-         << "\nBLOCKA Tag:" << *((ossimObject*)(blockaTag))
-         << std::endl;
-   }
-   
-   // Add the tag to the header.
-   ossimRefPtr<ossimNitfRegisteredTag> blockaTagRp = blockaTag;
-   ossimNitfTagInformation blockaTagInfo(blockaTagRp);
-   theImageHeader->addTag(blockaTagInfo);
-
-   // Reset the pixel type to original value
-   mapInfo.setPixelType(originalPixelType);
-}
-
-void ossimNitfWriter::addRpcbTag(const ossimIrect& rect,
-                                 ossimRefPtr<ossimProjection> proj)
-{
-   if (!proj.valid())
-   {
-      return;
-   }
-
-   bool useElevation = false;
-
-   if (PTR_CAST(ossimMapProjection, proj.get()))
-   {
-      // If we're already map projected turn the elevation off.
-      useElevation = false;
-   }
-
-   // Make an rpc solver.
-   ossimRpcSolver rs(useElevation);
-   
-   // Compute the coefficients.
-   rs.solveCoefficients(ossimDrect(rect),
-                        *proj.get(),
-                        64,
-                        64);
-   
-   // Add the tag.
-   ossimRefPtr<ossimNitfRegisteredTag> tag = rs.getNitfRpcBTag();
-   ossimNitfTagInformation tagInfo(tag);
-   theImageHeader->addTag(tagInfo);
-   
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimNitfWriter::addRpcbTag DEBUG:"
-         << "\nRPCB Tag:" << *((ossimObject*)(tag.get()))
-         << "\nProjection:" << std::endl;
-      
-      proj->print(ossimNotify(ossimNotifyLevel_DEBUG));
-      
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "\nRect: " << rect << std::endl;
-   }
-}
-
-ossim_uint32 ossimNitfWriter::getActualBitsPerPixel() const
-{
-   ossim_uint32 actualBitsPerPixel = 0;
-   if (theInputConnection)
-   {
-      ossimScalarType scalarType = theInputConnection->getOutputScalarType();
-      switch(scalarType)
-      {
-         case OSSIM_UCHAR:
-         {
-            actualBitsPerPixel = 8;
-            break;
-         }
-         case OSSIM_USHORT11:
-         {
-            actualBitsPerPixel = 11;
-            break;
-         }
-         case OSSIM_USHORT16:
-         case OSSIM_SSHORT16:
-         {
-            actualBitsPerPixel = 16;
-            break;
-         }
-         case OSSIM_FLOAT:
-         case OSSIM_NORMALIZED_FLOAT:
-         {
-            actualBitsPerPixel = 32;
-            break;
-         }
-         case OSSIM_DOUBLE:
-         case OSSIM_NORMALIZED_DOUBLE:
-         {
-            actualBitsPerPixel = 64;
-            break;
-         }
-         default:
-         {
-            break;
-         }
-      }
-   }
-   
-   return actualBitsPerPixel;
-}
-
-ossim_uint32 ossimNitfWriter::getBitsPerPixel() const
-{
-   ossim_uint32 bitsPerPixel = 0;
-
-   if (theInputConnection)
-   {
-      ossimScalarType scalarType = theInputConnection->getOutputScalarType();
-      switch(scalarType)
-      {
-         case OSSIM_UCHAR:
-         {
-            bitsPerPixel = 8;
-            break;
-         }
-         case OSSIM_USHORT11:
-         {
-            bitsPerPixel = 16;
-            break;
-         }
-         case OSSIM_USHORT16:
-         case OSSIM_SSHORT16:
-         {
-            bitsPerPixel = 16;
-            break;
-         }
-         case OSSIM_FLOAT:
-         case OSSIM_NORMALIZED_FLOAT:
-         {
-            bitsPerPixel = 32;
-            break;
-         }
-         case OSSIM_DOUBLE:
-         case OSSIM_NORMALIZED_DOUBLE:
-         {
-            bitsPerPixel = 64;
-            break;
-         }
-         default:
-         {
-            break;
-         }
-      }
-   }
-   return bitsPerPixel;
-}
-
-ossimString ossimNitfWriter::getNitfPixelType() const
-{
-   ossimString pixelType;
-   if (theInputConnection)
-   {
-      ossimScalarType scalarType = theInputConnection->getOutputScalarType();
-      switch(scalarType)
-      {
-         case OSSIM_UCHAR:
-         case OSSIM_USHORT11:
-         case OSSIM_USHORT16:
-         {
-            pixelType = "INT";
-            break;
-         }
-         case OSSIM_SSHORT16:
-         {
-            pixelType    = "SI";
-            break;
-         }
-         case OSSIM_FLOAT:
-         case OSSIM_NORMALIZED_FLOAT:
-         case OSSIM_DOUBLE:
-         case OSSIM_NORMALIZED_DOUBLE:
-         {
-            pixelType    = "R";
-            break;
-         }
-         default:
-         {
-            break;
-         }
-      }
-   }
-   return pixelType;
-}
-
 bool ossimNitfWriter::saveState(ossimKeywordlist& kwl,
                                 const char* prefix) const
 {
-   kwl.add(prefix, "enable_rpcb_tag", theEnableRpcbTagFlag, true);
-   kwl.add(prefix, "enable_blocka_tag", theEnableBlockaTagFlag, true);
-
-   return ossimImageFileWriter::saveState(kwl, prefix);
+   return ossimNitfWriterBase::saveState(kwl, prefix);
 }
 
 bool ossimNitfWriter::loadState(const ossimKeywordlist& kwl,
                                 const char* prefix)
 {
-   // Look for the rpcb enable flag keyword.
-   const char* lookup = kwl.find(prefix, "enable_rpcb_tag");
-   if(lookup)
-   {
-      ossimString os = lookup;
-      theEnableRpcbTagFlag = os.toBool();
-   }
-
-   // Look for the blocka enable flag keyword.
-   lookup = kwl.find(prefix, "enable_blocka_tag");
-   if(lookup)
-   {
-      ossimString os = lookup;
-      theEnableBlockaTagFlag = os.toBool();
-   }
-
-   return ossimImageFileWriter::loadState(kwl, prefix);
+   return ossimNitfWriterBase::loadState(kwl, prefix);
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNitfWriterBase.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNitfWriterBase.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..14440819ac579cff1b717f2ffedbe536735ed61a
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNitfWriterBase.cpp
@@ -0,0 +1,347 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: OSSIM Kakadu based nitf writer.
+//
+//----------------------------------------------------------------------------
+// $Id: ossimKakaduNitfWriter.cpp 15073 2009-08-13 19:55:34Z dburken $
+
+#include <ossim/imaging/ossimNitfWriterBase.h>
+#include <ossim/base/ossimBooleanProperty.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimIrect.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/base/ossimString.h>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/imaging/ossimImageSourceSequencer.h>
+#include <ossim/projection/ossimMapProjection.h>
+#include <ossim/projection/ossimMapProjectionInfo.h>
+#include <ossim/projection/ossimUtmProjection.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/projection/ossimRpcSolver.h>
+#include <ossim/support_data/ossimNitfBlockaTag.h>
+#include <ossim/support_data/ossimNitfFileHeader.h>
+#include <ossim/support_data/ossimNitfFileHeaderV2_X.h>
+#include <ossim/support_data/ossimNitfImageHeader.h>
+#include <ossim/support_data/ossimNitfImageHeaderV2_X.h>
+#include <ossim/support_data/ossimNitfRegisteredTag.h>
+#include <ossim/support_data/ossimNitfTagInformation.h>
+
+static const char ENABLE_BLOCKA_KW[] = "enable_blocka_tag";
+static const char ENABLE_RPCB_KW[]   = "enable_rpcb_tag";
+
+RTTI_DEF1(ossimNitfWriterBase, "ossimNitfWriterBase", ossimImageFileWriter)
+   
+static ossimTrace traceDebug(ossimString("ossimNitfWriterBase:debug"));
+
+ossimNitfWriterBase::ossimNitfWriterBase()
+   : ossimImageFileWriter(),
+     theEnableRpcbTagFlag(false),
+     theEnableBlockaTagFlag(true)
+{
+}
+
+ossimNitfWriterBase::ossimNitfWriterBase(const ossimFilename& filename,
+                                         ossimImageSource* inputSource)
+   : ossimImageFileWriter(filename, inputSource, 0),
+     theEnableRpcbTagFlag(false),
+     theEnableBlockaTagFlag(true)
+{
+}
+
+ossimNitfWriterBase::~ossimNitfWriterBase()
+{
+}
+
+void ossimNitfWriterBase::setProperty(ossimRefPtr<ossimProperty> property)
+{
+   if(property.valid())
+   {
+      ossimString name = property->getName();
+
+      if (name == ENABLE_RPCB_KW)
+      {
+         ossimBooleanProperty* boolProperty = PTR_CAST(ossimBooleanProperty,
+                                                       property.get());
+         if (boolProperty)
+         {
+            theEnableRpcbTagFlag = boolProperty->getBoolean();
+         }
+      }
+      else if (name == ENABLE_BLOCKA_KW)
+      {
+         ossimBooleanProperty* boolProperty = PTR_CAST(ossimBooleanProperty,
+                                                       property.get());
+         if (boolProperty)
+         {
+            theEnableBlockaTagFlag = boolProperty->getBoolean();
+         }
+      }
+      else
+      {
+         ossimImageFileWriter::setProperty(property);
+      }
+   }
+}
+
+ossimRefPtr<ossimProperty> ossimNitfWriterBase::getProperty(
+   const ossimString& name)const
+{
+   ossimRefPtr<ossimProperty> result = 0;
+   
+   if(name == ENABLE_RPCB_KW)
+   {
+      result = new ossimBooleanProperty(name, theEnableRpcbTagFlag);
+   }   
+   else if(name == ENABLE_BLOCKA_KW)
+   {
+      result = new ossimBooleanProperty(name, theEnableBlockaTagFlag);
+   }   
+   else
+   {
+      result = ossimImageFileWriter::getProperty(name);
+   }
+
+   return result;
+}
+
+void ossimNitfWriterBase::getPropertyNames(
+   std::vector<ossimString>& propertyNames)const
+{
+   ossimImageFileWriter::getPropertyNames(propertyNames);
+
+   propertyNames.push_back(ENABLE_BLOCKA_KW);
+   propertyNames.push_back(ENABLE_RPCB_KW);
+}
+
+
+bool ossimNitfWriterBase::saveState(ossimKeywordlist& kwl,
+                                    const char* prefix) const
+{
+   kwl.add(prefix, ENABLE_RPCB_KW, theEnableRpcbTagFlag, true);
+   kwl.add(prefix, ENABLE_BLOCKA_KW, theEnableBlockaTagFlag, true);
+
+   return ossimImageFileWriter::saveState(kwl, prefix);
+}
+
+bool ossimNitfWriterBase::loadState(const ossimKeywordlist& kwl,
+                                    const char* prefix)
+{
+   // Look for the rpcb enable flag keyword.
+   const char* lookup = kwl.find(prefix, ENABLE_RPCB_KW);
+   if(lookup)
+   {
+      ossimString os = lookup;
+      theEnableRpcbTagFlag = os.toBool();
+   }
+
+   // Look for the blocka enable flag keyword.
+   lookup = kwl.find(prefix, ENABLE_BLOCKA_KW);
+   if(lookup)
+   {
+      ossimString os = lookup;
+      theEnableBlockaTagFlag = os.toBool();
+   }
+
+   return ossimImageFileWriter::loadState(kwl, prefix);
+}
+
+void ossimNitfWriterBase::writeGeometry(ossimNitfImageHeaderV2_X* hdr,
+                                        ossimImageSourceSequencer* seq)
+{
+   if (hdr && seq)
+   {
+      ossimRefPtr<ossimImageGeometry> geom = theInputConnection->getImageGeometry();
+      ossimKeywordlist kwl;
+
+      if (geom.valid()&&geom->hasProjection())
+      {
+         // Get the requested bounding rectangles.
+         ossimIrect rect = seq->getBoundingRect();
+         
+         // See if it's a map projection; else, a sensor model.
+         ossimMapProjection* mapProj =
+            PTR_CAST(ossimMapProjection, geom->getProjection());
+         if (mapProj)
+         {
+            // Use map info to get the corners.
+            ossimMapProjectionInfo mapInfo(mapProj, rect);
+            mapInfo.setPixelType(OSSIM_PIXEL_IS_AREA);
+            
+            // See if it's utm.
+            ossimUtmProjection* utmProj = PTR_CAST(ossimUtmProjection,
+                                                   mapProj);
+            if(utmProj)
+            {
+               ossimDpt ul = mapInfo.ulEastingNorthingPt();
+               ossimDpt ur = mapInfo.urEastingNorthingPt();
+               ossimDpt lr = mapInfo.lrEastingNorthingPt();
+               ossimDpt ll = mapInfo.llEastingNorthingPt();
+               
+               if(utmProj->getHemisphere() == 'N')
+               {
+                  hdr->setUtmNorth(utmProj->getZone(), ul, ur, lr, ll);
+               }
+               else
+               {
+                  hdr->setUtmSouth(utmProj->getZone(), ul, ur, lr, ll);
+               }
+            }
+            else
+            {
+               ossimGpt ul = mapInfo.ulGroundPt();
+               ossimGpt ur = mapInfo.urGroundPt();
+               ossimGpt lr = mapInfo.lrGroundPt();
+               ossimGpt ll = mapInfo.llGroundPt();
+               hdr->setGeographicLocationDms(ul, ur, lr, ll);
+            }
+
+            if (theEnableBlockaTagFlag)
+            {
+               addBlockaTag(mapInfo, hdr);
+            }
+         }
+         
+         if (theEnableRpcbTagFlag)
+         {
+            addRpcbTag(rect, geom->getProjection(), hdr);
+         }
+         
+      } // matches:  if (proj.valid())
+      
+   } // matches: if (hdr && seq)
+}
+
+void ossimNitfWriterBase::addBlockaTag(ossimMapProjectionInfo& mapInfo,
+                                       ossimNitfImageHeaderV2_X* hdr)
+{
+   if (hdr)
+   {
+      // Capture the current pixel type.
+      ossimPixelType originalPixelType = mapInfo.getPixelType();
+      
+      // This tag wants corners as area:
+      mapInfo.setPixelType(OSSIM_PIXEL_IS_AREA);
+      
+      // Stuff the blocka tag which has six digit precision.
+      ossimNitfBlockaTag* blockaTag = new ossimNitfBlockaTag();
+      
+      // Set the block number.
+      blockaTag->setBlockInstance(1);
+      
+      // Set the number of lines.
+      blockaTag->setLLines(mapInfo.linesPerImage());
+      
+      // Set first row, first column.
+      blockaTag->setFrfcLoc(ossimDpt(mapInfo.ulGroundPt()));
+      
+      // Set first row, last column.
+      blockaTag->setFrlcLoc(ossimDpt(mapInfo.urGroundPt()));
+      
+      // Set last row, last column.
+      blockaTag->setLrlcLoc(ossimDpt(mapInfo.lrGroundPt()));
+      
+      // Set last row, first column.
+      blockaTag->setLrfcLoc(ossimDpt(mapInfo.llGroundPt()));
+      
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "ossimNitfWriterBase::addBlockaTag DEBUG:"
+            << "\nBLOCKA Tag:" << *((ossimObject*)(blockaTag))
+            << std::endl;
+      }
+      
+      // Add the tag to the header.
+      ossimRefPtr<ossimNitfRegisteredTag> blockaTagRp = blockaTag;
+      ossimNitfTagInformation blockaTagInfo(blockaTagRp);
+      hdr->addTag(blockaTagInfo);
+      
+      // Reset the pixel type to original value
+      mapInfo.setPixelType(originalPixelType);
+      
+   } // matches: if (hdr)
+}
+
+void ossimNitfWriterBase::addRpcbTag(const ossimIrect& rect,
+                                     ossimProjection* proj,
+                                     ossimNitfImageHeaderV2_X* hdr)
+{
+   if (proj && hdr)
+   {
+      bool useElevation = false;
+      
+      if (PTR_CAST(ossimMapProjection, proj))
+      {
+         // If we're already map projected turn the elevation off.
+         useElevation = false;
+      }
+      
+      // Make an rpc solver.
+      ossimRefPtr<ossimRpcSolver> rs = new ossimRpcSolver(useElevation);
+      
+      // Compute the coefficients.
+      rs->solveCoefficients(ossimDrect(rect), proj, 64, 64);
+      
+      // Add the tag.
+      ossimRefPtr<ossimNitfRegisteredTag> tag = rs->getNitfRpcBTag();
+      ossimNitfTagInformation tagInfo(tag);
+      hdr->addTag(tagInfo);
+      
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "ossimNitfWriterBase::addRpcbTag DEBUG:"
+            << "\nRPCB Tag:" << *((ossimObject*)(tag.get()))
+            << "\nProjection:\n";
+         
+         proj->print(ossimNotify(ossimNotifyLevel_DEBUG));
+         
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "\nRect: " << rect << std::endl;
+      }
+      
+   } // matches: if (proj && hdr)
+}
+
+void ossimNitfWriterBase::setComplexityLevel(std::streamoff endPosition,
+                                             ossimNitfFileHeaderV2_X* hdr)
+{
+   if (hdr)
+   {
+      //---
+      // See MIL-STD-2500C, Table A-10:
+      //
+      // Lots of rules here, but for now we will key off of file size.
+      //---
+      const std::streamoff MB   = 1024 * 1024;
+      const std::streamoff MB50 = 50   * MB;
+      const std::streamoff GIG  = 1000 * MB;
+      const std::streamoff GIG2 = 2    * GIG;
+      
+      ossimString complexity = "03"; // Less than 50 mb.
+      
+      if ( (endPosition >= MB50) && (endPosition < GIG) )
+      {
+         complexity = "05";
+      }
+      else if ( (endPosition >= GIG) && (endPosition < GIG2) )
+      {
+         complexity = "06";
+      }
+      else if (endPosition >= GIG2)
+      {
+         complexity = "07";
+      }
+      
+      hdr->setComplexityLevel(complexity);
+   }
+}
+
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedRemapTable.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedRemapTable.cpp
index 21002f40ef494217ef3a6a07d707acf624a2e431..05f26c90791aba1f04936424715658d8611f3e9a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedRemapTable.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedRemapTable.cpp
@@ -1,15 +1,36 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
 // 
-// Author:  David Burken (dburken@imagelinks.com)
+// See LICENSE.txt file in the top level directory for more details.
+// 
+// Author:  David Burken
+//
 // Description:
 //
 // Contains class definition for NormalizedRemapTable.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedRemapTable.cpp 9963 2006-11-28 21:11:01Z gpotts $
+//  $Id: ossimNormalizedRemapTable.cpp 15496 2009-09-29 11:36:56Z dburken $
 
 #include <ossim/imaging/ossimNormalizedRemapTable.h>
 
 ossimNormalizedRemapTable::ossimNormalizedRemapTable()
+{
+}
+
+ossimNormalizedRemapTable::~ossimNormalizedRemapTable()
+{
+}
+
+// Private copy constructor.
+ossimNormalizedRemapTable::ossimNormalizedRemapTable(
+   const ossimNormalizedRemapTable&)
 {}
+
+// Private assignment operator.
+ossimNormalizedRemapTable& ossimNormalizedRemapTable::operator=(
+   const ossimNormalizedRemapTable&)
+{
+   return *this;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedS16RemapTable.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedS16RemapTable.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..19b55b62c1faad3913dd080eb202f4a94aa7760f
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedS16RemapTable.cpp
@@ -0,0 +1,41 @@
+//*******************************************************************
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+// 
+// Description:
+//
+// Contains class definition for ossimNormalizedS16RemapTable.
+// 
+//*******************************************************************
+//  $Id: ossimNormalizedS16RemapTable.cpp 9963 2006-11-28 21:11:01Z gpotts $
+
+#include <ossim/imaging/ossimNormalizedS16RemapTable.h>
+
+ossim_float64 ossimNormalizedS16RemapTable::theTable[TABLE_ENTRIES];
+bool          ossimNormalizedS16RemapTable::theTableIsInitialized = false;
+
+ossimNormalizedS16RemapTable::ossimNormalizedS16RemapTable()
+   : ossimNormalizedRemapTable()
+{
+   if (!theTableIsInitialized)
+   {
+      const ossim_int32   ENTRIES     = getEntries();
+      const ossim_float64 DENOMINATOR = getNormalizer();
+      
+      //---
+      // Initialize the remap table.
+      //---
+      theTable[0] = 0.0; // Index zero always for null.
+      for (ossim_int32 i = 1; i < ENTRIES; ++i)
+      {
+         theTable[i] = static_cast<ossim_float64>(i)/DENOMINATOR;
+      }
+
+      theTableIsInitialized = true;
+   }
+}
+
+ossimNormalizedS16RemapTable::~ossimNormalizedS16RemapTable()
+{}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU11RemapTable.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU11RemapTable.cpp
index a8824a8158235f8270ca52772b581ea92fd5bb49..a8df5c9d682f16229955c220b85a31cc2f9e344f 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU11RemapTable.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU11RemapTable.cpp
@@ -1,31 +1,41 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
-// Author:  David Burken (dburken@imagelinks.com)
 // Description:
 //
 // Contains class definition for ossimNormalizedU11RemapTable.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedU11RemapTable.cpp 9963 2006-11-28 21:11:01Z gpotts $
+//  $Id: ossimNormalizedU11RemapTable.cpp 15743 2009-10-17 13:00:45Z dburken $
 
 #include <ossim/imaging/ossimNormalizedU11RemapTable.h>
 
-double ossimNormalizedU11RemapTable::theTable[TABLE_ENTRIES];
-bool   ossimNormalizedU11RemapTable::theTableIsInitialized = false;
+ossim_float64 ossimNormalizedU11RemapTable::theTable[TABLE_ENTRIES];
+bool          ossimNormalizedU11RemapTable::theTableIsInitialized = false;
 
 ossimNormalizedU11RemapTable::ossimNormalizedU11RemapTable()
+   : ossimNormalizedRemapTable()
 {
    if (!theTableIsInitialized)
    {
-      //***
+      const ossim_int32   ENTRIES     = getEntries();
+      const ossim_float64 DENOMINATOR = getNormalizer();
+      
+      //---
       // Initialize the remap table.
-      //***
-      for (ossim_int32 i = 0; i < TABLE_ENTRIES; i++)
+      //---
+      theTable[0] = 0.0; // Index zero always for null.
+      for (ossim_int32 i = 1; i < ENTRIES; ++i)
       {
-         ossim_float64 tmp = i;
-         theTable[i] = tmp / 2047.0;
+         theTable[i] = static_cast<ossim_float64>(i)/DENOMINATOR;
       }
+
       theTableIsInitialized = true;
    }
 }
+
+ossimNormalizedU11RemapTable::~ossimNormalizedU11RemapTable()
+{}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU16RemapTable.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU16RemapTable.cpp
index d1b13ddafa3ad7182ade32095a3ec05a6a657759..9bc807096cae5b2b9897fc1d2b7c658ab1d022c3 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU16RemapTable.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU16RemapTable.cpp
@@ -1,31 +1,44 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
-// Author:  David Burken (dburken@imagelinks.com)
 // Description:
 //
 // Contains class definition for ossimNormalizedU16RemapTable.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedU16RemapTable.cpp 9963 2006-11-28 21:11:01Z gpotts $
+//  $Id: ossimNormalizedU16RemapTable.cpp 15743 2009-10-17 13:00:45Z dburken $
 
 #include <ossim/imaging/ossimNormalizedU16RemapTable.h>
 
-double ossimNormalizedU16RemapTable::theTable[TABLE_ENTRIES];
-bool   ossimNormalizedU16RemapTable::theTableIsInitialized = false;
+ossim_float64 ossimNormalizedU16RemapTable::theTable[TABLE_ENTRIES];
+bool          ossimNormalizedU16RemapTable::theTableIsInitialized = false;
+
 
 ossimNormalizedU16RemapTable::ossimNormalizedU16RemapTable()
+   : ossimNormalizedRemapTable()
 {
    if (!theTableIsInitialized)
    {
-      //***
+      const ossim_int32   ENTRIES     = getEntries();
+      const ossim_float64 DENOMINATOR = getNormalizer();
+      
+      //---
       // Initialize the remap table.
-      //***
-      for (ossim_int32 i = 0; i < TABLE_ENTRIES; i++)
+      //---
+      theTable[0] = 0.0; // Index zero always for null.
+      for (ossim_int32 i = 1; i < ENTRIES; ++i)
       {
-         ossim_float64 tmp = i;
-         theTable[i] = tmp / 65535.0;
+         theTable[i] = static_cast<ossim_float64>(i)/DENOMINATOR;
       }
+
       theTableIsInitialized = true;
    }
 }
+
+ossimNormalizedU16RemapTable::~ossimNormalizedU16RemapTable()
+{}
+
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU8RemapTable.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU8RemapTable.cpp
index fbc1f81389f12b56de95b842cc1d8affd61f2c1b..a353d5aa7764cf3383fd5eb78cd19ae07b614f20 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU8RemapTable.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNormalizedU8RemapTable.cpp
@@ -1,31 +1,42 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
-// Author:  David Burken (dburken@imagelinks.com)
 // Description:
 //
 // Contains class definition for ossimNormalizedU8RemapTable.
+// 
 //*******************************************************************
-//  $Id: ossimNormalizedU8RemapTable.cpp 9963 2006-11-28 21:11:01Z gpotts $
+//  $Id: ossimNormalizedU8RemapTable.cpp 15743 2009-10-17 13:00:45Z dburken $
 
 #include <ossim/imaging/ossimNormalizedU8RemapTable.h>
 
-double ossimNormalizedU8RemapTable::theTable[TABLE_ENTRIES];
-bool   ossimNormalizedU8RemapTable::theTableIsInitialized = false;
+ossim_float64 ossimNormalizedU8RemapTable::theTable[TABLE_ENTRIES];
+bool          ossimNormalizedU8RemapTable::theTableIsInitialized = false;
 
 ossimNormalizedU8RemapTable::ossimNormalizedU8RemapTable()
+   : ossimNormalizedRemapTable()
 {
    if (!theTableIsInitialized)
    {
-      //***
+      const ossim_int32   ENTRIES     = getEntries();
+      const ossim_float64 DENOMINATOR = getNormalizer();
+      
+      //---
       // Initialize the remap table.
-      //***
-      for (ossim_int32 i = 0; i < TABLE_ENTRIES; i++)
+      //---
+      theTable[0] = 0.0; // Index zero always for null.
+      for (ossim_int32 i = 1; i < ENTRIES; ++i)
       {
-         ossim_float64 tmp = i;
-         theTable[i] = tmp / 255.0;
+         theTable[i] = static_cast<ossim_float64>(i)/DENOMINATOR;
       }
+
       theTableIsInitialized = true;
    }
 }
+
+ossimNormalizedU8RemapTable::~ossimNormalizedU8RemapTable()
+{}
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp
index 48842d8b7ac0a069677f00eec40f48449b3b7742..b1a912be635215008fd3ff2186621e15994e11a1 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp
@@ -5,46 +5,57 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimOrthoImageMosaic.cpp 13312 2008-07-27 01:26:52Z gpotts $
+//  $Id: ossimOrthoImageMosaic.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimOrthoImageMosaic.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/projection/ossimMapProjection.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 
-
 static ossimTrace traceDebug ("ossimOrthoImageMosaic:debug");
 
 RTTI_DEF1(ossimOrthoImageMosaic, "ossimOrthoImageMosaic", ossimImageMosaic);
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimOrthoImageMosaic::ossimOrthoImageMosaic()
    :ossimImageMosaic()
 {
-   theDelta.makeNan();
-   theUpperLeftTie.makeNan();
+   m_Delta.makeNan();
+   m_UpperLeftTie.makeNan();
 }
 
-ossimOrthoImageMosaic::ossimOrthoImageMosaic(const std::vector<ossimImageSource*>& inputSources)
+//**************************************************************************************************
+// 
+//**************************************************************************************************
+ossimOrthoImageMosaic::ossimOrthoImageMosaic(ossimConnectableObject::ConnectableObjectList& inputSources)
    :ossimImageMosaic(inputSources)
 {
-   theDelta.makeNan();
-   theUpperLeftTie.makeNan();
+   m_Delta.makeNan();
+   m_UpperLeftTie.makeNan();
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimOrthoImageMosaic::~ossimOrthoImageMosaic()
 {
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossim_uint32 ossimOrthoImageMosaic::getNumberOfOverlappingImages(const ossimIrect& rect,
-                                                           ossim_uint32 resLevel)const
+                                                                 ossim_uint32 resLevel)const
 {
    ossim_uint32 result = 0;
-   for(ossim_uint32 i = 0; i < theInputTiePoints.size(); ++i)
+   for(ossim_uint32 i = 0; i < m_InputTiePoints.size(); ++i)
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       getInput(i));
       if(interface&&
-         !theInputTiePoints[i].hasNans())
+         !m_InputTiePoints[i].hasNans())
       {
          ossimIrect tempRect = getRelativeRect(i, resLevel);
 
@@ -61,17 +72,20 @@ ossim_uint32 ossimOrthoImageMosaic::getNumberOfOverlappingImages(const ossimIrec
    return 0;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimOrthoImageMosaic::getOverlappingImages(std::vector<ossim_uint32>& result,
                                                  const ossimIrect& rect,
                                                  ossim_uint32 resLevel)const
 {
    result.clear();
-   for(ossim_uint32 i = 0; i < theInputTiePoints.size(); ++i)
+   for(ossim_uint32 i = 0; i < m_InputTiePoints.size(); ++i)
    {
       ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       getInput(i));
       if(interface&&
-         !theInputTiePoints[i].hasNans())
+         !m_InputTiePoints[i].hasNans())
       {
          ossimIrect tempRect = getRelativeRect(i, resLevel);
 
@@ -86,82 +100,61 @@ void ossimOrthoImageMosaic::getOverlappingImages(std::vector<ossim_uint32>& resu
    }
 }
 
-bool ossimOrthoImageMosaic::getImageGeometry(ossimKeywordlist& kwl,
-                                             const char* prefix)
+//**************************************************************************************************
+// Returns the image geometry for the complete mosaic
+//**************************************************************************************************
+ossimImageGeometry* ossimOrthoImageMosaic::getImageGeometry()
 {
-   bool result = true;
-   ossimImageSource* interface = PTR_CAST(ossimImageSource,
-                                                   getInput(0));
+   // If we already have a geometry object, return it:
+   if (m_Geometry.valid())
+      return m_Geometry.get();
+
+   // The geometry (projection) associated with this mosaic is necessarily the same for all
+   // single-image objects feeding into this combiner, So we will copy the first image source's
+   // geometry, and modify our copy to reflect the mosaic-specific items.
+   ossimImageSource* interface = PTR_CAST(ossimImageSource, getInput(0));
    if(interface)
    {
-      interface->getImageGeometry(kwl, prefix);
-      ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,
-                                                                                                       prefix);
-      ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj.get());
-      if(!mapProj) return false;
-      
-      if(theUnits == "degrees")
+      const ossimImageGeometry* inputGeom = interface->getImageGeometry();
+      if (inputGeom)
       {
-         mapProj->setDecimalDegreesPerPixel(theDelta);
-         mapProj->setUlGpt(ossimGpt(theUpperLeftTie.y,
-                                    theUpperLeftTie.x,
-                                    0.0,
-                                    mapProj->origin().datum()));
-         
-//           kwl.add(prefix,
-//                  ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT,
-//                  theDelta.y,
-//                  true);
-//           kwl.add(prefix,
-//                  ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON,
-//                  theDelta.x,
-//                   true);
-//           kwl.add(prefix,
-//                   ossimKeywordNames::TIE_POINT_LAT_KW,
-//                   theUpperLeftTie.y,
-//                   true);
-//           kwl.add(prefix,
-//                   ossimKeywordNames::TIE_POINT_LON_KW,
-//                   theUpperLeftTie.x,
-//                   true);
-//           kwl.remove(prefix, ossimKeywordNames::TIE_POINT_EASTING_KW);
-//           kwl.remove(prefix, ossimKeywordNames::TIE_POINT_NORTHING_KW);
-
-         mapProj->saveState(kwl, prefix);
+         m_Geometry = new ossimImageGeometry(*inputGeom);
+         updateGeometry();
       }
-      else if(theUnits == "meters")
+      return m_Geometry.get();
+   }
+   return 0;
+}
+
+//**************************************************************************************************
+//! If this object is maintaining an ossimImageGeometry, this method needs to be called after 
+//! each time the contents of the mosaic changes.
+//**************************************************************************************************
+void ossimOrthoImageMosaic::updateGeometry()
+{
+   if (!m_Geometry.valid())
+      return;
+
+   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, m_Geometry->getProjection());
+   if (mapProj)
+   {
+      if(m_Units == "degrees")
       {
-         mapProj->setMetersPerPixel(theDelta);
-         mapProj->setUlEastingNorthing(theUpperLeftTie);
-//           kwl.add(prefix,
-//                  ossimKeywordNames::METERS_PER_PIXEL_X_KW,
-//                  theDelta.x,
-//                  true);
-//           kwl.add(prefix,
-//                  ossimKeywordNames::METERS_PER_PIXEL_Y_KW,
-//                  theDelta.x,
-//                   true);
-//           kwl.add(prefix,
-//                   ossimKeywordNames::TIE_POINT_EASTING_KW,
-//                   theUpperLeftTie.x,
-//                   true);
-//           kwl.add(prefix,
-//                   ossimKeywordNames::TIE_POINT_NORTHING_KW,
-//                   theUpperLeftTie.y,
-//                   true);
-//           kwl.remove(prefix, ossimKeywordNames::TIE_POINT_LAT_KW);
-//           kwl.remove(prefix, ossimKeywordNames::TIE_POINT_LON_KW);
-         mapProj->saveState(kwl, prefix);
+         mapProj->setDecimalDegreesPerPixel(m_Delta);
+         mapProj->setUlGpt(ossimGpt(m_UpperLeftTie.y, m_UpperLeftTie.x, 0.0,
+                                    mapProj->origin().datum()));
       }
-      else
+      else if(m_Units == "meters")
       {
-         result = false;
+         mapProj->setMetersPerPixel(m_Delta);
+         mapProj->setUlEastingNorthing(m_UpperLeftTie);
       }
    }
-
-   return result;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimIrect ossimOrthoImageMosaic::getBoundingRect(ossim_uint32 resLevel) const
 {
    ossimDpt decimation;
@@ -177,16 +170,19 @@ ossimIrect ossimOrthoImageMosaic::getBoundingRect(ossim_uint32 resLevel) const
    }
    if(decimation.hasNans())
    {
-      return theBoundingRect;
+      return m_BoundingRect;
    }
-   return theBoundingRect*decimation;
+   return m_BoundingRect*decimation;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimOrthoImageMosaic::initialize()
 {
-   theInputTiePoints.clear();
-   theDelta.makeNan();
-   theUpperLeftTie.makeNan();
+   m_InputTiePoints.clear();
+   m_Delta.makeNan();
+   m_UpperLeftTie.makeNan();
 
    if(traceDebug())
    {
@@ -197,83 +193,73 @@ void ossimOrthoImageMosaic::initialize()
    }
    if(getNumberOfInputs())
    {
-      theInputTiePoints.resize(getNumberOfInputs());
+      m_InputTiePoints.resize(getNumberOfInputs());
       for(ossim_uint32 i = 0; i < getNumberOfInputs(); ++i)
       {
-         ossimImageSource *interface =
-            PTR_CAST(ossimImageSource, getInput(i));
-         theInputTiePoints[i].makeNan();
+         ossimImageSource *interface = PTR_CAST(ossimImageSource, getInput(i));
+         m_InputTiePoints[i].makeNan();
          if(interface)
          {
-            ossimKeywordlist kwl;
-
-            bool status = interface->getImageGeometry(kwl);
-            if(status)
+            const ossimImageGeometry* geom = interface->getImageGeometry();
+            if(geom)
             {
-               ossimProjection* prj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-               ossimMapProjection* mapPrj = PTR_CAST(ossimMapProjection, prj);
+               const ossimMapProjection* mapPrj = PTR_CAST(ossimMapProjection, geom->getProjection());
                if(mapPrj)
                {
                   if(!mapPrj->isGeographic())
                   {
-                     theUnits = "meters";
-                     theDelta = mapPrj->getMetersPerPixel();
+                     m_Units = "meters";
+                     m_Delta = mapPrj->getMetersPerPixel();
                   }
                   else
                   {
-                     theUnits = "degrees";
-                     theDelta = mapPrj->getDecimalDegreesPerPixel();
+                     m_Units = "degrees";
+                     m_Delta = mapPrj->getDecimalDegreesPerPixel();
                   }
-                  if(theUnits == "degrees")
+                  if(m_Units == "degrees")
                   {
-                     theInputTiePoints[i].x = mapPrj->getUlGpt().lond();
-                     theInputTiePoints[i].y = mapPrj->getUlGpt().latd();
+                     m_InputTiePoints[i].x = mapPrj->getUlGpt().lond();
+                     m_InputTiePoints[i].y = mapPrj->getUlGpt().latd();
                   }
-                  else if(theUnits == "meters")
+                  else if(m_Units == "meters")
                   {
-                     theInputTiePoints[i].x = mapPrj->getUlEastingNorthing().x;;
-                     theInputTiePoints[i].y = mapPrj->getUlEastingNorthing().y;
+                     m_InputTiePoints[i].x = mapPrj->getUlEastingNorthing().x;;
+                     m_InputTiePoints[i].y = mapPrj->getUlEastingNorthing().y;
                   }
 
                   if(traceDebug())
                   {
                      ossimNotify(ossimNotifyLevel_DEBUG)
                         << "tie points for input " << i << " = "
-                        << theInputTiePoints[i] << std::endl;
+                        << m_InputTiePoints[i] << std::endl;
                   }
 
                }
-               if(prj)
-               {
-                  delete prj;
-                  prj = NULL;
-                  mapPrj = NULL;
-               }
             }
-            if(!theInputTiePoints[i].hasNans())
+            if(!m_InputTiePoints[i].hasNans())
             {
-               if(theUpperLeftTie.hasNans())
+               if(m_UpperLeftTie.hasNans())
                {
-                  theUpperLeftTie = theInputTiePoints[i];
+                  m_UpperLeftTie = m_InputTiePoints[i];
                }
-               else if(!theInputTiePoints[i].hasNans())
+               else if(!m_InputTiePoints[i].hasNans())
                {
-                  if(theUnits == "meters")
+                  if(m_Units == "meters")
                   {
-                     theUpperLeftTie.x = std::min(theUpperLeftTie.x, theInputTiePoints[i].x);
-                     theUpperLeftTie.y = std::max(theUpperLeftTie.y, theInputTiePoints[i].y);
+                     m_UpperLeftTie.x = std::min(m_UpperLeftTie.x, m_InputTiePoints[i].x);
+                     m_UpperLeftTie.y = std::max(m_UpperLeftTie.y, m_InputTiePoints[i].y);
                   }
                   else
                   {
-                     theUpperLeftTie.lon = std::min(theUpperLeftTie.lon, theInputTiePoints[i].lon);
-                     theUpperLeftTie.lat = std::max(theUpperLeftTie.lat, theInputTiePoints[i].lat);
+                     m_UpperLeftTie.lon = std::min(m_UpperLeftTie.lon, m_InputTiePoints[i].lon);
+                     m_UpperLeftTie.lat = std::max(m_UpperLeftTie.lat, m_InputTiePoints[i].lat);
                   }
                }
             }
          }
          else
          {
-            theInputTiePoints[i].makeNan();
+            m_InputTiePoints[i].makeNan();
 //            CLOG << "Input " << i << " will not be used since no ortho information exists" << endl;
          }
       }
@@ -283,17 +269,24 @@ void ossimOrthoImageMosaic::initialize()
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << "theUpperLeftTie = " << theUpperLeftTie << std::endl
-         << "delta per pixel = " << theDelta        << std::endl
-         << "bounding rect   = " << theBoundingRect << std::endl;
+         << "m_UpperLeftTie = " << m_UpperLeftTie << std::endl
+         << "delta per pixel = " << m_Delta        << std::endl
+         << "bounding rect   = " << m_BoundingRect << std::endl;
    }
    ossimImageMosaic::initialize();
+
+   // Finally, update the geometry (if there was one already defined), to reflect the change in input
+   updateGeometry();
+
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << "ossimOrthoImageMosaic::initialize() DEBUG: Leaving..." << std::endl;
    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimRefPtr<ossimImageData> ossimOrthoImageMosaic::getNextTile(ossim_uint32& returnedIdx,
                                                                const ossimIrect& origin,
                                                                ossim_uint32 resLevel)
@@ -368,13 +361,16 @@ ossimRefPtr<ossimImageData> ossimOrthoImageMosaic::getNextTile(ossim_uint32& ret
    return result;
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 void ossimOrthoImageMosaic::computeBoundingRect(ossim_uint32 resLevel)
 {
    const char* MODULE = "ossimOrthoImageMosaic::computeBoundingRect";
    
-   theBoundingRect.makeNan();
+   m_BoundingRect.makeNan();
 
-   for(ossim_uint32 i = 0; i < theInputTiePoints.size(); ++ i)
+   for(ossim_uint32 i = 0; i < m_InputTiePoints.size(); ++ i)
    {
       ossimIrect shiftedRect = getRelativeRect(i, resLevel);
 
@@ -385,18 +381,21 @@ void ossimOrthoImageMosaic::computeBoundingRect(ossim_uint32 resLevel)
       }
       if(!shiftedRect.hasNans())
       {
-         if(theBoundingRect.hasNans())
+         if(m_BoundingRect.hasNans())
          {
-            theBoundingRect = shiftedRect;
+            m_BoundingRect = shiftedRect;
          }
          else
          {
-            theBoundingRect = theBoundingRect.combine(shiftedRect);
+            m_BoundingRect = m_BoundingRect.combine(shiftedRect);
          }
       }
    }
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimIrect ossimOrthoImageMosaic::getRelativeRect(ossim_uint32 index,
                                                   ossim_uint32 resLevel)const
 {
@@ -405,17 +404,17 @@ ossimIrect ossimOrthoImageMosaic::getRelativeRect(ossim_uint32 index,
                                                    getInput(index));
    result.makeNan();
    if(interface&&
-      !theInputTiePoints[index].hasNans())
+      !m_InputTiePoints[index].hasNans())
    {
       ossimIrect inputRect = interface->getBoundingRect();
       result = inputRect;
       
       if(!inputRect.hasNans())
       {
-         ossimDpt shift = (theInputTiePoints[index] - theUpperLeftTie);
+         ossimDpt shift = (m_InputTiePoints[index] - m_UpperLeftTie);
          
-         shift.x/= theDelta.x;
-         shift.y/=-theDelta.y;
+         shift.x/= m_Delta.x;
+         shift.y/=-m_Delta.y;
          
 	 result = result + shift;
          if(!resLevel)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderBase.cpp b/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderBase.cpp
index 5029f600e785e9d2313163f94002d37045e6c34f..3be21272d34c587738da44573f4236f6deb4e156 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderBase.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderBase.cpp
@@ -7,10 +7,17 @@
 // Description:  Interface class for overview builders.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewBuilderBase.cpp 9942 2006-11-22 21:49:44Z dburken $
+// $Id: ossimOverviewBuilderBase.cpp 15366 2009-09-04 13:30:04Z dburken $
 
 #include <ossim/imaging/ossimOverviewBuilderBase.h>
+#include <ossim/base/ossimIpt.h>
+#include <ossim/base/ossimPreferences.h>
+#include <ossim/imaging/ossimImageHandler.h>
 
+const char* ossimOverviewBuilderBase::OVERVIEW_STOP_DIMENSION_KW =
+   "overview_stop_dimension";
+
+// Property keywords.
 RTTI_DEF3(ossimOverviewBuilderBase,
           "ossimOverviewBuilderBase",
           ossimSource,
@@ -18,7 +25,9 @@ RTTI_DEF3(ossimOverviewBuilderBase,
           ossimConnectableObjectListener)
    
 ossimOverviewBuilderBase::ossimOverviewBuilderBase()
+   : theOverviewStopDimension(0)
 {
+   theOverviewStopDimension = getDefaultStopDimension();
 }
 
 ossimOverviewBuilderBase::~ossimOverviewBuilderBase()
@@ -41,3 +50,58 @@ bool ossimOverviewBuilderBase::hasOverviewType(const ossimString& type) const
    return false;
 }
 
+ossim_uint32 ossimOverviewBuilderBase::getRequiredResLevels(
+   const ossimImageHandler* ih) const
+{
+   ossim_uint32 result = 0;
+   if (ih)
+   {
+      // Note we always have one rset
+      result = 1;
+
+      ossim_uint32 largestImageDimension =
+         ih->getNumberOfSamples(0) >
+         ih->getNumberOfLines(0) ?
+         ih->getNumberOfSamples(0) :
+         ih->getNumberOfLines(0);
+
+      while(largestImageDimension > theOverviewStopDimension)
+      {
+         largestImageDimension /= 2;
+         ++result;
+      }
+   }
+   return result;
+}
+
+ossim_uint32 ossimOverviewBuilderBase::getOverviewStopDimension() const
+{
+   return theOverviewStopDimension;
+}
+
+void ossimOverviewBuilderBase::setOverviewStopDimension(ossim_uint32 dim)
+{
+   theOverviewStopDimension = dim;
+}
+
+ossim_uint32 ossimOverviewBuilderBase::getDefaultStopDimension() const
+{
+   ossim_uint32 result = 0;
+   
+     // Get the stop dimension from ossim preferences.
+   const char* lookup = ossimPreferences::instance()->
+      findPreference(OVERVIEW_STOP_DIMENSION_KW);
+   if (lookup)
+   {
+      result = ossimString(lookup).toUInt32();
+   }
+
+   if (result == 0)
+   {
+      // Use the smallest default tile size.
+      ossimIpt tileSize;
+      ossim::defaultTileSize(tileSize);
+      result  = tileSize.x < tileSize.y ? tileSize.x : tileSize.y;
+   }
+   return result;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderFactory.cpp
index 9a16da6560a7ec2e0789f593a9edfc62032b8302..32697a60f907511aa29b1a25b648abe4ff74a40c 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimOverviewBuilderFactory.cpp
@@ -7,7 +7,7 @@
 // Description: .
 //
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewBuilderFactory.cpp 9935 2006-11-22 19:30:28Z dburken $
+// $Id: ossimOverviewBuilderFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstddef> /* for NULL */
 
@@ -34,7 +34,7 @@ ossimOverviewBuilderFactory::~ossimOverviewBuilderFactory()
 ossimOverviewBuilderBase* ossimOverviewBuilderFactory::createBuilder(
    const ossimString& typeName) const
 {
-   ossimOverviewBuilderBase* result = new  ossimTiffOverviewBuilder();
+   ossimRefPtr<ossimOverviewBuilderBase> result = new  ossimTiffOverviewBuilder();
    if ( result->hasOverviewType(typeName) == true )
    {
       // Capture the type.  (This builder has more than one.)
@@ -42,20 +42,18 @@ ossimOverviewBuilderBase* ossimOverviewBuilderFactory::createBuilder(
    }
    else
    {
-      delete result;
-      result = NULL;
+      result = 0;
    }
    
-   return result;
+   return result.release();
 }
 
 void ossimOverviewBuilderFactory::getTypeNameList(
    std::vector<ossimString>& typeList) const
 {
-   ossimOverviewBuilderBase* builder = new  ossimTiffOverviewBuilder();
+   ossimRefPtr<ossimOverviewBuilderBase> builder = new  ossimTiffOverviewBuilder();
    builder->getTypeNameList(typeList);
-   delete builder;
-   builder = NULL;
+   builder = 0;
 }
 
 ossimOverviewBuilderFactory::ossimOverviewBuilderFactory()
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimOverviewSequencer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimOverviewSequencer.cpp
index 0f6f7f445e6689379f074fa7469e5f297b5c70f6..62a278e8897ef864bebd1648a23fd88b15769d57 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimOverviewSequencer.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimOverviewSequencer.cpp
@@ -1,13 +1,13 @@
 //----------------------------------------------------------------------------
 //
-// License:  See top level LICENSE.txt file.
-//
-// Author:  David Burken
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Description: Sequencer for building overview files.
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimOverviewSequencer.cpp 10272 2007-01-15 15:38:25Z dburken $
+// $Id: ossimOverviewSequencer.cpp 15794 2009-10-23 12:30:26Z dburken $
 
 #include <ossim/imaging/ossimOverviewSequencer.h>
 #include <ossim/base/ossimNotify.h>
@@ -21,7 +21,7 @@
 
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimOverviewSequencer.cpp 10272 2007-01-15 15:38:25Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimOverviewSequencer.cpp 15794 2009-10-23 12:30:26Z dburken $";
 #endif
 
 static ossimTrace traceDebug("ossimOverviewSequencer:debug");
@@ -273,8 +273,7 @@ void ossimOverviewSequencer::getInputTileRectangle(ossimIrect& inputRect) const
    
    getOutputTileRectangle(inputRect);
    inputRect = inputRect * theDecimationFactor;
-   inputRect = inputRect + theImageHandler->
-      getSubImageOffset(theSourceResLevel);
+   inputRect = inputRect;
 
 #if 0
    if (traceDebug())
@@ -409,92 +408,130 @@ void  ossimOverviewSequencer::resampleTile(const ossimImageData* inputTile, T  /
    }
 #endif
    
-   ossim_uint32 bands = theTile->getNumberOfBands();
+   const ossim_uint32 BANDS = theTile->getNumberOfBands();
+   const ossim_uint32 LINES = theTile->getHeight();
+   const ossim_uint32 SAMPS = theTile->getWidth();
+   const ossim_uint32 INPUT_WIDTH = theDecimationFactor*theTileSize.x;
+   
+   T nullPixel              = 0;
+   ossim_float64 weight     = 0.0;
+   ossim_float64 value      = 0.0;
+   ossim_uint32 sampOffset  = 0;
    
-   for (ossim_uint32 band=0; band<bands; ++band)
+   if (theResampleType ==
+       ossimFilterResampler::ossimFilterResampler_NEAREST_NEIGHBOR)
    {
-      const T* s = static_cast<const T*>(inputTile->getBuf(band)); // source
-      T*       d = static_cast<T*>(theTile->getBuf(band));         // destination
-      
-      T  nullPixel = static_cast<T>(inputTile->getNullPix(band));
-
-      ossim_uint32  lines      = theTile->getHeight();
-      ossim_uint32  samps      = theTile->getWidth();
-      ossim_uint32  inputWidth = theDecimationFactor*theTileSize.x;
-      ossim_float64 weight     = 0.0;
-      ossim_float64 value      = 0.0;
-      
-      for (ossim_uint32 i=0; i<lines; ++i)
+      for (ossim_uint32 band=0; band<BANDS; ++band)
       {
-         ossim_uint32 lineOffset1 = i*theDecimationFactor*inputWidth;
-         ossim_uint32 lineOffset2 = (i*theDecimationFactor+1)*inputWidth;
+         const T* s = static_cast<const T*>(inputTile->getBuf(band)); // source
+         T*       d = static_cast<T*>(theTile->getBuf(band)); // destination
          
-         for (ossim_uint32 j=0; j<samps; ++j)
+         nullPixel = static_cast<T>(inputTile->getNullPix(band));
+         weight = 0.0;
+         value  = 0.0;
+         
+         for (ossim_uint32 i=0; i<LINES; ++i)
          {
-            ossim_uint32 sampOffset = j*theDecimationFactor;
-            
-            switch(theResampleType)
+            for (ossim_uint32 j=0; j<SAMPS; ++j)
             {
-               case ossimFilterResampler::ossimFilterResampler_NEAREST_NEIGHBOR:
+               sampOffset = j*theDecimationFactor;
+               
+               weight = 1.0;
+               value  = *(s + i*theDecimationFactor*INPUT_WIDTH + sampOffset);
+               
+               if(weight)
                {
-                  weight = 1.0;
-                  value  = *(s + i*inputWidth + sampOffset);
-                  break;
+                  d[j] = static_cast<T>( value/weight );
                }
-               case ossimFilterResampler::ossimFilterResampler_BOX:
-               default:
+               else
                {
-                  weight = 0.0;
-                  value  = 0.0;
-
-                  //---
-                  // Grab four pixels from the source, average, and assign
-                  // to output.
-                  //---
-                  ossim_float64 ul = *(s + lineOffset1 + sampOffset);
-                  ossim_float64 ur = *(s + lineOffset1 + sampOffset + 1);
-                  ossim_float64 ll = *(s + lineOffset2 + sampOffset);
-                  ossim_float64 lr = *(s + lineOffset2 + sampOffset + 1);
-                  
-                  if(ul != nullPixel)
-                  {
-                     ++weight;
-                     value += ul;
-                  }
-                  if(ur != nullPixel)
-                  {
-                     ++weight;
-                     value += ur;
-                  }
-                  if(ll != nullPixel)
-                  {
-                     ++weight;
-                     value += ll;
-                  }
-                  if(lr != nullPixel)
-                  {
-                     ++weight;
-                     value += lr;
-                  }
-                  break;
+                  d[j] = nullPixel;
                }
                
-            } // End of switch(theResampleType)
+            } // End of sample loop.
+            
+            d += theTileSize.x;
+            
+         } // End of line loop.
          
-            if(weight)
-            {
-               d[j] = static_cast<T>( value/weight );
-            }
-            else
+      } // End of band loop.
+      
+   }
+   else // ossimFilterResampler::ossimFilterResampler_BOX
+   {
+      ossim_uint32 lineOffset1 = 0;
+      ossim_uint32 lineOffset2 = 0;
+      ossim_float64 ul = 0.0;
+      ossim_float64 ur = 0.0;
+      ossim_float64 ll = 0.0;
+      ossim_float64 lr = 0.0;
+
+      for (ossim_uint32 band=0; band<BANDS; ++band)
+      {
+         const T* s = static_cast<const T*>(inputTile->getBuf(band)); // source
+         T*       d = static_cast<T*>(theTile->getBuf(band)); // destination
+
+         nullPixel = static_cast<T>(inputTile->getNullPix(band));
+         weight = 0.0;
+         value  = 0.0;
+         
+         for (ossim_uint32 i=0; i<LINES; ++i)
+         {
+            lineOffset1 = i*theDecimationFactor*INPUT_WIDTH;
+            lineOffset2 = (i*theDecimationFactor+1)*INPUT_WIDTH;
+            
+            for (ossim_uint32 j=0; j<SAMPS; ++j)
             {
-               d[j] = nullPixel;
-            }
+               sampOffset = j*theDecimationFactor;
+               
+               weight = 0.0;
+               value  = 0.0;
+               
+               //---
+               // Grab four pixels from the source, average, and assign
+               // to output.
+               //---
+               ul = *(s + lineOffset1 + sampOffset);
+               ur = *(s + lineOffset1 + sampOffset + 1);
+               ll = *(s + lineOffset2 + sampOffset);
+               lr = *(s + lineOffset2 + sampOffset + 1);
+               
+               if(ul != nullPixel)
+               {
+                  ++weight;
+                  value += ul;
+               }
+               if(ur != nullPixel)
+               {
+                  ++weight;
+                  value += ur;
+               }
+               if(ll != nullPixel)
+               {
+                  ++weight;
+                  value += ll;
+               }
+               if(lr != nullPixel)
+               {
+                  ++weight;
+                  value += lr;
+               }
+
+               if(weight)
+               {
+                  d[j] = static_cast<T>( value/weight );
+               }
+               else
+               {
+                  d[j] = nullPixel;
+               }
             
-         } // End of sample loop.
-         
-         d += theTileSize.x;
+            } // End of sample loop.
+            
+            d += theTileSize.x;
+            
+         } // End of line loop.
          
-      } // End of line loop.
-      
-   } // End of band loop.
+      } // End of band loop.
+   }
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp
index 62f8581fe67e4220006d6e5b398562590132eefa..02b3f605f888591b0bc978d46f46004ab466b293 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp
@@ -10,11 +10,12 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimQuickbirdNitfTileSource.cpp 13330 2008-07-28 18:04:40Z dburken $
+//  $Id: ossimQuickbirdNitfTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimQuickbirdNitfTileSource.h>
 #include <ossim/support_data/ossimQuickbirdTile.h>
 #include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimTrace.h>
+#include <ossim/base/ossim2dTo2dShiftTransform.h>
 #include <ossim/support_data/ossimNitfImageHeader.h>
 
 RTTI_DEF1(ossimQuickbirdNitfTileSource, "ossimQuickbirdNitfTileSource", ossimNitfTileSource);
@@ -92,7 +93,7 @@ bool ossimQuickbirdNitfTileSource::open()
       ossimIpt urPt;
       ossimIpt lrPt;
       ossimIpt llPt;
-      
+      ossimDpt shift;
       if(tileFile.getInfo(info, theImageFile.file().upcase()))
       {
          ulPt.makeNan();
@@ -103,63 +104,14 @@ bool ossimQuickbirdNitfTileSource::open()
          if((info.theUlXOffset != OSSIM_INT_NAN) &&
             (info.theUlYOffset != OSSIM_INT_NAN))
          {
-            theSubImageOffset = ossimIpt(info.theUlXOffset, info.theUlYOffset);
+            shift = ossimIpt(info.theUlXOffset, info.theUlYOffset);
          }
          else
          {
-            theSubImageOffset = ossimIpt(0,0);
-         }
-          
-         ulPt = theSubImageOffset;
-         
-         if(traceDebug())
-         {
-            ossimNotify(ossimNotifyLevel_DEBUG)
-               << "ossimQuickbirdNitfTileSource::open(file) DEBUG:"
-               << "\nSub image offset  = " << theSubImageOffset
-               << std::endl;
-         }
-         
-         if((info.theUrXOffset != OSSIM_INT_NAN) &&
-            (info.theUrYOffset != OSSIM_INT_NAN))
-         {
-            urPt = ossimIpt(info.theUrXOffset,
-                            info.theUrYOffset);
-         }
-         else
-         {
-            urPt = tempBounds.ur() + ulPt;
-         }
-         
-         if((info.theLrXOffset != OSSIM_INT_NAN) &&
-            (info.theLrYOffset != OSSIM_INT_NAN))
-         {
-            lrPt = ossimIpt(info.theLrXOffset,
-                            info.theLrYOffset);
-         }
-         else
-         {
-            lrPt = tempBounds.lr() + ulPt;
-         }
-         
-         if((info.theLlXOffset != OSSIM_INT_NAN) &&
-            (info.theLlYOffset != OSSIM_INT_NAN))
-         {
-            llPt = ossimIpt(info.theLlXOffset,
-                            info.theLlYOffset);
-         }
-         else
-         {
-            llPt = tempBounds.ll() + ulPt;
+            shift = ossimIpt(0,0);
          }
+         m_transform = new ossim2dTo2dShiftTransform(shift);
       }
-
-      //---
-      // Set the base class image rectangle in case a sub image offset was
-      // picked up here.
-      //---
-      setBoundingRectangle(ossimIrect(ulPt, urPt, lrPt, llPt));
-      
       if(traceDebug())
       {
          ossimNotify(ossimNotifyLevel_DEBUG)
@@ -186,3 +138,18 @@ bool ossimQuickbirdNitfTileSource::open()
    
    return openedTileFile;
 }
+
+ossimImageGeometry* ossimQuickbirdNitfTileSource::getImageGeometry()
+{
+   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
+   
+   if(result)
+   {
+      if(!result->getTransform())
+      {
+         result->setTransform(m_transform.get());
+      }
+   }
+   
+   return result;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdTiffTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdTiffTileSource.cpp
index 4c4a248a3f28ea8cc1cbc890528034d501df0696..add748b4e58040c65af685dd01f12eeb376ab21f 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdTiffTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdTiffTileSource.cpp
@@ -13,7 +13,7 @@
 // Quick Bird ".TIL" files.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimQuickbirdTiffTileSource.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimQuickbirdTiffTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimQuickbirdTiffTileSource.h>
 #include <ossim/support_data/ossimQuickbirdTile.h>
@@ -65,24 +65,41 @@ bool ossimQuickbirdTiffTileSource::open()
          return false;
       }
    }
-
+   ossimDpt shift;
+   
    if((info.theUlXOffset != OSSIM_INT_NAN) &&
       (info.theUlYOffset != OSSIM_INT_NAN))
    {
-      theSubImageOffset = ossimIpt(info.theUlXOffset, info.theUlYOffset);
+      shift = ossimIpt(info.theUlXOffset, info.theUlYOffset);
    }
    else
    {
-      theSubImageOffset = ossimIpt(0,0);
+      shift = ossimIpt(0,0);
    }
    
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << "ossimQuickbirdTiffTileSource::open() DEBUG:"
-         << "\nSub image offset  = " << theSubImageOffset
+         << "\nSub image offset  = " << shift
          << std::endl;
    }
+   m_transform = new ossim2dTo2dShiftTransform(shift);
    
    return true;
 }
+
+ossimImageGeometry* ossimQuickbirdTiffTileSource::getImageGeometry()
+{
+   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
+   
+   if(result)
+   {
+      if(!result->getTransform())
+      {
+         result->setTransform(m_transform.get());
+      }
+   }
+   
+   return result;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimRLevelFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimRLevelFilter.cpp
index 9b8e9585d4f4309dac8df20e56e75a634bc5cba5..14128e409fc220ddd5327d6d31d868edbf71b7a6 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimRLevelFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimRLevelFilter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRLevelFilter.cpp 9526 2006-09-06 16:18:51Z dburken $
+// $Id: ossimRLevelFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimRLevelFilter.h>
 #include <ossim/projection/ossimMapProjection.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -21,6 +21,7 @@ static ossimTrace traceDebug("ossimRLevelFilter:debug");
 
 RTTI_DEF1(ossimRLevelFilter, "ossimRLevelFilter", ossimImageSourceFilter);
 
+//**************************************************************************************************
 ossimRLevelFilter::ossimRLevelFilter()
    : ossimImageSourceFilter(),
      theCurrentRLevel(0),
@@ -28,10 +29,12 @@ ossimRLevelFilter::ossimRLevelFilter()
 {
 }
 
+//**************************************************************************************************
 ossimRLevelFilter::~ossimRLevelFilter()
 {
 }
 
+//**************************************************************************************************
 void ossimRLevelFilter::getDecimationFactor(ossim_uint32 resLevel,
                                             ossimDpt& result) const
 {
@@ -44,93 +47,84 @@ void ossimRLevelFilter::getDecimationFactor(ossim_uint32 resLevel,
                                            result);
 }
 
+//**************************************************************************************************
 bool ossimRLevelFilter::getOverrideGeometryFlag() const
 {
    return theOverrideGeometryFlag;
 }
 
+//**************************************************************************************************
 void ossimRLevelFilter::setOverrideGeometryFlag(bool override)
 {
    theOverrideGeometryFlag = override;
 }
 
+//**************************************************************************************************
 void ossimRLevelFilter::setCurrentRLevel(ossim_uint32 rlevel)
 {
    theCurrentRLevel = rlevel;
+   updateGeometry();
 }
 
+//**************************************************************************************************
 ossim_uint32 ossimRLevelFilter::getCurrentRLevel()const
 {
    return theCurrentRLevel;
 }
 
-bool ossimRLevelFilter::getImageGeometry(ossimKeywordlist& kwl,
-                                         const char* prefix)
+//**************************************************************************************************
+// Returns a pointer reference to the active image geometry at this filter. The input source
+// geometry is modified, so we need to maintain our own geometry object as a data member.
+//**************************************************************************************************
+ossimImageGeometry* ossimRLevelFilter::getImageGeometry()
 {
+   // Have we already defined our own geometry? Return it if so:
+   if (m_ScaledGeometry.valid())
+      return m_ScaledGeometry.get();
+
    if (!theInputConnection)
-   {
-      return false;
-   }
+      return 0;
 
    ossim_uint32 rlevel = getCurrentRLevel();
-   bool status = theInputConnection->getImageGeometry(kwl, prefix);
-
-   if (!theOverrideGeometryFlag || (status == false) ||
-       (rlevel == 0) || (getEnableFlag() == false) )
-   {
-      return status;
-   }
+   ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
 
-   ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->
-      createProjection(kwl);
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);;
-   if(mapProj)
-   {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimRLevelFilter::getImageGeometry DEBUG:"
-            << "\nOriginal projection:\n";
-         mapProj->print(ossimNotify(ossimNotifyLevel_DEBUG));
-      }
+   // If no scaling is happening, just return the input image geometry:
+   if ((!inputGeom) || (rlevel == 0) || (getEnableFlag() == false))
+      return inputGeom;
 
-      ossimDpt decimation;
-      getDecimationFactor(rlevel, decimation);
-      decimation.x = 1.0/decimation.x;
-      decimation.y = 1.0/decimation.y;
+   // Need to create a copy of the input geom and modify it as our own, then pass that:
+   m_ScaledGeometry = new ossimImageGeometry(*inputGeom);
+   updateGeometry();
 
-      //---
-      // This will adjust both the scale and the tie point to account for
-      // decimation.
-      //---
-      mapProj->applyScale(decimation,
-                          true);  // recenter tie point flag
-
-      //---
-      // There are still old keywords out there so clear the original
-      // geometry file out prior to saving.
-      //---
-      kwl.clear();
-
-      // Save off the changes back to the keyword list.
-      mapProj->saveState(kwl, prefix);
+   // Return our version of the image geometry:
+   return m_ScaledGeometry.get();
+}
 
-      if (traceDebug())
+//**************************************************************************************************
+//! If this object is maintaining an ossimImageGeometry, this method needs to be called after 
+//! a scale change so that the geometry's projection is modified accordingly.
+//**************************************************************************************************
+void ossimRLevelFilter::updateGeometry()
+{
+   if (m_ScaledGeometry.valid())
+   {
+      // Modify the image geometry's projection with the scale factor before returning geom:
+      ossimProjection* proj = m_ScaledGeometry->getProjection();
+      ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);;
+      if(mapProj)
       {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimRLevelFilter::getImageGeometry DEBUG:"
-            << "\nUpdated projection:\n";
-         mapProj->print(ossimNotify(ossimNotifyLevel_DEBUG));
-         
-      }
+         ossimDpt decimation;
+         getDecimationFactor(theCurrentRLevel, decimation);
+         decimation.x = 1.0/decimation.x;
+         decimation.y = 1.0/decimation.y;
 
-      return true;
-
-   } // End of "if(mapProj))"
-
-   return status;
+         // This will adjust both the scale and the tie point to account for decimation.
+         mapProj->applyScale(decimation, true);  // recenter tie point flag
+      }
+   }
 }
 
+//**************************************************************************************************
 void ossimRLevelFilter::getSummedDecimation(ossimDpt& result) const
 {
    // Start with fresh values.
@@ -170,6 +164,7 @@ void ossimRLevelFilter::getSummedDecimation(ossimDpt& result) const
    }
 }
 
+//**************************************************************************************************
 ossimIrect ossimRLevelFilter::getBoundingRect(ossim_uint32 resLevel)const
 {
    ossimIrect rect;
@@ -183,6 +178,7 @@ ossimIrect ossimRLevelFilter::getBoundingRect(ossim_uint32 resLevel)const
    return theInputConnection->getBoundingRect(resLevel);
 }
 
+//**************************************************************************************************
 ossimRefPtr<ossimImageData> ossimRLevelFilter::getTile(
    const ossimIrect& tileRect,
    ossim_uint32 resLevel)
@@ -201,6 +197,7 @@ ossimRefPtr<ossimImageData> ossimRLevelFilter::getTile(
    return theInputConnection->getTile(tileRect, theCurrentRLevel);
 }
 
+//**************************************************************************************************
 bool ossimRLevelFilter::loadState(const ossimKeywordlist& kwl,
                                   const char* prefix)
 {
@@ -208,18 +205,18 @@ bool ossimRLevelFilter::loadState(const ossimKeywordlist& kwl,
    const char* override = kwl.find(prefix, OVERRIDE_GEOMETRY_KW);
 
    if(current)
-   {
       theCurrentRLevel = ossimString(current).toULong();
-   }
 
    if(override)
-   {
       theOverrideGeometryFlag = ossimString(override).toBool();
-   }
 
    return ossimImageSourceFilter::loadState(kwl, prefix);
+
+   // An existing image geometry object here will need to be updated:
+   updateGeometry();
 }
 
+//**************************************************************************************************
 bool ossimRLevelFilter::saveState(ossimKeywordlist& kwl,
                                   const char* prefix)const
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimReadmeFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimReadmeFileWriter.cpp
index dad656b26eecda566f88d0606c8a8cead04e30c7..1dcf3c4ec151badcdaa8408b8c87bf8f459ee55b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimReadmeFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimReadmeFileWriter.cpp
@@ -8,7 +8,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimReadmeFileWriter.cpp 11347 2007-07-23 13:01:59Z gpotts $
+//  $Id: ossimReadmeFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 using namespace std;
@@ -18,8 +18,8 @@ using namespace std;
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/projection/ossimMapProjection.h>
+#include <ossim/projection/ossimUtmProjection.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
-#include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageSource.h>
@@ -31,16 +31,25 @@ RTTI_DEF1(ossimReadmeFileWriter,
 static const char DEFAULT_FILE_NAME[] = "output_readme.txt";
 static ossimTrace traceDebug("ossimReadmeFileWriter:debug");
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimReadmeFileWriter::ossimReadmeFileWriter()
-   :
-      ossimMetadataFileWriter()
+:
+ossimMetadataFileWriter()
 {
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 ossimReadmeFileWriter::~ossimReadmeFileWriter()
 {
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 bool ossimReadmeFileWriter::writeFile()
 {
    static const char MODULE[] = "ossimReadmeFileWriter::writeFile";
@@ -59,52 +68,25 @@ bool ossimReadmeFileWriter::writeFile()
 
    std::ofstream out(theFilename.c_str(), ios_base::out);
    if (!out)
-   {
       return false;
-   }
 
-   ossimKeywordlist kwl;
-   theInputConnection->getImageGeometry(kwl);
-   
-   ossimProjection* proj;
-   proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   if (!proj)
+   // Fetch the map projection of the input image if it exists:
+   const ossimMapProjection* mapProj = 0;
+   const ossimImageGeometry* imgGeom = theInputConnection->getImageGeometry();
+   if (imgGeom)
    {
-      if (traceDebug())
-      {
-         CLOG << "DEBUG:"
-              << "\nCould not create projection from geometry!"
-              << "\nGeometry keyword list dump:\n"
-              << kwl
-              << "\nReturning..."
-              << endl;
-      }
-      return false;
+      const ossimProjection* proj = imgGeom->getProjection();
+      mapProj = PTR_CAST(ossimMapProjection, proj);
    }
-   
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);
    if (!mapProj)
    {
-      if (traceDebug())
-      {
-         CLOG << "DEBUG:"
-              << "\nCould not create map projection from geometry!"
-              << "\nGeometry keyword list dump:\n"
-              << kwl
-              << "\nReturning..."
-              << endl;
-      }
-
-      delete proj;
+      out.close();
       return false;
    }
 
-   ossimMapProjectionInfo* projectionInfo
-      = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
-
+   ossimMapProjectionInfo* projectionInfo = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
    if(projectionInfo)
    {
-	   
       out << setiosflags(ios::fixed)
           << setiosflags(ios::left)
           << setw(16) << "Image: "
@@ -134,16 +116,16 @@ bool ossimReadmeFileWriter::writeFile()
           << projectionInfo->getUsSurveyFeetPerPixel().y
           << " U.S. feet";
       
-      const char* type  = kwl.find(ossimKeywordNames::TYPE_KW);
-      const char* zone  = kwl.find(ossimKeywordNames::ZONE_KW);
-      const char* datum = kwl.find(ossimKeywordNames::DATUM_KW);
-      const char* ellipsoid = kwl.find(ossimKeywordNames::ELLIPSE_CODE_KW);
-      
+      const ossimString type  = TYPE_NAME(mapProj);
+      const ossimString datum = mapProj->getDatum()->code();
+      const ossimString ellipsoid = mapProj->getEllipsoid().code();
+
       if(type)
          out << setw(17) << "\nProjection:" << type;
-      
-      if(zone)
-         out << setw(17) << "\nUTM map zone:" << zone;
+
+      const ossimUtmProjection* utmProj = PTR_CAST(ossimUtmProjection, mapProj);
+      if (utmProj)
+         out << setw(17) << "\nUTM map zone:" << utmProj->getZone();
       
       if(datum && ellipsoid)
          out << setw(17) << "\nDatum:"      << datum
@@ -160,15 +142,15 @@ bool ossimReadmeFileWriter::writeFile()
       ossimString tmpString;
       double tmpDouble;
       
-      const char* parallel1
-         = kwl.find(ossimKeywordNames::STD_PARALLEL_1_KW);
-      const char* parallel2
-         = kwl.find(ossimKeywordNames::STD_PARALLEL_2_KW);
-      const char* scaleFactor
-         = kwl.find(ossimKeywordNames::SCALE_FACTOR_KW);
+      // HACK: Easiest way to get projection info for optional params is via the old keywordlist:
+      ossimKeywordlist kwl;
+      mapProj->saveState(kwl);
+      const char* parallel1   = kwl.find(ossimKeywordNames::STD_PARALLEL_1_KW);
+      const char* parallel2   = kwl.find(ossimKeywordNames::STD_PARALLEL_2_KW);
+      const char* scaleFactor = kwl.find(ossimKeywordNames::SCALE_FACTOR_KW);
       
-      ossimString proj_name = mapProj->getClassName();
       
+      ossimString proj_name = mapProj->getClassName();
       if ( ( proj_name.contains("Lambert")           ) ||
            ( proj_name.contains("Albers")            ) ||
            ( proj_name.contains("TransverseMercator" ) ) )
@@ -222,6 +204,7 @@ bool ossimReadmeFileWriter::writeFile()
       
       if (proj_name.contains("TransverseMercator"))
       {
+
          out << setiosflags(ios::left)
              << "\n"
              << setw(18) << "Scale Factor:"
@@ -450,25 +433,22 @@ bool ossimReadmeFileWriter::writeFile()
       delete projectionInfo;
    }
    
-   if(proj)
-   {
-      delete proj;
-      proj = NULL;
-   }
-
    out.close();
-   
    return true;
 }
 
-void ossimReadmeFileWriter::getMetadatatypeList(
-   std::vector<ossimString>& metadatatypeList) const
+//**************************************************************************************************
+// 
+//**************************************************************************************************
+void ossimReadmeFileWriter::getMetadatatypeList(std::vector<ossimString>& metadatatypeList) const
 {
    metadatatypeList.push_back(ossimString("ossim_readme")); 
 }
 
-bool ossimReadmeFileWriter::hasMetadataType(
-   const ossimString& metadataType)const
+//**************************************************************************************************
+// 
+//**************************************************************************************************
+bool ossimReadmeFileWriter::hasMetadataType(const ossimString& metadataType) const
 {
    return (metadataType == "ossim_readme");
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimResampler.cpp b/Utilities/otbossim/src/ossim/imaging/ossimResampler.cpp
index 828fa0a94b8a31d0d7e2963471eaeeb4d4d5244f..f52f050801d2673de33a593f09f6beb03f2a5344 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimResampler.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimResampler.cpp
@@ -10,7 +10,7 @@
 // Contains class definition for ossimResampler.
 // 
 //*******************************************************************
-//  $Id: ossimResampler.cpp 11411 2007-07-27 13:53:51Z dburken $
+//  $Id: ossimResampler.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 
 #include <iostream>
@@ -698,7 +698,7 @@ void ossimResampler::resampleTile(T,// not used
                                   const ossimDpt& deltaUr,
                                   const ossimDpt& outLength)
 {
-   ossimImageData* dupIn = input;
+   ossimRefPtr<ossimImageData> dupIn = input;
    ossimDpt origin = input->getOrigin();
    ossimDpt newInputUl = inputUl;
    ossimDpt newInputUr = inputUr;
@@ -737,7 +737,7 @@ void ossimResampler::resampleTile(T,// not used
                                  roundedRect.height());
       dupIn->setOrigin(roundedRect.ul());
       dupIn->initialize();
-      resampleTile(static_cast<T>(0), input, dupIn);
+      resampleTile(static_cast<T>(0), input, dupIn.get());
    }
    long    inWidth        = dupIn->getWidth();
    long    inHeight       = dupIn->getHeight();
@@ -800,10 +800,7 @@ void ossimResampler::resampleTile(T,// not used
          end.y   += newDeltaUr.y;
       }
    }
-   if(theResamplerType != ossimResampler_NEAREST_NEIGHBOR)
-   {
-      delete dupIn;
-   }
+   dupIn = 0;
 }
 
 template <class T>
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimRgbToIndexFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimRgbToIndexFilter.cpp
index 42d1915796a53ab0b922e4705b611e9517da982d..276c6f777f1fc977a2a45dd5882b5d8a037fcb9d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimRgbToIndexFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimRgbToIndexFilter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbToIndexFilter.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbToIndexFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimRgbToIndexFilter.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -21,7 +21,7 @@ RTTI_DEF1(ossimRgbToIndexFilter,
 
 ossimRgbToIndexFilter::ossimRgbToIndexFilter()
    :ossimImageSourceFilter(),
-    theLut(0),
+    theLut(new ossimRgbLutDataObject()),
     theTile(NULL)
 {
 }
@@ -29,13 +29,14 @@ ossimRgbToIndexFilter::ossimRgbToIndexFilter()
 ossimRgbToIndexFilter::ossimRgbToIndexFilter(ossimImageSource* inputSource,
                                              const ossimRgbLutDataObject& rgbLut)
    :ossimImageSourceFilter(inputSource),
-    theLut(rgbLut),
+    theLut((ossimRgbLutDataObject*)rgbLut.dup()),
     theTile(NULL)
 {
 }
 
 ossimRgbToIndexFilter::~ossimRgbToIndexFilter()
 {
+   theLut = 0;
 }
 
 void ossimRgbToIndexFilter::initialize()
@@ -138,7 +139,7 @@ ossimRefPtr<ossimImageData> ossimRgbToIndexFilter::convertInputTile(ossimRefPtr<
 
       for(ossim_uint32 offset = 0; offset < upper; ++offset)
       {
-         *outBand = theLut.findIndex(*band[0], *band[1], *band[2]);
+         *outBand = theLut->findIndex(*band[0], *band[1], *band[2]);
          
          ++outBand;
          ++band[0];
@@ -156,7 +157,7 @@ bool ossimRgbToIndexFilter::saveState(ossimKeywordlist& kwl,
    ossimString newPrefix = prefix;
    newPrefix = newPrefix + "lut.";
 
-   theLut.saveState(kwl, newPrefix.c_str());
+   theLut->saveState(kwl, newPrefix.c_str());
 
    return ossimImageSourceFilter::saveState(kwl, prefix);
 }
@@ -166,7 +167,7 @@ bool ossimRgbToIndexFilter::loadState(const ossimKeywordlist& kwl, const char* p
    ossimString newPrefix = prefix;
    newPrefix = newPrefix + "lut.";
 
-   theLut.loadState(kwl, newPrefix.c_str());
+   theLut->loadState(kwl, newPrefix.c_str());
    
    return ossimImageSourceFilter::loadState(kwl, prefix);
 }
@@ -193,7 +194,7 @@ ossimScalarType ossimRgbToIndexFilter::getOutputScalarType() const
 
 void ossimRgbToIndexFilter::setLut(ossimRgbLutDataObject& lut)
 {
-   theLut = lut;
+   theLut = (ossimRgbLutDataObject*) lut.dup();
 }
 
 double ossimRgbToIndexFilter::getNullPixelValue(ossim_uint32 band)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimS16ImageData.cpp b/Utilities/otbossim/src/ossim/imaging/ossimS16ImageData.cpp
index 293b327482cd255e6cbae3f1157a258a14269fab..de60a2bcb7ac779c22f963aeed3d88aac5f4aa12 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimS16ImageData.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimS16ImageData.cpp
@@ -6,11 +6,11 @@
 //
 // Description:
 //
-// Class definition of ossimU16ImageData.  Specialized image data object for
+// Class definition of ossimS16ImageData.  Specialized image data object for
 // signed short data.
 //
 //*************************************************************************
-// $Id: ossimS16ImageData.cpp 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimS16ImageData.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimS16ImageData.h>
 #include <ossim/base/ossimErrorCodes.h>
@@ -20,18 +20,21 @@
 #include <ossim/base/ossimHistogram.h>
 
 RTTI_DEF1(ossimS16ImageData, "ossimS16ImageData", ossimImageData)
+   
+const ossimNormalizedS16RemapTable ossimS16ImageData::theRemapTable;
 
 ossimS16ImageData::ossimS16ImageData()
    :
       ossimImageData()
 {
+   theScalarType = OSSIM_SINT16;
 }
 
 ossimS16ImageData::ossimS16ImageData(ossimSource* source,
                                      ossim_uint32 bands)
    :
       ossimImageData(source,
-                     OSSIM_SSHORT16,
+                     OSSIM_SINT16,
                      bands)
 {
 }
@@ -42,7 +45,7 @@ ossimS16ImageData::ossimS16ImageData(ossimSource* source,
                                      ossim_uint32 height)
    :
       ossimImageData(source,
-                     OSSIM_SSHORT16,
+                     OSSIM_SINT16,
                      bands,
                      width,
                      height)
@@ -102,34 +105,24 @@ void ossimS16ImageData::getNormalizedFloat(ossim_uint32 offset,
                                            ossim_uint32 bandNumber,
                                            float& result)const
 {
-   // make sure that the types and width and height are good.
-   if( (getDataObjectStatus() == OSSIM_NULL) && isValidBand(bandNumber) )
+   if( (getDataObjectStatus() != OSSIM_NULL) && isValidBand(bandNumber) )
    {
-      return;
+      const ossim_sint16* sourceBuf = getSshortBuf(bandNumber);
+      result =
+         static_cast<float>(theRemapTable.normFromPix(sourceBuf[offset]));
    }
-   
-   ossim_int32 p = getSshortBuf(bandNumber)[offset];
-
-   getNormFromPix(p, result, bandNumber);
 }
 
 void ossimS16ImageData::setNormalizedFloat(ossim_uint32 offset,
                                            ossim_uint32 bandNumber,
                                            float inputValue)
 {
-   // make sure that the types and width and height are
-   // good.
-   if((getDataObjectStatus() == OSSIM_NULL)&&
-      (bandNumber < getNumberOfBands()))
+   if( (getDataObjectStatus() != OSSIM_NULL) &&  isValidBand(bandNumber) )
    {
-      return;
+      ossim_sint16* sourceBuf = getSshortBuf(bandNumber);
+      sourceBuf[offset]
+         = static_cast<ossim_sint16>(theRemapTable.pixFromNorm(inputValue));
    }
-
-   ossim_int32 p;
-
-   getPixFromNorm(p, inputValue, bandNumber);
-   
-   getSshortBuf(bandNumber)[offset] = static_cast<ossim_sint16>(p);
 }
 
 void
@@ -150,22 +143,25 @@ ossimS16ImageData::convertToNormalizedFloat(ossimImageData* result)const
    {
       return;
    }
-
+   
    ossim_uint32 size = getSizePerBand();
    
    if(size > 0)
    {
-      for(ossim_uint32 bandCount = 0; bandCount < theNumberOfDataComponents;
+      for(ossim_uint32 bandCount = 0;
+          bandCount < theNumberOfDataComponents;
           ++bandCount)
       {
          const ossim_sint16* sourceBuf = getSshortBuf(bandCount);
-         ossim_float32* resultBuf = static_cast<ossim_float32*>(result->getBuf(bandCount));
+         float* resultBuf = static_cast<float*>(result->getBuf(bandCount));
          for(ossim_uint32 counter = 0; counter <  size; ++counter)
          {
-            getNormFromPix(sourceBuf[counter], resultBuf[counter], bandCount);
+            resultBuf[counter]
+               = static_cast<float>(theRemapTable.
+                                    normFromPix(sourceBuf[counter]));
          }
       }
-   }
+   }   
 }
 
 void ossimS16ImageData::convertToNormalizedDouble(ossimImageData* result)const
@@ -186,25 +182,23 @@ void ossimS16ImageData::convertToNormalizedDouble(ossimImageData* result)const
    {
       return;
    }
-
+   
    ossim_uint32 size = getSizePerBand();
    
    if(size > 0)
    {
-      for(ossim_uint32 bandCount = 0; bandCount < theNumberOfDataComponents;
+      for(ossim_uint32 bandCount = 0;
+          bandCount < theNumberOfDataComponents;
           ++bandCount)
       {
          const ossim_sint16* sourceBuf = getSshortBuf(bandCount);
-         ossim_float64* resultBuf = static_cast<ossim_float64*>(result->getBuf(bandCount));
+         double* resultBuf = static_cast<double*>(result->getBuf(bandCount));
          for(ossim_uint32 counter = 0; counter <  size; ++counter)
          {
-            getNormFromPix(sourceBuf[counter],
-                           resultBuf[counter],
-                           bandCount);
+            resultBuf[counter] = theRemapTable.normFromPix(sourceBuf[counter]);
          }
       }
    }
-
 }
 
 void ossimS16ImageData::unnormalizeInput(ossimImageData* normalizedInput)
@@ -220,22 +214,21 @@ void ossimS16ImageData::unnormalizeInput(ossimImageData* normalizedInput)
    ossim_uint32 bandCount = 0;
    ossim_uint32 size = getSizePerBand();
    ossimScalarType scalarType = normalizedInput->getScalarType();
-
+   
    if(size > 0)
    {
       if(scalarType == OSSIM_NORMALIZED_FLOAT)
       {
          for(bandCount = 0; bandCount < theNumberOfDataComponents; ++bandCount)
          {
-            ossim_float32* sourceBuf =
-               static_cast<ossim_float32*>(normalizedInput->getBuf(bandCount));
+            float* sourceBuf =
+               static_cast<float*>(normalizedInput->getBuf(bandCount));
             ossim_sint16* resultBuf = getSshortBuf(bandCount);
             for(counter = 0; counter <  size; ++counter)
             {
-               ossim_float32 f = sourceBuf[counter];
-               ossim_int32 p;
-               getPixFromNorm(p, f, bandCount);
-               resultBuf[counter] = static_cast<ossim_sint16>(p);
+               resultBuf[counter]
+                  = static_cast<ossim_sint16>(theRemapTable.
+                                              pixFromNorm(sourceBuf[counter]));
             }
          }
       }
@@ -243,18 +236,18 @@ void ossimS16ImageData::unnormalizeInput(ossimImageData* normalizedInput)
       {
          for(bandCount = 0; bandCount < theNumberOfDataComponents; ++bandCount)
          {
-            ossim_float64* sourceBuf =
-               static_cast<ossim_float64*>(normalizedInput->getBuf(bandCount));
+            double* sourceBuf =
+               static_cast<double*>(normalizedInput->getBuf(bandCount));
             ossim_sint16* resultBuf = getSshortBuf(bandCount);
             for(counter = 0; counter <  size; ++counter)
             {
-               ossim_int32 p;
-               getPixFromNorm(p, sourceBuf[counter], bandCount);
-               resultBuf[counter] = static_cast<ossim_sint16>(p);
+               resultBuf[counter]
+                  = static_cast<ossim_sint16>(theRemapTable.
+                                              pixFromNorm(sourceBuf[counter]));
             }
          }
       }
-   }   
+   }
 }
 
 double ossimS16ImageData::computeMeanSquaredError(double meanValue,
@@ -400,24 +393,27 @@ void ossimS16ImageData::copyTileToNormalizedBuffer(double* buf) const
 {
    if (!buf)
    {
-      ossimNotify(ossimNotifyLevel_WARN) << "ossimS16ImageData::copyTileToNormalizedBuffer ERROR:"
-           << "\nBuffer passed to method is NULL!"
-           << endl;
+      ossimSetError(getClassName(),
+                    ossimErrorCodes::OSSIM_ERROR,
+                    "ossimS16ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
+                    __FILE__,
+                    __LINE__);
       return;
    }
+
+   const ossim_uint32 SIZE = getSizePerBand();
    
-   ossim_uint32 size = getSizePerBand();
-   
-   if(size > 0)
-   {
-      for(ossim_uint32 band = 0; band < getNumberOfBands(); band++)
+   if(SIZE > 0)
+   {   
+      for(ossim_uint32 band = 0; band < getNumberOfBands(); ++band)
       {
          const ossim_sint16* s = getSshortBuf(band);  // source
-         ossim_float64*      d = buf + (band*size);   // destination
-
-         for(ossim_uint32 index = 0; index < size; index++)
+         double* d = buf + (band*SIZE);   // destination
+         
+         for(ossim_uint32 index = 0; index < SIZE; ++index)
          {
-            getNormFromPix(s[index], d[index], band);
+            d[index] = theRemapTable.
+               normFromPix(static_cast<ossim_int32>(s[index]));
          }
       }
    }
@@ -429,24 +425,46 @@ void ossimS16ImageData::copyTileToNormalizedBuffer(ossim_uint32 band,
    if (!buf)
    {
       ossimSetError(getClassName(),
-                    ossimErrorCodes::OSSIM_ERROR,
-                    "ossimU11ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
+                     ossimErrorCodes::OSSIM_ERROR,
+                    "ossimS16ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
                     __FILE__,
                     __LINE__);
       return;
    }
+   
    if(!getBuf(band)) return;
    
-   ossim_uint32 size = getSizePerBand();
+   const ossim_uint32 SIZE = getSizePerBand();
    
-   if(size > 0)
+   if(SIZE)
    {
+      const ossim_float64 RANGE = (getMaxPix(band)-getMinPix(band)+1);
+      
       const ossim_sint16* s = getSshortBuf(band);  // source
       double* d = buf;   // destination
       
-      for(ossim_uint32 index = 0; index < size; index++)
+      for(ossim_uint32 index = 0; index < SIZE; ++index)
       {
-         getNormFromPix(*s, *d, band);
+         ossim_float64 p = s[index];
+         
+         if (p == theNullPixelValue[band])
+         {
+            d[index] = 0.0;
+         }
+         else if (p >= theMaxPixelValue[band])
+         {
+            d[index] = 1.0;
+         }
+         else
+         {
+            //---
+            // Normalize...
+            // Note that this will shift any negatives to positive prior
+            // to dividing.
+            //---
+            d[index] =
+               ((p-theMinPixelValue[band]+1) / RANGE);
+         }
       }
    }
 }
@@ -469,17 +487,15 @@ void ossimS16ImageData::copyNormalizedBufferToTile(double* buf)
    {
       for(ossim_uint32 band = 0; band < getNumberOfBands(); band++)
       {
-         ossim_float64* s = buf + (band*size);  // source
-         ossim_sint16*  d = getSshortBuf(band); // destination
-
-         for(ossim_uint32 index = 0; index < size; index++)
+         double* s = buf + (band*size); // source
+         ossim_sint16* d = getSshortBuf(band); // destination
+         
+         for(ossim_uint32 index = 0; index <  size; index++)
          {
-            ossim_int32 p;
-            getPixFromNorm(p, s[index], band);
-            d[index] = static_cast<ossim_sint16>(p);
+            d[index] = theRemapTable.pixFromNorm(s[index]);
          }
       }
-   }
+   }   
 }
 
 void ossimS16ImageData::copyNormalizedBufferToTile(ossim_uint32 band,
@@ -489,7 +505,7 @@ void ossimS16ImageData::copyNormalizedBufferToTile(ossim_uint32 band,
    {
       ossimSetError(getClassName(),
                     ossimErrorCodes::OSSIM_ERROR,
-                    "ossimU11ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
+                    "ossimS11ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
                     __FILE__,
                     __LINE__);
       return;
@@ -502,11 +518,9 @@ void ossimS16ImageData::copyNormalizedBufferToTile(ossim_uint32 band,
       double* s = buf; // source
       ossim_sint16* d = getSshortBuf(band); // destination
       
-      for(ossim_uint32 index = 0; index <  size; index++)
+      for(ossim_uint32 index = 0; index <  size; ++index)
       {
-         ossim_int32 p;
-         getPixFromNorm(p, *s, band);
-         *d = static_cast<ossim_sint16>(p);
+         *d = theRemapTable.pixFromNorm(*s);
          ++d;
          ++s;
       }
@@ -517,9 +531,11 @@ void ossimS16ImageData::copyTileToNormalizedBuffer(float* buf) const
 {
    if (!buf)
    {
-      ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimS16ImageData::copyTileToNormalizedBuffer ERROR:"
-         << "\nBuffer passed to method is NULL!" << endl;
+      ossimSetError(getClassName(),
+                    ossimErrorCodes::OSSIM_ERROR,
+                    "ossimS16ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
+                    __FILE__,
+                    __LINE__);
       return;
    }
    
@@ -527,14 +543,15 @@ void ossimS16ImageData::copyTileToNormalizedBuffer(float* buf) const
    
    if(size > 0)
    {
-      for(ossim_uint32 band = 0; band < getNumberOfBands(); band++)
+      for(ossim_uint32 band = 0; band < getNumberOfBands(); ++band)
       {
          const ossim_sint16* s = getSshortBuf(band);  // source
-         float*    d = buf + (band*size);   // destination
-
-         for(ossim_uint32 index = 0; index < size; index++)
+         float* d = buf + (band*size);   // destination
+         
+         for(ossim_uint32 index = 0; index < size; ++index)
          {
-            getNormFromPix(s[index], d[index], band);
+            d[index] = theRemapTable.
+               normFromPix(static_cast<ossim_int32>(s[index]));
          }
       }
    }
@@ -547,7 +564,7 @@ void ossimS16ImageData::copyTileToNormalizedBuffer(ossim_uint32 band,
    {
       ossimSetError(getClassName(),
                     ossimErrorCodes::OSSIM_ERROR,
-                    "ossimU11ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
+                    "ossimS16ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
                     __FILE__,
                     __LINE__);
       return;
@@ -561,9 +578,9 @@ void ossimS16ImageData::copyTileToNormalizedBuffer(ossim_uint32 band,
       const ossim_sint16* s = getSshortBuf(band);  // source
       float* d = buf;   // destination
       
-      for(ossim_uint32 index = 0; index < size; index++)
+      for(ossim_uint32 index = 0; index < size; ++index)
       {
-         getNormFromPix(*s, *d, band);
+         *d = theRemapTable.normFromPix(static_cast<ossim_int32>(*s));
       }
    }
 }
@@ -584,16 +601,14 @@ void ossimS16ImageData::copyNormalizedBufferToTile(float* buf)
    
    if(size > 0)
    {
-      for(ossim_uint32 band = 0; band < getNumberOfBands(); band++)
+      for(ossim_uint32 band = 0; band < getNumberOfBands(); ++band)
       {
-         float*    s = buf + (band*size);  // source
+         float* s = buf + (band*size); // source
          ossim_sint16* d = getSshortBuf(band); // destination
-
-         for(ossim_uint32 index = 0; index < size; index++)
+         
+         for(ossim_uint32 index = 0; index <  size; ++index)
          {
-            ossim_int32 p;
-            getPixFromNorm(p, s[index], band);
-            d[index] = static_cast<ossim_sint16>(p);
+            d[index] = theRemapTable.pixFromNorm(s[index]);
          }
       }
    }
@@ -606,7 +621,7 @@ void ossimS16ImageData::copyNormalizedBufferToTile(ossim_uint32 band,
    {
       ossimSetError(getClassName(),
                     ossimErrorCodes::OSSIM_ERROR,
-                    "ossimU11ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
+                    "ossimS16ImageData::copyTileToNormalizedBuffer File %s line %d\nNull pointer passed to method!",
                     __FILE__,
                     __LINE__);
       return;
@@ -619,11 +634,9 @@ void ossimS16ImageData::copyNormalizedBufferToTile(ossim_uint32 band,
       float* s = buf; // source
       ossim_sint16* d = getSshortBuf(band); // destination
       
-      for(ossim_uint32 index = 0; index <  size; index++)
+      for(ossim_uint32 index = 0; index <  size; ++index)
       {
-         ossim_int32 p;
-         getPixFromNorm(p, *s, band);
-         *d = static_cast<ossim_sint16>(p);
+         *d = theRemapTable.pixFromNorm(*s);
          ++d;
          ++s;
       }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimScalarRemapper.cpp b/Utilities/otbossim/src/ossim/imaging/ossimScalarRemapper.cpp
index d48575ab8b3f98037b240b8ab668f12c5b7dc803..55efc0e58fbb396c3fb0f44cee6e7b434c4e2ac4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimScalarRemapper.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimScalarRemapper.cpp
@@ -11,7 +11,7 @@
 // This class is used to remap image data from one scalar type to another.
 //
 //*******************************************************************
-//  $Id: ossimScalarRemapper.cpp 11347 2007-07-23 13:01:59Z gpotts $
+//  $Id: ossimScalarRemapper.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 
@@ -179,6 +179,21 @@ ossimRefPtr<ossimImageData> ossimScalarRemapper::getTile(
                                                 inputTile->getBuf()));
          break;
       }
+      case OSSIM_SINT16:
+      case OSSIM_UINT16:
+      case OSSIM_SINT32:
+      {
+         //---
+         // Special case.  Stretch assuming caller want to view this data.
+         //---
+         inputTile->stretchMinMax();
+
+         // Normalize and copy the source tile to a buffer.
+         inputTile->copyTileToNormalizedBuffer(theNormBuf);
+         
+         // Un-normalize and copy the buffer to the destination tile.
+         theTile->copyNormalizedBufferToTile(theNormBuf);
+      }
       default:
       {
          // Normalize and copy the source tile to a buffer.
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimScaleFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimScaleFilter.cpp
index 2eb4e259451e2b9db28ed6d48c0ffbd90d40abe9..2ceacb5a5d1e28ac9dc469d9b2ac4b9bd19a35e1 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimScaleFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimScaleFilter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimScaleFilter.cpp 11955 2007-10-31 16:10:22Z gpotts $
+// $Id: ossimScaleFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/imaging/ossimScaleFilter.h>
 #include <ossim/imaging/ossimFilter.h>
 #include <ossim/imaging/ossimDiscreteConvolutionKernel.h>
@@ -19,86 +19,90 @@
 
 RTTI_DEF1(ossimScaleFilter, "ossimScaleFilter", ossimImageSourceFilter);
 
+//**************************************************************************************************
 ossimScaleFilter::ossimScaleFilter()
    :ossimImageSourceFilter(),
-    theBlankTile(NULL),
-    theTile(NULL),
-    theMinifyFilter(NULL),
-    theMagnifyFilter(NULL),
-    theMinifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
-    theMagnifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
-    theScaleFactor(1.0, 1.0),
-    theInverseScaleFactor(1.0, 1.0),
-    theTileSize(64, 64),
-    theBlurFactor(1.0)
+    m_BlankTile(NULL),
+    m_Tile(NULL),
+    m_MinifyFilter(NULL),
+    m_MagnifyFilter(NULL),
+    m_MinifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
+    m_MagnifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
+    m_ScaleFactor(1.0, 1.0),
+    m_InverseScaleFactor(1.0, 1.0),
+    m_TileSize(64, 64),
+    m_BlurFactor(1.0)
 {
-   theInputRect.makeNan();
-   theMinifyFilter  = new ossimNearestNeighborFilter();
-   theMagnifyFilter = new ossimNearestNeighborFilter();
+   m_InputRect.makeNan();
+   m_MinifyFilter  = new ossimNearestNeighborFilter();
+   m_MagnifyFilter = new ossimNearestNeighborFilter();
 }
 
+//**************************************************************************************************
 ossimScaleFilter::ossimScaleFilter(ossimImageSource* inputSource,
                                    const ossimDpt& scaleFactor)
    :ossimImageSourceFilter(inputSource),
-    theBlankTile(NULL),
-    theTile(NULL),
-    theMinifyFilter(NULL),
-    theMagnifyFilter(NULL),
-    theMinifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
-    theMagnifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
-    theScaleFactor(scaleFactor),
-    theTileSize(64, 64),
-    theBlurFactor(1.0)
+    m_BlankTile(NULL),
+    m_Tile(NULL),
+    m_MinifyFilter(NULL),
+    m_MagnifyFilter(NULL),
+    m_MinifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
+    m_MagnifyFilterType(ossimScaleFilter_NEAREST_NEIGHBOR),
+    m_ScaleFactor(scaleFactor),
+    m_TileSize(64, 64),
+    m_BlurFactor(1.0)
 {
-   theInputRect.makeNan();
-   theMinifyFilter  = new ossimNearestNeighborFilter();
-   theMagnifyFilter = new ossimNearestNeighborFilter();
+   m_InputRect.makeNan();
+   m_MinifyFilter  = new ossimNearestNeighborFilter();
+   m_MagnifyFilter = new ossimNearestNeighborFilter();
 }
 
+//**************************************************************************************************
 ossimScaleFilter::~ossimScaleFilter()
 {
-   if(theMinifyFilter)
+   if(m_MinifyFilter)
    {
-      delete theMinifyFilter;
-      theMinifyFilter = NULL;
+      delete m_MinifyFilter;
+      m_MinifyFilter = NULL;
    }
    
-   if(theMagnifyFilter)
+   if(m_MagnifyFilter)
    {
-      delete theMagnifyFilter;
-      theMagnifyFilter = NULL;
+      delete m_MagnifyFilter;
+      m_MagnifyFilter = NULL;
    }
 }
 
+//**************************************************************************************************
 ossimRefPtr<ossimImageData> ossimScaleFilter::getTile(
    const ossimIrect& tileRect, ossim_uint32 resLevel)
 {
    
    if((!isSourceEnabled())||
       (!theInputConnection)||
-      ((theScaleFactor.x == 1.0)&&
-       (theScaleFactor.y == 1.0)&&
-       (theBlurFactor == 1.0)))
+      ((m_ScaleFactor.x == 1.0)&&
+       (m_ScaleFactor.y == 1.0)&&
+       (m_BlurFactor == 1.0)))
    {
       return ossimImageSourceFilter::getTile(tileRect, resLevel);
    }
-   if(!theTile.valid())
+   if(!m_Tile.valid())
    {
       allocate();
    }
 
-   if(!theTile)
+   if(!m_Tile)
    {
       return ossimImageSourceFilter::getTile(tileRect, resLevel);
    }
 
-   theTile->makeBlank();
+   m_Tile->makeBlank();
 
                        
-   ossimIrect imageRect = tileRect*theInverseScaleFactor;
+   ossimIrect imageRect = tileRect*m_InverseScaleFactor;
 
-   theTile->setImageRectangle(tileRect);
-   theBlankTile->setImageRectangle(tileRect);
+   m_Tile->setImageRectangle(tileRect);
+   m_BlankTile->setImageRectangle(tileRect);
 
 
    double xSupport;
@@ -118,15 +122,16 @@ ossimRefPtr<ossimImageData> ossimScaleFilter::getTile(
    
    runFilter(imageRect, tileRect);
    
-   theTile->validate();
+   m_Tile->validate();
    
-   return theTile;
+   return m_Tile;
 }
 
+//**************************************************************************************************
 void ossimScaleFilter::runFilter(const ossimIrect& imageRect,
                                  const ossimIrect& viewRect)
 {
-   switch(theTile->getScalarType())
+   switch(m_Tile->getScalarType())
    {
       case OSSIM_UINT8:
       {
@@ -178,6 +183,7 @@ void ossimScaleFilter::runFilter(const ossimIrect& imageRect,
    }
 }
 
+//**************************************************************************************************
 template <class T>
 void ossimScaleFilter::runFilterTemplate(T dummy,
                                          const ossimIrect& imageRect,
@@ -205,8 +211,8 @@ void ossimScaleFilter::runFilterTemplate(T dummy,
    
    tempData->initialize();
    
-   if((theScaleFactor.x != 1.0)||
-      (theBlurFactor != 1.0))
+   if((m_ScaleFactor.x != 1.0)||
+      (m_BlurFactor != 1.0))
    {
       runHorizontalFilterTemplate(dummy,
                                   inputData,
@@ -218,21 +224,22 @@ void ossimScaleFilter::runFilterTemplate(T dummy,
       tempData->loadTile(inputData.get());
    }
    
-   if((theScaleFactor.y != 1.0)||
-      (theBlurFactor != 1.0))
+   if((m_ScaleFactor.y != 1.0)||
+      (m_BlurFactor != 1.0))
    {
       runVerticalFilterTemplate(dummy,
                                 tempData,
-                                theTile);
+                                m_Tile);
    }
    else
    {
-      theTile->loadTile(tempData.get());
+      m_Tile->loadTile(tempData.get());
    }
    
-   theTile->validate();
+   m_Tile->validate();
 }
 
+//**************************************************************************************************
 ossimIrect ossimScaleFilter::getBoundingRect(ossim_uint32 resLevel)const
 {
    ossimIrect result = ossimImageSourceFilter::getBoundingRect(resLevel);
@@ -243,39 +250,42 @@ ossimIrect ossimScaleFilter::getBoundingRect(ossim_uint32 resLevel)const
                           result.ul().y,
                           result.lr().x+1,
                           result.lr().y+1);
-      result *= theScaleFactor;
+      result *= m_ScaleFactor;
    }
    
    return result;
 }
 
+//**************************************************************************************************
 void ossimScaleFilter::setFilterType(ossimScaleFilterType filterType)
 {
    setFilterType(filterType, filterType);
 }
 
 
+//**************************************************************************************************
 void ossimScaleFilter::setFilterType(ossimScaleFilterType minifyFilterType,
                                      ossimScaleFilterType magnifyFilterType)
 {
-   if(theMinifyFilter)
+   if(m_MinifyFilter)
    {
-      delete theMinifyFilter;
-      theMinifyFilter = NULL;
+      delete m_MinifyFilter;
+      m_MinifyFilter = NULL;
    }
-   if(theMagnifyFilter)
+   if(m_MagnifyFilter)
    {
-      delete theMagnifyFilter;
-      theMagnifyFilter = NULL;
+      delete m_MagnifyFilter;
+      m_MagnifyFilter = NULL;
    }
    
-   theMinifyFilterType  = minifyFilterType;
-   theMagnifyFilterType = magnifyFilterType;
+   m_MinifyFilterType  = minifyFilterType;
+   m_MagnifyFilterType = magnifyFilterType;
    
-   theMinifyFilter  = createNewFilter(minifyFilterType, theMinifyFilterType);
-   theMagnifyFilter = createNewFilter(magnifyFilterType, theMagnifyFilterType);
+   m_MinifyFilter  = createNewFilter(minifyFilterType, m_MinifyFilterType);
+   m_MagnifyFilter = createNewFilter(magnifyFilterType, m_MagnifyFilterType);
 }
 
+//**************************************************************************************************
 ossimFilter* ossimScaleFilter::createNewFilter(ossimScaleFilterType filterType,
                                                ossimScaleFilterType& result)
 {
@@ -348,23 +358,29 @@ ossimFilter* ossimScaleFilter::createNewFilter(ossimScaleFilterType filterType,
    return new ossimNearestNeighborFilter();
 }
 
+//**************************************************************************************************
 void ossimScaleFilter::setScaleFactor(const ossimDpt& scale)
 {
-   theScaleFactor = scale;
-   if(fabs(theScaleFactor.x) <= FLT_EPSILON)
+   m_ScaleFactor = scale;
+   if(fabs(m_ScaleFactor.x) <= FLT_EPSILON)
    {
-      theScaleFactor.x = 1.0;
+      m_ScaleFactor.x = 1.0;
    }
-   if(fabs(theScaleFactor.y) <= FLT_EPSILON)
+   if(fabs(m_ScaleFactor.y) <= FLT_EPSILON)
    {
-      theScaleFactor.y = 1.0;
+      m_ScaleFactor.y = 1.0;
    }
 
-   theInverseScaleFactor.x = 1.0/theScaleFactor.x;
-   theInverseScaleFactor.y = 1.0/theScaleFactor.y;
+   m_InverseScaleFactor.x = 1.0/m_ScaleFactor.x;
+   m_InverseScaleFactor.y = 1.0/m_ScaleFactor.y;
+
+   // A change in the scale factor implies a change to the image geometry. If one has been created
+   // it needs to be modified:
+   updateGeometry();
 }
 
 
+//**************************************************************************************************
 template <class T> void ossimScaleFilter::runHorizontalFilterTemplate(
    T dummy,
    const ossimRefPtr<ossimImageData>& input,
@@ -377,8 +393,8 @@ template <class T> void ossimScaleFilter::runHorizontalFilterTemplate(
    ossim_int32 iw = imageRect.width();
    ossimIpt origin(viewRect.ul());
    ossimIpt imageOrigin(imageRect.ul());
-   ossimIpt inputUl = theInputRect.ul();
-   ossimIpt inputLr = theInputRect.lr();
+   ossimIpt inputUl = m_InputRect.ul();
+   ossimIpt inputLr = m_InputRect.lr();
    
    double scale = 0.0;
    double support = 0.0;
@@ -390,9 +406,9 @@ template <class T> void ossimScaleFilter::runHorizontalFilterTemplate(
    const ossimFilter* filter = getHorizontalFilter();
    ossim_float64 center = 0.0;
    ossim_int32 bandIdx = 0;
-   ossim_int32 numberOfBands = theTile->getNumberOfBands();
+   ossim_int32 numberOfBands = m_Tile->getNumberOfBands();
    
-   scale = theBlurFactor*ossim::max(1.0/theScaleFactor.x, 1.0);
+   scale = m_BlurFactor*ossim::max(1.0/m_ScaleFactor.x, 1.0);
    
    support=scale*filter->getSupport();
    if (support <= 0.5)
@@ -412,7 +428,7 @@ template <class T> void ossimScaleFilter::runHorizontalFilterTemplate(
       
       for(x = 0; x < vw; ++x)
       {
-         center=(origin.x + x+ .5)/theScaleFactor.x;
+         center=(origin.x + x+ .5)/m_ScaleFactor.x;
          start=ossim::max((ossim_int32)ossim::round<int>(center-support), (ossim_int32)inputUl.x);
          stop=ossim::min((ossim_int32)ossim::round<int>(center+support), (ossim_int32)inputLr.x);
          ossim_int32 delta = stop-start;
@@ -487,6 +503,7 @@ template <class T> void ossimScaleFilter::runHorizontalFilterTemplate(
    }
 }
 
+//**************************************************************************************************
 template <class T> void ossimScaleFilter::runVerticalFilterTemplate(
    T dummy,
    const ossimRefPtr<ossimImageData>& input,
@@ -499,8 +516,8 @@ template <class T> void ossimScaleFilter::runVerticalFilterTemplate(
    ossim_int32 iw = imageRect.width();
    ossimIpt origin(viewRect.ul());
    ossimIpt imageOrigin(imageRect.ul());
-   ossimIpt inputUl = theInputRect.ul();
-   ossimIpt inputLr = theInputRect.lr();
+   ossimIpt inputUl = m_InputRect.ul();
+   ossimIpt inputLr = m_InputRect.lr();
    double scale = 0.0;
    double support = 0.0;
    ossim_int32 x = 0;
@@ -511,9 +528,9 @@ template <class T> void ossimScaleFilter::runVerticalFilterTemplate(
    const ossimFilter* filter = getVerticalFilter();
    ossim_float64 center = 0.0;
    ossim_int32 bandIdx = 0;
-   ossim_int32 numberOfBands = theTile->getNumberOfBands();
+   ossim_int32 numberOfBands = m_Tile->getNumberOfBands();
    
-   scale = theBlurFactor*ossim::max(1.0/theScaleFactor.y, 1.0);
+   scale = m_BlurFactor*ossim::max(1.0/m_ScaleFactor.y, 1.0);
    
    support=scale*filter->getSupport();
    if (support <= 0.5)
@@ -534,7 +551,7 @@ template <class T> void ossimScaleFilter::runVerticalFilterTemplate(
      
       for(y = 0; y < vh; ++y)
       {
-         center=(double) ((y + origin.y+0.5)/theScaleFactor.y);
+         center=(double) ((y + origin.y+0.5)/m_ScaleFactor.y);
          start=ossim::max((ossim_int32)ossim::round<int>(center-support), (ossim_int32)inputUl.y);
          stop=ossim::min((ossim_int32)ossim::round<int>(center+support), (ossim_int32)inputLr.y);
          ossim_int32 delta = stop-start;
@@ -606,63 +623,71 @@ template <class T> void ossimScaleFilter::runVerticalFilterTemplate(
    }
 }
 
+//**************************************************************************************************
 void ossimScaleFilter::initialize()
 {
    ossimImageSourceFilter::initialize();
 
    // Force an allocate next getTile.
-   theTile = NULL;
-   theBlankTile = NULL;
-   theInputRect.makeNan();
+   m_Tile = NULL;
+   m_BlankTile = NULL;
+   m_InputRect.makeNan();
 }
 
+//**************************************************************************************************
 void ossimScaleFilter::allocate()
 {
-   theTile      = NULL;
-   theBlankTile = NULL;
-   theInputRect.makeNan();
+   m_Tile      = NULL;
+   m_BlankTile = NULL;
+   m_InputRect.makeNan();
 
    if(theInputConnection&&isSourceEnabled())
    {
-      theTile      = ossimImageDataFactory::instance()->create(this, this);
-      theBlankTile = ossimImageDataFactory::instance()->create(this, this);
+      m_Tile      = ossimImageDataFactory::instance()->create(this, this);
+      m_BlankTile = ossimImageDataFactory::instance()->create(this, this);
       
-      theTile->initialize();
+      m_Tile->initialize();
 
-      theInputRect = theInputConnection->getBoundingRect();
+      m_InputRect = theInputConnection->getBoundingRect();
    }
 }
 
-bool ossimScaleFilter::getImageGeometry(ossimKeywordlist& kwl,
-                                        const char* prefix)
+//**************************************************************************************************
+// Returns a pointer reference to the active image geometry at this filter. The input source
+// geometry is modified, so we need to maintain our own geometry object as a data member.
+//**************************************************************************************************
+ossimImageGeometry* ossimScaleFilter::getImageGeometry()
 {
+   // Have we already defined our own geometry? Return it if so:
+   if (m_ScaledGeometry.valid())
+      return m_ScaledGeometry.get();
+
+   // Otherwise we'll need to establish a geometry based on the input connection:
    if(theInputConnection)
    {
-      theInputConnection->getImageGeometry(kwl, prefix);
+      // Fetch the map projection of the input image if it exists:
+      ossimImageGeometry* inputGeom = theInputConnection->getImageGeometry();
 
-      ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,
-                                                                                           prefix);
+      // If trivial case of identity scale, just pass along the input connection's geometry:
+      if ((m_ScaleFactor.x == 1.0) && (m_ScaleFactor.y == 1.0))
+         return inputGeom;
 
-      if(proj)
+      // Need to create a copy of the input geom and modify it as our own, then pass that:
+      if (inputGeom)
       {
-         ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection,
-                                                proj);
-
-         if(mapProj)
-         {
-            mapProj->applyScale(theInverseScaleFactor, true);
-
-            mapProj->saveState(kwl, prefix);
-         }
-         
-         delete proj;
+         m_ScaledGeometry = new ossimImageGeometry(*inputGeom);
+         updateGeometry();
 
-         return true;
+         // Return the modified geometry:
+         return m_ScaledGeometry.get();
       }
    }
-   return false;
+
+   // No geometry defined, return NULL pointer:
+   return 0;
 }
 
+//**************************************************************************************************
 ossimIrect ossimScaleFilter::scaleRect(const ossimIrect input,
                                        const ossimDpt& scaleFactor)const
 {
@@ -680,6 +705,7 @@ ossimIrect ossimScaleFilter::scaleRect(const ossimIrect input,
                      origin.y + (h-1));
 }
 
+//**************************************************************************************************
 ossimString ossimScaleFilter::getFilterTypeAsString(ossimScaleFilterType type)const
 {
    switch(type)
@@ -749,6 +775,7 @@ ossimString ossimScaleFilter::getFilterTypeAsString(ossimScaleFilterType type)co
    return "nearest_neighbor";
 }
 
+//**************************************************************************************************
 ossimScaleFilter::ossimScaleFilterType ossimScaleFilter::getFilterType(const ossimString& type)const
 {
    ossimString typeUpper = type;
@@ -818,61 +845,66 @@ ossimScaleFilter::ossimScaleFilterType ossimScaleFilter::getFilterType(const oss
    return ossimScaleFilter_NEAREST_NEIGHBOR;
 }
 
+//**************************************************************************************************
 void ossimScaleFilter::getSupport(double& x, double& y)
 {
    const ossimFilter* horizontalFilter = getHorizontalFilter();
    const ossimFilter* verticalFilter   = getVerticalFilter();
    
-   x = theBlurFactor*ossim::max(1.0/theScaleFactor.x, 1.0)*
+   x = m_BlurFactor*ossim::max(1.0/m_ScaleFactor.x, 1.0)*
        horizontalFilter->getSupport();
-   y = theBlurFactor*ossim::max(1.0/theScaleFactor.y, 1.0)*
+   y = m_BlurFactor*ossim::max(1.0/m_ScaleFactor.y, 1.0)*
        verticalFilter->getSupport();
 }
 
+//**************************************************************************************************
 const ossimFilter* ossimScaleFilter::getHorizontalFilter()const
 {
-   if(theScaleFactor.x < 1)
+   if(m_ScaleFactor.x < 1)
    {
-      return theMinifyFilter;
+      return m_MinifyFilter;
    }
 
-   return theMagnifyFilter;
+   return m_MagnifyFilter;
 }
 
+//**************************************************************************************************
 const ossimFilter* ossimScaleFilter::getVerticalFilter()const
 {
-   if(theScaleFactor.y < 1)
+   if(m_ScaleFactor.y < 1)
    {
-      return theMinifyFilter;
+      return m_MinifyFilter;
    }
 
-   return theMagnifyFilter;
+   return m_MagnifyFilter;
 }
 
 
 
+//**************************************************************************************************
 bool ossimScaleFilter::saveState(ossimKeywordlist& kwl, const char* prefix)const
 {
    kwl.add(prefix,
            ossimKeywordNames::SCALE_X_KW,
-           theScaleFactor.x,
+           m_ScaleFactor.x,
            true);
    kwl.add(prefix,
            ossimKeywordNames::SCALE_Y_KW,
-           theScaleFactor.y,
+           m_ScaleFactor.y,
            true);
    kwl.add(prefix,
            "minify_type",
-           getFilterTypeAsString(theMinifyFilterType),
+           getFilterTypeAsString(m_MinifyFilterType),
            true);
    kwl.add(prefix,
            "magnify_type",
-           getFilterTypeAsString(theMagnifyFilterType),
+           getFilterTypeAsString(m_MagnifyFilterType),
            true);
    
    return ossimImageSourceFilter::saveState(kwl, prefix);
 }
 
+//**************************************************************************************************
 bool ossimScaleFilter::loadState(const ossimKeywordlist& kwl,
                                  const char* prefix)
 {
@@ -885,24 +917,43 @@ bool ossimScaleFilter::loadState(const ossimKeywordlist& kwl,
    ossimString magnify = kwl.find(prefix,
                                   "magnify_type");
    
-   theScaleFactor.x = scalex.toDouble();
-   theScaleFactor.y = scaley.toDouble();
+   m_ScaleFactor.x = scalex.toDouble();
+   m_ScaleFactor.y = scaley.toDouble();
 
-   if(fabs(theScaleFactor.x) <= FLT_EPSILON)
+   if(fabs(m_ScaleFactor.x) <= FLT_EPSILON)
    {
-      theScaleFactor.x = 1.0;
+      m_ScaleFactor.x = 1.0;
    }
-   if(fabs(theScaleFactor.y) <= FLT_EPSILON)
+   if(fabs(m_ScaleFactor.y) <= FLT_EPSILON)
    {
-      theScaleFactor.y = 1.0;
+      m_ScaleFactor.y = 1.0;
    }
 
-   theInverseScaleFactor.x = 1.0/theScaleFactor.x;
-   theInverseScaleFactor.y = 1.0/theScaleFactor.y;
+   m_InverseScaleFactor.x = 1.0/m_ScaleFactor.x;
+   m_InverseScaleFactor.y = 1.0/m_ScaleFactor.y;
    
    setFilterType(getFilterType(minify),
                  getFilterType(magnify));
    
+   // A change in the scale factor implies a change to the image geometry. If one has been created
+   // it needs to be modified:
+   updateGeometry();
+
    return ossimImageSourceFilter::loadState(kwl, prefix);
 }
 
+//**************************************************************************************************
+//! If this object is maintaining an ossimImageGeometry, this method needs to be called after 
+//! a scale change so that the geometry's projection is modified accordingly.
+//**************************************************************************************************
+void ossimScaleFilter::updateGeometry()
+{
+   if (m_ScaledGeometry.valid())
+   {
+      // Modify the image geometry's projection with the scale factor before returning geom:
+      ossimProjection* proj = m_ScaledGeometry->getProjection();
+      ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);
+      if(mapProj)
+         mapProj->applyScale(m_InverseScaleFactor, true);
+   }
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimSrtmTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimSrtmTileSource.cpp
index 07302425ade6ccacb9721d8cc49d6824dabb7afa..b1274f91a37f86fc99f9e812e47caaf14f388352 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimSrtmTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimSrtmTileSource.cpp
@@ -9,12 +9,13 @@
 // Image handler class for a Shuttle Radar Topography Mission (SRTM) file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimSrtmTileSource.cpp 10275 2007-01-15 16:39:53Z dburken $
+// $Id: ossimSrtmTileSource.cpp 15801 2009-10-23 20:04:16Z gpotts $
 
 #include <ossim/imaging/ossimSrtmTileSource.h>
 #include <ossim/base/ossimDirectory.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/support_data/ossimSrtmSupportData.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
 
 RTTI_DEF1(ossimSrtmTileSource,
                "ossimSrtmTileSource",
@@ -25,7 +26,7 @@ static ossimTrace traceDebug("ossimSrtmTileSource:debug");
 ossimSrtmTileSource::ossimSrtmTileSource()
    :
    ossimGeneralRasterTileSource(),
-   theSrtmSupportData()
+   m_SrtmSupportData()
 {
 }
 
@@ -52,7 +53,7 @@ bool ossimSrtmTileSource::open()
    // in a omd file so this is a one time hit typically taken when building
    // reduced res sets.
    //---
-   if (!theSrtmSupportData.setFilename(theImageFile, true))
+   if (!m_SrtmSupportData.setFilename(theImageFile, true))
    {
       if (traceDebug()) CLOG << " Unable to set filename"<< std::endl;
       
@@ -60,7 +61,7 @@ bool ossimSrtmTileSource::open()
    }
 
    ossimKeywordlist kwl;
-   theSrtmSupportData.saveState(kwl);
+   m_SrtmSupportData.saveState(kwl);
    
    ossimGeneralRasterInfo generalRasterInfo;
    bool result = generalRasterInfo.loadState(kwl);
@@ -81,29 +82,34 @@ bool ossimSrtmTileSource::open()
    return result;
 }
    
-bool ossimSrtmTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                              const char* prefix)
+//**************************************************************************************************
+//! Returns the image geometry object associated with this tile source or NULL if non defined.
+//! The geometry contains full-to-local image transform as well as projection (image-to-world)
+//**************************************************************************************************
+ossimImageGeometry* ossimSrtmTileSource::getInternalImageGeometry()
 {
    // Check for override for an external geometry file, or a previous save.
-   if(ossimImageHandler::getImageGeometry(kwl, prefix))
-   {
-      return true;
-   }
-
-   if (theSrtmSupportData.getImageGeometry(kwl, prefix))
+   if(!theGeometry.valid())
+      theGeometry = new ossimImageGeometry();
+   ossimKeywordlist kwl;
+   if (m_SrtmSupportData.getImageGeometry(kwl))
    {
-      // Capture for next time...
-      setImageGeometry(kwl);
-      return true;
+      // Capture for next time.
+      ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+      if (proj)
+      {
+         theGeometry->setProjection(proj);
+         return theGeometry.get();
+      }
    }
 
-   return false;
+   return 0;
 }
 
 bool ossimSrtmTileSource::saveState(ossimKeywordlist& kwl,
                                     const char* prefix)const
 {
-   if (theSrtmSupportData.saveState(kwl, prefix))
+   if (m_SrtmSupportData.saveState(kwl, prefix))
    {
       return ossimImageHandler::saveState(kwl,prefix);
    }
@@ -113,9 +119,9 @@ bool ossimSrtmTileSource::saveState(ossimKeywordlist& kwl,
 bool ossimSrtmTileSource::loadState(const ossimKeywordlist& kwl,
                                     const char* prefix)
 {
-   if (theSrtmSupportData.loadState(kwl, prefix))
+   if (m_SrtmSupportData.loadState(kwl, prefix))
    {
-      setFilename(theSrtmSupportData.getFilename());
+      setFilename(m_SrtmSupportData.getFilename());
       if (open())
       {
          // Must call to pick up id for connections.
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp
index 2f441f0e161d2f4c16c826aca30f6a5f274fdc8a..72fd8547c763d52734cee8dfc95fcc92becc915d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
@@ -9,9 +11,10 @@
 // Contains class definition for TiffOverviewBuilder
 // 
 //*******************************************************************
-//  $Id: ossimTiffOverviewBuilder.cpp 13155 2008-07-08 15:59:52Z gpotts $
+//  $Id: ossimTiffOverviewBuilder.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
-#include <cstring>
+#include <algorithm> /* for std::fill */
+// #include <cstring>
 #include <sstream>
 using namespace std;
 #include <xtiffio.h>
@@ -48,8 +51,11 @@ RTTI_DEF1(ossimTiffOverviewBuilder,
 
 static ossimTrace traceDebug("ossimTiffOverviewBuilder:degug");
 
+// Property keywords.
+static const char COPY_ALL_KW[] = "copy_all_flag";
+
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimTiffOverviewBuilder.cpp 13155 2008-07-08 15:59:52Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimTiffOverviewBuilder.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 
@@ -60,9 +66,7 @@ ossimTiffOverviewBuilder::ossimTiffOverviewBuilder()
    :
       ossimOverviewBuilderBase(),
       theImageHandler(0),
-      theOwnsImageHandlerFlag(false),
       theOutputFile(ossimFilename::NIL),
-      theOutputFileTmp(ossimFilename::NIL),
       theNullDataBuffer(0),
       theBytesPerPixel(1),
       theBitsPerSample(8),
@@ -77,34 +81,26 @@ ossimTiffOverviewBuilder::ossimTiffOverviewBuilder()
       theNullPixelValues(),
       theCopyAllFlag(false),
       theOutputTileSizeSetFlag(false)
-   
 {
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimTiffOverviewBuilder::ossimTiffOverviewBuilder DEBUG:"
-         << std::endl;
+         << "ossimTiffOverviewBuilder::ossimTiffOverviewBuilder DEBUG:\n";
 #ifdef OSSIM_ID_ENABLED
       ossimNotify(ossimNotifyLevel_DEBUG)
          << "OSSIM_ID:  "
          << OSSIM_ID
+         << "\n";
+#endif
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "overview stop dimension: " << theOverviewStopDimension
          << std::endl;
-#endif      
    }
 }
 
 ossimTiffOverviewBuilder::~ossimTiffOverviewBuilder()
 {
-   if (theOwnsImageHandlerFlag && theImageHandler)
-   {
-      delete theImageHandler;
-      theImageHandler = 0;
-   }
-   if (theNullDataBuffer)
-   {
-      delete [] theNullDataBuffer;
-      theNullDataBuffer = 0;
-   }
+   theImageHandler = 0;
 }
 
 void ossimTiffOverviewBuilder::setResampleType(
@@ -113,7 +109,8 @@ void ossimTiffOverviewBuilder::setResampleType(
    theResampleType = resampleType;
 }
 
-bool ossimTiffOverviewBuilder::buildOverview(const ossimFilename& overview_file, bool copy_all)
+bool ossimTiffOverviewBuilder::buildOverview(
+   const ossimFilename& overview_file, bool copy_all)
 {
    if (traceDebug())
    {
@@ -150,14 +147,12 @@ bool ossimTiffOverviewBuilder::execute()
       return false;
    }
 
+   theOutputFile = getOutputFile();
    if (theOutputFile == ossimFilename::NIL)
    {
-      if (initializeOutputFilenamFromHandler() == false)
-      {
-         return false;
-      }
+      return false;
    }
-   theOutputFileTmp = theOutputFile + ".tmp";
+
    // Check the file.  Disallow same file overview building.
    if (theImageHandler->getFilename() == theOutputFile)
    {
@@ -167,29 +162,37 @@ bool ossimTiffOverviewBuilder::execute()
       return false;
    }
 
-   //---
-   // Calculate the number of reduced resolution data sets (rrds).
-   // The image will be reduced until the smallest dimension is
-   // It will go all the way to a 1x1 pixel.
-   //---
-   ossim_int32 number_of_sets = getNumberOfSets();
+   // Add .tmp in case process gets aborted to avoid leaving bad .ovr file.
+   ossimFilename outputFileTemp = theOutputFile + ".tmp";
+
+   // Required number of levels needed including r0.
+   ossim_uint32 requiedResLevels = getRequiredResLevels(theImageHandler.get());
+
+   // Zero based starting resLevel.
+   ossim_uint32 startingResLevel  = 0;
+   if (!theCopyAllFlag)
+   {
+      startingResLevel = theImageHandler->getNumberOfDecimationLevels();
+   }
    
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE
-         << "\nNumber of reduced res sets:  " << number_of_sets
+         << "\nCurrent number of reduced res sets: "
+         << theImageHandler->getNumberOfDecimationLevels()
+         << "\nNumber of required reduced res sets:  " << requiedResLevels
+         << "\nStarting reduced res set:    " << startingResLevel
          << "\nResampling type:  " << getOverviewType().c_str()
          << std::endl;
    }
-   
-   if (!number_of_sets)
+
+   if ( startingResLevel >= requiedResLevels )
    {
       ossimNotify(ossimNotifyLevel_INFO)
          << MODULE << " NOTICE:"
-         << "\nFile size not large enough to require reduced resolution"
-         << " data sets."
-         << "\nReturning..." << std::endl;
+         << "\nImage has required reduced resolution data sets.\nReturning..."
+         << std::endl;
       return false;
    }
    
@@ -213,15 +216,25 @@ bool ossimTiffOverviewBuilder::execute()
       ossimString openMode = "w";
       if((byteCheck*static_cast<ossim_uint64>(2))>fourGigs)
       {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << " Big tiff activated\n";
+         }
          openMode += "8";
       }
+      else
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG) << " No big tiff activated\n";
+         }
+      }
       
       //---
       // See if the file can be opened for writing.
       // Note:  If this file existed previously it will be overwritten.
       //---
-//       tif = TIFFOpen(theOutputFileTmp.c_str(), openMode.c_str());
-      tif = openTiff(theOutputFileTmp, openMode);
+      tif = openTiff(outputFileTemp, openMode);
       if (!tif)
       {
          // Set the error...
@@ -231,7 +244,7 @@ bool ossimTiffOverviewBuilder::execute()
                        MODULE,
                        __FILE__,
                        __LINE__,
-                       theOutputFileTmp.c_str());      
+                       outputFileTemp.c_str());      
          return false;
       } 
 
@@ -245,7 +258,8 @@ bool ossimTiffOverviewBuilder::execute()
          progressListener = new ossimStdOutProgress(0, true);
          addListener(progressListener);
       }
-      if (theCopyAllFlag)
+
+      if (startingResLevel == 0)
       {       
          if (!writeR0(tif))
          {
@@ -265,10 +279,9 @@ bool ossimTiffOverviewBuilder::execute()
             return false;
          }
 
+         ++startingResLevel; // Go to r1.
       }
-         // now try to write out any geo tags
-         //
-      
+
       if (needsAborting())
       {
          closeTiff(tif);
@@ -280,105 +293,90 @@ bool ossimTiffOverviewBuilder::execute()
          }
          return false;
       }
+      
       TIFFFlush(tif);
+      
    } // End of master only write of r0.
-
-   if (number_of_sets > 1)
+        
+   for (ossim_uint32 i = startingResLevel; i < requiedResLevels; ++i)
    {
-      for (ossim_int32 i=1; i<=number_of_sets; ++i)
+      if (ossimMpi::instance()->getRank() == 0 )
       {
-         if (ossimMpi::instance()->getRank() == 0 )
-         {
-            TIFFFlush(tif);
-         }
-         // Sync all processes...
-         ossimMpi::instance()->barrier();
+         TIFFFlush(tif);
+      }
+      // Sync all processes...
+      ossimMpi::instance()->barrier();
+      
+      ossimRefPtr<ossimImageHandler> ih = 0;
 
-         ossimImageHandler* ih = 0;
-         bool deleteLocalHandler = false;
-         
-         //---
-         // If we copied r0 to the overview file use it instead of the
-         // original image handler as it is probably faster.
-         //---
-         if ( (i == 1) && !theCopyAllFlag )
-         {
-            ih = theImageHandler;
-         }
-         else
-         {
-            ih = ossimImageHandlerRegistry::instance()->open(theOutputFileTmp);
-            if (!ih)
-            {
-               // Set the error...
-               ossimSetError(getClassName(),
-                             ossimErrorCodes::OSSIM_OPEN_FILE_ERROR,
-                             "%s file %s line %d\nCannot open file:  %s",
-                             MODULE,
-                             __FILE__,
-                             __LINE__,
-                             theOutputFileTmp.c_str());   
-               return false;
-            }
-            deleteLocalHandler = true;
-         }
-         
-         if ( !writeRn(ih, tif, i) )
+      //---
+      // If we copied r0 to the overview file use it instead of the
+      // original image handler as it is probably faster.
+      //---
+      if ( i <= theImageHandler->getNumberOfDecimationLevels())
+      {
+         ih = theImageHandler;
+      }
+      else
+      {
+         ih = ossimImageHandlerRegistry::instance()->open(outputFileTemp);
+         if (!ih)
          {
             // Set the error...
             ossimSetError(getClassName(),
-                          ossimErrorCodes::OSSIM_WRITE_FILE_ERROR,
-                          "\
-%s file %s line %d\nError creating reduced res set!",
+                          ossimErrorCodes::OSSIM_OPEN_FILE_ERROR,
+                          "%s file %s line %d\nCannot open file:  %s",
                           MODULE,
                           __FILE__,
-                          __LINE__);
-            if (deleteLocalHandler)
-            {
-               delete ih;
-               ih = 0;
-            }
-            if (tif)
-            {
-               closeTiff(tif);
-               tif = 0;
-            }
-            if (progressListener)
-            {
-               removeListener(progressListener);
-               delete progressListener;
-               progressListener = 0;
-            }
+                          __LINE__,
+                          outputFileTemp.c_str());   
             return false;
          }
-
-         if (needsAborting())
+      }
+      
+      if ( !writeRn(ih.get(), tif, i) )
+      {
+         // Set the error...
+         ossimSetError(getClassName(),
+                       ossimErrorCodes::OSSIM_WRITE_FILE_ERROR,
+                       "\
+%s file %s line %d\nError creating reduced res set!",
+                       MODULE,
+                       __FILE__,
+                       __LINE__);
+         ih = 0;
+         if (tif)
          {
-            if (deleteLocalHandler)
-            {
-               delete ih;
-               ih = 0;
-            }
-            if (tif)
-            {
-               closeTiff(tif);
-               tif = 0;
-            }
-            if (progressListener)
-            {
-               removeListener(progressListener);
-               delete progressListener;
-               progressListener = 0;
-            }
-            return false;
+            closeTiff(tif);
+            tif = 0;
          }
-         
-         if (deleteLocalHandler)
+         if (progressListener)
          {
-            delete ih;
-            ih = 0;
+            removeListener(progressListener);
+            delete progressListener;
+            progressListener = 0;
          }
+         return false;
       }
+      
+      if (needsAborting())
+      {
+         ih = 0;
+         if (tif)
+         {
+            closeTiff(tif);
+            tif = 0;
+         }
+         if (progressListener)
+         {
+            removeListener(progressListener);
+            delete progressListener;
+            progressListener = 0;
+         }
+         return false;
+      }
+      
+      ih = 0;
    }
 
    if (ossimMpi::instance()->getRank() == 0 )
@@ -395,13 +393,13 @@ bool ossimTiffOverviewBuilder::execute()
          delete progressListener;
          progressListener = 0;
       }
-
-      theOutputFileTmp.rename(theOutputFile);
-		if(traceDebug())
-		{
-			ossimNotify(ossimNotifyLevel_INFO)
-         << "Wrote file:  " << theOutputFile.c_str() << std::endl;
-		}
+      
+      outputFileTemp.rename(theOutputFile);
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_INFO)
+            << "Wrote file:  " << theOutputFile.c_str() << std::endl;
+      }
       ossimFilename file=theOutputFile;
       file = file.setExtension("omd");
       ossimKeywordlist kwl;
@@ -445,15 +443,15 @@ bool ossimTiffOverviewBuilder::writeR0(TIFF* tif)
    }
    // now set the geotiff tags
    //
-   ossimKeywordlist kwl;
-   theImageHandler->getImageGeometry(kwl);
-   ossimDrect areaOfInterest = theImageHandler->getBoundingRect();
-   ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->
-      createProjection(kwl);
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);
-   ossimRefPtr<ossimMapProjectionInfo> projInfo;
+   // Get the geometry from the input.
+   const ossimMapProjection* mapProj = 0;
+   const ossimImageGeometry* inputGeom = theImageHandler->getImageGeometry();
+   if (inputGeom)
+      mapProj = PTR_CAST(ossimMapProjection, inputGeom->getProjection());
+
    if(mapProj)
    {
+      ossimDrect areaOfInterest = theImageHandler->getBoundingRect();
       ossimRefPtr<ossimMapProjectionInfo> projInfo = new ossimMapProjectionInfo(mapProj, areaOfInterest);
       ossimGeoTiff::writeTags(tif, projInfo);
    }
@@ -519,7 +517,7 @@ bool ossimTiffOverviewBuilder::writeR0(TIFF* tif)
             }
             else
             {
-               data = static_cast<tdata_t>(theNullDataBuffer);
+               data = static_cast<tdata_t>(&(theNullDataBuffer.front()));
             }
 
             // Write the tile.
@@ -580,7 +578,7 @@ bool ossimTiffOverviewBuilder::writeR0(TIFF* tif)
 
 bool ossimTiffOverviewBuilder::writeRn(ossimImageHandler* imageHandler,
                                        TIFF* tif,
-                                       ossim_uint32 rrdsLevel)
+                                       ossim_uint32 resLevel)
 {
    //---
    // Set up the sequencer.  This will be one of three depending on if we're
@@ -605,7 +603,11 @@ bool ossimTiffOverviewBuilder::writeRn(ossimImageHandler* imageHandler,
    }
 
    sequencer->setImageHandler(imageHandler);
-   sequencer->setSourceLevel(rrdsLevel-1);
+
+   ossim_uint32 sourceResLevel =
+      imageHandler->getNumberOfDecimationLevels() - 1;
+
+   sequencer->setSourceLevel(sourceResLevel);
    sequencer->setResampleType(theResampleType);
    sequencer->setTileSize( ossimIpt(theTileWidth, theTileHeight) );
    sequencer->initialize();
@@ -623,18 +625,18 @@ bool ossimTiffOverviewBuilder::writeRn(ossimImageHandler* imageHandler,
    static const char MODULE[] = "ossimTiffOverviewBuilder::writeRn";
 
    ostringstream os;
-   os << "creating r" << rrdsLevel << "...";
+   os << "creating r" << resLevel << "...";
    setCurrentMessage(os.str());
 
-   if (rrdsLevel == 0)
+   if (resLevel == 0)
    {
       return false;
    }
 
    ossimIrect rect;
    sequencer->getOutputImageRectangle(rect);
-   
-   if (!setTags(tif, rect, rrdsLevel))
+
+   if (!setTags(tif, rect, resLevel))
    {
       closeTiff(tif);
       ossimNotify(ossimNotifyLevel_WARN)
@@ -656,7 +658,7 @@ bool ossimTiffOverviewBuilder::writeRn(ossimImageHandler* imageHandler,
          << "\nnumberOfTiles:    " << numberOfTiles
          << std::endl;
    }
-
+ 
    // Tile loop in the line direction.
    ossim_uint32 y = 0;
    for(ossim_uint32 i = 0; i < outputTilesHigh; ++i)
@@ -731,30 +733,12 @@ bool ossimTiffOverviewBuilder::writeRn(ossimImageHandler* imageHandler,
    return true;
 }
 
-ossim_int32 ossimTiffOverviewBuilder::getNumberOfSets() const
-{
-   ossim_int32 a = theImageHandler->getNumberOfSamples(0) <
-             theImageHandler->getNumberOfLines(0) ?
-             theImageHandler->getNumberOfSamples(0) :
-             theImageHandler->getNumberOfLines(0);
-
-   ossim_int32 n = 0;
-
-   while(a > 2)
-   {
-      a /= 2;
-      ++n;
-   }
-
-   return n;
-}
-
 //*******************************************************************
 // Private Method:
 //*******************************************************************
 bool ossimTiffOverviewBuilder::setTags(TIFF* tif,
                                        const ossimIrect& outputRect,
-                                       ossim_int32 rrds_level) const
+                                       ossim_int32 resLevel) const
 {
    if (outputRect.hasNans())
    {
@@ -767,7 +751,7 @@ bool ossimTiffOverviewBuilder::setTags(TIFF* tif,
    ossim_float64 minSampleValue  = theImageHandler->getMinPixelValue();
    ossim_float64 maxSampleValue  = theImageHandler->getMaxPixelValue();
 
-   if (rrds_level)
+   if (resLevel)
    {
       TIFFSetField( tif, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE );
    }
@@ -776,7 +760,7 @@ bool ossimTiffOverviewBuilder::setTags(TIFF* tif,
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << "ossimTiffOverviewBuilder::setTags DEBUG:"
-         << "\nrrds_level:      " << rrds_level
+         << "\nrrds_level:      " << resLevel
          << "\nimageWidth:      " << imageWidth
          << "\nimageHeight:     " << imageHeight
          << "\nminSampleValue:  " << minSampleValue
@@ -908,7 +892,6 @@ Range is 100 to 1.  Current quality set to default of 75.",
    }
 }
 
-
 bool ossimTiffOverviewBuilder::getCopyAllFlag() const
 {
    return theCopyAllFlag;
@@ -929,14 +912,24 @@ const ossimObject* ossimTiffOverviewBuilder::getObject() const
    return this;
 }
 
-ossimFilename ossimTiffOverviewBuilder::getOutputFile() const
+void ossimTiffOverviewBuilder::setOutputFile(const ossimFilename& file)
 {
-   return theOutputFile;
+   theOutputFile = file;
 }
 
-void ossimTiffOverviewBuilder::setOutputFile(const ossimFilename& file)
+ossimFilename ossimTiffOverviewBuilder::getOutputFile() const
 {
-   theOutputFile = file;
+   ossimFilename result = theOutputFile;
+   if (theOutputFile == ossimFilename::NIL)
+   {
+      if (theImageHandler.valid())
+      {
+         bool usePrefix = (theImageHandler->getNumberOfEntries()>1?true:false);
+         result = theImageHandler->
+            getFilenameWithThisExtension(ossimString("ovr"), usePrefix);
+      }
+   }
+   return result;
 }
 
 void ossimTiffOverviewBuilder::setOutputTileSize(const ossimIpt& tileSize)
@@ -946,25 +939,13 @@ void ossimTiffOverviewBuilder::setOutputTileSize(const ossimIpt& tileSize)
    theOutputTileSizeSetFlag = true;
 }
 
-bool ossimTiffOverviewBuilder::setInputSource(ossimImageHandler* imageSource,
-                                              bool youOwnItFlag)
+bool ossimTiffOverviewBuilder::setInputSource(ossimImageHandler* imageSource)
 {
    static const char MODULE[] =
       "ossimTiffOverviewBuilder::initializeFromHandler";
 
-   if (theOwnsImageHandlerFlag && theImageHandler)
-   {
-      delete theImageHandler;
-   }
    theImageHandler         = imageSource;
-   theOwnsImageHandlerFlag = youOwnItFlag;
 
-   if (theNullDataBuffer)
-   {
-      delete [] theNullDataBuffer;
-      theNullDataBuffer = 0;
-   }
-   
    if (!theImageHandler)
    {
       // Set the error...
@@ -1093,13 +1074,14 @@ bool ossimTiffOverviewBuilder::setInputSource(ossimImageHandler* imageSource,
 
    theTileSizeInBytes = theTileWidth * theTileHeight * theBytesPerPixel;
 
-   //***
+   //---
    // Make a buffer to pass to pass to the write tile methods when an image
    // handler returns a null tile.
-   //***
-   theNullDataBuffer = new ossim_uint8[theTileSizeInBytes];
-   
-   memset(theNullDataBuffer, 0, theTileSizeInBytes); // Fill it with zeroes.
+   //---
+   theNullDataBuffer.resize(theTileSizeInBytes);
+
+   // Fill it with zeroes.
+   std::fill(theNullDataBuffer.begin(), theNullDataBuffer.end(), 0);
 
    return true;
 }
@@ -1177,10 +1159,15 @@ void ossimTiffOverviewBuilder::setProperty(ossimRefPtr<ossimProperty> property)
          theTiffCompressType = COMPRESSION_NONE;
       }
    }
-   else if(property->getName() == "copy_all_flag")
+   else if(property->getName() == COPY_ALL_KW)
    {
       theCopyAllFlag = property->valueToString().toBool();
    }
+   else if(property->getName() ==
+           ossimOverviewBuilderBase::OVERVIEW_STOP_DIMENSION_KW)
+   {
+     theOverviewStopDimension = property->valueToString().toUInt32();
+   }
    else if(property->getName() == ossimKeywordNames::OUTPUT_TILE_SIZE_KW)
    {
       ossimIpt ipt;
@@ -1195,50 +1182,9 @@ void ossimTiffOverviewBuilder::getPropertyNames(std::vector<ossimString>& proper
 {
    propertyNames.push_back(ossimKeywordNames::COMPRESSION_QUALITY_KW);
    propertyNames.push_back(ossimKeywordNames::COMPRESSION_TYPE_KW);
-   propertyNames.push_back("copy_all_flag");
-}
-
-bool ossimTiffOverviewBuilder::initializeOutputFilenamFromHandler()
-{
-   if (!theImageHandler)
-   {
-      return false;
-   }
-   
-   // Set the output filename to a default.
-   theOutputFile = theImageHandler->getFilename();
-   if(theImageHandler->getNumberOfEntries() > 1)
-   {
-      ossim_uint32 currentEntry = theImageHandler->getCurrentEntry();
-      theOutputFile.setExtension("");
-      theOutputFile += "_e";
-      theOutputFile += ossimString::toString(currentEntry);
-      
-      //---
-      // Note:  Set extension was not used here deliberately to avoid messing
-      // up a MODIS file in hdf format with multiple '.'s in the file
-      // name.
-      //---
-      theOutputFile += ".ovr";
-   }
-   else
-   {
-      theOutputFile.setExtension("ovr");
-   }
-
-   if (theOutputFile == theImageHandler->getFilename())
-   {
-      // Don't allow this.
-      theOutputFile = ossimFilename::NIL;
-   }
-   theOutputFileTmp += ".tmp";
-
-   if (theOutputFile.empty())
-   {
-      return false;
-   }
-
-   return true;
+   propertyNames.push_back(COPY_ALL_KW);
+   propertyNames.push_back(
+      ossimOverviewBuilderBase::OVERVIEW_STOP_DIMENSION_KW);
 }
 
 bool ossimTiffOverviewBuilder::canConnectMyInputTo(
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp
index 0a8783342bfe93658043ef0c5dbba05460379897..25d3622c708349a2c7ed59d376653144d91524be 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp
@@ -12,7 +12,7 @@
 // Contains class definition for TiffTileSource.
 //
 //*******************************************************************
-//  $Id: ossimTiffTileSource.cpp 14425 2009-04-30 16:17:49Z gpotts $
+//  $Id: ossimTiffTileSource.cpp 15825 2009-10-27 15:31:44Z dburken $
 
 #include <cstdlib> /* for abs(int) */
 #include <ossim/imaging/ossimTiffTileSource.h>
@@ -29,20 +29,8 @@
 #include <ossim/base/ossimBooleanProperty.h>
 #include <ossim/base/ossimStringProperty.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
-#include <ossim/projection/ossimEquDistCylProjection.h>
-#include <ossim/projection/ossimAlbersProjection.h>
-#include <ossim/projection/ossimCylEquAreaProjection.h>
-#include <ossim/projection/ossimEquDistCylProjection.h>
-#include <ossim/projection/ossimVanDerGrintenProjection.h>
-#include <ossim/projection/ossimLambertConformalConicProjection.h>
-#include <ossim/projection/ossimMercatorProjection.h>
-#include <ossim/projection/ossimMillerProjection.h>
-#include <ossim/projection/ossimOrthoGraphicProjection.h>
-#include <ossim/projection/ossimPolyconicProjection.h>
-#include <ossim/projection/ossimSinusoidalProjection.h>
-#include <ossim/projection/ossimTransMercatorProjection.h>
-#include <ossim/projection/ossimCassiniProjection.h>
-#include <ossim/projection/ossimUtmProjection.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <xtiffio.h>
 
 RTTI_DEF1(ossimTiffTileSource, "ossimTiffTileSource", ossimImageHandler)
 
@@ -59,12 +47,14 @@ static ossimTrace traceDebug("ossimTiffTileSource:debug");
 ossimTiffTileSource::ossimTiffTileSource()
    :
       ossimImageHandler(),
+      theTiffPtr(0),
       theTile(0),
       theBuffer(0),
       theBufferSize(0),
       theBufferRect(0, 0, 0, 0),
       theBufferRLevel(0),
-      theTiffPtr(0),
+      theCurrentTileWidth(0),
+      theCurrentTileHeight(0),
       theSamplesPerPixel(0),
       theBitsPerSample(0),
       theSampleFormatUnit(0),
@@ -94,133 +84,178 @@ ossimTiffTileSource::~ossimTiffTileSource()
 ossimRefPtr<ossimImageData> ossimTiffTileSource::getTile(
    const  ossimIrect& tile_rect,
    ossim_uint32 resLevel)
+{
+   if (theTile.valid())
+   {
+      // Image rectangle must be set prior to calling getTile.
+      theTile->setImageRectangle(tile_rect);
+
+      if ( getTile( theTile.get(), resLevel ) == false )
+      {
+         if (theTile->getDataObjectStatus() != OSSIM_NULL)
+         {
+            theTile->makeBlank();
+         }
+      }
+   }
+
+   return theTile;
+}
+
+bool ossimTiffTileSource::getTile(ossimImageData* result,
+                                  ossim_uint32 resLevel)
 {
    static const char MODULE[] ="ossimTiffTileSource::getTile(rect, res)";
 
+   bool status = false;
+
    //---
    // Not open, this tile source bypassed, or invalid res level,
    // return a blank tile.
    //---
-   if( !isOpen() || !isSourceEnabled() || !isValidRLevel(resLevel) )
-   {
-      return ossimRefPtr<ossimImageData>();
-   }
-
-   //---
-   // Subtract an sub image offset to work in zero based image space from
-   // here on out.
-   //---
-   ossimIrect zeroBasedTileRect = tile_rect - getSubImageOffset(resLevel);
-   
-   //---
-   // If there is an overview and the current rr level is not at "0" then
-   // send the getTile call to the overview image handler.
-   //---
-   if (resLevel&&theOverview)
+   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
+       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
    {
+      result->ref(); // Increment ref count.
+      
       //---
-      // Overviews are not aware of sub image offsets so request a zero based
-      // rectangle.
+      // 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.
       //---
-      ossimRefPtr<ossimImageData> tile =
-         theOverview->getTile(zeroBasedTileRect, resLevel);
-      if (tile.valid())
+      status = getOverviewTile(resLevel, result);
+
+      if (!status) // Did not get an overview tile.
       {
+         status = true;
+         
+         ossim_uint32 level = resLevel;
+
          //---
-         // Since the overview request was zero based we must reset the
-         // rectangle to be relative to any sub image offset.
+         // If we have r0 our reslevels are the same as the callers so
+         // no adjustment necessary.
          //---
-         tile->setImageRectangle(tile_rect);
-
-         if(getOutputScalarType() == OSSIM_USHORT11)
+         if (theStartingResLevel && !theR0isFullRes) // Used as overview.
          {
             //---
-            // Temp fix:
-            // The overview handler could return a tile of OSSIM_UINT16 if
-            // the max sample value was not set to 2047.
+            // If we have r0 our reslevels are the same as the callers so
+            // no adjustment necessary.
             //---
-            tile->setScalarType(OSSIM_USHORT11);
+            if (level >= theStartingResLevel)
+            {
+               //---
+               // Adjust the level to be relative to the reader using this
+               // as overview.
+               //---
+               level -= theStartingResLevel; 
+            }
          }
-      }
 
-      return tile;
-   }
-
-   bool reallocateBuffer = false;   
-   if ( (tile_rect.width()  != theTile->getWidth()) ||
-        (tile_rect.height() != theTile->getHeight()) )
-   {
-      reallocateBuffer = true;
-   }
-   
-   if (getCurrentTiffRLevel() != resLevel)
-   {
-      // Change the tiff directory to the requested level.
-      ossim_uint32 dir = 0;
-      if (resLevel)
-      {
-         dir = theR0isFullRes ? resLevel : resLevel - 1;
-      }
+         //---
+         // Subtract any sub image offset to get the zero based image space
+         // rectangle.
+         //---
+         ossimIrect tile_rect = result->getImageRectangle();
 
-      if (setTiffDirectory(dir) == false)
-      {
-         return ossimRefPtr<ossimImageData>();
-      }
-      reallocateBuffer = true;
-   }
+         //---
+         // This should be the zero base image rectangle for this res level.
+         // Note passed the non adjusted resLevel by design.
+         //---
+         ossimIrect zeroBasedTileRect = tile_rect;
 
-   //---
-   // The tile's internal rectangle should be relative to any sub image.
-   // 
-   // Note:
-   //
-   // Since the allocate buffer method relies on theTile->getHeight() it is
-   // important to do this prior to the allocateBuffer call.
-   //---
-   theTile->setImageRectangle(tile_rect);
+         //---
+         // This should be the zero base image rectangle for this res level.
+         // Note passed the non adjusted resLevel by design.
+         //---
+         ossimIrect image_rect = getImageRectangle(resLevel);
 
-   if (reallocateBuffer)
-   {
-      allocateBuffer();
-   }
+         //---
+         // See if any point of the requested tile is in the image.
+         //---
+         if ( zeroBasedTileRect.intersects(image_rect) )
+         {
+            // Initialize the tile if needed as we're going to stuff it.
+            if (result->getDataObjectStatus() == OSSIM_NULL)
+            {
+               result->initialize();
+            }
 
-   // 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 ( zeroBasedTileRect.intersects(image_rect) )
-   {
-      ossimIrect clip_rect = zeroBasedTileRect.clipToRect(image_rect);
+            bool reallocateBuffer = false;   
+            if ( (tile_rect.width()  != theCurrentTileWidth) ||
+                 (tile_rect.height() != theCurrentTileHeight) )
+            {
+               // Current tile size must be set prior to allocatBuffer call.
+               theCurrentTileWidth = tile_rect.width();
+               theCurrentTileHeight = tile_rect.height();
+               
+               reallocateBuffer = true;
+            }
+            
+            if (getCurrentTiffRLevel() != level)
+            {
+               status = setTiffDirectory(level);
+               if (status)
+               {
+                  reallocateBuffer = true;
+               }
+            }
 
-      if ( !zeroBasedTileRect.completely_within(clip_rect) )
-      {
-         // Start with a blank tile.
-         theTile->makeBlank();
-      }
+            if (status)
+            {
+               if (reallocateBuffer)
+               {
+                  // NOTE: Using this buffer will be a thread issue. (drb) 
+                  allocateBuffer();
+               }
+               
+               ossimIrect clip_rect = zeroBasedTileRect.clipToRect(image_rect);
+               
+               if ( !zeroBasedTileRect.completely_within(clip_rect) )
+               {
+                  //---
+                  // We're not going to fill the whole tile so start with a
+                  // blank tile.
+                  //---
+                  result->makeBlank();
+               }
+               
+               // Load the tile buffer with data from the tif.
+               if ( loadTile(zeroBasedTileRect, clip_rect, result) )
+               {
+                  result->validate();
+                  status = true;
+               }
+               else
+               {
+                  // Would like to change this to throw ossimException.(drb)
+                  status = false;
+                  if(traceDebug())
+                  {
+                     // Error in filling buffer.
+                     ossimNotify(ossimNotifyLevel_WARN)
+                        << MODULE
+                        << " Error filling buffer. Return status = false..."
+                        << std::endl;
+                  }
+               }
 
-      // Load the tile buffer with data from the tif.
-      if (loadTile(zeroBasedTileRect, clip_rect))
-      {
-         theTile->validate();
-         return theTile;
-      }
-      else
-      {
-         theTile->makeBlank();
-         if(traceDebug())
+            } // matches: if (status)
+               
+         } // matches:  if ( zeroBasedTileRect.intersects(image_rect) )
+         else 
          {
-            // Error in filling buffer.
-            ossimNotify(ossimNotifyLevel_WARN)
-            << MODULE << " Returning blank tile..." << endl;
+            // No part of requested tile within the image rectangle.
+            status = true; // Not an error.
+            result->makeBlank();
          }
-         return theTile;
-      }
-   }
-   theTile->makeBlank();
-   // No part of requested tile within the image rectangle.
-   return theTile;
+         
+      } // matches: if (!status)
+      
+      result->unref(); // Decrement ref count.
+      
+   } // matches: if( isOpen() && isSourceEnabled() && isValidRLevel(level) )
+
+   return status;
 }
 
 //*******************************************************************
@@ -276,7 +311,7 @@ void ossimTiffTileSource::close()
 {
    if(theTiffPtr)
    {
-      TIFFClose(theTiffPtr);
+      XTIFFClose(theTiffPtr);
       theTiffPtr = 0;
    }
    theImageWidth.clear();
@@ -317,7 +352,7 @@ bool ossimTiffTileSource::open()
    {
       return false;
    }
-   
+#if 0  
    // First we do a quick test to see if the file looks like a tiff file.
    FILE		*fp;
    unsigned char header[2];
@@ -332,11 +367,11 @@ bool ossimTiffTileSource::open()
    if( (header[0] != 'M' || header[1] != 'M')
        && (header[0] != 'I' || header[1] != 'I') )
        return false;
-
+#endif
    //---
    // Note:  The 'm' in "rm" is to tell TIFFOpen to not memory map the file.
    //---
-   theTiffPtr = TIFFOpen(theImageFile.c_str(), "rm");
+   theTiffPtr = XTIFFOpen(theImageFile.c_str(), "rm");
    if (!theTiffPtr)
    {
       if (traceDebug())
@@ -650,53 +685,110 @@ bool ossimTiffTileSource::open()
    return true;
 }
    
-ossim_uint32 ossimTiffTileSource::getNumberOfLines(ossim_uint32 reduced_res_level) const
+ossim_uint32 ossimTiffTileSource::getNumberOfLines(
+   ossim_uint32 resLevel) const
 {
-   if(!theTiffPtr) return 0;
+   ossim_uint32 result = 0;
    
-   if (isValidRLevel(reduced_res_level))
+   if ( theTiffPtr && isValidRLevel(resLevel) )
    {
-      if (reduced_res_level && theOverview)
+      //---
+      // If we have r0 our reslevels are the same as the callers so
+      // no adjustment necessary.
+      //---
+      if (!theStartingResLevel || theR0isFullRes) // not an overview or has r0.
       {
-         return theOverview->getNumberOfLines(reduced_res_level);
+         //---
+         // If we have r0 our reslevels are the same as the callers so
+         // no adjustment necessary.
+         //---
+         if (resLevel < theNumberOfDirectories)
+         {
+            result = theImageLength[resLevel];
+         }
+         else if (theOverview.valid())
+         {
+            result = theOverview->getNumberOfLines(resLevel);
+         }
+      }
+      else // this is an overview without r0
+      {
+         if (resLevel >= theStartingResLevel)
+         {
+            //---
+            // Adjust the level to be relative to the reader using this as
+            // overview.
+            //---
+            ossim_uint32 level = resLevel - theStartingResLevel;
+            if (level < theNumberOfDirectories)
+            {
+               result = theImageLength[level];
+            }
+         }
       }
-      
-      return (theR0isFullRes ?
-              theImageLength[reduced_res_level] :
-              theImageLength[reduced_res_level - 1]);
    }
-
-   return 0;
+   
+   return result;
 }
 
-ossim_uint32
-ossimTiffTileSource::getNumberOfSamples(ossim_uint32 reduced_res_level) const
+ossim_uint32 ossimTiffTileSource::getNumberOfSamples(
+   ossim_uint32 resLevel) const
 {
-   if(!theTiffPtr) return 0;
-   if (isValidRLevel(reduced_res_level))
+   ossim_uint32 result = 0;
+   
+   if ( theTiffPtr && isValidRLevel(resLevel) )
    {
-      if (reduced_res_level && theOverview)
+      //---
+      // If we have r0 our reslevels are the same as the callers so
+      // no adjustment necessary.
+      //---
+      if (!theStartingResLevel || theR0isFullRes) // not an overview or has r0.
       {
-         return theOverview->getNumberOfSamples(reduced_res_level);
+         if (resLevel < theNumberOfDirectories)
+         {
+            result = theImageWidth[resLevel];
+         }
+         else if (theOverview.valid())
+         {
+            result = theOverview->getNumberOfSamples(resLevel);
+         }
+      }
+      else // this is an overview.
+      {
+         if (resLevel >= theStartingResLevel)
+         {
+            //---
+            // Adjust the level to be relative to the reader using this as
+            // overview.
+            //---
+            ossim_uint32 level = resLevel - theStartingResLevel;
+            if (level < theNumberOfDirectories)
+            {
+               result = theImageWidth[level];
+            }
+         }
       }
-      
-      return (theR0isFullRes ?
-              theImageWidth[reduced_res_level] :
-              theImageWidth[reduced_res_level-1]);
    }
    
-   return 0;
+   return result;
 }
 
 ossim_uint32 ossimTiffTileSource::getNumberOfDecimationLevels() const
 {
-   if (theOverview)
+   ossim_uint32 result = theNumberOfDirectories;
+
+   // If starting res level is not 0 then this is an overview.
+   if (theStartingResLevel && theR0isFullRes)
    {
-      return theOverview->getNumberOfDecimationLevels();
+      // Don't count r0.
+      --result;
    }
-   
-   return ( theR0isFullRes ? theNumberOfDirectories :
-            theNumberOfDirectories+1 );
+   else if (theOverview.valid())
+   {
+      result += theOverview->getNumberOfDecimationLevels();
+   }
+
+   return result;
 }
 
 //*******************************************************************
@@ -740,7 +832,8 @@ ossim_uint32 ossimTiffTileSource::getTileHeight() const
 }
 
 bool ossimTiffTileSource::loadTile(const ossimIrect& tile_rect,
-                                   const ossimIrect& clip_rect)
+                                   const ossimIrect& clip_rect,
+                                   ossimImageData* result)
 {
    static const char MODULE[] = "ossimTiffTileSource::loadTile";
 
@@ -749,23 +842,23 @@ bool ossimTiffTileSource::loadTile(const ossimIrect& tile_rect,
    switch(theReadMethod[theCurrentDirectory])
    {
       case READ_TILE:
-         status = loadFromTile(clip_rect);
+         status = loadFromTile(clip_rect, result);
          break;
          
       case READ_SCAN_LINE:
-         status = loadFromScanLine(clip_rect);
+         status = loadFromScanLine(clip_rect, result);
          break;
          
       case READ_RGBA_U8_TILE:
-         status = loadFromRgbaU8Tile(tile_rect, clip_rect);
+         status = loadFromRgbaU8Tile(tile_rect, clip_rect, result);
          break;
          
       case READ_RGBA_U8_STRIP:
-         status = loadFromRgbaU8Strip(tile_rect, clip_rect);
+         status = loadFromRgbaU8Strip(tile_rect, clip_rect, result);
          break;
          
       case READ_RGBA_U8A_STRIP:
-         status = loadFromRgbaU8aStrip(tile_rect, clip_rect);
+         status = loadFromRgbaU8aStrip(tile_rect, clip_rect, result);
          break;
          
       default:
@@ -778,7 +871,8 @@ bool ossimTiffTileSource::loadTile(const ossimIrect& tile_rect,
    return status;
 }
 
-bool ossimTiffTileSource::loadFromScanLine(const ossimIrect& clip_rect)
+bool ossimTiffTileSource::loadFromScanLine(const ossimIrect& clip_rect,
+                                           ossimImageData* result)
 {
    ossimInterleaveType type =
       (thePlanarConfig[theCurrentDirectory] == PLANARCONFIG_CONTIG) ?
@@ -832,17 +926,22 @@ bool ossimTiffTileSource::loadFromScanLine(const ossimIrect& clip_rect)
    // "clip_rect" before passing to
    // theTile->loadTile method.
    //---
-   ossimIpt   subImageOffset     = getSubImageOffset(theBufferRLevel);
-   ossimIrect bufRectWithOffset  = theBufferRect + subImageOffset;
-   ossimIrect clipRectWithOffset = clip_rect     + subImageOffset;
-   theTile->loadTile(theBuffer,
-                     bufRectWithOffset,
-                     clipRectWithOffset,
-                     type);
+   
+   // WE ARE REMOVING THE NEED FOR SUB IMAGES
+//   ossimIpt subImageOffset =
+//      getSubImageOffset(theBufferRLevel+theStartingResLevel);
+   
+//   ossimIrect bufRectWithOffset  = theBufferRect + subImageOffset;
+//   ossimIrect clipRectWithOffset = clip_rect     + subImageOffset;
+   result->loadTile(theBuffer,
+                   theBufferRect,
+                   clip_rect,
+                   type);
    return true;
 }
 
-bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect)
+bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect,
+                                       ossimImageData* result)
 {
    static const char MODULE[] = "ossimTiffTileSource::loadFromTile";
 
@@ -857,74 +956,7 @@ bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect)
    (thePlanarConfig[theCurrentDirectory] == PLANARCONFIG_CONTIG) ?
    OSSIM_BIP : OSSIM_BIL;
    ossimIpt ulTilePt       = tileOrigin;
-   ossimIpt subImageOffset = getSubImageOffset(getCurrentTiffRLevel());
-
-   // if the requested tile is not clipped and the origin is starting at a tile boundary and
-   // the width and height are the same as the image tile then do a direct copy if we can and then return
-//    if((clip_rect.width() == theTile->getWidth())&&
-//       (clip_rect.height() == theTile->getHeight())&&
-//       (tileOrigin==theTile->getOrigin())&&
-//       (theImageTileLength[theCurrentDirectory]==theTile->getHeight())&&
-//       (theImageTileWidth[theCurrentDirectory]==theTile->getWidth()))
-//    {
-            
-//      if(thePlanarConfig[theCurrentDirectory] == PLANARCONFIG_CONTIG)
-//       {
-//          ossimIrect bufRectWithOffset = tiff_tile_rect + subImageOffset;
-//          ossimIrect clipRectWithOffset =
-//             tiff_tile_clip_rect + subImageOffset;
-            
-//          tileSizeRead = TIFFReadTile(theTiffPtr,
-//                                      theBuffer,
-//                                      tileOrigin.x,
-//                                      tileOrigin.y,
-//                                      0,
-//                                      0);
-//          if (tileSizeRead > 0)
-//          {
-//             theTile->loadTile(theBuffer,
-//                               bufRectWithOffset,
-//                               clipRectWithOffset,
-//                               type);
-//          }
-//          else if(tileSizeRead < 0)
-//          {
-//             if(traceDebug())
-//             {
-//                ossimNotify(ossimNotifyLevel_WARN)
-//                   << MODULE << " Read Error!"
-//                   << "\nReturning error...  " << endl;
-//             }
-//             theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
-//             return false;
-//          }
-//       }
-//       else
-//       {
-//          // band separate tiles...
-//          for (ossim_uint32 band=0; band<theSamplesPerPixel; ++band)
-//          {
-//             tileSizeRead = TIFFReadTile(theTiffPtr,
-//                                         theTile->getBuf(band),
-//                                         tileOrigin.x,
-//                                         tileOrigin.y,
-//                                         0,
-//                                         band);
-//             if (tileSizeRead < 0)
-//             {
-//                if(traceDebug())
-//                {
-//                   ossimNotify(ossimNotifyLevel_WARN)
-//                      << MODULE << " Read Error!"
-//                      << "\nReturning error...  " << endl;
-//                }
-//                theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
-//                return false;
-//             }            
-//          }
-//          return true;
-//       }
-//    }
+//   ossimIpt subImageOffset = getSubImageOffset(getCurrentTiffRLevel()+theStartingResLevel);
 
    //---
    // Calculate the number of tiles needed in the line/sample directions.
@@ -966,9 +998,8 @@ bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect)
             // "theBufferRect" and the zero based "clip_rect" before
             // passing to theTile->loadTile method.
             //---
-            ossimIrect bufRectWithOffset = tiff_tile_rect + subImageOffset;
-            ossimIrect clipRectWithOffset =
-               tiff_tile_clip_rect + subImageOffset;
+            ossimIrect bufRectWithOffset = tiff_tile_rect;// + subImageOffset;
+            ossimIrect clipRectWithOffset = tiff_tile_clip_rect;// + subImageOffset;
             
             if  (thePlanarConfig[theCurrentDirectory] == PLANARCONFIG_CONTIG)
             {
@@ -980,10 +1011,10 @@ bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect)
                                            0);
                if (tileSizeRead > 0)
                {
-                  theTile->loadTile(theBuffer,
-                                    bufRectWithOffset,
-                                    clipRectWithOffset,
-                                    type);
+                  result->loadTile(theBuffer,
+                                  bufRectWithOffset,
+                                  clipRectWithOffset,
+                                  type);
                }
                else if(tileSizeRead < 0)
                {
@@ -1010,10 +1041,10 @@ bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect)
                                               band);
                   if(tileSizeRead > 0)
                   {
-                     theTile->loadBand(theBuffer,
-                                       bufRectWithOffset,
-                                       clipRectWithOffset,
-                                       band);
+                     result->loadBand(theBuffer,
+                                     bufRectWithOffset,
+                                     clipRectWithOffset,
+                                     band);
                   }
                   else if (tileSizeRead < 0)
                   {
@@ -1043,7 +1074,8 @@ bool ossimTiffTileSource::loadFromTile(const ossimIrect& clip_rect)
 }
 
 bool ossimTiffTileSource::loadFromRgbaU8Tile(const ossimIrect& tile_rect,
-                                             const ossimIrect& clip_rect)
+                                             const ossimIrect& clip_rect,
+                                             ossimImageData* result)
 {
    static const char MODULE[] = "ossimTiffTileSource::loadFromRgbaTile";
 
@@ -1144,7 +1176,7 @@ bool ossimTiffTileSource::loadFromRgbaU8Tile(const ossimIrect& tile_rect,
          
          ossim_uint32 out_buf_offset =
             (tile_clip_rect.ul().y - tile_rect.ul().y) *
-            ((ossim_int32)theTile->getWidth()) +
+            ((ossim_int32)result->getWidth()) +
             tile_clip_rect.ul().x - tile_rect.ul().x;
          
          //
@@ -1152,11 +1184,11 @@ bool ossimTiffTileSource::loadFromRgbaU8Tile(const ossimIrect& tile_rect,
          //
          ossim_uint32* s = (ossim_uint32*)(theBuffer + in_buf_offset);  // s for source...
 //         ossim_uint8* s = theBuffer + in_buf_offset;  // s for source...
-         ossim_uint8* r = static_cast<ossim_uint8*>(theTile->getBuf(0))+
+         ossim_uint8* r = static_cast<ossim_uint8*>(result->getBuf(0))+
             out_buf_offset;
-         ossim_uint8* g = static_cast<ossim_uint8*>(theTile->getBuf(1))+
+         ossim_uint8* g = static_cast<ossim_uint8*>(result->getBuf(1))+
             out_buf_offset;
-         ossim_uint8* b = static_cast<ossim_uint8*>(theTile->getBuf(2))+
+         ossim_uint8* b = static_cast<ossim_uint8*>(result->getBuf(2))+
             out_buf_offset;
          
          ossim_uint32 lines2copy = tile_clip_rect.lr().y-tile_clip_rect.ul().y+1;
@@ -1181,7 +1213,7 @@ bool ossimTiffTileSource::loadFromRgbaU8Tile(const ossimIrect& tile_rect,
             }
             
             // Increment the pointers by one line.
-            const ossim_uint32 OUTPUT_TILE_WIDTH = theTile->getWidth();
+            const ossim_uint32 OUTPUT_TILE_WIDTH = result->getWidth();
             r += OUTPUT_TILE_WIDTH;
             g += OUTPUT_TILE_WIDTH;
             b += OUTPUT_TILE_WIDTH;
@@ -1200,7 +1232,8 @@ bool ossimTiffTileSource::loadFromRgbaU8Tile(const ossimIrect& tile_rect,
 }
 
 bool ossimTiffTileSource::loadFromRgbaU8Strip(const ossimIrect& tile_rect,
-                                              const ossimIrect& clip_rect)
+                                              const ossimIrect& clip_rect,
+                                              ossimImageData* result)
 {
    static const char MODULE[] = "ossimTiffTileSource::loadFromRgbaU8Strip";
 
@@ -1214,7 +1247,7 @@ bool ossimTiffTileSource::loadFromRgbaU8Strip(const ossimIrect& tile_rect,
    //***
    // Calculate the number of strips to read.
    //***
-   const ossim_uint32 OUTPUT_TILE_WIDTH = theTile->getWidth();
+   const ossim_uint32 OUTPUT_TILE_WIDTH = result->getWidth();
 
    ossim_uint32 starting_strip = clip_rect.ul().y /
       theRowsPerStrip[theCurrentDirectory];
@@ -1251,7 +1284,7 @@ bool ossimTiffTileSource::loadFromRgbaU8Strip(const ossimIrect& tile_rect,
    ossim_uint8** d = new ossim_uint8*[theSamplesPerPixel];
    for (band = 0; band < theSamplesPerPixel; band++)
    {
-      d[band] = static_cast<ossim_uint8*>(theTile->getBuf(band))+output_tile_offset;
+      d[band] = static_cast<ossim_uint8*>(result->getBuf(band))+output_tile_offset;
    }
 
    // Loop through strips...
@@ -1334,16 +1367,17 @@ bool ossimTiffTileSource::loadFromRgbaU8Strip(const ossimIrect& tile_rect,
 // Private Method:
 //*******************************************************************
 bool ossimTiffTileSource::loadFromRgbaU8aStrip(const ossimIrect& tile_rect,
-                                               const ossimIrect& clip_rect)
+                                               const ossimIrect& clip_rect,
+                                               ossimImageData* result)
 {
    static const char MODULE[] = "ossimTiffTileSource::loadFromRgbaU8aStrip";
 
    //***
    // Specialized for one bit data to handle null values.
    //***
-   const ossim_uint32 OUTPUT_TILE_WIDTH = theTile->getWidth();
-   const ossim_uint8 NULL_PIX = static_cast<ossim_uint8>(theTile->getNullPix(0));
-   const ossim_uint8 MIN_PIX  = static_cast<ossim_uint8>(theTile->getMinPix(0));
+   const ossim_uint32 OUTPUT_TILE_WIDTH = result->getWidth();
+   const ossim_uint8 NULL_PIX = static_cast<ossim_uint8>(result->getNullPix(0));
+   const ossim_uint8 MIN_PIX  = static_cast<ossim_uint8>(result->getMinPix(0));
 
    if (theSamplesPerPixel > 4 || theBytesPerPixel!= 1)
    {
@@ -1388,7 +1422,7 @@ bool ossimTiffTileSource::loadFromRgbaU8aStrip(const ossimIrect& tile_rect,
    ossim_uint8** d = new ossim_uint8*[theSamplesPerPixel];
    for (band = 0; band < theSamplesPerPixel; band++)
    {
-      d[band] = static_cast<ossim_uint8*>(theTile->getBuf(band))+output_tile_offset;
+      d[band] = static_cast<ossim_uint8*>(result->getBuf(band))+output_tile_offset;
    }
 
    // Loop through strips...
@@ -1502,41 +1536,31 @@ void ossimTiffTileSource::adjustToStartOfTile(ossimIpt& pt) const
    }
 }
 
-bool ossimTiffTileSource::isValidRLevel(ossim_uint32 reduced_res_level) const
+bool ossimTiffTileSource::isValidRLevel(ossim_uint32 resLevel) const
 {
-   if ( ( reduced_res_level > getHighestReducedResSet()  ) ||
-        ( !theR0isFullRes && (reduced_res_level == 0) ) )
+   bool result = false;
+   
+   const ossim_uint32 LEVELS = getNumberOfDecimationLevels();
+
+   //---
+   // If we have r0 our reslevels are the same as the callers so
+   // no adjustment necessary.
+   //---
+   if ( !theStartingResLevel || theR0isFullRes) // Not an overview or has r0.
    {
-#if 0
-      ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimTiffTileSource::isValidRLevel Invalid reduced_res_level:  "
-         << reduced_res_level
-         << "\nHighest available:  " << getHighestReducedResSet()
-         << "\nR0 is "
-         << (theR0isFullRes ? "valid level." : "not a valid level.") 
-         << endl;
-#endif
-      return false;
+      result = (resLevel < LEVELS);
    }
-
-   return true;
-}
-
-ossim_uint32 ossimTiffTileSource::getHighestReducedResSet() const
-{
-   if (theOverview)
+   else if (resLevel >= theStartingResLevel) // Used as overview.
    {
-      return theOverview->getHighestReducedResSet();
+      result = ( (resLevel - theStartingResLevel) < LEVELS);
    }
    
-   return (theR0isFullRes ?
-           theNumberOfDirectories-1 :
-           theNumberOfDirectories);
+   return result;
 }
 
 ossim_uint32 ossimTiffTileSource::getCurrentTiffRLevel() const
 {
-   return (theR0isFullRes ? theCurrentDirectory : theCurrentDirectory + 1);
+   return theCurrentDirectory;
 }
 
 ossimString ossimTiffTileSource::getReadMethod(ossim_uint32 directory) const
@@ -1595,7 +1619,7 @@ bool ossimTiffTileSource::allocateBuffer()
          
       case READ_SCAN_LINE:
          buffer_size = theImageWidth[0] * theBytesPerPixel *
-            theSamplesPerPixel * theTile->getHeight();
+            theSamplesPerPixel * theCurrentTileHeight;
          break;
          
       default:
@@ -1727,7 +1751,7 @@ std::ostream& ossimTiffTileSource::print(std::ostream& os) const
       os << "\nOutput tile dump:\n" << *theTile << endl;
    }
 
-   if (theOverview)
+   if (theOverview.valid())
    {
       os << "\nOverview file:\n";
       theOverview->print(os);
@@ -1863,6 +1887,11 @@ void ossimTiffTileSource::initializeBuffers()
    // stuffed in it.
    //
    theTile->initialize();
+
+   // The width and height mus be set prior to call to allocateBuffer.
+   theCurrentTileWidth  = theTile->getWidth();
+   theCurrentTileHeight = theTile->getHeight();
+   
    allocateBuffer();
 }
 
@@ -1986,3 +2015,81 @@ void ossimTiffTileSource::validateMinMax()
       theMaxSampleValue = tempMax;
    }
 }
+
+#if 0
+ossimImageGeometry* ossimTiffTileSource::getImageGeometry()
+{
+   //---
+   // Call base class getImageGeometry which will check for external geometry
+   // or an already set geometry.
+   //---
+   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
+
+   if (result)
+   {
+      //---
+      // TODO: Add transform from tags.
+      //---
+
+      
+      // if ( !result->getTransform() )
+      // {
+      //    if ( transform.valid() )
+      //    {
+      //       result->setTransform( transform.get() );
+      //    }
+      // }
+      //else
+      //{
+      //   ossimImageGeometryRegistry::instance()->createTransform(this);
+      //}
+      
+      if ( !result->getProjection() )
+      {
+         // Get the projection from the tags.
+         
+         ossimRefPtr<ossimProjection> proj = 0;
+
+         if (theTiffPtr)
+         {
+            ossimGeoTiff geotiff;
+
+            //---
+            // Note: must pass false to readTags so it doesn't close our
+            // tiff pointer.
+            //---
+            geotiff.readTags(theTiffPtr, getCurrentEntry(), false);
+            ossimKeywordlist kwl;
+            if(geotiff.addImageGeometry(kwl))
+            {
+               proj = ossimProjectionFactoryRegistry::instance()->
+                  createProjection(kwl);
+            }
+            
+            if ( proj.valid() )
+            {
+               result->setProjection( proj.get() );
+            }
+            //else
+            //{
+            // ossimImageGeometryRegistry::instance()->createProjection(this);
+            //}
+         }
+      }
+      
+   } // matches: if (result)
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "ossimTiffTileSource::createImageGeometry DEBUG:\n";
+
+      if (result)
+      {
+         result->print(ossimNotify(ossimNotifyLevel_DEBUG)) << "\n";
+      }
+   }
+
+   return result;
+}
+#endif
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp
index dc3a7c64be6fd4322604015754bd5ace964e7d3a..54e9b3aaf653232e1bfbd4db9c77e1ac2a5e1aa1 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp
@@ -5,7 +5,7 @@
 // Author:  Frank Warmerdam (warmerda@home.com)
 //
 //*******************************************************************
-//  $Id: ossimTiffWriter.cpp 11971 2007-11-01 16:44:19Z gpotts $
+//  $Id: ossimTiffWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <algorithm>
 #include <sstream>
@@ -54,7 +54,7 @@ static const long  DEFAULT_JPEG_QUALITY = 75;
 RTTI_DEF1(ossimTiffWriter, "ossimTiffWriter", ossimImageFileWriter);
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimTiffWriter.cpp 11971 2007-11-01 16:44:19Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimTiffWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 ossimTiffWriter::ossimTiffWriter()
@@ -71,6 +71,7 @@ ossimTiffWriter::ossimTiffWriter()
       theForceBigTiffFlag(false),
       theBigTiffFlag(false)
 {
+   theColorLut = new ossimNBandLutDataObject();
    ossim::defaultTileSize(theOutputTileSize);
    theOutputImageType = "tiff_tiled_band_separate";
 
@@ -304,7 +305,7 @@ Call setFilename method.\n",
                       ((scalarType == OSSIM_UINT8)||
                        (scalarType == OSSIM_UINT16)||
                        (scalarType == OSSIM_USHORT11))&&
-                      (theColorLut.getNumberOfEntries() > 0)&&
+                      (theColorLut->getNumberOfEntries() > 0)&&
                       (theInputConnection->getNumberOfOutputBands() == 1));
    if(lutEnabled)
    {
@@ -319,11 +320,11 @@ Call setFilename method.\n",
          memset(g, '\0', sizeof(ossim_uint16)*256);
          memset(b, '\0', sizeof(ossim_uint16)*256);
          
-         for(ossim_uint32 i = 0; i < theColorLut.getNumberOfEntries(); i++)
+         for(ossim_uint32 i = 0; i < theColorLut->getNumberOfEntries(); i++)
          {
-            r[i] = (ossim_uint16) ((theColorLut[i][0]/255.0)*65535);
-            g[i] = (ossim_uint16) ((theColorLut[i][1]/255.0)*65535);
-            b[i] = (ossim_uint16) ((theColorLut[i][2]/255.0)*65535);
+            r[i] = (ossim_uint16) (((*theColorLut)[i][0]/255.0)*65535);
+            g[i] = (ossim_uint16) (((*theColorLut)[i][1]/255.0)*65535);
+            b[i] = (ossim_uint16) (((*theColorLut)[i][2]/255.0)*65535);
          }
          TIFFSetField(theTif, TIFFTAG_COLORMAP, r, g ,b);
       }
@@ -334,11 +335,11 @@ Call setFilename method.\n",
          memset(g, '\0', sizeof(ossim_uint16)*65536);
          memset(b, '\0', sizeof(ossim_uint16)*65536);
          
-         for(ossim_uint32 i = 0; i < theColorLut.getNumberOfEntries(); i++)
+         for(ossim_uint32 i = 0; i < theColorLut->getNumberOfEntries(); i++)
          {
-            r[i] = (ossim_uint16) (theColorLut[i][0]);
-            g[i] = (ossim_uint16) (theColorLut[i][1]);
-            b[i] = (ossim_uint16) (theColorLut[i][2]);
+            r[i] = (ossim_uint16) ((*theColorLut)[i][0]);
+            g[i] = (ossim_uint16) ((*theColorLut)[i][1]);
+            b[i] = (ossim_uint16) ((*theColorLut)[i][2]);
          }
          TIFFSetField(theTif, TIFFTAG_COLORMAP, r, g ,b);
       }
@@ -613,7 +614,7 @@ Call setFilename method.\n",
       gcs = USER_DEFINED;
 
       std::ostringstream os;
-      os << "IMAGINE GeoTIFF Support\nCopyright 1991 -  2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 11971 $ $Date: 2007-11-02 00:44:19 +0800 (Fri, 02 Nov 2007) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)";
+      os << "IMAGINE GeoTIFF Support\nCopyright 1991 -  2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 15766 $ $Date: 2009-10-20 20:37:09 +0800 (Tue, 20 Oct 2009) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)";
 
       GTIFKeySet(gtif,
                  GeogCitationGeoKey,
@@ -965,7 +966,7 @@ bool ossimTiffWriter::writeFile()
    {
       theNBandToIndexFilter = new ossimNBandToIndexFilter;
       theNBandToIndexFilter->connectMyInputTo(0, theInputConnection->getInput());
-      theNBandToIndexFilter->setLut(theColorLut);
+      theNBandToIndexFilter->setLut(*theColorLut.get());
       theNBandToIndexFilter->initialize();
       theInputConnection->disconnect();
       theInputConnection->connectMyInputTo(0, theNBandToIndexFilter.get());
@@ -976,7 +977,7 @@ bool ossimTiffWriter::writeFile()
       theNBandToIndexFilter = 0;
    }
    
-   if (traceDebug() && theInputConnection)
+   if (traceDebug() && theInputConnection.get())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE << "DEBUG:"
@@ -1072,7 +1073,7 @@ bool ossimTiffWriter::writeFile()
    // Write the geotiff tags.
    if (theOutputGeotiffTagsFlag)
    {
-      if(theViewController) // let this override
+      if(theViewController.get()) // let this override
       {                     // found in ossimImageWriter base
          ossimMapProjection* proj = PTR_CAST(ossimMapProjection,
                                              theViewController->getView());
@@ -1112,12 +1113,14 @@ bool ossimTiffWriter::writeFile()
       }
       else
       {
-         ossimKeywordlist kwl;
-         theInputConnection->getImageGeometry(kwl);
-         
-         ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->
-            createProjection(kwl);
-         ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);
+         // Fetch the map projection of the input image if it exists:
+         ossimMapProjection* mapProj = 0;
+         const ossimImageGeometry* imgGeom = theInputConnection->getImageGeometry();
+         if (imgGeom)
+         {
+            const ossimProjection* proj = imgGeom->getProjection();
+            mapProj = PTR_CAST(ossimMapProjection, proj);
+         }
          if(mapProj)
          {
             ossimRefPtr<ossimMapProjectionInfo> projectionInfo
@@ -1133,18 +1136,9 @@ bool ossimTiffWriter::writeFile()
                      << "\nError detected writing geotiff tags.  Returning..."
                      << std::endl;
                }
-               if(proj)
-               {
-                  delete proj;
-               }
                return false;
             }
          }
-         if(proj)
-         {
-            delete proj;
-            proj = NULL;
-         }
       }
 
    } // End of "if (theOutputGeotiffTagsFlag)"
@@ -1197,7 +1191,7 @@ bool ossimTiffWriter::writeFile()
 
 void ossimTiffWriter::setLut(const ossimNBandLutDataObject& lut)
 {
-   theColorLut = lut;
+   theColorLut = (ossimNBandLutDataObject*)lut.dup();
 }
 
 bool ossimTiffWriter::saveState(ossimKeywordlist& kwl,
@@ -1245,7 +1239,7 @@ bool ossimTiffWriter::saveState(ossimKeywordlist& kwl,
       else
       {
          ossimString newPrefix = ossimString(prefix) + "lut.";
-         theColorLut.saveState(kwl, newPrefix.c_str());
+         theColorLut->saveState(kwl, newPrefix.c_str());
       }
    }
 
@@ -1342,11 +1336,11 @@ bool ossimTiffWriter::loadState(const ossimKeywordlist& kwl,
    theLutFilename = ossimFilename(theLutFilename.trim());
    if(theLutFilename != "")
    {
-      theColorLut.open(theLutFilename);
+      theColorLut->open(theLutFilename);
    }
    else
    {
-      theColorLut.loadState(kwl, newPrefix.c_str());
+      theColorLut->loadState(kwl, newPrefix.c_str());
    }
 
    if(ossimImageFileWriter::loadState(kwl,
@@ -1396,11 +1390,11 @@ bool ossimTiffWriter::writeToTiles()
 
    if(theColorLutFlag)
    {
-      tempTile = ossimImageDataFactory::instance()->create(this, 1, theInputConnection);
+      tempTile = ossimImageDataFactory::instance()->create(this, 1, theInputConnection.get());
    }
    else
    {
-      tempTile = ossimImageDataFactory::instance()->create(this, theInputConnection);
+      tempTile = ossimImageDataFactory::instance()->create(this, theInputConnection.get());
    }
    if(tempTile.valid())
    {
@@ -1968,7 +1962,7 @@ void ossimTiffWriter::setProperty(ossimRefPtr<ossimProperty> property)
    else if(property->getName() == "lut_file")
    {
       theLutFilename = ossimFilename(property->valueToString());
-      theColorLut.open(theLutFilename);
+      theColorLut->open(theLutFilename);
    }
    else if(property->getName() == "color_lut_flag")
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTileCache.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTileCache.cpp
index b2ce729834756f88f121cbd091b731d753ca84f7..2a72825973437a72e53da59c9d0fc5be73e2371d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTileCache.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTileCache.cpp
@@ -6,7 +6,7 @@
 // Description: This file contains the cache algorithm
 //
 //***********************************
-// $Id: ossimTileCache.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimTileCache.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimTileCache.h>
 #include <ossim/base/ossimDataObject.h>
@@ -56,7 +56,7 @@ ossimDataObject* ossimTileCache::get(const ossimDpt3d &origin,
          if(info->theOrigin   == origin &&
             info->theResLevel == resLevel)
          {
-            return info->theCachedTile;
+            return info->theCachedTile.get();
          }
       }
 
@@ -84,7 +84,7 @@ ossimDataObject* ossimTileCache::remove(const ossimDpt3d &origin,
             theCache[bucket].erase(anIterator);
             theSizeInBytes -= info->theCachedTile->getDataSizeInBytes();
 
-            result = info->theCachedTile;
+            result = info->theCachedTile.get();
 
             delete info;
             return result;
@@ -164,7 +164,6 @@ void ossimTileCache::deleteAll()
       while(anIterator != theCache[bucket].end())
       {
          CacheDataPtr info = (*anIterator).second;
-         delete info->theCachedTile;
          delete info;
          
          ++anIterator;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp
index 57916975eaad92462a4649b1fb8f0c99e785f840..4399131a843117729d984e9a0ae8c8faddc2e4cb 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp
@@ -57,11 +57,7 @@ ossimTileMapTileSource::ossimTileMapTileSource(const ossimKeywordlist& kwl,
 //*******************************************************************
 ossimTileMapTileSource::~ossimTileMapTileSource()
 {
-   if (theFfHdr)
-   {
-      delete theFfHdr;
-      theFfHdr = NULL;
-   }
+   theFfHdr = NULL;
 }
 
 bool ossimTileMapTileSource::open()
@@ -78,130 +74,6 @@ bool ossimTileMapTileSource::open()
      return true;
      }
    return false;
-
-//    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,
-// 					    fileList.size(),
-// 					    theFfHdr->getLinesPerBand(),
-// 					    theFfHdr->getPixelsPerLine(),
-// 					    0,
-// 					    ossimGeneralRasterInfo::NONE,
-// 					    0);
-//    if(fileList.size() == 1)
-//    {
-//       generalRasterInfo = ossimGeneralRasterInfo(fileList,
-//                                                  OSSIM_UINT8,
-//                                                  OSSIM_BSQ,
-//                                                  fileList.size(),
-//                                                  theFfHdr->getLinesPerBand(),
-//                                                  theFfHdr->getPixelsPerLine(),
-//                                                  0,
-//                                                  ossimGeneralRasterInfo::NONE,
-//                                                  0);
-//    }
-//    theMetaData.clear();
-//    theMetaData.setScalarType(OSSIM_UINT8);
-//    theMetaData.setNumberOfBands(fileList.size());
-//    theImageData = generalRasterInfo;
-//    if(initializeHandler())
-//    {
-//       theImageFile = tempFilename;
-
-//       completeOpen();
-//    }
-//    else
-//    {
-//       if (traceDebug()) CLOG << " Exited..." << std::endl;
-//       return false;
-//    }
-
-//    if (traceDebug()) CLOG << " Exited..." << std::endl;
-
-//    return true;
 }
 
 void ossimTileMapTileSource::openHeader(const ossimFilename& file)
@@ -228,124 +100,29 @@ void ossimTileMapTileSource::openHeader(const ossimFilename& file)
    }
    if (theFfHdr->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
    {
-      delete theFfHdr;
-      theFfHdr = NULL;
+      theFfHdr = 0;
    }
    return;
 
-   // I had to force the open to go with a header since there are duplicate entries when scanning
-   // landsat directories.
-   //  For now I am commenting this code out.
-   //
-#if 0
-   //***
-   // User may have passed in an image file name in which case the header file
-   // must be derived from it.
-   //***
-   if (hdr.size() < 25)
-   {
-      // file name not long enough...
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimTileMapTileSource::openHeader DEBUG:"
-            << "\nNot a standard landsat 7 file name:  " << hdr << std::endl;
-         return;
-      }
-   }
-
-   char substr[4];
-   const char* f = hdr.c_str();
-   strncpy(substr, (f+22), 3);
-   substr[3] = '\0';
-   ossimString s1 = substr;
-   ossimString s2;
-   s1.downcase();
-   if (s1 == "b80")
-   {
-      s2 = "hpn";
-   }
-   else if (s1 == "b61" || s1 == "b62")
-   {
-      s2 = "htm";
-   }
-   else if (s1 == "b10" || s1 == "b20" || s1 == "b30" ||
-            s1 == "b40" || s1 == "b50" || s1 == "b70")
-   {
-      s2 = "hrf";
-   }
-   else
-   {
-      // Not of any format we know of...
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimTileMapTileSource::openHeader DEBUG:"
-            << "\nCould not derive header name from:  " << file
-            << std::endl;
-      }
-
-      return;
-   }
-
-   // Set the case to be the same as the file passed in.
-   if (substr[0] == 0x42) // ascii "B"
-   {
-      s1.upcase();
-      s2.upcase();
-      hdr.upcase();
-
-      // Header files alway start with "L71"
-      hdr = hdr.substitute(ossimString("L72"), ossimString("L71"));
-   }
-   else
-   {
-      // Header files alway start with "l71"
-      hdr = hdr.substitute(ossimString("l72"), ossimString("l71"));
-   }
-
-   // Make the hdr file name.
-   hdr = hdr.substitute(s1, s2);
-
-   ossimFilename f1 = file.drive();
-   f1 += file.path();
-   hdr = f1.dirCat(hdr);
-   theFfHdr = new ossimFfL7(hdr.c_str());
-
-   if (theFfHdr->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
-   {
-      delete theFfHdr;
-      theFfHdr = NULL;
-   }
-#endif
 }
 
-bool ossimTileMapTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                              const char* prefix)
+ossimImageGeometry* ossimTileMapTileSource::getImageGeometry()
 {
-   // Check for override for an external geometry file, or a previous save.
-   if(ossimImageHandler::getImageGeometry(kwl, prefix))
-   {
-      return true;
-   }
 
-//   if (!theFfHdr) return false;
+   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
+   if (result->getProjection())
+      return theGeometry.get();
 
-   // Make a model
-   ossimTileMapModel model;
+   if (!theFfHdr) return result;
 
-   if (model.getErrorStatus() != ossimErrorCodes::OSSIM_OK)
-   {
+   // Make a model
+   ossimTileMapModel* model = new ossimTileMapModel (*theFfHdr);
 
+   if (model->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
       return false;
-   }
 
-   bool result = model.saveState(kwl, prefix);
-   if (result)
-   {
-      // Capture for next time...
-      setImageGeometry(kwl);
-   }
+   //initialize the image geometry object with the model
+   result->setProjection(model);
    return result;
 }
 
@@ -354,25 +131,7 @@ bool ossimTileMapTileSource::loadState(const ossimKeywordlist& kwl,
 {
    const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
    return true;
-//    if (lookup)
-//    {
-//       ossimFilename fileName = lookup;
-
-//       ossimString ext = fileName.ext();
-
-//       if((ext.upcase() == "FST") || (ext.upcase() == "DAT"))
-//       {
-//          //---
-//          // This will call:
-//          // ossimImageHandler::loadState() the open()
-//          //---
-//          if (ossimGeneralRasterTileSource::loadState(kwl, prefix))
-//          {
-//             return true;
-//          }
-//       }
-//    }
-//    return false;
+
 }
 
 ossimRefPtr<ossimProperty> ossimTileMapTileSource::getProperty(
@@ -380,7 +139,7 @@ ossimRefPtr<ossimProperty> ossimTileMapTileSource::getProperty(
 {
    ossimRefPtr<ossimProperty> result = 0;
 
-   if (theFfHdr)
+   if (theFfHdr.valid())
    {
       result = theFfHdr->getProperty(name);
    }
@@ -396,7 +155,7 @@ ossimRefPtr<ossimProperty> ossimTileMapTileSource::getProperty(
 void ossimTileMapTileSource::getPropertyNames(
    std::vector<ossimString>& propertyNames)const
 {
-   if (theFfHdr)
+   if (theFfHdr.valid())
    {
       theFfHdr->getPropertyNames(propertyNames);
    }
@@ -490,18 +249,4 @@ ossimFilename ossimTileMapTileSource::getBandFilename(ossim_uint32 idx)const
    return ossimFilename();
 }
 
-bool ossimTileMapTileSource::isPan()const
-{
-   return (getNumberOfInputBands() == 1);
-}
-
-bool ossimTileMapTileSource::isVir()const
-{
-   return (getNumberOfInputBands() == 6);
-}
-
-bool ossimTileMapTileSource::isTm()const
-{
-   return (getNumberOfInputBands() == 2);
-}
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimU11ImageData.cpp b/Utilities/otbossim/src/ossim/imaging/ossimU11ImageData.cpp
index 8aa5f32841e9360394b33e6abdde4f29deada739..f0d345ad2d281aeb0d800b9326ed869ecb651a24 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimU11ImageData.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimU11ImageData.cpp
@@ -17,10 +17,7 @@
 //        If you want anything else use the less efficient ossimImageData.
 //
 //*************************************************************************
-// $Id: ossimU11ImageData.cpp 11721 2007-09-13 13:19:34Z gpotts $
-
-#include <cstring>  // for memset function
-using namespace std;
+// $Id: ossimU11ImageData.cpp 15792 2009-10-22 18:03:13Z dburken $
 
 #include <ossim/imaging/ossimU11ImageData.h>
 #include <ossim/base/ossimSource.h>
@@ -37,6 +34,7 @@ ossimU11ImageData::ossimU11ImageData()
    :
       ossimImageData()
 {
+   theScalarType = OSSIM_USHORT11;
 }
 
 ossimU11ImageData::ossimU11ImageData(ossimSource* source,
@@ -91,10 +89,10 @@ ossimDataObjectStatus ossimU11ImageData::validate() const
    for(ossim_uint32 band = 0; band < NUMBER_OF_BANDS; ++band)
    {
       const ossim_uint16* p  = getUshortBuf(band);
-      for (ossim_uint32 i=0; i<BOUNDS; i++)
+      for (ossim_uint32 i=0; i<BOUNDS; ++i)
       {
          // check if the band is null
-         if (p[i] != 0) count++;         
+         if (p[i] != 0) ++count;         
       }
    }
    
@@ -112,31 +110,24 @@ void ossimU11ImageData::getNormalizedFloat(ossim_uint32 offset,
                                            ossim_uint32 bandNumber,
                                            float& result)const
 {
-   // make sure that the types and width and height are good.
-   if( (getDataObjectStatus() == OSSIM_NULL) && isValidBand(bandNumber) )
+   if( (getDataObjectStatus() != OSSIM_NULL) && isValidBand(bandNumber) )
    {
-      return;
+      const ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
+      result =
+         static_cast<float>(theRemapTable.normFromPix(sourceBuf[offset]));
    }
-   
-   const ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
-   result = static_cast<float>(theRemapTable.normFromPix(sourceBuf[offset]));
 }
 
 void ossimU11ImageData::setNormalizedFloat(ossim_uint32 offset,
                                            ossim_uint32 bandNumber,
                                            float inputValue)
 {
-   // make sure that the types and width and height are
-   // good.
-   if((getDataObjectStatus() == OSSIM_NULL)&&
-      (bandNumber < getNumberOfBands()))
+   if( (getDataObjectStatus() != OSSIM_NULL) &&  isValidBand(bandNumber) )
    {
-      return;
+      ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
+      sourceBuf[offset]
+         = static_cast<ossim_uint16>(theRemapTable.pixFromNorm(inputValue));
    }
-
-   ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
-   sourceBuf[offset]
-      = static_cast<ossim_uint16>(theRemapTable.pixFromNorm(inputValue));
 }
 
 void
@@ -322,16 +313,18 @@ double ossimU11ImageData::computeAverageBandValue(ossim_uint32 bandNumber)
 
 void ossimU11ImageData::makeBlank()
 {
-   void* s = getBuf();
+   if ( (theDataBuffer.size() == 0) || (getDataObjectStatus() == OSSIM_EMPTY) )
+   {
+      return; // nothing to do...
+   }
 
-   if (s == NULL) return; // nothing to do...
+   const ossim_uint32 BANDS = getNumberOfBands();
+   const ossim_uint32 SPB   = getSizePerBand();
    
-   ossim_uint32 size_in_pixels = getSizePerBand();
-   
-   for(ossim_uint32 band =0; band < getNumberOfBands(); ++band)
+   for(ossim_uint32 band =0; band < BANDS; ++band)
    {
       ossim_uint16* p = getUshortBuf(band);
-      for (ossim_uint32 i=0; i<size_in_pixels; i++) p[i] = 0;
+      for (ossim_uint32  i = 0; i < SPB; ++i) p[i] = 0; // zero is our null
    }
 
    setDataObjectStatus(OSSIM_EMPTY);
@@ -418,16 +411,17 @@ void ossimU11ImageData::copyTileToNormalizedBuffer(double* buf) const
    
    if(size > 0)
    {
-      for(ossim_uint32 band = 0; band < getNumberOfBands(); band++)
+      for(ossim_uint32 band = 0; band < getNumberOfBands(); ++band)
       {
          const ossim_uint16* s = getUshortBuf(band);  // source
          double* d = buf + (band*size);   // destination
 
-         for(ossim_uint32 index = 0; index < size; index++)
+         for(ossim_uint32 index = 0; index < size; ++index)
          {
             d[index] = theRemapTable.
-                       normFromPix(static_cast<ossim_int32>(s[index]));
+               normFromPix(static_cast<ossim_int32>(s[index]));
          }
+
       }
    }
 }
@@ -444,6 +438,7 @@ void ossimU11ImageData::copyTileToNormalizedBuffer(ossim_uint32 band,
                     __LINE__);
       return;
    }
+   
    if(!getBuf(band)) return;
    
    ossim_uint32 size = getSizePerBand();
@@ -455,13 +450,11 @@ void ossimU11ImageData::copyTileToNormalizedBuffer(ossim_uint32 band,
       
       for(ossim_uint32 index = 0; index < size; index++)
       {
-         *d = theRemapTable.
-              normFromPix(static_cast<ossim_int32>(*s));
+         *d = theRemapTable.normFromPix(static_cast<ossim_int32>(*s));
       }
    }
 }
 
-
 void ossimU11ImageData::copyNormalizedBufferToTile(double* buf)
 {
    if (!buf)
@@ -572,10 +565,9 @@ void ossimU11ImageData::copyTileToNormalizedBuffer(ossim_uint32 band,
       const ossim_uint16* s = getUshortBuf(band);  // source
       float* d = buf;   // destination
       
-      for(ossim_uint32 index = 0; index < size; index++)
+      for(ossim_uint32 index = 0; index < size; ++index)
       {
-         *d = theRemapTable.
-              normFromPix(static_cast<ossim_int32>(*s));
+         *d = theRemapTable.normFromPix(static_cast<ossim_int32>(*s));
       }
    }
 }
@@ -596,12 +588,12 @@ void ossimU11ImageData::copyNormalizedBufferToTile(float* buf)
    
    if(size > 0)
    {
-      for(ossim_uint32 band = 0; band < getNumberOfBands(); band++)
+      for(ossim_uint32 band = 0; band < getNumberOfBands(); ++band)
       {
          float* s = buf + (band*size); // source
          ossim_uint16* d = getUshortBuf(band); // destination
 
-         for(ossim_uint32 index = 0; index <  size; index++)
+         for(ossim_uint32 index = 0; index <  size; ++index)
          {
             d[index] = theRemapTable.pixFromNorm(s[index]);
          }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimU16ImageData.cpp b/Utilities/otbossim/src/ossim/imaging/ossimU16ImageData.cpp
index 636f48dbffd267f0c3e091919ea54cf70d2fc952..cceff5fc15a0a5fe67ed2f06ba6cfab6b2775efe 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimU16ImageData.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimU16ImageData.cpp
@@ -17,9 +17,7 @@
 //        If you want anything else use the less efficient ossimImageData.
 //
 //*************************************************************************
-// $Id: ossimU16ImageData.cpp 11721 2007-09-13 13:19:34Z gpotts $
-
-#include <string.h>  // for memset function
+// $Id: ossimU16ImageData.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimU16ImageData.h>
 #include <ossim/base/ossimSource.h>
@@ -36,14 +34,13 @@ ossimU16ImageData::ossimU16ImageData()
    :
       ossimImageData()
 {
+   theScalarType = OSSIM_UINT16;
 }
 
 ossimU16ImageData::ossimU16ImageData(ossimSource* source,
                                      ossim_uint32 bands)
    :
-      ossimImageData(source,
-                     OSSIM_USHORT16,
-                     bands)
+      ossimImageData(source, OSSIM_UINT16, bands)
 {
 }
 
@@ -52,11 +49,7 @@ ossimU16ImageData::ossimU16ImageData(ossimSource* source,
                                      ossim_uint32 width,
                                      ossim_uint32 height)
    :
-      ossimImageData(source,
-                     OSSIM_USHORT16,
-                     bands,
-                     width,
-                     height)
+      ossimImageData(source, OSSIM_UINT16, bands, width, height)
 {
 }
 
@@ -112,31 +105,24 @@ void ossimU16ImageData::getNormalizedFloat(ossim_uint32 offset,
                                            ossim_uint32 bandNumber,
                                            float& result)const
 {
-   // make sure that the types and width and height are good.
-   if( (getDataObjectStatus() == OSSIM_NULL) && isValidBand(bandNumber) )
+   if( (getDataObjectStatus() != OSSIM_NULL) && isValidBand(bandNumber) )
    {
-      return;
+      const ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
+      result =
+         static_cast<float>(theRemapTable.normFromPix(sourceBuf[offset]));
    }
-   
-   const ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
-   result = static_cast<float>(theRemapTable.normFromPix(sourceBuf[offset]));
 }
 
 void ossimU16ImageData::setNormalizedFloat(ossim_uint32 offset,
                                            ossim_uint32 bandNumber,
                                            float inputValue)
 {
-   // make sure that the types and width and height are
-   // good.
-   if((getDataObjectStatus() == OSSIM_NULL)&&
-      (bandNumber < getNumberOfBands()))
+   if( (getDataObjectStatus() != OSSIM_NULL) &&  isValidBand(bandNumber) )
    {
-      return;
+      ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
+      sourceBuf[offset]
+         = static_cast<ossim_uint16>(theRemapTable.pixFromNorm(inputValue));
    }
-
-   ossim_uint16* sourceBuf = getUshortBuf(bandNumber);
-   sourceBuf[offset]
-      = static_cast<ossim_uint16>(theRemapTable.pixFromNorm(inputValue));
 }
 
 void
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimU8ImageData.cpp b/Utilities/otbossim/src/ossim/imaging/ossimU8ImageData.cpp
index bc543389dc46de91a77f1a994ef1c03a7dd9176f..fa60fc91bd106adecb2f500a6d6ff0c92c3d5a8d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimU8ImageData.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimU8ImageData.cpp
@@ -17,7 +17,7 @@
 //        If you want anything else use the less efficient ossimImageData.
 //
 //*************************************************************************
-// $Id: ossimU8ImageData.cpp 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimU8ImageData.cpp 15495 2009-09-29 11:19:04Z dburken $
 
 #include <cstring>  // for memset function
 using namespace std;
@@ -644,10 +644,3 @@ void ossimU8ImageData::copyNormalizedBufferToTile(ossim_uint32 band,
    }
 }
 
-
-const ossimU8ImageData& ossimU8ImageData::operator=(
-   const ossimU8ImageData& /* rhs */)
-{
-   return *this;
-}
-
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimUsgsDemTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimUsgsDemTileSource.cpp
index f6cbcc7a6345b703c3e66c16d80185d13a5b5cbd..352ca6f39dcab0ac25656ef28732992cf800ceed 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimUsgsDemTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimUsgsDemTileSource.cpp
@@ -1,19 +1,18 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt.
-//
-// Author:  David Burken
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Description:
 //
 // Contains class declaration for ossimUsgsDemTileSource.
 //
 //********************************************************************
-// $Id: ossimUsgsDemTileSource.cpp 11419 2007-07-27 16:24:57Z dburken $
+// $Id: ossimUsgsDemTileSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <fstream>
-
 #include <ossim/imaging/ossimUsgsDemTileSource.h>
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimCommon.h>
@@ -28,7 +27,8 @@
 #include <ossim/support_data/ossimDemHeader.h>
 #include <ossim/support_data/ossimDemProfile.h>
 #include <ossim/support_data/ossimDemGrid.h>
-
+#include <ossim/support_data/ossimDemUtil.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
 
 RTTI_DEF1(ossimUsgsDemTileSource, "ossimUsgsDemTileSource", ossimImageHandler)
 
@@ -67,80 +67,102 @@ ossimUsgsDemTileSource::~ossimUsgsDemTileSource()
 ossimRefPtr<ossimImageData> ossimUsgsDemTileSource::getTile(
    const  ossimIrect& tile_rect, ossim_uint32 resLevel)
 {
-   // This tile source bypassed, or invalid res level, return a blank tile.
-   if (!isOpen() || !isSourceEnabled() || !isValidRLevel(resLevel))
-   {
-      return ossimRefPtr<ossimImageData>();
-   }
-
-   if (theOverview)
+   if (theTile.valid())
    {
-      if (theOverview->hasR0() || resLevel)
+      // Image rectangle must be set prior to calling getTile.
+      theTile->setImageRectangle(tile_rect);
+      
+      if ( getTile( theTile.get(), resLevel ) == false )
       {
-         ossimRefPtr<ossimImageData> temp = theOverview->getTile(tile_rect,
-                                                                 resLevel);
-         if(temp.valid() && temp->getBuf())
-         {
-            temp->setMinPix(theTile->getMinPix(), theTile->getNumberOfBands());
-            temp->setMaxPix(theTile->getMaxPix(), theTile->getNumberOfBands());
-            temp->setNullPix(theTile->getNullPix(), theTile->getNumberOfBands());
-         }
-         else
+         if (theTile->getDataObjectStatus() != OSSIM_NULL)
          {
-            return ossimRefPtr<ossimImageData>();
+            theTile->makeBlank();
          }
-         return temp;
       }
    }
+   
+   return theTile;
+}
 
-   if (!theTile.valid())
-   {
-      return theTile;
-   }
+bool ossimUsgsDemTileSource::getTile(ossimImageData* result,
+                                     ossim_uint32 resLevel)
+{
+   bool status = false;
 
-   theTile->setImageRectangle(tile_rect);
-   
-   ossimIrect image_rect = getImageRectangle(resLevel);
-   
-   //***
-   // See if any point of the requested tile is in the image.
-   //***
-   if ( tile_rect.intersects(image_rect) )
+   //---
+   // Not open, this tile source bypassed, or invalid res level,
+   // return a blank tile.
+   //---
+   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
+       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
    {
-      ossimIrect clip_rect = tile_rect.clipToRect(image_rect);
-      
-      if ( !tile_rect.completely_within(clip_rect) )
-      {
-         // Start with a blank tile.
-         theTile->makeBlank();
-      }
+      result->ref(); // Increment ref count.
 
-      // Load the tile buffer with data from the dem cell.
-      bool status;
-      if (theScalarType == OSSIM_FLOAT32)
-      {
-         status = fillBuffer(ossim_float32(0.0), tile_rect, clip_rect);
-      }
-      else
-      {
-         status = fillBuffer(ossim_sint16(0), tile_rect, clip_rect);
-  
-      }
-      if (status == true)
+      //---
+      // 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) // From old code.  Not sure if still needed.
       {
-         theTile->validate();
-         return theTile;
+         result->setMinPix(theTile->getMinPix(), theTile->getNumberOfBands());
+         result->setMaxPix(theTile->getMaxPix(), theTile->getNumberOfBands());
+         result->setNullPix(theTile->getNullPix(), theTile->getNumberOfBands());
       }
-      else
+      
+      if (!status) // Did not get an overview tile.
       {
-         return ossimRefPtr<ossimImageData>();
+         status = true;
+         
+         ossimIrect tile_rect = result->getImageRectangle();
+         
+         ossimIrect image_rect = getImageRectangle(resLevel);
+         
+         //---
+         // 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);
+            
+            if ( !tile_rect.completely_within(clip_rect) )
+            {
+               // Start with a blank tile.
+               result->makeBlank();
+            }
+            
+            // Load the tile buffer with data from the dem cell.
+            if (theScalarType == OSSIM_FLOAT32)
+            {
+               status = fillBuffer(ossim_float32(0.0),
+                                   tile_rect,
+                                   clip_rect,
+                                   result);
+            }
+            else
+            {
+               status = fillBuffer(ossim_sint16(0),
+                                   tile_rect,
+                                   clip_rect,
+                                   result);
+            }
+            if (status == true)
+            {
+               result->validate();
+            }
+         }    
+         else // No intersection:  if ( tile_rect.intersects(image_rect) )
+         {
+            result->makeBlank();
+         }
       }
-      
-   } // End of if ( tile_rect.intersects(image_rect) )
 
-   // No part of requested tile within the image rectangle.
-   return ossimRefPtr<ossimImageData>();
-   
+      result->unref(); // Decrement ref count.
+   }
+
+   return status;
 }
 
 //*******************************************************************
@@ -149,11 +171,12 @@ ossimRefPtr<ossimImageData> ossimUsgsDemTileSource::getTile(
 template <class T>
 bool ossimUsgsDemTileSource::fillBuffer(T,
                                         const ossimIrect& tile_rect,
-                                        const ossimIrect& clip_rect)
+                                        const ossimIrect& clip_rect,
+                                        ossimImageData* tile)
 {
-   const uint32 TILE_WIDTH = theTile->getWidth();
+   const uint32 TILE_WIDTH = tile->getWidth();
 
-   T* d = static_cast<T*>(theTile->getBuf());
+   T* d = static_cast<T*>(tile->getBuf());
    
    ossim_float32 spatialResZ = theDem->getHeader().getSpatialResZ();
    if (spatialResZ == 0.0) spatialResZ = 1.0;
@@ -202,200 +225,74 @@ bool ossimUsgsDemTileSource::open()
            << "\nAttempting to parse file:  " << theImageFile.c_str()
            << std::endl;
    }
-   
-   if (!theImageFile.exists()) // See if file exists.
-   {
-      if (traceDebug())
-      {
-         CLOG << "DEBUG:"
-              << "\nFile " << theImageFile.c_str() << " does not exist!"
-              << std::endl;
-      }
-      return false;
-   }
 
-   //---
-   // Open checks:
-   // 1) Check extension for .dem
-   //
-   // 2) Look for file.omd (ossim meta data) file containing keyword
-   //    "dem_type" with value of "usgs_dem".
-   //
-   // 3) Look for file.kwl (keyword list) file containing keyword
-   //    "dem_type" with value of "usgs_dem".
-   //
-   // NOTE:
-   // There is a keyword list template stored in the templates directory:
-   // "ossim/etc/templates/usgs_dem_template.kwl"
-   //---
-   ossimString ext = theImageFile.ext();
-   ext.downcase();
-   if ( (ext == "kwl") || (ext == "omd") )
-   {
-      // Don't allow keyword list to be fed to open.  Only image files.
-      return false;
-   }
-      
-   if (ext == "dem")
-   {
-      theIsDemFlag = true;
-   }
+   theIsDemFlag = ossimDemUtil::isUsgsDem(theImageFile);
 
-   // Look for filename.omd
-   ossimFilename kwl_file = theImageFile;
-   kwl_file.setExtension("omd");
-   if (kwl_file.exists()) // See if file exists.
+   if (theIsDemFlag)
    {
-      ossimKeywordlist kwl(kwl_file);
-      if (kwl.getErrorStatus() == ossimErrorCodes::OSSIM_OK)
+      // Open up the file for reading.
+      std::ifstream is(theImageFile.c_str(),
+                       std::ios_base::in | std::ios_base::binary);
+      if (is.good())
       {
-         const char* lookup;
+         // Start out with a fresh dem.
+         if (theDem) delete theDem;
          
-         if (!theIsDemFlag)
-         {
-            const char* lookup = kwl.find(DEM_TYPE_KW);
-            if (lookup)
-            {
-               ossimString s = lookup;
-               s.downcase();
-               if (s == USGS_DEM_KW)
-               {
-                  theIsDemFlag = true;
-               }
-            }
-         }
-
          //---
-         // Look for scalar type override.
-         //
-         // Note: We only allow float or signed 16 bit.
+         // Set the null to -32768.  This will also be the missing data values.
          //---
-         lookup = kwl.find(ossimKeywordNames::SCALAR_TYPE_KW);
-         if (lookup)
-         {
-            ossimScalarType st =
-               static_cast<ossimScalarType>(ossimScalarTypeLut::instance()->
-                                            getEntryNumber(lookup));
-            if ( (st == OSSIM_FLOAT32) || (st == OSSIM_SINT16))
-            {
-               theScalarType = st;
-            }
-            else
-            {
-               if (traceDebug())
-               {
-                  ossimNotify(ossimNotifyLevel_WARN)
-                     << "ossimUsgsDemTileSource::loadState WARNING:"
-                     << "\nInvalid scalar type: "
-                     << ossimScalarTypeLut::instance()->
-                     getEntryString(st)
-                     << std::endl;
-               }
-            }
-         }
+         theNullValue = OSSIM_DEFAULT_NULL_PIX_SINT16;
+         
+         //---
+         // Read the dem.
+         // 
+         // NOTE:  This defines the missing data value.  It should be the
+         // same as null for mosaicing and min/max calculations.
+         //---
+         theDem = new ossimDemGrid(theNullValue);
+         theDem->read(is);
+         
+         is.close();
+      }
+      else
+      {
+         theIsDemFlag = false;
       }
    }
-
-   if (!theIsDemFlag)
-   {
-      return false;
-   }
-
-   // Open up the file for reading.
-   std::ifstream is(theImageFile.c_str(), ios::in | ios::binary);
-   if (!is)
+   
+   if (theIsDemFlag)
    {
-      theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
+      theFeetFlag  = (theDem->getHeader().getElevationUnits() == 1) ?
+         true : false;
       
-      cerr << MODULE << " ERROR!"
-           << "\nCould not open file:  " << theImageFile.c_str()
-           << "\nReturning..." << std::endl;
-      if (traceDebug())  CLOG << "returning with error..." << std::endl;
-      theIsDemFlag = false;
-      return false;
-   }
-
-   //---
-   // SPECIAL HACK (drb):
-   // Check some bytes and make sure there is no binary data.  There are
-   // files out there with .dem extension that are binary rasters.
-   //---
-   ossim_uint8* ubuf = new ossim_uint8[512];
-   is.read((char*)ubuf, 512);
-   if (is)
-   {
-      for (int i = 0; i < 512; ++i)
+      theMinHeight = theFeetFlag ? theDem->getHeader().getMinimumElev() *
+         MTRS_PER_FT : theDem->getHeader().getMinimumElev();
+      theMaxHeight = theFeetFlag ? theDem->getHeader().getMaximumElev() *
+         MTRS_PER_FT : theDem->getHeader().getMaximumElev();
+      
+      completeOpen();
+      
+      //---
+      // Set up the tiles.  Note the blank tile will not get initialized to
+      // save memory.  This includes setting the min and max pixel value
+      // gathered from the statistics.
+      //---
+      theTile = ossimImageDataFactory::instance()->create(this, this);
+      theTile->initialize();
+      
+      if (traceDebug())
       {
-         if (ubuf[i] > 0x7f)
-         {
-            theIsDemFlag = false;
-            break;
-         }
+         CLOG << setiosflags(ios::fixed) << setprecision(5) << "DEBUG:"
+              << "\nNull pix:  " << (theTile->getNullPix(0))
+              << "\nMin  pix:  " << (theTile->getMinPix(0))
+              << "\nMax  pix:  " << (theTile->getMaxPix(0))
+              << "\nlines:     " << theDem->getHeight()
+              << "\nsamples:   " << theDem->getWidth()
+              << std::endl;
       }
    }
-   else
-   {
-      theIsDemFlag = false;
-   }
-   delete [] ubuf;
-   ubuf = NULL;
-   if (theIsDemFlag == false)
-   {
-      is.close();
-      return false;
-   }
-   is.seekg(0, ios::beg);
-   // End of "SPECIAL HACK".
-
-   // Start out with a fresh dem.
-   if (theDem) delete theDem;
-
-   //---
-   // Set the null to -32768.  This will also be the missing data values.
-   //---
-   theNullValue = OSSIM_DEFAULT_NULL_PIX_SINT16;
-
-   //---
-   // Read the dem.
-   // 
-   // NOTE:  This defines the missing data value.  It should be the same as
-   // null for mosaicing and min/max calculations.
-   //---
-   theDem = new ossimDemGrid(theNullValue);
-   theDem->read(is);
 
-   is.close();
-
-   theFeetFlag  = (theDem->getHeader().getElevationUnits() == 1) ?
-                  true : false;
-
-   theMinHeight = theFeetFlag ? theDem->getHeader().getMinimumElev() *
-                  MTRS_PER_FT : theDem->getHeader().getMinimumElev();
-   theMaxHeight = theFeetFlag ? theDem->getHeader().getMaximumElev() *
-                  MTRS_PER_FT : theDem->getHeader().getMaximumElev();
-
-   completeOpen();
-
-   //***
-   // Set up the tiles.  Note the blank tile will not get initialized to save
-   // memory.  This includes setting the min and max pixel value gathered
-   // from the statistics.
-   //***
-   theTile = ossimImageDataFactory::instance()->create(this, this);
-   theTile->initialize();
-
-   if (traceDebug())
-   {
-      CLOG << setiosflags(ios::fixed) << setprecision(5) << "DEBUG:"
-           << "\nNull pix:  " << (theTile->getNullPix(0))
-           << "\nMin  pix:  " << (theTile->getMinPix(0))
-           << "\nMax  pix:  " << (theTile->getMaxPix(0))
-           << "\nlines:     " << theDem->getHeight()
-           << "\nsamples:   " << theDem->getWidth()
-           << std::endl;
-   }
-
-   return true;
+   return theIsDemFlag;
 }
 
 bool ossimUsgsDemTileSource::saveState(ossimKeywordlist& kwl,
@@ -468,53 +365,52 @@ bool ossimUsgsDemTileSource::loadState(const ossimKeywordlist& kwl,
    return false;
 }
 
-bool ossimUsgsDemTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                              const char* prefix)
+ossimImageGeometry* ossimUsgsDemTileSource::getInternalImageGeometry()
 {
-   if (!theDem)
+   if ( !theGeometry )
    {
-      return false;
+      theGeometry = new ossimImageGeometry();
    }
-
-   // Previously saved...
-   if (theGeometryKwl.getSize())
+   
+   if (theDem)
    {
-      kwl = theGeometryKwl;
-      return true;
-   }  
+      const ossimDemHeader HDR = theDem->getHeader();
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "ossimUsgsDemTileSource::getImageGeometry DEBUG:"
+            << "\nDEM Header:"
+            << std::endl;
+         HDR.print(ossimNotify(ossimNotifyLevel_DEBUG));
+      }
       
-   const ossimDemHeader HDR = theDem->getHeader();
-
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimUsgsDemTileSource::getImageGeometry DEBUG:"
-         << "\nDEM Header:"
-         << std::endl;
-      HDR.print(ossimNotify(ossimNotifyLevel_DEBUG));
-   }
-
-   if (HDR.getImageGeometry(kwl, prefix) == false)
-   {
-      return false;
-   }
-
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimUsgsDemTileSource::getImageGeometry DEBUG:"
-         << "keyword list:\n" << kwl
-         << std::endl;
+      // The DEM's image geometry is a map projection, obtained here via KWL:
+      ossimKeywordlist proj_kwl;
+      if ( HDR.getImageGeometry(proj_kwl) ) 
+      {
+         if (traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << "ossimUsgsDemTileSource::getImageGeometry DEBUG:"
+               << "keyword list:\n" << proj_kwl
+               << std::endl;
+         }
+         
+         // Capture for next time.
+         ossimRefPtr<ossimProjection> proj =
+            ossimProjectionFactoryRegistry::instance()->
+            createProjection(proj_kwl);
+         if ( proj.valid() )
+         {
+            theGeometry->setProjection(proj.get());
+         }
+      }
    }
-
-   // Capture for next time.
-   setImageGeometry(kwl);
-
-   return true;
+   
+   return theGeometry.get();
 }
 
-ossimScalarType
-ossimUsgsDemTileSource::getOutputScalarType() const
+ossimScalarType ossimUsgsDemTileSource::getOutputScalarType() const
 {
    return theScalarType;
 }
@@ -544,7 +440,7 @@ ossim_uint32 ossimUsgsDemTileSource::getNumberOfLines(ossim_uint32 reduced_res_l
          return 0;
       }
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfLines(reduced_res_level);
    }
@@ -567,7 +463,7 @@ ossim_uint32 ossimUsgsDemTileSource::getNumberOfSamples(ossim_uint32 reduced_res
          return 0;
       }
    }
-   else if (theOverview)
+   else if (theOverview.valid())
    {
       return theOverview->getNumberOfSamples(reduced_res_level);
    }
@@ -595,7 +491,7 @@ ossimString ossimUsgsDemTileSource::getLongName() const
    return ossimString("usgs dem reader");
 }
 
-ossimString ossimUsgsDemTileSource::className() const
+ossimString ossimUsgsDemTileSource::getClassName() const
 {
    return ossimString("ossimUsgsDemTileSource");
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationCoverageInfo.cpp b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationCoverageInfo.cpp
index be2dde230ae00ee7e381a0b4f7b78816bbe8be40..5b457016d12f96c6aa070884c87f41bb9bf6c06c 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationCoverageInfo.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationCoverageInfo.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 // 
 //**************************************************************************
-// $Id: ossimVpfAnnotationCoverageInfo.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimVpfAnnotationCoverageInfo.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <vector>
 #include <algorithm>
@@ -73,11 +73,11 @@ ossimIrect ossimVpfAnnotationCoverageInfo::getBoundingProjectedRect()const
 }
 
 
-void ossimVpfAnnotationCoverageInfo::transform(ossimProjection* proj)
+void ossimVpfAnnotationCoverageInfo::transform(ossimImageGeometry* geom)
 {
   for(ossim_uint32 idx = 0; idx < theFeatureInfoArray.size();++idx)
   {
-     theFeatureInfoArray[idx]->transform(proj);
+     theFeatureInfoArray[idx]->transform(geom);
   }
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationFeatureInfo.cpp b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationFeatureInfo.cpp
index c3b2dffc7727d30c83e713f20e5efa80283d9342..8c986aeffd6e9afe426856d6da01f3bd633aff67 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationFeatureInfo.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationFeatureInfo.cpp
@@ -58,7 +58,7 @@ ossimVpfAnnotationFeatureInfo::~ossimVpfAnnotationFeatureInfo()
    deleteAllObjects();
 }
 
-void ossimVpfAnnotationFeatureInfo::transform(ossimProjection* proj)
+void ossimVpfAnnotationFeatureInfo::transform(ossimImageGeometry* proj)
 {
    if(theEnabledFlag)
    {
@@ -417,11 +417,6 @@ ossimVpfAnnotationFeatureInfo::ossimVpfAnnotationFeatureType ossimVpfAnnotationF
 
 void ossimVpfAnnotationFeatureInfo::deleteAllObjects()
 {
-  for(int idx = 0; idx < (int)theAnnotationArray.size();++idx)
-    {
-      delete theAnnotationArray[idx];
-    }
-
   theAnnotationArray.clear();
 }
 
@@ -449,7 +444,7 @@ void ossimVpfAnnotationFeatureInfo::setDrawingFeaturesToAnnotation()
    case ossimVpfAnnotationFeatureType_TEXT:
    {
       ossimGeoAnnotationFontObject* annotation = NULL;
-      ossimFont* font = ossimFontFactoryRegistry::instance()->createFont(theFontInformation);
+      ossimRefPtr<ossimFont> font = ossimFontFactoryRegistry::instance()->createFont(theFontInformation);
 
       for(int idx = 0; idx < (int)theAnnotationArray.size();++idx)
       {
@@ -459,7 +454,7 @@ void ossimVpfAnnotationFeatureInfo::setDrawingFeaturesToAnnotation()
                               thePenColor.getB());
          annotation->setThickness(theThickness);
          
-         if(font)
+         if(font.valid())
          {
             annotation->setFont((ossimFont*)font->dup());
          }
@@ -468,11 +463,6 @@ void ossimVpfAnnotationFeatureInfo::setDrawingFeaturesToAnnotation()
          annotation->setShear(theFontInformation.theShear);
          annotation->setRotation(theFontInformation.theRotation);
       }
-      if(font)
-      {
-         delete font;
-         font = NULL;
-      }
       break;
    }
    case ossimVpfAnnotationFeatureType_LINE:
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationLibraryInfo.cpp b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationLibraryInfo.cpp
index 14cc64ab12bfdfd5164c06a6296a62ce179debe1..4f8385afbf371ca6bd3a924cc908e7a63839497b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationLibraryInfo.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationLibraryInfo.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 // 
 //**************************************************************************
-// $Id: ossimVpfAnnotationLibraryInfo.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimVpfAnnotationLibraryInfo.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <algorithm>
 
@@ -106,7 +106,7 @@ void ossimVpfAnnotationLibraryInfo::getAllFeatures(std::vector<ossimVpfAnnotatio
    }
 }
 
-void ossimVpfAnnotationLibraryInfo::transform(ossimProjection* proj)
+void ossimVpfAnnotationLibraryInfo::transform(ossimImageGeometry* geom)
 {
    if(traceDebug())
    {
@@ -121,7 +121,7 @@ void ossimVpfAnnotationLibraryInfo::transform(ossimProjection* proj)
          ossimNotify(ossimNotifyLevel_DEBUG) << "transforming coverage = " << theCoverageLayerList[idx]->getName() << std::endl;
       }
       
-      theCoverageLayerList[idx]->transform(proj);
+      theCoverageLayerList[idx]->transform(geom);
    }
 
    if(traceDebug())
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationSource.cpp
index 4ed9e2dc3e9d5f6e93dd441087d107568e381877..847a7e920fa3ab096779f5a8b8eddffb45f79051 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimVpfAnnotationSource.cpp
@@ -14,17 +14,16 @@ static ossimTrace traceDebug("ossimVpfAnnotationSource:debug");
 ossimVpfAnnotationSource::ossimVpfAnnotationSource()
    :ossimGeoAnnotationSource()
 {
-  if(!theProjection)
-    {
-      theProjection = new ossimEquDistCylProjection;
-      theOwnsProjectionFlag = true;
-    }
-   ossimMapProjection* mapProj = (ossimMapProjection*) theProjection;
+  if(!m_geometry)
+  {
+     m_geometry = new ossimImageGeometry(0, new ossimEquDistCylProjection);
+  }
+   ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(m_geometry->getProjection());
 
    if(mapProj)
-     {
-       mapProj->setMetersPerPixel(ossimDpt(30, 30));
-     }
+   {
+      mapProj->setMetersPerPixel(ossimDpt(30, 30));
+   }
 }
 
 ossimVpfAnnotationSource::~ossimVpfAnnotationSource()
@@ -90,23 +89,23 @@ ossimFilename ossimVpfAnnotationSource::getFilename()const
    return theFilename;
 }
 
-void ossimVpfAnnotationSource::transformObjects(ossimProjection* projection)
+void ossimVpfAnnotationSource::transformObjects(ossimImageGeometry* geom)
 {
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << "ossimVpfAnnotationSource::transformObjects DEBUG: entered..." << std::endl;
    }
-   ossimProjection* proj = projection;
+   ossimImageGeometry* tempGeom = geom;
    
-   if(!proj)
+   if(!tempGeom)
    {
-      proj = theProjection;
+      tempGeom = m_geometry.get();
    }
    
-   if(!proj) return;
+   if(!tempGeom) return;
    for(int idx = 0; idx < (int)theLibraryInfo.size(); ++idx)
    {
-      theLibraryInfo[idx]->transform(proj);
+      theLibraryInfo[idx]->transform(tempGeom);
    }
    computeBoundingRect();
    if(traceDebug())
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimVpfTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimVpfTileSource.cpp
index 354d921f6aa185c180a2e8204cd97f53d1099201..dfa4a06b002b6d62b8286f4d08a62185815421aa 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimVpfTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimVpfTileSource.cpp
@@ -6,7 +6,7 @@
 //
 // Description: 
 //
-// $Id: ossimVpfTileSource.cpp 9306 2006-07-19 18:23:40Z dburken $
+// $Id: ossimVpfTileSource.cpp 15812 2009-10-25 13:09:24Z dburken $
 //----------------------------------------------------------------------------
 #include <ossim/imaging/ossimVpfTileSource.h>
 
@@ -17,23 +17,19 @@ ossimVpfTileSource::ossimVpfTileSource()
       ossimViewInterface()
 {
    theObject = this;
-   theAnnotationSource = new ossimVpfAnnotationSource;
-   theAnnotationSource->setNumberOfBands(3);
+   m_AnnotationSource = new ossimVpfAnnotationSource;
+   m_AnnotationSource->setNumberOfBands(3);
 }
 
 ossimVpfTileSource::~ossimVpfTileSource()
 {
-   if(theAnnotationSource)
-   {
-      delete theAnnotationSource;
-      theAnnotationSource = NULL;
-   }
+   m_AnnotationSource = 0;
 }
 
 bool ossimVpfTileSource::saveState(ossimKeywordlist& kwl,
 				   const char* prefix)const
 {
-   return theAnnotationSource->saveState(kwl, prefix);
+   return m_AnnotationSource->saveState(kwl, prefix);
 }
 
 bool ossimVpfTileSource::loadState(const ossimKeywordlist& kwl,
@@ -41,7 +37,7 @@ bool ossimVpfTileSource::loadState(const ossimKeywordlist& kwl,
 {
    if (ossimImageHandler::loadState(kwl, prefix))
    {
-      return theAnnotationSource->loadState(kwl, prefix);
+      return m_AnnotationSource->loadState(kwl, prefix);
    }
 
    return false;
@@ -49,33 +45,33 @@ bool ossimVpfTileSource::loadState(const ossimKeywordlist& kwl,
 
 void ossimVpfTileSource::close()
 {
-   theAnnotationSource->close();
+   m_AnnotationSource->close();
 }
 
 bool ossimVpfTileSource::open()
 {
-   return theAnnotationSource->open(theImageFile);
+   return m_AnnotationSource->open(theImageFile);
 }
 
 ossimRefPtr<ossimImageData> ossimVpfTileSource::getTile(
    const ossimIrect& tileRect, ossim_uint32 resLevel)
 {
-   return theAnnotationSource->getTile(tileRect, resLevel);
+   return m_AnnotationSource->getTile(tileRect, resLevel);
 }
 
 ossim_uint32 ossimVpfTileSource::getNumberOfInputBands() const
 {
-   return theAnnotationSource->getNumberOfOutputBands();
+   return m_AnnotationSource->getNumberOfOutputBands();
 }
 
 ossim_uint32 ossimVpfTileSource::getNumberOfOutputBands() const
 {
-   return theAnnotationSource->getNumberOfOutputBands();
+   return m_AnnotationSource->getNumberOfOutputBands();
 }
 
 ossim_uint32 ossimVpfTileSource::getNumberOfLines(ossim_uint32 /* reduced_res_level */) const
 {
-   ossimIrect theBounds = theAnnotationSource->getBoundingRect();
+   ossimIrect theBounds = m_AnnotationSource->getBoundingRect();
    
    if(theBounds.hasNans())
    {
@@ -87,7 +83,7 @@ ossim_uint32 ossimVpfTileSource::getNumberOfLines(ossim_uint32 /* reduced_res_le
 
 ossim_uint32 ossimVpfTileSource::getNumberOfSamples(ossim_uint32 /* reduced_res_level */) const
 {
-   ossimIrect theBounds = theAnnotationSource->getBoundingRect();
+   ossimIrect theBounds = m_AnnotationSource->getBoundingRect();
    
    if(theBounds.hasNans())
    {
@@ -104,46 +100,40 @@ ossim_uint32 ossimVpfTileSource::getNumberOfDecimationLevels() const
 
 ossimIrect ossimVpfTileSource::getImageRectangle(ossim_uint32 /* reduced_res_level */) const
 {
-   return theAnnotationSource->getBoundingRect();
+   return m_AnnotationSource->getBoundingRect();
 }
 
-bool ossimVpfTileSource::getImageGeometry(ossimKeywordlist& kwl,
-                                          const char* prefix)
+//**************************************************************************************************
+// Returns the image geometry object associated with this tile source or NULL if non defined.
+//**************************************************************************************************
+ossimImageGeometry* ossimVpfTileSource::getImageGeometry()
 {
-   if (theGeometryKwl.getSize())
-   {
-      kwl = theGeometryKwl;
-      return true;
-   }
+   if (theGeometry.valid())
+      return theGeometry.get();
    
-   ossimObject* view = theAnnotationSource->getView();
-   if(view)
+   const ossimImageGeometry* annotGeom = m_AnnotationSource->getImageGeometry();
+   if (annotGeom)
    {
-      bool result = view->saveState(kwl, prefix);
-      if (result)
-      {
-         // Capture for next time...
-         setImageGeometry(kwl);
-      }
-      return result;
+      // Copy the annotation source's geometry as our own:
+      theGeometry = new ossimImageGeometry(*annotGeom);
+      return theGeometry.get();
    }
-   
-   return false;
+   return 0;
 }
 
 ossimScalarType ossimVpfTileSource::getOutputScalarType() const
 {
-   return theAnnotationSource->getOutputScalarType();
+   return m_AnnotationSource->getOutputScalarType();
 }
 
 ossim_uint32 ossimVpfTileSource::getTileWidth() const
 {
-   return theAnnotationSource->getTileWidth();         
+   return m_AnnotationSource->getTileWidth();         
 }
 
 ossim_uint32 ossimVpfTileSource::getTileHeight() const
 {
-   return theAnnotationSource->getTileHeight();
+   return m_AnnotationSource->getTileHeight();
 }
 
 ossim_uint32 ossimVpfTileSource::getImageTileWidth() const
@@ -158,62 +148,55 @@ ossim_uint32 ossimVpfTileSource::getImageTileHeight() const
 
 bool ossimVpfTileSource::isOpen()const
 {
-   return theAnnotationSource->isOpen();
+   return m_AnnotationSource->isOpen();
 }
    
 double ossimVpfTileSource::getNullPixelValue(ossim_uint32 band)const
 {
-   return theAnnotationSource->getNullPixelValue(band);
+   return m_AnnotationSource->getNullPixelValue(band);
 }
 
 double ossimVpfTileSource::getMinPixelValue(ossim_uint32 band)const
 {
-   return theAnnotationSource->getMinPixelValue(band);
+   return m_AnnotationSource->getMinPixelValue(band);
 }
       
 double ossimVpfTileSource::getMaxPixelValue(ossim_uint32 band)const
 {
-   return theAnnotationSource->getMaxPixelValue(band);
+   return m_AnnotationSource->getMaxPixelValue(band);
 }
 
 ossimObject* ossimVpfTileSource::getView()
 {
-   return theAnnotationSource->getView();
+   return m_AnnotationSource->getView();
 }
 
 const ossimObject* ossimVpfTileSource::getView()const
 {
-   return theAnnotationSource->getView();
+   return m_AnnotationSource->getView();
 }
    
-bool ossimVpfTileSource::setView(ossimObject*  baseObject,
-                                 bool ownsTheView)
+bool ossimVpfTileSource::setView(ossimObject*  baseObject)
 {
-   return theAnnotationSource->setView(baseObject, ownsTheView);
+   return m_AnnotationSource->setView(baseObject);
 }
 
 void ossimVpfTileSource::getAllFeatures(std::vector<ossimVpfAnnotationFeatureInfo*>& featureList)
 {
-   if(theAnnotationSource)
-   {
-      theAnnotationSource->getAllFeatures(featureList);
-   }
+   m_AnnotationSource->getAllFeatures(featureList);
 }
 
 void ossimVpfTileSource::setAllFeatures(std::vector<ossimVpfAnnotationFeatureInfo*>& featureList)
 {
-   if(theAnnotationSource)
-   {
-      theAnnotationSource->setAllFeatures(featureList);
-   }
+   m_AnnotationSource->setAllFeatures(featureList);
 }
 
 void ossimVpfTileSource::transformObjects()
 {
-   theAnnotationSource->transformObjects();
+   m_AnnotationSource->transformObjects();
 }
 
 void ossimVpfTileSource::computeBoundingRect()
 {
-   theAnnotationSource->computeBoundingRect();
+   m_AnnotationSource->computeBoundingRect();
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimWatermarkFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimWatermarkFilter.cpp
index faee8be2f622294d158ae93bc9dfaf11cfefdb74..1b0ae1afa0e356fe06bfaecf3d3258ccc2228679 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimWatermarkFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimWatermarkFilter.cpp
@@ -10,7 +10,7 @@
 // Density is base on alpha weight.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimWatermarkFilter.cpp 12623 2008-04-07 14:10:08Z gpotts $
+// $Id: ossimWatermarkFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <vector>
 
@@ -37,7 +37,7 @@ static const char WATERMARK_MODE_KW[] = "watermark_mode";
 static const char WEIGHT_KW[]         = "weight";
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimWatermarkFilter.cpp 12623 2008-04-07 14:10:08Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimWatermarkFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 const ossim_float64 DEFAULT_WEIGHT = 0.20;
@@ -810,7 +810,7 @@ bool ossimWatermarkFilter::openWatermarkFile()
    theWatermark = NULL; // This will destroy any previous tiles.
 
    // Open the watermark image.
-   ossimImageHandler* ih =
+   ossimRefPtr<ossimImageHandler> ih =
       ossimImageHandlerRegistry::instance()->open(theFilename);
    if (!ih)
    {
@@ -837,34 +837,34 @@ bool ossimWatermarkFilter::openWatermarkFile()
    }
 
    ih->initialize();
-   ossimImageSource* imageSource = ih;
-   ossimScalarRemapper* remapper = NULL;
+   ossimRefPtr<ossimImageSource> imageSource = ih.get();
+   ossimRefPtr<ossimScalarRemapper> remapper;
    
    if (ih->getOutputScalarType() != theInputConnection->getOutputScalarType())
    {
       // Remap the watemark to the same scalar type as the input.
-      remapper = new ossimScalarRemapper(imageSource,
+      remapper = new ossimScalarRemapper(imageSource.get(),
                                          theInputConnection->
                                          getOutputScalarType());
       remapper->initialize();
-      imageSource = remapper;
+      imageSource = remapper.get();
    }
    
    // Get the full image rectangle.
    theWatermark = imageSource->getTile(ih->getImageRectangle(), 0);
 
    // Cleanup...
-   if (remapper)
+   if (remapper.valid())
    {
-      delete remapper;
+      remapper->disconnect();
       remapper = NULL;
    }
-   if (ih)
+   if(ih.valid())
    {
-      delete ih;
-      ih = NULL;
+      ih->disconnect();
+      ih = 0;
    }
-   imageSource = NULL;
+   imageSource = 0;
    
    if (theWatermark.valid() == false)
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimWorldFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimWorldFileWriter.cpp
index 91128430af50367d3ea65d46118461d1edae7f5b..d54612788e15ac9260a71caa682a452fe544ce2d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimWorldFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimWorldFileWriter.cpp
@@ -6,7 +6,7 @@
 // Author:  Kenneth Melero (kmelero@sanz.com)
 //
 //*******************************************************************
-//  $Id: ossimWorldFileWriter.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimWorldFileWriter.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/imaging/ossimWorldFileWriter.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -55,95 +55,64 @@ bool ossimWorldFileWriter::loadState(const ossimKeywordlist& kwl,
    return ossimMetadataFileWriter::loadState(kwl, prefix);
 }
 
+//**************************************************************************************************
+// Outputs projection information to the output file. Returns TRUE if successful.
+//**************************************************************************************************
 bool ossimWorldFileWriter::writeFile()
 {
-   bool result = true;
    if(!theInputConnection)
-   {
       return false;
-   }
 
    std::ofstream out(theFilename.c_str(), ios_base::out);
    if (!out)
-   {
       return false;
-   }
    
-   ossimKeywordlist kwl;
-
-   theInputConnection->getImageGeometry(kwl);
-   ossimProjection* proj;
-   proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, proj);
-
-   if(mapProj)
+   // Fetch the map projection of the input image if it exists:
+   const ossimMapProjection* mapProj = 0;
+   const ossimImageGeometry* imgGeom = theInputConnection->getImageGeometry();
+   if (imgGeom)
    {
-      ossimMapProjectionInfo* projectionInfo
-         = new ossimMapProjectionInfo(mapProj, theAreaOfInterest);
-
-      projectionInfo->setPixelType(thePixelType);
-      
-      if(projectionInfo)
-      {
-         ossimDpt gsd;
-         ossimDpt ul;
-
-         if(projectionInfo->getProjection()->isGeographic())
-         {
-            gsd = projectionInfo->getDecimalDegreesPerPixel();
-            ul  = projectionInfo->ulGroundPt();
-         }
-         else
-         {
-            gsd = projectionInfo->getMetersPerPixel();
-            ul  = projectionInfo->ulEastingNorthingPt();
-
-            if (theUnits == OSSIM_FEET)
-            {
-               gsd.x = ossimUnitConversionTool(gsd.x, OSSIM_METERS).getFeet();
-               gsd.y = ossimUnitConversionTool(gsd.y, OSSIM_METERS).getFeet();
-               ul.x  = ossimUnitConversionTool(ul.x,  OSSIM_METERS).getFeet();
-               ul.y  = ossimUnitConversionTool(ul.y,  OSSIM_METERS).getFeet();
-            }
-            else if (theUnits == OSSIM_US_SURVEY_FEET)
-            {
-               gsd.x = ossimUnitConversionTool(gsd.x,
-                                               OSSIM_METERS).getUsSurveyFeet();
-               gsd.y = ossimUnitConversionTool(gsd.y,
-                                               OSSIM_METERS).getUsSurveyFeet();
-               ul.x  = ossimUnitConversionTool(ul.x,
-                                               OSSIM_METERS).getUsSurveyFeet();
-               ul.y = ossimUnitConversionTool(ul.y,
-                                              OSSIM_METERS).getUsSurveyFeet();
-            }
-         }
-         
-         out << setiosflags(ios::fixed) << setprecision(15)
-             << gsd.x  << endl
-             << 0.0    << endl // rotation value X
-             << 0.0    << endl // rotation value y
-             << -gsd.y << endl
-             << ul.x   << endl
-             << ul.y   << endl;
-         
-         delete projectionInfo;
-      }
+      const ossimProjection* proj = imgGeom->getProjection();
+      mapProj = PTR_CAST(ossimMapProjection, proj);
    }
-   else
+   if (!mapProj)
    {
-      result = false;
+      out.close();
+      return false;
    }
-   if(proj)
+
+   // Convert projection info to proper units:
+   ossimDpt gsd = mapProj->getMetersPerPixel();
+   ossimDpt ul  = mapProj->getUlEastingNorthing();
+   if (theUnits == OSSIM_FEET)
    {
-      delete proj;
-      proj = NULL;
+      gsd.x = ossimUnitConversionTool(gsd.x, OSSIM_METERS).getFeet();
+      gsd.y = ossimUnitConversionTool(gsd.y, OSSIM_METERS).getFeet();
+      ul.x  = ossimUnitConversionTool(ul.x,  OSSIM_METERS).getFeet();
+      ul.y  = ossimUnitConversionTool(ul.y,  OSSIM_METERS).getFeet();
+   }
+   else if (theUnits == OSSIM_US_SURVEY_FEET)
+   {
+      gsd.x = ossimUnitConversionTool(gsd.x, OSSIM_METERS).getUsSurveyFeet();
+      gsd.y = ossimUnitConversionTool(gsd.y, OSSIM_METERS).getUsSurveyFeet();
+      ul.x  = ossimUnitConversionTool(ul.x,  OSSIM_METERS).getUsSurveyFeet();
+      ul.y  = ossimUnitConversionTool(ul.y,  OSSIM_METERS).getUsSurveyFeet();
    }
 
+   // output projection info to file:
+   out << setiosflags(ios::fixed) << setprecision(15)
+      << gsd.x  << endl
+      << 0.0    << endl // rotation value X
+      << 0.0    << endl // rotation value y
+      << -gsd.y << endl
+      << ul.x   << endl
+      << ul.y   << endl;
+
    out.close();
-   
-   return result;
+   return true;
 }
 
+//**************************************************************************************************
 void ossimWorldFileWriter::getMetadatatypeList(
    std::vector<ossimString>& metadatatypeList) const
 {
diff --git a/Utilities/otbossim/src/ossim/init/ossimInit.cpp b/Utilities/otbossim/src/ossim/init/ossimInit.cpp
index 6d7d2a6a0dad6679c0282afba5dab2c7aae92a29..1bffed453b968118cf36a42d5244fbe437956a55 100644
--- a/Utilities/otbossim/src/ossim/init/ossimInit.cpp
+++ b/Utilities/otbossim/src/ossim/init/ossimInit.cpp
@@ -16,7 +16,7 @@
 //   24Apr2001  Oscar Kramer
 //              Initial coding.
 //*****************************************************************************
-// $Id: ossimInit.cpp 13830 2008-11-02 18:02:03Z dburken $
+// $Id: ossimInit.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 
 #include <ossim/init/ossimInit.h>
@@ -38,6 +38,8 @@
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/imaging/ossimImageSourceFactoryRegistry.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/base/ossim2dTo2dTransformRegistry.h>
+#include <ossim/imaging/ossimImageGeometryRegistry.h>
 #include <ossim/elevation/ossimElevManager.h>
 #include <ossim/base/ossimGeoidManager.h>
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
@@ -559,7 +561,8 @@ void ossimInit::initializeDefaultFactories()
    ossimImageWriterFactoryRegistry::instance();
    ossimImageMetaDataWriterRegistry::instance();
    ossimImageHandlerRegistry::instance();
-
+   ossim2dTo2dTransformRegistry::instance();
+   ossimImageGeometryRegistry::instance();
    // Initialize the overview factories.
    ossimOverviewBuilderFactoryRegistry::instance()->
       registerFactory(ossimOverviewBuilderFactory::instance(), true);
diff --git a/Utilities/otbossim/src/ossim/parallel/ossimIgen.cpp b/Utilities/otbossim/src/ossim/parallel/ossimIgen.cpp
index 3dcb634df28e1b8dda94d609e9f456accb9745b9..f5f05194c83e21698054e84c4c5340161019d54a 100644
--- a/Utilities/otbossim/src/ossim/parallel/ossimIgen.cpp
+++ b/Utilities/otbossim/src/ossim/parallel/ossimIgen.cpp
@@ -7,7 +7,7 @@
 // Description: implementation for image generator
 //
 //*************************************************************************
-// $Id: ossimIgen.cpp 13676 2008-10-03 17:35:02Z gpotts $
+// $Id: ossimIgen.cpp 15785 2009-10-21 14:55:04Z dburken $
 
 #include <iterator>
 #include <sstream>
@@ -22,6 +22,7 @@
 #endif
 
 #include <ossim/parallel/ossimIgen.h>
+#include <ossim/base/ossimException.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimStdOutProgress.h>
@@ -46,7 +47,6 @@
 #include <ossim/base/ossimDatumFactory.h>
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
 #include <ossim/imaging/ossimImageHandler.h>
-#include <ossim/projection/ossimImageViewProjectionTransform.h>
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/imaging/ossimGeoAnnotationSource.h>
 #include <ossim/base/ossimPreferences.h>
@@ -67,7 +67,7 @@ static ossimTrace traceDebug(ossimString("ossimIgen:debug"));
 static ossimTrace traceLog(ossimString("ossimIgen:log"));
 
 ossimIgen::ossimIgen()
-   :
+   :theContainer(new ossimConnectableContainer()),
     theProductProjection(0),
     theOutputRect(),
     theBuildThumbnailFlag(false),
@@ -342,26 +342,25 @@ bool ossimIgen::loadProduct()//ossimKeywordlist& kwl,
       CLOG << " Creating object1..." << std::endl;
    }
 
-   theContainer.deleteAllChildren();
+   theContainer->deleteAllChildren();
 
-   theContainer.loadState(theKwl);
+   theContainer->loadState(theKwl);
 
    theProductProjection = buildProductProjection(theKwl);
 
-   if(theProductProjection)
+   if(theProductProjection.valid())
    {
       vector<ossimImageViewTransform*> transforms;
-      setView(&theContainer, theProductProjection);
+      setView(theContainer.get(), theProductProjection.get());
       // if it's a thumbnail then adjust the GSD and
       // reset the view proj to the chain.
       if(theBuildThumbnailFlag)
       {
          buildThumbnail();
-         delete theProductProjection;
          
          theProductProjection = buildProductProjection(theKwl);
          
-         setView(&theContainer, theProductProjection);
+         setView(theContainer.get(), theProductProjection.get());
       }
       
    }
@@ -386,7 +385,7 @@ bool ossimIgen::loadProduct()//ossimKeywordlist& kwl,
    }
    theOutputRect = rect;
    
-   if(theProductProjection)
+   if(theProductProjection.valid())
    {
       theProductProjection->saveState(proj, "projection.");
          
@@ -404,12 +403,12 @@ bool ossimIgen::loadProduct()//ossimKeywordlist& kwl,
 
 void ossimIgen::outputProduct()
 {
-   ossimImageChain* chain = getChain();
-   if(chain)
+   ossimRefPtr<ossimImageChain> chain = getChain();
+   if(chain.valid())
    {
       chain->initialize();
    }
-   ossimImageSourceSequencer* sequencer = 0;
+   ossimRefPtr<ossimImageSourceSequencer> sequencer = 0;
    
 #ifdef OSSIM_HAS_MPI
 #  if OSSIM_HAS_MPI
@@ -447,36 +446,56 @@ void ossimIgen::outputProduct()
    
 #endif
    
-   std::vector<ossimConnectableObject*> imageWriters =
-      theContainer.findAllObjectsOfType(STATIC_TYPE_INFO(ossimImageFileWriter),
+   ossimConnectableObject::ConnectableObjectList imageWriters =
+      theContainer->findAllObjectsOfType(STATIC_TYPE_INFO(ossimImageFileWriter),
                                         false);
    if(imageWriters.size() > 0)
    {
       ossimImageFileWriter* writer =
-         PTR_CAST(ossimImageFileWriter, imageWriters[0]);
+         PTR_CAST(ossimImageFileWriter, imageWriters[0].get());
+      
+      writer->changeSequencer(sequencer.get());
+      writer->connectMyInputTo(chain.get());
+
+      //---
+      // Check for writing to standard output flag.
+      // Not all writers support this so check and throw an error if not
+      // supported.
+      //---
+      const char* lookup = theKwl.find("igen.write_to_stdout");
+      if (lookup)
+      {
+         // cout << "igen.write_to_stdout: " << lookup << endl;
+         if ( ossimString(lookup).toBool() )
+         {
+            if ( writer->setOutputStream(std::cout) == false )
+            {
+               std::string err = "ERROR:  The write to standard out flag is set; however, writer does not support going to standard out. Bummer...";
+               throw(ossimException(err));
+            }
+         }
+      }     
       
-      writer->changeSequencer(sequencer);
-      writer->connectMyInputTo(chain);
       writer->initialize();
    }
    else
    {
-      delete sequencer;
+      sequencer->disconnect();
       sequencer = 0;
    }
-   
-   std::vector<ossimConnectableObject*> processObjects =
-      theContainer.findAllObjectsOfType(STATIC_TYPE_INFO(ossimProcessInterface),
+
+   ossimConnectableObject::ConnectableObjectList processObjects =
+      theContainer->findAllObjectsOfType(STATIC_TYPE_INFO(ossimProcessInterface),
                                         false);
    ossim_uint32 i = 0;
-   ossimImageFileWriter* writer  = 0;
+   ossimRefPtr<ossimImageFileWriter> writer  = 0;
    for(i = 0; ((i < processObjects.size())&&(!writer)); ++i)
    {
       writer = PTR_CAST(ossimImageFileWriter,
-                        processObjects[i]);
+                        processObjects[i].get());
    }
 
-   if(writer)
+   if(writer.valid())
    {
       ossimRefPtr<ossimProjection> proj = buildProductProjection(theKwl);
       ossimMapProjection *mapProj = PTR_CAST(ossimMapProjection,proj.get());
@@ -511,12 +530,12 @@ void ossimIgen::outputProduct()
                writer->addListener(prog);
             }
             
-            setView(chain, view.get());
+            setView(chain.get(), view.get());
             chain->initialize();
             cut->setRectangle(clipRect);
             chain->initialize();
             writer->disconnect();
-            writer->connectMyInputTo(chain);
+            writer->connectMyInputTo(chain.get());
             writer->setFilename(tempFile.dirCat(tileName));
             writer->initialize();
 
@@ -614,13 +633,13 @@ void ossimIgen::outputProduct()
       for(ossim_uint32 i = 0; i < processObjects.size(); ++i)
       {
          if(!PTR_CAST(ossimImageFileWriter,
-                      processObjects[i]))
+                      processObjects[i].get()))
          {
             ossimProcessInterface* process = PTR_CAST(ossimProcessInterface,
-                                                      processObjects[i]);
+                                                      processObjects[i].get());
             if(process)
             {
-               processObjects[i]->connectMyInputTo(chain);
+               processObjects[i]->connectMyInputTo(chain.get());
                process->execute();
             }
          }
@@ -630,12 +649,10 @@ void ossimIgen::outputProduct()
 
 void ossimIgen::deleteAttributes()
 {
-   if(theProductProjection)
-   {
-      delete theProductProjection;
-      theProductProjection = 0;
-   }
-   theContainer.deleteAllChildren();
+   theProductProjection = 0;
+   theContainer->disconnect();
+   theContainer->deleteAllChildren();
+   theContainer = 0;
 }
 
 ossimProjection* ossimIgen::createImageProjection(const ossimKeywordlist& kwl)
@@ -674,10 +691,10 @@ ossimProjection* ossimIgen::buildProductProjection(const ossimKeywordlist& kwl,
    double      originLat = 0.0;
    double      originLon = 0.0;
    
-   ossimProjection* projection = 0;
+   ossimRefPtr<ossimProjection> projection = 0;
    projection = ossimProjectionFactoryRegistry::instance()->createProjection(kwl, "product.projection.");
    
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, projection);
+   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, projection.get());
    
 
    if(mapProj)
@@ -725,7 +742,6 @@ ossimProjection* ossimIgen::buildProductProjection(const ossimKeywordlist& kwl,
                      originLon,
                      true);
       }
-      delete mapProj;
       
       projection = ossimProjectionFactoryRegistry::instance()->createProjection(projKwl);
 
@@ -739,7 +755,7 @@ ossimProjection* ossimIgen::buildProductProjection(const ossimKeywordlist& kwl,
    }
 
    
-   return projection;
+   return projection.release();
 }
 
 void ossimIgen::setView(ossimConnectableObject* obj,
@@ -749,17 +765,17 @@ void ossimIgen::setView(ossimConnectableObject* obj,
    {
       return;
    }
-   vector<ossimConnectableObject*> result;
+   ossimConnectableObject::ConnectableObjectList result;
    obj->findAllInputsOfType(result, STATIC_TYPE_INFO(ossimViewInterface), true, true);
 
    for(ossim_uint32 i = 0; i < result.size();++i)
    {
       ossimViewInterface* viewInterface = PTR_CAST(ossimViewInterface,
-                                                   result[i]);
+                                                   result[i].get());
       if(viewInterface)
       {
-         ossimObject* obj = viewObj->dup();
-         viewInterface->setView(obj, true);
+         ossimRefPtr<ossimObject> obj = viewObj->dup();
+         viewInterface->setView(obj.get());
       }
    }
 }
@@ -768,23 +784,19 @@ void ossimIgen::setView(ossimConnectableObject* obj,
 bool ossimIgen::getOutputRect(const ossimKeywordlist& kwl,
                               ossimDrect& rect)
 {
-   ossimProjection* viewProj = buildProductProjection(kwl);
-   ossimImageChain* chain = getChain();
+   ossimRefPtr<ossimProjection> viewProj = buildProductProjection(kwl);
+   ossimImageChain* chain    = getChain();
    
    
    
    if(chain)
    {
-      setView(chain, viewProj);
+      setView(chain, viewProj.get());
       chain->initialize();
       rect = chain->getBoundingRect();
       
       return true;
    }
-   if(viewProj)
-   {
-      delete viewProj;
-   }
 
    return false;
 }
@@ -792,8 +804,8 @@ bool ossimIgen::getOutputRect(const ossimKeywordlist& kwl,
 void ossimIgen::buildThumbnail()
 {
    double resolution = ossim::max(theThumbnailResolution.x, theThumbnailResolution.y);
-   ossimProjection* viewProj   = buildProductProjection(theKwl);
-   ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, viewProj);
+   ossimRefPtr<ossimProjection> viewProj   = buildProductProjection(theKwl);
+   ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(viewProj.get());
    
    
    ossimDrect rect;
@@ -821,13 +833,12 @@ void ossimIgen::buildThumbnail()
       mapProj->saveState(theKwl, "product.projection.");
    }
    
-   delete viewProj;
 }
 
 ossimImageChain* ossimIgen::getChain()
 {
-   ossimConnectableObject* obj = theContainer.findFirstObjectOfType(STATIC_TYPE_NAME(ossimImageChain),
+   ossimConnectableObject* obj = theContainer->findFirstObjectOfType(STATIC_TYPE_NAME(ossimImageChain),
                                                                     false);
 
-   return PTR_CAST(ossimImageChain, obj);
+   return dynamic_cast<ossimImageChain*>(obj);
 }
diff --git a/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp b/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp
index e23a8cfb8d5da0033d52822311e78e5f9159ff23..12c2cb0e61a80d8b2eeeea96ab2352a57af9d603 100644
--- a/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp
+++ b/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp
@@ -1,10 +1,15 @@
-// $Id: ossimOrthoIgen.cpp 14069 2009-03-08 21:25:47Z dburken $
+// $Id: ossimOrthoIgen.cpp 15785 2009-10-21 14:55:04Z dburken $
 #include <sstream>
 #include <ossim/parallel/ossimOrthoIgen.h>
 #include <ossim/parallel/ossimIgen.h>
+#include <ossim/parallel/ossimMpi.h>
+#include <ossim/base/ossimException.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimNotifyContext.h>
+#include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/base/ossimTrace.h>
-#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimUnitConversionTool.h>
 #include <ossim/imaging/ossimGeoAnnotationSource.h>
 #include <ossim/imaging/ossimImageChain.h>
 #include <ossim/imaging/ossimImageHandler.h>
@@ -15,16 +20,14 @@
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
 #include <ossim/imaging/ossimOrthoImageMosaic.h>
 #include <ossim/imaging/ossimImageWriterFactoryRegistry.h>
-#include <ossim/base/ossimKeywordNames.h>
 #include <ossim/imaging/ossimTiffWriter.h>
 #include <ossim/projection/ossimUtmProjection.h>
 #include <ossim/projection/ossimEquDistCylProjection.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
-#include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/imaging/ossimGeoPolyCutter.h>
 #include <ossim/imaging/ossimEastingNorthingCutter.h>
-#include <ossim/base/ossimUnitConversionTool.h>
-#include <ossim/parallel/ossimMpi.h>
+
+
 
 static ossimTrace traceDebug("ossimOrthoIgen:debug");
 static ossimTrace traceLog("ossimOrthoIgen:log");
@@ -87,6 +90,8 @@ ossimOrthoIgen::ossimOrthoIgen()
    theHighPercentClip(ossim::nan()),
    theUseAutoMinMaxFlag(false),
    theScaleToEightBitFlag(false),
+   // theSrsCode(),
+   theStdoutFlag(false),
    theFilenames()
 {
    // setDefaultValues();
@@ -129,6 +134,12 @@ void ossimOrthoIgen::addArguments(ossimArgumentParser& argumentParser)
 
    argumentParser.getApplicationUsage()->addCommandLineOption("--scale-to-8-bit","Scales output to eight bits if not already.");
    argumentParser.getApplicationUsage()->addCommandLineOption("--writer-prop","Passes a name=value pair to the writer for setting it's property.  Any number of these can appear on the line.");
+
+#if 0 /* TODO */
+   argumentParser.getApplicationUsage()->addCommandLineOption("--srs-code","Takes spatial reference system(srs) code supplied to the option and attempts to derive output projection.   This will return an error if the projection cannont be derived from code.");
+#endif
+   
+   argumentParser.getApplicationUsage()->addCommandLineOption("--stdout","Output the image to standard out.  This will return an error if writer does not support writing to standard out.  Callers should combine this with the --ossim-logfile option to ensure output image stream does not get corrupted.  You must still pass an output file so the writer type can be determined like \"dummy.png\".");
 }
 
 void ossimOrthoIgen::initialize(ossimArgumentParser& argumentParser)
@@ -240,16 +251,31 @@ void ossimOrthoIgen::initialize(ossimArgumentParser& argumentParser)
    {
       theUseAutoMinMaxFlag = true;
    }
-   if(argumentParser.read("--scale-to-8-bit"))
-   {
-      theScaleToEightBitFlag = true;
-   }
+
    if(argumentParser.read("--meters", doubleParam))
    {
       theDeltaPerPixelUnit = OSSIM_METERS;
       theDeltaPerPixelOverride.x = tempDouble;
       theDeltaPerPixelOverride.y = tempDouble;
    }
+   
+   if(argumentParser.read("--scale-to-8-bit"))
+   {
+      theScaleToEightBitFlag = true;
+   }
+
+#if 0
+   if (argumentParser.read("--srs-code", stringParam))
+   {
+      theSrsCode = tempString;
+   }
+#endif
+ 
+   if (argumentParser.read("--stdout"))
+   {
+      theStdoutFlag = true;
+   }
+   
    if(argumentParser.read("--writer-template",
                           stringParam))
    {
@@ -373,15 +399,20 @@ bool ossimOrthoIgen::execute()
    ossimKeywordlist inputGeom;
    if(ossimMpi::instance()->getRank() == 0)
    {
-      if(!setupIgenKwl(igenKwl))
+      try
+      {
+         setupIgenKwl(igenKwl);
+      }
+      catch (const ossimException& e)
       {
          if (traceDebug())
          {
             ossimNotify(ossimNotifyLevel_DEBUG)
-               << "ossimOrthoIgen::execute DEBUG: setupIgenKwl returned false..."
+               << "ossimOrthoIgen::execute DEBUG: setupIgenKwl caught exception."
                << std::endl;
          }
-         return false;
+
+         throw; // re-throw exception
       }
 
       if (traceLog())
@@ -398,7 +429,17 @@ bool ossimOrthoIgen::execute()
    
    ossimIgen *igen = new ossimIgen;
    igen->initialize(igenKwl);
-   igen->outputProduct();
+
+   try
+   {
+      igen->outputProduct();
+   }
+   catch(const ossimException& e)
+   {
+      delete igen;
+      igen = 0;
+      throw; // re-throw
+   }
    
 //    if(ossimMpi::instance()->getRank() == 0)
 //    {
@@ -408,7 +449,7 @@ bool ossimOrthoIgen::execute()
 //          << std::endl;
 //    }
    delete igen;
-   igen = NULL;
+   igen = 0;
 
    return true;
 }
@@ -505,7 +546,7 @@ void ossimOrthoIgen::setCutDxDy(const ossimDpt& dpt,
    theCutDxDyUnit = unit;
 }
 
-bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
+void ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
 {
    if (traceDebug())
    {
@@ -524,6 +565,12 @@ bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
               theThumbnailRes.c_str(),
               true);
    }
+
+   // Pass the write to standard out flag to ossimIgen.
+   kwl.add("igen.write_to_stdout", theStdoutFlag, true);
+
+   // TODO: kwl.add("igen.srs_code", theSrsCode, true);
+   
    if(theSlaveBuffers == "")
    {
       kwl.add("igen.slave_tile_buffers",
@@ -537,15 +584,20 @@ bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
               true);
    }
    ossim_uint32 inputFileIdx = 0;
-   if(!setupView(kwl))
+
+   try
+   {
+      setupView(kwl);
+   }
+   catch (const ossimException& e)
    {
       if (traceDebug())
       {
          ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimOrthoIgen::execute DEBUG: setupView returned false..."
+            << "ossimOrthoIgen::execute DEBUG: setupView through exception!"
             << std::endl;
       }
-       return false;
+      throw; // re-throw exception
    }
 
    if(theFilenames.size() > 1)
@@ -577,9 +629,7 @@ bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
       
       if(!mosaicObject)
       {
-         ossimNotify(ossimNotifyLevel_WARN)
-            << "Unable to create a mosaic object" << std::endl;
-         return false;
+         throw(ossimException(std::string("Unable to create a mosaic object...")));
       }
       bool orthoMosaic = (PTR_CAST(ossimOrthoImageMosaic, mosaicObject.get())!=0);
 
@@ -752,7 +802,11 @@ bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
               "ossimImageChain",
               true);
 
-      if(!setupWriter(kwl, input.get()))
+      try
+      {
+         setupWriter(kwl, input.get());
+      }
+      catch (const ossimException& e)
       {
          if (traceDebug())
          {
@@ -760,12 +814,14 @@ bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
                << "ossimOrthoIgen::execute DEBUG: setupWriter returned false..."
                << std::endl;
          }
-         return false;
+         throw; // re-throw exception
       }
       
+   } // matches: if(theFilenames.size() > 1)
+   else
+   {
+      throw(ossimException(std::string("Must suppy an output file.")));
    }
-
-   return true;
 }
 
 ossimRefPtr<ossimConnectableObject> ossimOrthoIgen::setupCutter(
@@ -917,7 +973,8 @@ ossimRefPtr<ossimConnectableObject> ossimOrthoIgen::setupCutter(
    return result;
 }
 
-bool ossimOrthoIgen::setupWriter(ossimKeywordlist& kwl, ossimConnectableObject* input)
+void ossimOrthoIgen::setupWriter(ossimKeywordlist& kwl,
+                                 ossimConnectableObject* input)
 {
    ossimFilename outputFilename = theFilenames[theFilenames.size()-1].theFilename;
    ossimImageFileWriter* writer = 0;
@@ -1036,14 +1093,12 @@ bool ossimOrthoIgen::setupWriter(ossimKeywordlist& kwl, ossimConnectableObject*
       }
       else
       {
-         return false;
+         throw(ossimException(std::string("Unable to create writer.")));
       }
    }
-   
-   return true;
 }
 
-bool ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
+void ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
 {
    if (traceDebug())
    {
@@ -1070,7 +1125,7 @@ bool ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
          if(!theDeltaPerPixelOverride.hasNans())
          {
             ossimMapProjection* mapProj = PTR_CAST(ossimMapProjection, productObj.get());
-
+            
             if(mapProj)
             {
                if(mapProj->isGeographic())
@@ -1103,34 +1158,23 @@ bool ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
    }
    else
    {
-      ossimKeywordlist inputGeom;
       // Open up the image.
       ossimFilename input  = theFilenames[0].theFilename;
-      ossimRefPtr<ossimImageHandler> handler =
-         ossimImageHandlerRegistry::instance()->open(input);
+      ossimRefPtr<ossimImageHandler> handler = ossimImageHandlerRegistry::instance()->open(input);
+
       if(!handler)
       {
-         if (traceDebug())
-         {
-            ossimNotify(ossimNotifyLevel_DEBUG)
-               << "ossimOrthoIgen::setupView DEBUG:"
-               << "\nCould not open: " << input.c_str()
-               << std::endl;
-            ossimNotify(ossimNotifyLevel_DEBUG)
-               << "ossimOrthoIgen::setupView DEBUG:"
-               << "Leaving...." << __LINE__
-               << std::endl;
-         }
-         return false;
+         std::string errMsg = "Could not open file: ";
+         errMsg += input;
+         throw(ossimException(errMsg));
       }
-      handler->getImageGeometry(inputGeom);
-      
-      // Get the input projection.
-      ossimRefPtr<ossimProjection> inputProj =
-         ossimProjectionFactoryRegistry::instance()->createProjection(
-            inputGeom);
-      if(inputProj.valid()&&
-         (theProjectionType !=OSSIM_UNKNOWN_PROJECTION))
+
+      const ossimProjection* inputProj = 0;
+      const ossimImageGeometry* inputGeom = handler->getImageGeometry();
+      if (inputGeom)
+         inputProj = inputGeom->getProjection();
+
+      if(inputProj && (theProjectionType !=OSSIM_UNKNOWN_PROJECTION))
       {
          // Get the input resolution.
          ossimDpt metersPerPixel = inputProj->getMetersPerPixel();
@@ -1159,25 +1203,23 @@ bool ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
             outputProjection->setOrigin(gpt);
             // Set the resolution.
 //             outputProjection->setMetersPerPixel(ossimDpt(gsd, gsd));
-            outputProjection->setDecimalDegreesPerPixel(ossimDpt(ossimUnitConversionTool(gsd.x,
-                                                                                         gsdUnits).getValue(OSSIM_DEGREES),
-                                                                 ossimUnitConversionTool(gsd.y,
-                                                                                         gsdUnits).getValue(OSSIM_DEGREES)));
+            outputProjection->setDecimalDegreesPerPixel
+               (ossimDpt(ossimUnitConversionTool(gsd.x, gsdUnits).getValue(OSSIM_DEGREES),
+                         ossimUnitConversionTool(gsd.y, gsdUnits).getValue(OSSIM_DEGREES)));
+
             // Save the state to keyword list.
             outputProjection->saveState(kwl, "product.projection.");
          }
-         else if((theProjectionType == OSSIM_UTM_PROJECTION)||
+         else if ((theProjectionType == OSSIM_UTM_PROJECTION) ||
                  ((theProjectionType == OSSIM_INPUT_PROJECTION) &&
-                  !PTR_CAST(ossimMapProjection, inputProj.get())))
+                  !PTR_CAST(ossimMapProjection, inputProj)))
             
          {
             // Default to UTM.
             ossimUtmProjection* utm = new ossimUtmProjection;
             ossimGpt midGpt;
             
-            
-            inputProj->lineSampleToWorld(ossimDpt(rect.midPoint()),
-                                         midGpt);
+            inputProj->lineSampleToWorld(ossimDpt(rect.midPoint()), midGpt);
             
             utm->setZone(midGpt);
             utm->setHemisphere(midGpt);
@@ -1221,7 +1263,6 @@ bool ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
          << "Leaving...." << __LINE__
          << std::endl;
    }
-   return true;
 }
 
 ossimRefPtr<ossimConnectableObject> ossimOrthoIgen::setupAnnotation(
@@ -1248,17 +1289,14 @@ ossimRefPtr<ossimConnectableObject> ossimOrthoIgen::setupAnnotation(
                                                obj.get());
       if (oga)
       {
+         ossimRefPtr<ossimImageGeometry> geom = new ossimImageGeometry;
+         geom->loadState(kwl, "product.projection.");
          // Connect to input.
          oga->connectMyInputTo(input);
          
-         // Set the view.
-         ossimRefPtr<ossimProjection> viewProj =
-            ossimProjectionFactoryRegistry::instance()->createProjection(
-               kwl, "product.projection.");
-         if (viewProj.valid())
+         if (geom->hasProjection())
          {
-            oga->setProjection(viewProj.get(),
-                               false); // False for doesn't own projection.
+            oga->setGeometry(geom.get()); 
          }
 
          result = oga;
diff --git a/Utilities/otbossim/src/ossim/plugin/ossimDynamicLibrary.cpp b/Utilities/otbossim/src/ossim/plugin/ossimDynamicLibrary.cpp
index 140dc1bf16100f0d051662c7b0071362acf971b1..b34da4fa4460d47d73b96f9d00c385e2ae277a37 100644
--- a/Utilities/otbossim/src/ossim/plugin/ossimDynamicLibrary.cpp
+++ b/Utilities/otbossim/src/ossim/plugin/ossimDynamicLibrary.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*********************************************************************
-// $Id: ossimDynamicLibrary.cpp 13616 2008-09-29 15:32:12Z dburken $
+// $Id: ossimDynamicLibrary.cpp 15003 2009-07-27 18:58:27Z gpotts $
 #include <ossim/plugin/ossimDynamicLibrary.h>
 #include <ossim/plugin/ossimSharedObjectBridge.h>
 #include <ossim/base/ossimTrace.h>
@@ -42,12 +42,12 @@ bool ossimDynamicLibrary::load()
 
 bool ossimDynamicLibrary::load(const ossimString& name)
 {
-   ossimFilename libraryName = name;
+   ossimFilename libraryName = name.trim();
+   if(libraryName.empty()||!libraryName.isFile()) return false;
+   
 #  if defined(__WIN32__) || defined(_WIN32)
-   libraryName.convertForwardToBackSlashes();
    theLibrary = LoadLibrary(libraryName.c_str());
 #  else 
-   libraryName.convertBackToForwardSlashes();
    theLibrary = dlopen(libraryName.c_str(), RTLD_LAZY);
 #endif
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimAdjMapModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimAdjMapModel.cpp
index ab3c4374e7bd871467145951df69dadc976187a7..7b9e4a44cc892431c62e9df4ac528080a35116f0 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimAdjMapModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimAdjMapModel.cpp
@@ -15,7 +15,7 @@
 // information and error output.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimAdjMapModel.cpp 13004 2008-06-08 20:18:37Z dburken $
+// $Id: ossimAdjMapModel.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib> /* for atof */
 #include <ossim/projection/ossimAdjMapModel.h>
@@ -336,7 +336,7 @@ bool ossimAdjMapModel::loadState(const ossimKeywordlist& kwl, const char* prefix
          setParameterCenter(i, value);
       }
    }
-   catch (const char* message)
+   catch (const char* /*message*/)
    {
       theErrorStatus++;
       success = false;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimAffineProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimAffineProjection.cpp
index 8a9ebe6d0e8c5e3902759205c03b6410c0d1a35e..a6f0c58b3201308c9f588674fba539a822a5360a 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimAffineProjection.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimAffineProjection.cpp
@@ -9,7 +9,7 @@
 //   implementation of a warping interpolation model.
 //
 //*****************************************************************************
-//  $Id: ossimAffineProjection.cpp 11428 2007-07-27 18:44:18Z gpotts $
+//  $Id: ossimAffineProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimAffineProjection.h>
 RTTI_DEF1(ossimAffineProjection, "ossimAffineProjection", ossimProjection);
@@ -77,8 +77,6 @@ ossimAffineProjection::ossimAffineProjection(const ossimKeywordlist& geom_kwl,
 //*****************************************************************************
 ossimAffineProjection::~ossimAffineProjection()
 {
-   delete theClientProjection;
-   delete theAffineTransform;
 }
 
 //*****************************************************************************
@@ -90,7 +88,7 @@ ossimAffineProjection::worldToLineSample (const ossimGpt& worldPoint,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::worldToLineSample: Entering..." << std::endl;
 
-   if (theClientProjection && theAffineTransform)
+   if (theClientProjection.valid() && theAffineTransform.valid())
    {
       theClientProjection->worldToLineSample(worldPoint, lineSampPt);
       theAffineTransform->inverse(lineSampPt);
@@ -110,7 +108,7 @@ ossimAffineProjection::lineSampleToWorld(const ossimDpt& lineSampPt,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::lineSampleToWorld: Entering..." << std::endl;
 
-   if (theClientProjection && theAffineTransform)
+   if (theClientProjection.valid() && theAffineTransform.valid())
    {
       ossimDpt adjustedPt;
       theAffineTransform->forward(lineSampPt, adjustedPt);
@@ -134,7 +132,7 @@ ossimAffineProjection::lineSampleHeightToWorld(const ossimDpt& lineSampPt,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::lineSampleHeightToWorld: Entering..." << std::endl;
 
-   if (theClientProjection && theAffineTransform)
+   if (theClientProjection.valid() && theAffineTransform.valid())
    {
       ossimDpt adjustedPt;
       theAffineTransform->forward(lineSampPt, adjustedPt);
@@ -154,7 +152,7 @@ ossimAffineProjection::lineSampleHeightToWorld(const ossimDpt& lineSampPt,
 std::ostream& ossimAffineProjection::print(std::ostream& out) const
 {
    
-   if (theClientProjection && theAffineTransform)
+   if (theClientProjection.valid() && theAffineTransform.valid())
    {
       out <<
          "ossimAffineProjection:\n"
@@ -183,7 +181,7 @@ bool ossimAffineProjection::saveState(ossimKeywordlist& kwl,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::saveState: entering..." << std::endl;
 
-   if (theClientProjection && theAffineTransform)
+   if (theClientProjection.valid() && theAffineTransform.valid())
    {
       theClientProjection->saveState(kwl, prefix);
       theAffineTransform->saveState(kwl, prefix);
@@ -254,7 +252,7 @@ ossimObject* ossimAffineProjection::dup() const
 //*****************************************************************************
 ossimGpt ossimAffineProjection::origin() const
 {
-   if (theClientProjection)
+   if (theClientProjection.valid())
       return theClientProjection->origin();
    return ossimGpt(0.0, 0.0, 0.0);
 }
@@ -264,7 +262,7 @@ ossimGpt ossimAffineProjection::origin() const
 //*****************************************************************************
 ossimDpt  ossimAffineProjection::getMetersPerPixel() const
 {
-   if (theClientProjection)
+   if (theClientProjection.valid())
       return theClientProjection->getMetersPerPixel();
    return ossimDpt(ossim::nan(), ossim::nan());
 }
diff --git a/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp
index ddb7b992489cddaf10b3193bde8ed8cf1f77f1ed..290f46fb2d46eea43f6c07c0edab39490479d573 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp
@@ -1,12 +1,13 @@
 //*******************************************************************
-// Copyright (C) 2005 Garrett Potts
 //
-// LGPL
+// License:  LGPL
 // 
+// See LICENSE.txt file in the top level directory for more details.
+//
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimApplanixEcefModel.cpp 13691 2008-10-07 12:46:58Z dburken $
+//  $Id: ossimApplanixEcefModel.cpp 15434 2009-09-16 20:38:18Z dburken $
 #include <sstream>
 #include <ossim/projection/ossimApplanixEcefModel.h>
 #include <ossim/base/ossimEllipsoid.h>
@@ -25,7 +26,7 @@ static ossimTrace traceDebug("ossimApplanixEcefModel:debug");
 RTTI_DEF1(ossimApplanixEcefModel, "ossimApplanixEcefModel", ossimSensorModel);
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimApplanixEcefModel.cpp 13691 2008-10-07 12:46:58Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimApplanixEcefModel.cpp 15434 2009-09-16 20:38:18Z dburken $";
 #endif
 
 ossimApplanixEcefModel::ossimApplanixEcefModel()
@@ -397,6 +398,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
    {
       std::cout << "ossimApplanixEcefModel::loadState: ......... entered" << std::endl;
    }
+
    theImageClipRect = ossimDrect(0,0,4076,4091);
    theRefImgPt      = ossimDpt(2046.0, 2038.5);
 
@@ -494,6 +496,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(ecef_platform_position);
+         tempString.split(splitString, ossimString(" "));
          if(splitString.size() > 2)
          {
             theEcefPlatformPosition  = ossimEcefPoint(splitString[0].toDouble(),
@@ -505,6 +508,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(latlonh_platform_position);
+         tempString.split(splitString, ossimString(" "));
          std::string datumString;
          double lat=0.0, lon=0.0, h=0.0;
          if(splitString.size() > 2)
@@ -546,6 +550,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(image_size);
+         tempString.split(splitString, ossimString(" "));
          double w=1, h=1;
          if(splitString.size() == 2)
          {
@@ -563,6 +568,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(principal_point);
+         tempString.split(splitString, ossimString(" "));
          if(splitString.size() == 2)
          {
             thePrincipalPoint.x = splitString[0].toDouble();
@@ -573,6 +579,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(pixel_size);
+         tempString.split(splitString, ossimString(" "));
          if(splitString.size() == 1)
          {
             thePixelSize.x = splitString[0].toDouble();
@@ -598,9 +605,9 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
          {
             std::vector<ossimString> splitString;
             ossimString tempString(value);
+            tempString.split(splitString, ossimString(" "));
             double distance = 0.0;
             double distortion = 0.0;
-
             if(splitString.size() == 2)
             {
                distance = splitString[0].toDouble();
@@ -642,6 +649,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(principal_point);
+         tempString.split(splitString, ossimString(" "));
          if(splitString.size() == 2)
          {
             thePrincipalPoint.x = splitString[0].toDouble();
@@ -660,6 +668,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       {
          std::vector<ossimString> splitString;
          ossimString tempString(pixel_size);
+         tempString.split(splitString, ossimString(" "));
          if(splitString.size() == 1)
          {
             thePixelSize.x = splitString[0].toDouble();
@@ -714,6 +723,7 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
          computeGsd();
       }
    }
+   
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << std::setprecision(15) << std::endl;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimBilinearProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimBilinearProjection.cpp
index 180013cdb3a80b436f0b036890f8779f7c9015e0..e0dae93961d145f631047028710257bc624f0ab3 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimBilinearProjection.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimBilinearProjection.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 // 
 //********************************************************************
-// $Id: ossimBilinearProjection.cpp 12136 2007-12-07 14:26:43Z gpotts $
+// $Id: ossimBilinearProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <sstream>
 using namespace std;
@@ -25,7 +25,7 @@ using namespace std;
 #include <ossim/base/ossimTieGptSet.h>
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimBilinearProjection.cpp 12136 2007-12-07 14:26:43Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimBilinearProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 // static const ossim_uint32 MINIMUM_NMBER_OF_POINTS = 4;
@@ -514,3 +514,14 @@ ossimBilinearProjection::optimizeFit(const ossimTieGptSet& tieSet, double* targe
    tieSet.getSlaveMasterPoints(imagePoints, groundPoints);
    return setTiePoints(imagePoints, groundPoints); //variance in meters
 }
+
+//**************************************************************************************************
+//! Access method for tie point information
+//**************************************************************************************************
+void ossimBilinearProjection::getTiePoints(std::vector<ossimDpt>& lsPt, 
+                                           std::vector<ossimGpt>& geoPt) const
+{
+   lsPt  = theLineSamplePt;
+   geoPt = theGeographicPt;
+}
+
diff --git a/Utilities/otbossim/src/ossim/projection/ossimCoarseGridModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimCoarseGridModel.cpp
index 66c0e6d37bd77ef2112fc08e6cfb0ef760d29e00..75b8c759fee45940ddc628faa73b8a520aa69bf8 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimCoarseGridModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimCoarseGridModel.cpp
@@ -14,7 +14,7 @@
 //   elevations relative to the ellipsoid.
 //
 //*****************************************************************************
-//  $Id: ossimCoarseGridModel.cpp 11955 2007-10-31 16:10:22Z gpotts $
+//  $Id: ossimCoarseGridModel.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimCoarseGridModel.h>
 
@@ -27,6 +27,7 @@ RTTI_DEF1(ossimCoarseGridModel, "ossimCoarseGridModel", ossimSensorModel);
 #include <ossim/base/ossimDatumFactory.h>
 #include <ossim/base/ossimNotifyContext.h>
 #include <ossim/elevation/ossimElevManager.h>
+#include <ossim/imaging/ossimImageGeometry.h>
 
 #include <cstdio>
 #include <fstream>
@@ -158,10 +159,20 @@ void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
                                      double heightDelta,
                                      bool enableHeightFlag,
                                      bool makeAdjustableFlag)
+{
+   ossimRefPtr<ossimImageGeometry> geom = new ossimImageGeometry();
+   geom->setProjection(proj);
+   buildGrid(imageBounds, geom.get(), heightDelta, enableHeightFlag, makeAdjustableFlag);
+}   
+void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
+                                     ossimImageGeometry* geom,
+                                     double heightDelta,
+                                     bool enableHeightFlag,
+                                     bool makeAdjustableFlag)
 {
    theHeightEnabledFlag =  enableHeightFlag;
    
-   if(proj&&(!imageBounds.hasNans()))
+   if(geom->getProjection()&&(!imageBounds.hasNans()))
    {
      // don't let it get any smaller than 100, 100 pixels
      // on the input projector
@@ -201,7 +212,7 @@ void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
         theDlonDparamGrid = NULL;
      }
      
-     proj->lineSampleToWorld(imageBounds.midPoint(), gpt);
+     geom->localToWorld(imageBounds.midPoint(), gpt);
 
      do
      {
@@ -233,13 +244,15 @@ void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
               ossimDpt pt(imageOrigin.x + norm.x*(imageSize.x-1),
                           imageOrigin.y + norm.y*(imageSize.y-1));
               
-              proj->lineSampleToWorld(pt, gpt);
+              geom->localToWorld(pt, gpt);
               double h = gpt.height();
               if(ossim::isnan(h))
               {
                  h += heightDelta;
               }
-              proj->lineSampleHeightToWorld(pt, h, gpt2);
+              ossimDpt fullPt;
+              geom->localToFullImage(pt, fullPt);
+              geom->getProjection()->lineSampleHeightToWorld(fullPt, h, gpt2);
               gpt.changeDatum(targetDatum);
               gpt2.changeDatum(targetDatum);
               
@@ -293,7 +306,7 @@ void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
                                   imageOrigin.y + norm.y*(imageSize.y-1));
               ossimDpt testIpt;
 
-               proj->lineSampleToWorld(imagePoint, gpt);
+               geom->localToWorld(imagePoint, gpt);
                worldToLineSample(gpt, testIpt);
 //               lineSampleToWorld(imagePoint, bilinearGpt);
 //               gpt.changeDatum(targetDatum);
@@ -315,7 +328,7 @@ void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
      gridSize = theLatGrid.size();
 
      ossimAdjustableParameterInterface* adjustableParameters = PTR_CAST(ossimAdjustableParameterInterface,
-                                                                        proj);
+                                                                        geom->getProjection());
      removeAllAdjustments();
      if(adjustableParameters&&makeAdjustableFlag)
      {
@@ -365,8 +378,9 @@ void ossimCoarseGridModel::buildGrid(const ossimDrect& imageBounds,
                           
                           ossimDpt pt(imageOrigin.x + norm.x*(imageSize.x-1),
                                       imageOrigin.y + norm.y*(imageSize.y-1));
-                          
-                          proj->lineSampleHeightToWorld(pt, 0.0, gpt);
+                          ossimDpt fullPt;
+                          geom->localToFullImage(pt, fullPt);
+                          geom->getProjection()->lineSampleHeightToWorld(fullPt, 0.0, gpt);
 
                           gpt.changeDatum(targetDatum);
                           gpt2.latd(theLatGrid(pt));
diff --git a/Utilities/otbossim/src/ossim/projection/ossimIkonosRpcModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimIkonosRpcModel.cpp
index 33bf74a081521d7f99dfbb07994e8cf151741bfa..854745f7b278deeea127273b050a1cbf3877a5d2 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimIkonosRpcModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimIkonosRpcModel.cpp
@@ -13,16 +13,16 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimIkonosRpcModel.cpp 14426 2009-04-30 16:22:28Z gpotts $
+//  $Id: ossimIkonosRpcModel.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <ossim/projection/ossimIkonosRpcModel.h>
+#include <ossim/base/ossimException.h>
 #include <ossim/base/ossimNotify.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/imaging/ossimTiffTileSource.h>
 #include <ossim/base/ossimTrace.h>
-#include <ossim/support_data/ossimIkonosMetaData.h>
 
 
 RTTI_DEF1(ossimIkonosRpcModel, "ossimIkonosRpcModel", ossimRpcModel);
@@ -188,11 +188,7 @@ ossimIkonosRpcModel::ossimIkonosRpcModel(const ossimFilename& metadata,
 
 ossimIkonosRpcModel::~ossimIkonosRpcModel()
 {
-   if (theSupportData)
-   {
-      delete theSupportData;
-      theSupportData = 0;
-   }
+   theSupportData = 0;
 }
 
 //*****************************************************************************
@@ -212,7 +208,6 @@ void ossimIkonosRpcModel::finishConstruction()
    theRefGndPt.lat  = theLatOffset;
    theRefGndPt.lon  = theLonOffset;
    theRefGndPt.hgt  = theHgtOffset;
-   theMeanGSD       = (theGSD.x + theGSD.y)/2.0;
 
    //***
    // Assign the bounding image space rectangle:
@@ -220,6 +215,13 @@ void ossimIkonosRpcModel::finishConstruction()
    theImageClipRect = ossimDrect(0.0, 0.0,
                                  theImageSize.samp-1, theImageSize.line-1);
 
+   //---
+   // NOTE:  We must call "updateModel()" to set parameter used by base
+   // ossimRpcModel prior to calling lineSampleHeightToWorld or all
+   // the world points will be same.
+   //---
+   updateModel();   
+
    //***
    // Assign the bounding ground polygon:
    //***
@@ -234,8 +236,34 @@ void ossimIkonosRpcModel::finishConstruction()
    lineSampleHeightToWorld(ip3, 0.0, v3);
    theBoundGndPolygon
       = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3));
+
+   //---
+   // Call compute gsd:
+   // 
+   // This will set theGSD and theMeanGSD using lineSampleHeightToWorld on
+   // three image points.  Previously this was pulled from metadata.  Some of
+   // which was in US Survey feet and not converted to meters.  This method
+   // is more accurate as it uses the sensor model to compute.
+   //---
+   try
+   {
+      // Method throws ossimException.
+      computeGsd();
+   }
+   catch (const ossimException& e)
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+         << "ossimIkonosRpcModel finishConstruction Caught Exception:\n"
+         << e.what() << std::endl;
+   }
+   
+   if (traceExec())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimIkonosRpcModel finishConstruction(): returning..."
+         << std::endl;
+   }
    
-   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): returning..." << std::endl;
    return;
 }
 
@@ -315,10 +343,9 @@ void ossimIkonosRpcModel::parseMetaData(const ossimFilename& data_file)
    }
    sscanf(strptr, "%8c %s", dummy, name);
    theSensorID = name;
-   
-   
+
    //***
-   // GSD:
+   // GSD:  NOTE - this will be recomputed by computeGsd method later.
    //***
    strptr = strstr(strptr, "\nPixel Size X:");
    if (!strptr)
@@ -333,6 +360,7 @@ void ossimIkonosRpcModel::parseMetaData(const ossimFilename& data_file)
          return;
       }
    }
+   
    sscanf(strptr, "%14c %lf", dummy, &theGSD.samp);
    strptr = strstr(strptr, "\nPixel Size Y:");
    if (!strptr)
@@ -421,7 +449,7 @@ bool ossimIkonosRpcModel::parseHdrData(const ossimFilename& data_file)
       return false;
    }
 
-   char* strptr;
+   char* strptr = 0;
    // char linebuf[80];
    char dummy[80];
    // , name[80];
@@ -433,7 +461,7 @@ bool ossimIkonosRpcModel::parseHdrData(const ossimFilename& data_file)
    fread(filebuf, 1, 5000, fptr);
 
    //***
-   // GSD:
+   // GSD:  NOTE - this will be recomputed by computeGsd method later.
    //***
    strptr = strstr(filebuf, "\nPixel Size X:");
    if (!strptr)
@@ -551,7 +579,6 @@ void ossimIkonosRpcModel::parseRpcData(const ossimFilename& data_file)
                                           << keyword << std::endl;
       return;
    }
-
    theLineOffset = atof(buf);
       
    keyword = SAMP_OFF_KW;
@@ -747,7 +774,7 @@ void ossimIkonosRpcModel::writeGeomTemplate(ostream& os)
 bool ossimIkonosRpcModel::saveState(ossimKeywordlist& kwl,
 				    const char* prefix)const
 {
-   if(theSupportData)
+   if(theSupportData.valid())
    {
       ossimString supportPrefix = ossimString(prefix) + "support_data.";
       // copy ossimIkonosMetada-sensor into ossimIkonosRpcModel-sensorId
@@ -755,6 +782,7 @@ bool ossimIkonosRpcModel::saveState(ossimKeywordlist& kwl,
    }
 
    ossimRpcModel::saveState(kwl, prefix);
+
   // this model just sets the base class values so
   // we do not need to re-construct this model so 
   // specify the type as the base class type
@@ -772,7 +800,7 @@ bool ossimIkonosRpcModel::saveState(ossimKeywordlist& kwl,
 bool ossimIkonosRpcModel::loadState(const ossimKeywordlist& kwl,
                                     const char* prefix)
 {
-   if(theSupportData)
+   if(theSupportData.valid())
    {
       ossimString supportPrefix = ossimString(prefix) + "support_data.";
       theSupportData->loadState(kwl, supportPrefix);
@@ -783,105 +811,8 @@ bool ossimIkonosRpcModel::loadState(const ossimKeywordlist& kwl,
 
 bool ossimIkonosRpcModel::parseFile(const ossimFilename& file)
 {
-//    if (!ossimRpcModel::ossimParseFile(file))
-//    {
       return parseTiffFile(file);
-//    }
-//    return true;
-}
-
-#if 0
-bool ossimIkonosRpcModel::parseNitfFile(const ossimFilename& geom_file)
-{
-   if(!isNitf(geom_file))
-	   return false;
-   
-   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel parseNitfFile: entering..." << std::endl;
-
-   ossimKeywordlist kwl(geom_file);
-   const char* value;
-   
-   //***
-   // Assure this keywordlist contains correct type info:
-   //***
-   value = kwl.find(ossimKeywordNames::TYPE_KW);
-   if (!value || (strcmp(value, "ossimIkonosRpcModel")))
-   {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG  ossimIkonosRpcModel parseNitfFile:"
-            << "\nFailed attempt to construct. sensor type \""<<value
-            << "\" does not match \"ossimIkonosRpcModel\"." << std::endl;
-      }
-
-      theErrorStatus++;
-      
-      if (traceExec())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG  ossimIkonosRpcModel parseNitfFile: returning..."
-            << std::endl;
-      }
-      return false;
-   }
-
-   //***
-   // Read meta data filename from geom file:
-   //***
-   value = kwl.find(META_DATA_FILE);
-   if (!value)
-   {
-      theErrorStatus++;
-      if (traceExec())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG ossimIkonosRpcModel parseNitfFile: returning..."
-            << std::endl;
-      }
-      return false;
-   }
-
-   ossimFilename metadata (value);
-
-   //***
-   // Read RPC data filename from geom file:
-   //***
-   value = kwl.find(RPC_DATA_FILE);
-   if (!value)
-   {
-      theErrorStatus++;
-      if (traceExec())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG  ossimIkonosRpcModel parseNitfFile: returning..."
-            << std::endl;
-      }
-      return false;
-   }
-   ossimFilename rpcdata (value);
-
-   parseMetaData(metadata);
-   parseRpcData (rpcdata);
-   finishConstruction();
-
-   ossimString drivePart;
-   ossimString pathPart;
-   ossimString filePart;
-   ossimString extPart;
-   geom_file.split(drivePart,
-                   pathPart,
-                   filePart,
-                   extPart);
-
-   if (traceExec())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG returning..." << std::endl;
-   }
-   
-   return true;
 }
-#endif
 
 bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename)
 {
@@ -903,7 +834,7 @@ bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename)
       {
          // Currently not required by model so we will not error out here.
          ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimIkonosRpcModel::parseTiffFile parse returned false.\n"
+         << "WARNING: ossimIkonosMetaData::open returned false.\n"
          << std::endl;
       }
    }
@@ -952,9 +883,8 @@ bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename)
                        INIT_RPC_GEOM_FILENAME,
                        "");
    ossimKeywordlist kwl (init_rpc_geom);
- 
    saveState(kwl);
-
+   
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel parseTiffFile: returning..." << std::endl;
 
    return true;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp
index 66d2ef71c6c3db161a4b949a69fae69dbbe1361b..e15a021ced2c0ed17692a1dd4b0eb3b18b1fc67c 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp
@@ -16,7 +16,6 @@
 #include <ossim/projection/ossimImageProjectionModel.h>
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/projection/ossimProjection.h>
-#include <ossim/projection/ossimProjectionFactoryRegistry.h>
 
 RTTI_DEF1(ossimImageProjectionModel,
           "ossimImageProjectionModel",
@@ -30,11 +29,7 @@ ossimImageProjectionModel::ossimImageProjectionModel()
 
 ossimImageProjectionModel::~ossimImageProjectionModel()
 {
-   if (theProjection)
-   {
-      delete theProjection;
-      theProjection = 0;
-   }
+   theProjection = 0;
 }
 
 void ossimImageProjectionModel::initialize(const ossimImageHandler& ih)
@@ -42,20 +37,14 @@ void ossimImageProjectionModel::initialize(const ossimImageHandler& ih)
    // Initialize base.
    ossimImageModel::initialize(ih);
    
-   if (theProjection)
-   {
-      delete theProjection;
-      theProjection = 0;
-   }
-
-   // cast away constness for  ossimImageHandler::getImageGeometry call.
-   ossimImageHandler* iih = const_cast<ossimImageHandler*>(&ih);
+   theProjection = 0;
 
-   ossimKeywordlist kwl;
-   if ( iih->getImageGeometry(kwl, 0) )
+   // Fetch the handler's image geometry and see if it has a projection:
+   ossimImageHandler* iih = const_cast<ossimImageHandler*>(&ih); // cast away constness
+   ossimImageGeometry* image_geom = iih->getImageGeometry();
+   if (image_geom)
    {
-      theProjection = ossimProjectionFactoryRegistry::instance()->
-         createProjection(kwl);
+      theProjection = image_geom->getProjection();
    }
 }
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimImageViewAffineTransform.cpp b/Utilities/otbossim/src/ossim/projection/ossimImageViewAffineTransform.cpp
index 8ea83c37e0600a0537d561e7059119b31319f9ed..9d989e01b6f232062981bbb4f76e31fa0e35c8cf 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimImageViewAffineTransform.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimImageViewAffineTransform.cpp
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimImageViewAffineTransform.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageViewAffineTransform.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimImageViewAffineTransform.h>
 #include <ossim/base/ossimKeywordlist.h>
@@ -321,8 +321,7 @@ bool ossimImageViewAffineTransform::isValid()const
    return true;
 }
 
-bool ossimImageViewAffineTransform::setView(ossimObject* /* obj */,
-                                            bool /* ownsProjection*/ )
+bool ossimImageViewAffineTransform::setView(ossimObject* /* obj */)
 {
    return false;
 }
diff --git a/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp b/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp
index 657567ceabc7bd4922fb01313c7cf161f2c8f9f6..efa52620c430be5577da8f192ff2c990a0d8068f 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp
@@ -6,6 +6,7 @@
 // See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR: Garrett Potts
+//         Oscar Kramer (oscar@krameranalytic.com)
 //
 // DESCRIPTION: Contains declaration of ossimImageViewProjectionTransform.
 //    This class provides an image to view transform that utilizes two
@@ -15,398 +16,231 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimImageViewProjectionTransform.cpp 13516 2008-08-29 14:54:12Z dburken $
+//  $Id: ossimImageViewProjectionTransform.cpp 15766 2009-10-20 12:37:09Z gpotts $
 //
 #include <ossim/projection/ossimImageViewProjectionTransform.h>
-#include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimKeywordlist.h>
-#include <ossim/projection/ossimProjectionFactoryRegistry.h>
-#include <ossim/projection/ossimEquDistCylProjection.h>
-#include <ossim/projection/ossimUtmProjection.h>
 #include <ossim/base/ossimGeoPolygon.h>
 #include <ossim/base/ossimPolyArea2d.h>
-#include <ossim/base/ossimAdjustableParameterInterface.h>
 
 RTTI_DEF1(ossimImageViewProjectionTransform,
           "ossimImageViewProjectionTransform",
           ossimImageViewTransform);
 
-//***
-// Define Trace flags for use within this file:
-//***
-// #include <ossim/base/ossimTrace.h>
-// static ossimTrace traceExec  ("ossimImageViewProjectionTransform:exec");
-// static ossimTrace traceDebug ("ossimImageViewProjectionTransform:debug");
-
 //*****************************************************************************
 //  CONSTRUCTOR: ossimImageViewProjectionTransform
-//  
 //*****************************************************************************
 ossimImageViewProjectionTransform::ossimImageViewProjectionTransform
-(  ossimProjection* imageProjection,
-   ossimProjection* viewProjection,
-   bool ownsImageProjectionFlag,
-   bool ownsViewProjectionFlag)
-   :
-      ossimImageViewTransform(),
-      theImageProjection(imageProjection),
-      theViewProjection(viewProjection),
-      theOwnsImageProjFlag(ownsImageProjectionFlag),
-      theOwnsViewProjFlag(ownsViewProjectionFlag),
-      theSameProjection(false),
-      theInputMapProjectionFlag(false),
-      theOutputMapProjectionFlag(false)
+(  ossimImageGeometry* imageGeometry, ossimImageGeometry* viewGeometry)
+:  m_ImageGeometry(imageGeometry),
+   m_ViewGeometry(viewGeometry)
 {
-   if(!theViewProjection)
-   {
-//      theViewProjection    = new ossimEquDistCylProjection;
-      theOwnsViewProjFlag  = true;
-   }
- 
-   if(!theImageProjection)
-   {
-      theImageProjection   = new ossimEquDistCylProjection;
-      theOwnsImageProjFlag = true;
-   }
 }
 
-ossimImageViewProjectionTransform::ossimImageViewProjectionTransform(
-   const ossimImageViewProjectionTransform& src)
-   : ossimImageViewTransform(src),
-     theImageProjection(0),
-     theViewProjection(0),
-     theOwnsImageProjFlag(src.theOwnsImageProjFlag),
-     theOwnsViewProjFlag(src.theOwnsViewProjFlag),
-     theSameProjection(src.theSameProjection),
-     theInputMapProjectionFlag(src.theInputMapProjectionFlag),
-     theOutputMapProjectionFlag(src.theOutputMapProjectionFlag)
+//*****************************************************************************
+//  CONSTRUCTOR: ossimImageViewProjectionTransform
+//*****************************************************************************
+ossimImageViewProjectionTransform::
+ossimImageViewProjectionTransform(const ossimImageViewProjectionTransform& src)
+: ossimImageViewTransform(src),
+  m_ImageGeometry(src.m_ImageGeometry),
+  m_ViewGeometry(src.m_ViewGeometry)
 {
-   if(theOwnsImageProjFlag)
-   {
-      theImageProjection = src.theImageProjection?(ossimProjection*)src.theImageProjection->dup():(ossimProjection*)0;
-   }
-   else
-   {
-      theImageProjection = src.theImageProjection;
-   }
-   if(theOwnsViewProjFlag)
-   {
-      theViewProjection = src.theViewProjection?(ossimProjection*)src.theViewProjection->dup():(ossimProjection*)0;
-   }
-   else
-   {
-      theViewProjection = src.theViewProjection;
-   }
 }
 
-
 //*****************************************************************************
 //  DESTRUCTOR: ~ossimImageViewProjectionTransform
-//  
 //*****************************************************************************
 ossimImageViewProjectionTransform::~ossimImageViewProjectionTransform()
 {
-   if(theImageProjection && theOwnsImageProjFlag)
-   {
-      delete theImageProjection;
-      theImageProjection = 0;
-   }
-   if(theViewProjection && theOwnsViewProjFlag)
-   {
-      delete theViewProjection;
-      theViewProjection = 0;
-   }
 }
 
 //*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::imageToView
-//  
+//  Workhorse of the object. Converts image-space to view-space.
 //*****************************************************************************
-void ossimImageViewProjectionTransform::imageToView
-(   const ossimDpt& imagePoint,
-    ossimDpt&       viewPoint) const
+void ossimImageViewProjectionTransform::imageToView(const ossimDpt& ip, ossimDpt& vp) const
 {
-   if(theImageProjection&&theViewProjection)
-   {
-      ossimGpt gpt;
+    // Check for same geometries on input and output (this includes NULL geoms):
+    if (m_ImageGeometry == m_ViewGeometry)
+    {
+        vp = ip;
+        return;
+    }
+
+    // Otherwise we need access to good geoms. Check for a bad geometry object:
+    if (!m_ImageGeometry || !m_ViewGeometry)
+    {
+        vp.makeNan();
+        return;
+    }
+
+    // Check for same projection on input and output sides to save projection to ground:
+    if (m_ImageGeometry->getProjection() == m_ViewGeometry->getProjection())
+    {
+        // Check for possible same 2D transforms as well:
+        if (m_ImageGeometry->getTransform() == m_ViewGeometry->getTransform())
+        {
+            vp = ip;
+            return;
+        }
+
+        // Not the same 2D transform, so just perform local-image -> full-image -> local-view:
+        ossimDpt fp;
+        m_ImageGeometry->localToFullImage(ip, fp);
+        m_ViewGeometry->fullToLocalImage(fp, vp);
+        return;
+    }
+
+    // Completely different left and right side geoms (typical situation). Need to project to ground
+    ossimGpt gp;
+    m_ImageGeometry->localToWorld(ip, gp);
+    m_ViewGeometry->worldToLocal(gp, vp);
 
-//       if(theInputMapProjectionFlag)
-// 	{
-// 	  ((ossimMapProjection*)theImageProjection)->lineSampleToWorldIterate(imagePoint,
-// 									      gpt);
-// 	}
-//       else
-// 	{
-      theImageProjection->lineSampleToWorld(imagePoint, gpt);
-//	}
-      
-      if(gpt.isLatNan()||gpt.isLonNan())
-      {
-         viewPoint.makeNan();
-         return;
-      }
-      theViewProjection->worldToLineSample(gpt, viewPoint);
 #if 0
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG ossimImageViewProjectionTransform::imageToView:"
-            <<"\n    viewPoint:  "<<viewPoint
-            <<"\n    gpt:        "<<gpt
-            <<"\n    imagePoint: "<<imagePoint<<std::endl;
-         
-      }
+    if (traceDebug())
+    {
+     ossimNotify(ossimNotifyLevel_DEBUG)<<"DEBUG ossimImageViewProjectionTransform::imageToView:"
+        <<"\n    ip: "<<ip
+        <<"\n    gp: "<<gp
+        <<"\n    vp: "<<vp<<std::endl;
+     
+    }
 #endif
-   }
 }
    
 //*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::viewToImage
-//  
+//  Other workhorse of the object. Converts view-space to image-space.
 //*****************************************************************************
-void ossimImageViewProjectionTransform::viewToImage
-(   const ossimDpt& viewPoint,
-    ossimDpt&       imagePoint) const
+void ossimImageViewProjectionTransform::viewToImage(const ossimDpt& vp, ossimDpt& ip) const
 {
-   bool transformed = false;
-   if(theSameProjection)
-   {
-      ossimDpt en;
-      ossimMapProjection* mapIProj = (ossimMapProjection*)theImageProjection;
-      ossimMapProjection* mapVProj = (ossimMapProjection*)theViewProjection;
+    // Check for same geometries on input and output (this includes NULL geoms):
+    if (m_ImageGeometry == m_ViewGeometry)
+    {
+        ip = vp;
+        return;
+    }
+
+    // Otherwise we need access to good geoms. Check for a bad geometry object:
+    if (!m_ImageGeometry || !m_ViewGeometry)
+    {
+        ip.makeNan();
+        return;
+    }
+
+    // Check for same projection on input and output sides to save projection to ground:
+    if (m_ImageGeometry->getProjection() == m_ViewGeometry->getProjection())
+    {
+        // Check for possible same 2D transforms as well:
+        if (m_ImageGeometry->getTransform() == m_ViewGeometry->getTransform())
+        {
+            ip = vp;
+            return;
+        }
+
+        // Not the same 2D transform, so just perform local-image -> full-image -> local-view:
+        ossimDpt fp;
+        m_ViewGeometry->localToFullImage(vp, fp);
+        m_ImageGeometry->fullToLocalImage(fp, ip);
+        return;
+    }
+
+    // Completely different left and right side geoms (typical situation). Need to project to ground
+    ossimGpt gp;
+    m_ViewGeometry->localToWorld(vp, gp);
+    m_ImageGeometry->worldToLocal(gp, ip);
 
-      if(mapIProj&&mapVProj)
-      {
-         mapVProj->lineSampleToEastingNorthing(viewPoint, en);
-         mapIProj->eastingNorthingToLineSample(en, imagePoint);
-         return;
-      }
-   }
-   
-   if(!transformed&&theImageProjection&&theViewProjection)
-   {
-      ossimGpt gpt;
-      theViewProjection->lineSampleToWorld(viewPoint, gpt);
-      
-      if(gpt.isLatNan()||gpt.isLonNan())
-      {
-         imagePoint.makeNan();
-         return;
-      }
-      theImageProjection->worldToLineSample(gpt, imagePoint);
-      
 #if 0
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG ossimImageViewProjectionTransform::viewToImage:"
-            <<"\n    viewPoint:  "<<viewPoint
-            <<"\n    gpt:        "<<gpt
-            <<"\n    imagePoint: "<<imagePoint<<std::endl;
-      }
+    if (traceDebug())
+    {
+        ossimNotify(ossimNotifyLevel_DEBUG)<<"DEBUG ossimImageViewProjectionTransform::viewToImage:"
+            <<"\n    vp: "<<vp
+            <<"\n    gp: "<<gp
+            <<"\n    ip: "<<ip<<std::endl;
+
+    }
 #endif
-//       if(removeError&&!imagePoint.hasNans()&&!viewPoint.hasNans())
-//       {
-//          ossimDpt err;
-         
-// 	 getRoundTripErrorImage(err, ossimIpt(imagePoint));
-//          imagePoint+=err;
-//          if( fabs(imagePoint.x - (int)imagePoint.x) <= FLT_EPSILON)
-//          {
-//             imagePoint.x = (int)imagePoint.x;
-//          }
-//          if( fabs(imagePoint.y - (int)imagePoint.y) <= FLT_EPSILON)
-//          {
-//             imagePoint.y = (int)imagePoint.y;
-//          }
-//       }
-   }
 }
 
 //*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::setViewProjection
-//  
+//! OLK: Not sure where this is used, but needed to satisfy ossimViewInterface base class.
 //*****************************************************************************
-void ossimImageViewProjectionTransform::setViewProjection(ossimProjection* viewProjection, bool ownsViewProjection) 
+bool ossimImageViewProjectionTransform::setView(ossimObject* baseObject)
 {
-   if(theViewProjection &&
-      (theViewProjection!=viewProjection) &&
-      theOwnsViewProjFlag)
+   ossimImageGeometry* g = dynamic_cast<ossimImageGeometry*>(baseObject);
+   if (g)
    {
-      delete theViewProjection;
-      theViewProjection = (ossimProjection*)0;
-   }
-   theOwnsViewProjFlag = ownsViewProjection;
-   theViewProjection   = viewProjection;
-   if(PTR_CAST(ossimMapProjection,
-               theViewProjection))
-   {
-      theOutputMapProjectionFlag = true;
+      m_ViewGeometry = g;
+      return true;
    }
    else
    {
-      theOutputMapProjectionFlag = false;
-   }
-   checkSameProjection();
-}
-
-bool ossimImageViewProjectionTransform::setView(ossimObject* baseObject,
-                                                bool ownsTheView)
-{
-   bool result = true;
-   if(baseObject)
-   {
-      // if not null then we will set it if it is of
-      // our type
-      ossimProjection* proj = PTR_CAST(ossimProjection, baseObject);
-      
+      ossimProjection* proj = dynamic_cast<ossimProjection*>(baseObject);
       if(proj)
       {
-         setViewProjection(proj, ownsTheView);
-      }
-      else
-      {
-         result = false;
+         if(m_ViewGeometry.valid())
+         {
+            m_ViewGeometry->setProjection(proj);
+         }
+         else
+         {
+            m_ViewGeometry = new ossimImageGeometry(0, proj);
+         }
       }
    }
-   else
-   {
-      // if it's null we will just clear the view out
-      setViewProjection((ossimProjection*)0, true);
-   }
-
-   checkSameProjection();
-   return result;
-}
-
-//*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::setImageProjection
-//  
-//*****************************************************************************
-void ossimImageViewProjectionTransform::setImageProjection(ossimProjection* imageProjection, bool ownsImageProjection)
-{
-   if(theImageProjection &&
-      (theImageProjection!=imageProjection) &&
-      theOwnsImageProjFlag)
-   {
-      delete theImageProjection;
-      theImageProjection = (ossimProjection*)0;
-   }
-   theOwnsImageProjFlag = ownsImageProjection;
-   theImageProjection = imageProjection;
-   if(PTR_CAST(ossimMapProjection,
-               theImageProjection))
-   {
-      theInputMapProjectionFlag = true;
-   }
-   else
-   {
-      theInputMapProjectionFlag = false;
-   }
-   
-   checkSameProjection();
-}
-
-//*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::setViewProjection
-//  
-//*****************************************************************************
-void ossimImageViewProjectionTransform::setViewProjection(const ossimProjection& viewProjection)                                                          
-{
-   if(theViewProjection && theOwnsViewProjFlag)
-   {
-      delete theViewProjection;
-      theViewProjection = (ossimProjection*)0;
-   }
-   theViewProjection   = (ossimProjection*)viewProjection.dup();
-   theOwnsViewProjFlag = true;
-   if(PTR_CAST(ossimMapProjection,
-               theViewProjection))
-   {
-      theOutputMapProjectionFlag = true;
-   }
-   else
-   {
-      theOutputMapProjectionFlag = false;
-   }
-   checkSameProjection();
+   return false;
 }
 
 //*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::setImageProjection
-//  
-//*****************************************************************************
-void ossimImageViewProjectionTransform::setImageProjection(const ossimProjection& imageProjection)
-{
-   if(theImageProjection && theOwnsImageProjFlag)
-   {
-      delete theImageProjection;
-   }
-
-   theImageProjection = (ossimProjection*)imageProjection.dup();
-   if(PTR_CAST(ossimMapProjection,
-               theImageProjection))
-   {
-      theInputMapProjectionFlag = true;
-   }
-   theOwnsImageProjFlag = true;
-   checkSameProjection();
-}
-
-//*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::print
+//  Dumps contents to stream
 //*****************************************************************************
 std::ostream& ossimImageViewProjectionTransform::print(std::ostream& out)const
 {
-   if(theImageProjection)
-   {
-      out << "image projection: " << endl;
-      theImageProjection->print(out);
-   }
-   if(theViewProjection)
-   {
-      out << "view projection: " << endl;
-      theViewProjection->print(out);
-   }
-   return out;
-}
+    out << "ossimImageViewProjectionTransform::print: ..... entered " <<endl;
 
-//*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::getImageProjection
-//*****************************************************************************
-ossimProjection* ossimImageViewProjectionTransform::getImageProjection()
-{
-   return theImageProjection;
-}
-
-//*****************************************************************************
-//  METHOD: ossimImageViewProjectionTransform::getViewProjection
-//  
-//*****************************************************************************
-ossimProjection* ossimImageViewProjectionTransform::getViewProjection()
-{
-   return theViewProjection;
+    if(m_ImageGeometry.valid())
+    {
+        out << "  Input Image (LEFT) Geometry: " << endl;
+        m_ImageGeometry->print(out);
+    }
+    else
+    {
+        out << "  None defined." << endl;
+    }
+    if(m_ViewGeometry.valid())
+    {
+        out << "Output View (RIGHT) Geometry: " << endl;
+        m_ViewGeometry->print(out);
+    }
+    else
+    {
+        out << "  None defined." << endl;
+    }
+    return out;
 }
 
+//**************************************************************************************************
+// Converts the local image space rect into bounding view-space rect
+//**************************************************************************************************
 ossimDrect ossimImageViewProjectionTransform::getImageToViewBounds(const ossimDrect& imageRect)const
 {
+    // Let base class try:
    ossimDrect result = ossimImageViewTransform::getImageToViewBounds(imageRect);
 
-   if(result.hasNans()&&theImageProjection&&theViewProjection)
+   // If not successful, compute using input and output geometries:
+   if (result.hasNans() && m_ImageGeometry.valid() && m_ViewGeometry.valid() &&
+       m_ImageGeometry->hasProjection() && m_ViewGeometry->hasProjection())
    {
       ossimGeoPolygon viewClip;
-      theViewProjection->getGroundClipPoints(viewClip);
+      m_ViewGeometry->getProjection()->getGroundClipPoints(viewClip);
       if(viewClip.size())
       {
-         std::vector<ossimPolygon> visiblePolygons;
-         
          std::vector<ossimGpt> imageGpts(4);
-         const ossimDatum* viewDatum = theViewProjection->origin().datum();
-         theImageProjection->lineSampleToWorld(imageRect.ul(), imageGpts[0]);
-         theImageProjection->lineSampleToWorld(imageRect.ur(), imageGpts[1]);
-         theImageProjection->lineSampleToWorld(imageRect.lr(), imageGpts[2]);
-         theImageProjection->lineSampleToWorld(imageRect.ll(), imageGpts[3]);
+         m_ImageGeometry->localToWorld(imageRect.ul(), imageGpts[0]);
+         m_ImageGeometry->localToWorld(imageRect.ur(), imageGpts[1]);
+         m_ImageGeometry->localToWorld(imageRect.lr(), imageGpts[2]);
+         m_ImageGeometry->localToWorld(imageRect.ll(), imageGpts[3]);
 
+         const ossimDatum* viewDatum = m_ViewGeometry->getProjection()->origin().datum();
          imageGpts[0].changeDatum(viewDatum);
          imageGpts[1].changeDatum(viewDatum);
          imageGpts[2].changeDatum(viewDatum);
@@ -415,111 +249,71 @@ ossimDrect ossimImageViewProjectionTransform::getImageToViewBounds(const ossimDr
          ossimPolyArea2d viewPolyArea(viewClip.getVertexList());
          ossimPolyArea2d imagePolyArea(imageGpts);
          viewPolyArea &= imagePolyArea;
+         std::vector<ossimPolygon> visiblePolygons;
          viewPolyArea.getVisiblePolygons(visiblePolygons);
          if(visiblePolygons.size())
          {
-            
             std::vector<ossimDpt> vpts;
             ossim_uint32 idx = 0;
             for(idx=0; idx<visiblePolygons[0].getNumberOfVertices();++idx)
             {
                ossimDpt tempPt;
-               ossimGpt gpt(visiblePolygons[0][idx].lat,
-                            visiblePolygons[0][idx].lon,
-                            0.0,
-                            viewDatum);
-               theViewProjection->worldToLineSample(gpt,
-                                                    tempPt);
+               ossimGpt gpt(visiblePolygons[0][idx].lat, visiblePolygons[0][idx].lon, 0.0,  viewDatum);
+               m_ViewGeometry->worldToLocal(gpt, tempPt);
                vpts.push_back(tempPt);
             }
             result = ossimDrect(vpts);
          }
       }
-      
    }
-
    return result;
 }
 
 //*****************************************************************************
 //  METHOD: ossimImageViewProjectionTransform::loadState
-//  
 //*****************************************************************************
 bool ossimImageViewProjectionTransform::loadState(const ossimKeywordlist& kwl,
                                                   const char* prefix)
 {
-   ossimString newPrefix = prefix;
-
-   if(theImageProjection)
-   {
-      delete theImageProjection;
-      theImageProjection = 0;
-   }
-   if(theViewProjection)
-   {
-      delete theViewProjection;
-      theViewProjection = 0;
-   }
-
-   newPrefix = ossimString(prefix) + "view_proj.";
-   theViewProjection
-      = ossimProjectionFactoryRegistry::instance()->createProjection(kwl, newPrefix.c_str());
-
-   theImageProjection
-      = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,
-                                                                     (ossimString(prefix)+"image_proj.").c_str());
-   
-   theOwnsImageProjFlag = true;   
-   theOwnsViewProjFlag = true;
-   if(PTR_CAST(ossimMapProjection,
-               theImageProjection))
-   {
-      theInputMapProjectionFlag = true;
-   }
-   else
-   {
-      theInputMapProjectionFlag = false;
-   }
-   if(PTR_CAST(ossimMapProjection,
-               theViewProjection))
-   {
-      theOutputMapProjectionFlag = true;
-   }
-   else
-   {
-      theOutputMapProjectionFlag = false;
-   }
-
    return ossimImageViewTransform::loadState(kwl, prefix);
 }
 
+//**************************************************************************************************
+// 
+//**************************************************************************************************
 bool ossimImageViewProjectionTransform::saveState(ossimKeywordlist& kwl,
                                                   const char* prefix)const
 {
-   if(theViewProjection)
-   {
-      theViewProjection->saveState(kwl,
-                                   (ossimString(prefix) + "view_proj.").c_str());
-   }
-   ossimAdjustableParameterInterface* adjustablesInterface = PTR_CAST(ossimAdjustableParameterInterface,
-                                                                      theImageProjection);
-   if(adjustablesInterface)
-   {
-      if(adjustablesInterface->hasDirtyAdjustments())
-      {
-         theImageProjection->saveState(kwl,
-                                       (ossimString(prefix) + "image_proj.").c_str());            
-      }
-   }
-   kwl.add(prefix,
-           "type",
-           STATIC_TYPE_NAME(ossimImageViewProjectionTransform),
-           true);
-   
    return ossimImageViewTransform::saveState(kwl, prefix);
 }
 
-void ossimImageViewProjectionTransform::checkSameProjection()
+//**************************************************************************************************
+// Returns the GSD of input image.
+//**************************************************************************************************
+ossimDpt ossimImageViewProjectionTransform::getInputMetersPerPixel() const
 {
-   theSameProjection = false;
+    ossimDpt result;
+
+    if(m_ImageGeometry->hasProjection())
+        result = m_ImageGeometry->getProjection()->getMetersPerPixel();
+    else
+        result.makeNan();
+
+    return result;
 }
+
+//**************************************************************************************************
+// Returns the GSD of the output view.
+//**************************************************************************************************
+ossimDpt ossimImageViewProjectionTransform::getOutputMetersPerPixel() const
+{
+    ossimDpt result;
+
+    if(m_ViewGeometry->hasProjection())
+        result = m_ViewGeometry->getProjection()->getMetersPerPixel();
+    else
+        result.makeNan();
+
+    return result;
+}
+
diff --git a/Utilities/otbossim/src/ossim/projection/ossimMapProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimMapProjection.cpp
index 739c4dd3c7722b212c102e25040413af72287746..200afc81ab6cbb25ae568f7eac14e3d3f7ab7359 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimMapProjection.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimMapProjection.cpp
@@ -9,7 +9,7 @@
 // Base class for all map projections.
 // 
 //*******************************************************************
-//  $Id: ossimMapProjection.cpp 13913 2008-12-04 19:16:38Z gpotts $
+//  $Id: ossimMapProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <cstdlib>
@@ -50,7 +50,7 @@ ossimMapProjection::ossimMapProjection(const ossimEllipsoid& ellipsoid,
     theUlEastingNorthing(0, 0),
     theFalseEastingNorthing(0, 0),
     thePcsCode(0),
-    theElevationLookupFlag(true),
+    theElevationLookupFlag(false),
     theModelTransformUnitType(OSSIM_UNIT_UNKNOWN)
 {
    theUlGpt = theOrigin;
@@ -69,7 +69,7 @@ ossimMapProjection::ossimMapProjection(const ossimMapProjection& src)
         theUlEastingNorthing(src.theUlEastingNorthing),
         theFalseEastingNorthing(src.theFalseEastingNorthing),
         thePcsCode(src.thePcsCode),
-        theElevationLookupFlag(true),
+        theElevationLookupFlag(false),
         theModelTransform(src.theModelTransform),
         theInverseModelTransform(src.theInverseModelTransform),
         theModelTransformUnitType(src.theModelTransformUnitType)
diff --git a/Utilities/otbossim/src/ossim/projection/ossimMapProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimMapProjectionFactory.cpp
index 7e91580a37198916e13370d9e04671ab06ebac0b..c4c78e4f1bf491acf754cf51a36a3a5803ca7956 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimMapProjectionFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimMapProjectionFactory.cpp
@@ -12,7 +12,7 @@
 //              Initial coding.
 //<
 //*****************************************************************************
-//  $Id: ossimMapProjectionFactory.cpp 12082 2007-11-26 21:46:44Z dburken $
+//  $Id: ossimMapProjectionFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimMapProjectionFactory.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -175,7 +175,6 @@ ossimProjection* ossimMapProjectionFactory::createProjection(const ossimKeywordl
 
 //*****************************************************************************
 //  METHOD: ossimSensorModelFactory::create(projection_name)
-//  
 //*****************************************************************************
 ossimProjection* ossimMapProjectionFactory::createProjection(const ossimString &name) const
 {
diff --git a/Utilities/otbossim/src/ossim/projection/ossimMapViewController.cpp b/Utilities/otbossim/src/ossim/projection/ossimMapViewController.cpp
index f1a8ad72d4b6f847a195e60ebed347a27fad8c37..6abc76becfa21f5e6c7f4b6ded72aa86bbf786b8 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimMapViewController.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimMapViewController.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks)
 //
 //*************************************************************************
-// $Id: ossimMapViewController.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimMapViewController.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/projection/ossimMapViewController.h>
 #include <ossim/projection/ossimEquDistCylProjection.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -106,17 +106,10 @@ void ossimMapViewController::setFilename(const ossimFilename& file)
       ossimKeywordlist kwl;
       kwl.addFile(file.c_str());
       
-      ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-      if(PTR_CAST(ossimMapProjection, proj))
+      ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+      if(dynamic_cast<ossimMapProjection*>(proj.get()))
       {
-         setView(proj);
-      }
-      else
-      {
-         if(proj)
-         {
-            delete proj;
-         }
+         setView(proj.get());
       }
    }
 
@@ -169,7 +162,7 @@ bool ossimMapViewController::loadState(const ossimKeywordlist& kwl,
    ossimSource::loadState(kwl, prefix);
 
    theGeometryFile = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
-   ossimProjection* proj=(ossimProjection*)NULL;
+   ossimRefPtr<ossimProjection> proj;
    
    if(theGeometryFile == "")
    {
@@ -185,16 +178,9 @@ bool ossimMapViewController::loadState(const ossimKeywordlist& kwl,
       proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl2);
    }
    
-   if(PTR_CAST(ossimMapProjection, proj))
+   if(dynamic_cast<ossimMapProjection*>(proj.get()))
    {
-      setView(proj);
-   }
-   else
-   {
-      if(proj)
-      {
-         delete proj;
-      }      
+      setView(proj.get());
    }
 
    return true;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimMgrs.c b/Utilities/otbossim/src/ossim/projection/ossimMgrs.c
index 7ece302907c5c28819df2d157af768211d6936a8..fea3f42e1d992559510164d9200c8087f1cc4ea6 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimMgrs.c
+++ b/Utilities/otbossim/src/ossim/projection/ossimMgrs.c
@@ -915,7 +915,7 @@ long Make_OSSIM_MGRS_String (char* OSSIM_MGRS,
 } /* Make_OSSIM_MGRS_String */
 
 
-long Break_OSSIM_MGRS_String (char* OSSIM_MGRS,
+long Break_OSSIM_MGRS_String (const char* OSSIM_MGRS,
                         long* Zone,
                         long Letters[OSSIM_MGRS_LETTERS],
                         double* Easting,
@@ -1108,7 +1108,7 @@ long Convert_Geodetic_To_OSSIM_MGRS (double Latitude,
 } /* Convert_Geodetic_To_OSSIM_MGRS */
 
 
-long Convert_OSSIM_MGRS_To_Geodetic (char* OSSIM_MGRS, 
+long Convert_OSSIM_MGRS_To_Geodetic (const char* OSSIM_MGRS, 
                                double *Latitude, 
                                double *Longitude)
 /*
@@ -1208,7 +1208,7 @@ long Convert_UTM_To_OSSIM_MGRS (long Zone,
 } /* Convert_UTM_To_OSSIM_MGRS */
 
 
-long Convert_OSSIM_MGRS_To_UTM (char   *OSSIM_MGRS,
+long Convert_OSSIM_MGRS_To_UTM (const char   *OSSIM_MGRS,
                           long   *Zone,
                           char   *Hemisphere,
                           double *Easting,
@@ -1289,7 +1289,7 @@ long Convert_UPS_To_OSSIM_MGRS (char   Hemisphere,
 } /* Convert_UPS_To_OSSIM_MGRS */
 
 
-long Convert_OSSIM_MGRS_To_UPS ( char   *OSSIM_MGRS,
+long Convert_OSSIM_MGRS_To_UPS ( const char   *OSSIM_MGRS,
                            char   *Hemisphere,
                            double *Easting,
                            double *Northing)
diff --git a/Utilities/otbossim/src/ossim/projection/ossimNitfProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimNitfProjectionFactory.cpp
index c7064b7b5c4f369dff1d66c04f9683a53526e31c..6037292635884a857c3672465a30874bbb6b530f 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimNitfProjectionFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimNitfProjectionFactory.cpp
@@ -9,7 +9,7 @@
 //
 // Contains class definition for ossimNitfProjectionFactory.
 //
-// $Id: ossimNitfProjectionFactory.cpp 13909 2008-12-03 20:55:04Z gpotts $
+// $Id: ossimNitfProjectionFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 //----------------------------------------------------------------------------
 
 #include <fstream>
@@ -38,7 +38,7 @@
 #include <ossim/support_data/ossimNitfFile.h>
 #include <ossim/support_data/ossimNitfImageHeader.h>
 
-
+#include <ossim/imaging/ossimNitfTileSource.h>
 //---
 // Define Trace flags for use within this file:
 //---
@@ -92,11 +92,9 @@ ossimNitfProjectionFactory::createProjection(const ossimFilename& filename,
       return result; // result is NULL
    }
 
-   ossimNitfFile* nitf = new ossimNitfFile();
+   ossimRefPtr<ossimNitfFile> nitf = new ossimNitfFile();
    if (!nitf->parseFile(filename))
    {
-      delete nitf;
-      nitf = NULL;
       return result; // result is NULL
    }
 
@@ -114,22 +112,11 @@ ossimNitfProjectionFactory::createProjection(const ossimFilename& filename,
       }
    }
 
-   ossimString coordinateSystem   = imageHeader->getCoordinateSystem();
-   ossimString version = nitf->getHeader()->getVersion();
-   if (coordinateSystem == "G" || coordinateSystem == "D")
-   {
-      result = makeGeographic(imageHeader.get(), coordinateSystem, filename);
-   }
-   else if(coordinateSystem == "N" || coordinateSystem == "S")
-   {
-      if((coordinateSystem == 'N') && (version.toDouble() > 2.0))
-      {
-         result = makeUtm(imageHeader.get(), coordinateSystem, filename);
-      }
-   }
-
+   result = createProjectionFromHeaders(nitf->getHeader(),
+                                        imageHeader.get());
    if (traceDebug())
    {
+      ossimString coordinateSystem   = imageHeader->getCoordinateSystem();
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE << " DEBUG:"
          << "\ncoordinateSysetm:       " << coordinateSystem
@@ -171,6 +158,31 @@ void ossimNitfProjectionFactory::getTypeNameList(std::vector<ossimString>& typeL
    
 }
 
+ossimProjection* ossimNitfProjectionFactory::createProjection(ossimImageHandler* handler)const
+{
+   ossimNitfTileSource* nitfTileSource = dynamic_cast<ossimNitfTileSource*> (handler);
+   ossimProjection* result = 0;
+   if(nitfTileSource)
+   {
+      result = createModel(nitfTileSource);
+      
+      if(!result)
+      {
+         ossimNitfImageHeader* imageHeader = nitfTileSource->getCurrentImageHeader();
+         if(imageHeader)
+         {
+            result = createProjectionFromHeaders(nitfTileSource->getFileHeader(),imageHeader);
+         }
+      }
+   }
+   else if(isNitf(handler->getFilename()))
+   {
+      result =  createProjection(handler->getFilename(), handler->getCurrentEntry());
+   }
+   
+   return result;
+}
+
 bool ossimNitfProjectionFactory::isNitf(const ossimFilename& filename)const
 {
    std::ifstream in(filename.c_str(), ios::in|ios::binary);
@@ -189,10 +201,48 @@ bool ossimNitfProjectionFactory::isNitf(const ossimFilename& filename)const
    return false;
 }
 
+ossimProjection* ossimNitfProjectionFactory::createModel(ossimNitfTileSource* nitf)const
+{
+   ossimRefPtr<ossimProjection> result;
+   if(nitf)
+   {
+      if(nitf->getCurrentImageHeader())
+      {
+         ossimNitfRpcModel* model = new ossimNitfRpcModel;
+         result = model;
+         if(!model->parseImageHeader(nitf->getCurrentImageHeader()))
+         {
+            result = 0;
+         }
+      }
+   }
+   
+   return result.release();
+}
+
+ossimProjection* ossimNitfProjectionFactory::createProjectionFromHeaders(ossimNitfFileHeader* fileHeader,
+                                                                         ossimNitfImageHeader* imageHeader)const
+{
+   ossimProjection* result = 0;
+   ossimString version = fileHeader->getVersion();
+   ossimString coordinateSystem   = imageHeader->getCoordinateSystem();
+   if (coordinateSystem == "G" || coordinateSystem == "D")
+   {
+      result = makeGeographic(imageHeader, coordinateSystem);
+   }
+   else if(coordinateSystem == "N" || coordinateSystem == "S")
+   {
+      if((coordinateSystem == 'N') && (version.toDouble() > 2.0))
+      {
+         result = makeUtm(imageHeader, coordinateSystem);
+      }
+   }
+   return result;
+}
+
 ossimProjection* ossimNitfProjectionFactory::makeGeographic(
    const ossimNitfImageHeader* hdr,
-   const ossimString& coordinateSysetm,
-   const ossimFilename& filename) const
+   const ossimString& coordinateSysetm) const
 {
    ossimProjection* proj = NULL;
    if (!hdr)
@@ -209,7 +259,7 @@ ossimProjection* ossimNitfProjectionFactory::makeGeographic(
    // Look for points from the BLOCKA tag.  This may or may not be present.
    // If present since it has six digit precision use it for the points.
    //---
-   if ( getBlockaPoints(hdr, gpts, filename) == false )
+   if ( getBlockaPoints(hdr, gpts) == false )
    {
       ossimString geographicLocation = hdr->getGeographicLocation();
 
@@ -278,8 +328,7 @@ ossimProjection* ossimNitfProjectionFactory::makeGeographic(
 
 ossimProjection* ossimNitfProjectionFactory::makeUtm(
    const ossimNitfImageHeader* hdr,
-   const ossimString& coordinateSystem,
-   const ossimFilename& filename) const
+   const ossimString& coordinateSystem) const
 {
    ossimUtmProjection* proj = NULL;
    if (!hdr)
@@ -325,7 +374,7 @@ ossimProjection* ossimNitfProjectionFactory::makeUtm(
       std::vector<ossimGpt> gpts;
 
       // Try blocka points first as they are more accurate.
-      if ( getBlockaPoints(hdr, gpts, filename) == false )
+      if ( getBlockaPoints(hdr, gpts) == false )
       {
          ossimGpt ul = proj->inverse(utmPoints[0]);
          ossimGpt ur = proj->inverse(utmPoints[1]);
@@ -359,7 +408,7 @@ ossimProjection* ossimNitfProjectionFactory::makeUtm(
       //---
       ossimDpt tie;
       std::vector<ossimGpt> gpts;
-      if ( getBlockaPoints(hdr, gpts, filename) )
+      if ( getBlockaPoints(hdr, gpts) )
       {
          if (traceDebug())
          {
@@ -447,7 +496,7 @@ ossimProjection* ossimNitfProjectionFactory::makeBilinear(
    ossimDpt lr(cols-1.0, rows-1.0);
    ossimDpt ll(0.0, rows-1.0);
 
-   ossimBilinearProjection* proj = 0;
+   ossimRefPtr<ossimBilinearProjection> proj;
    try
    {
      proj = new ossimBilinearProjection(ul,
@@ -461,14 +510,10 @@ ossimProjection* ossimNitfProjectionFactory::makeBilinear(
    }
    catch(...)
    {
-      if(proj)
-      {
-         delete proj;
-         proj = 0;
-      }
+      proj = 0;
    }
    
-   return proj;
+   return proj.release();
 }
 
 bool ossimNitfProjectionFactory::isSkewed(
@@ -494,8 +539,7 @@ bool ossimNitfProjectionFactory::isSkewed(
 
 bool ossimNitfProjectionFactory::getBlockaPoints(
    const ossimNitfImageHeader* hdr,
-   std::vector<ossimGpt>& gpts,
-   const ossimFilename& filename) const
+   std::vector<ossimGpt>& gpts) const
 {
    if (!hdr)
    {
diff --git a/Utilities/otbossim/src/ossim/projection/ossimNitfRpcModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimNitfRpcModel.cpp
index fe256a116d44de7828f4bb3aa31542e338924f4d..2866b9bffe83d2d1134d93d7ba618edcb39aa22e 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimNitfRpcModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimNitfRpcModel.cpp
@@ -1,7 +1,9 @@
 //*****************************************************************************
 // FILE: ossimNitfRpcModel.cc
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR: Oscar Kramer
 //
@@ -12,7 +14,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimNitfRpcModel.cpp 11981 2007-11-02 16:33:10Z dburken $
+//  $Id: ossimNitfRpcModel.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimNitfRpcModel.h>
 
@@ -97,7 +99,8 @@ ossimObject* ossimNitfRpcModel::dup() const
    return new ossimNitfRpcModel(*this);
 }
 
-bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
+bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile,
+                                  ossim_uint32 entryIndex)
 {
    ossimRefPtr<ossimNitfFile> file = new ossimNitfFile;
 
@@ -106,14 +109,35 @@ bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
       setErrorStatus();
       return false;
    }
-
-   ossimRefPtr<ossimNitfImageHeader> ih = file->getNewImageHeader(0);
+   
+   ossimRefPtr<ossimNitfImageHeader> ih = file->getNewImageHeader(entryIndex);
    if(!ih)
    {
       setErrorStatus();
       return false;
    }
 
+   return parseImageHeader(ih.get());
+   
+}
+
+bool ossimNitfRpcModel::parseImageHeader(const ossimNitfImageHeader* ih)
+{
+   // Do this first so we don't waste time if not rpc image.
+   if (getRpcData(ih) == false)
+   {
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+         << "ossimNitfRpcModel::parseFile DEBUG:"
+         << "\nError parsing rpc tags.  Aborting with error."
+         << std::endl;
+      }
+      setErrorStatus();
+      return false;
+   }
+   
+   
    //---
    // Get the decimation if any from the header "IMAG" field.
    // 
@@ -139,33 +163,21 @@ bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
    // Fetch Image ID:
    //***
    theImageID = ih->getImageId();
-
+   
    ossimIrect imageRect = ih->getImageRect();
    
    //---
    // Fetch Image Size:
    //---
    theImageSize.line =
-      static_cast<ossim_int32>(imageRect.height() / theDecimation);
+   static_cast<ossim_int32>(imageRect.height() / theDecimation);
    theImageSize.samp =
-      static_cast<ossim_int32>(imageRect.width() / theDecimation);
-
+   static_cast<ossim_int32>(imageRect.width() / theDecimation);
+   
    // Search for the STDID Tag to fetch mission (satellite) name:
-   getSensorID(ih.get());
-
-   if (getRpcData(ih.get()) == false)
-   {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimNitfRpcModel::parseFile DEBUG:"
-            << "\nError parsing rpc tags.  Aborting with error."
-            << std::endl;
-      }
-      setErrorStatus();
-      return false;
-   }
-
+   getSensorID(ih);
+   
+   
    //***
    // Assign other data members:
    //***
@@ -175,13 +187,13 @@ bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
    theRefGndPt.lat  = theLatOffset;
    theRefGndPt.lon  = theLonOffset;
    theRefGndPt.hgt  = theHgtOffset;
-
+   
    //***
    // Assign the bounding image space rectangle:
    //***
    theImageClipRect = ossimDrect(0.0, 0.0,
                                  theImageSize.samp-1, theImageSize.line-1);
-
+   
    //---
    // Assign the bounding ground polygon:
    //
@@ -197,12 +209,12 @@ bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
    ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2);
    ossimDpt ip3 (0.0, theImageSize.line-1.0);
    ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3);
-
+   
    theBoundGndPolygon
-      = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3));
-
+   = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3));
+   
    updateModel();
-
+   
    // Set the ground reference point.
    ossimRpcModel::lineSampleHeightToWorld(theRefImgPt,
                                           theHgtOffset,
@@ -212,15 +224,15 @@ bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
       if (traceDebug())
       {
          ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:"
-            << "\nGround Reference Point not valid." 
-            << " Aborting with error..."
-            << std::endl;
+         << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:"
+         << "\nGround Reference Point not valid." 
+         << " Aborting with error..."
+         << std::endl;
       }
       setErrorStatus();
       return false;
    }
-
+   
    //---
    // This will set theGSD and theMeanGSD.  This model doesn't need these but
    // others do.
@@ -234,20 +246,21 @@ bool ossimNitfRpcModel::parseFile(const ossimFilename& nitfFile)
       if (traceDebug())
       {
          ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n"
-            << e.what() << std::endl;
+         << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n"
+         << e.what() << std::endl;
       }
    }
-
+   
    if (traceExec())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << "DEBUG ossimNitfRpcModel::parseFile: returning..."
-         << std::endl;
+      << "DEBUG ossimNitfRpcModel::parseFile: returning..."
+      << std::endl;
    }
    
    return true;
 }
+
 void ossimNitfRpcModel::worldToLineSample(const ossimGpt& world_point,
                                           ossimDpt&       image_point) const
 {
diff --git a/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryBase.cpp b/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryBase.cpp
index 3827d95233d235b4a8f9dc15931ea5459b115935..c9324b43953f99c60ce3d6fba9b7957574a2f877 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryBase.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryBase.cpp
@@ -7,12 +7,12 @@
 //
 // Author: Garrett Potts
 //*******************************************************************
-//  $Id: ossimProjectionFactoryBase.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimProjectionFactoryBase.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimProjectionFactoryBase.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/base/ossimFilename.h>
-
+#include <ossim/imaging/ossimImageHandler.h>
 //---
 // Define Trace flags for use within this file:
 //---
@@ -88,3 +88,10 @@ ossimProjection* ossimProjectionFactoryBase::createProjectionFromGeometryFile(co
 
    return NULL;
 }
+
+ossimProjection* ossimProjectionFactoryBase::createProjection(ossimImageHandler* handler)const
+{
+   if(!handler) return 0;
+   return createProjection(handler->getFilename(), handler->getCurrentEntry());
+}
+
diff --git a/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryRegistry.cpp
index b0bc0d0e902e8309ce0598d77ba6a9d2a3ebca82..33c296d0583453330d9f699ce4cf0bb12766be70 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryRegistry.cpp
@@ -4,7 +4,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimProjectionFactoryRegistry.cpp 14012 2009-01-24 15:35:56Z dburken $
+// $Id: ossimProjectionFactoryRegistry.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <algorithm>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimProjectionFactoryBase.h>
@@ -19,6 +19,8 @@
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 
+ossimProjectionFactoryRegistry* ossimProjectionFactoryRegistry::m_instance = 0;
+
 
 ossimProjectionFactoryRegistry::ossimProjectionFactoryRegistry()
 {
@@ -36,15 +38,16 @@ void ossimProjectionFactoryRegistry::operator=(const ossimProjectionFactoryRegis
 
 ossimProjectionFactoryRegistry::~ossimProjectionFactoryRegistry()
 {
-   theFactoryList.clear();
 }
 
 ossimProjectionFactoryRegistry* ossimProjectionFactoryRegistry::instance()
 {
-   static ossimProjectionFactoryRegistry sharedInstance;
+   if(!m_instance)
+   {
+      m_instance = new ossimProjectionFactoryRegistry();
+   }
    
-
-   return &sharedInstance;
+   return m_instance;
 }
 
 ossimProjection*
@@ -52,35 +55,22 @@ ossimProjectionFactoryRegistry::createProjection(const ossimFilename& name,
                                                  ossim_uint32 entryIdx)const
 {
    ossimProjection* result = 0;
-   std::vector<ossimProjectionFactoryBase*>::const_iterator factory = theFactoryList.begin();
-
-   while( (factory != theFactoryList.end()) && !result )
+   ossim_uint32 idx = 0;
+   for(idx = 0; ((idx < m_factoryList.size())&&(!result)); ++idx)
    {
-      if(*factory)
-      {
-         result = (*factory)->createProjection(name, entryIdx);
-      }
-      
-      ++factory;
+      result = m_factoryList[idx]->createProjection(name, entryIdx);
    }
    
    return result;
 }
 
-ossimProjection* ossimProjectionFactoryRegistry::createProjection(const ossimString& name)const
+ossimProjection* ossimProjectionFactoryRegistry::createProjection(ossimImageHandler* handler)const
 {
    ossimProjection* result = 0;
-   std::vector<ossimProjectionFactoryBase*>::const_iterator factory = theFactoryList.begin();
-
-   while((factory != theFactoryList.end()&&!
-          result))
+   ossim_uint32 idx = 0;
+   for(idx = 0; ((idx < m_factoryList.size())&&(!result)); ++idx)
    {
-      if(*factory)
-      {
-         result = (*factory)->createProjection(name);
-      }
-      
-      ++factory;
+      result = m_factoryList[idx]->createProjection(handler);
    }
    
    return result;
@@ -89,18 +79,7 @@ ossimProjection* ossimProjectionFactoryRegistry::createProjection(const ossimStr
 ossimProjection* ossimProjectionFactoryRegistry::createProjection(
    const ossimKeywordlist& kwl, const char* prefix)const
 {
-   ossimProjection* result = 0;
-   std::vector<ossimProjectionFactoryBase*>::const_iterator factory = theFactoryList.begin();
-
-   while( (factory != theFactoryList.end()) && !result )
-   {
-      if(*factory)
-      {
-         result = (*factory)->createProjection(kwl, prefix);
-      }
-      
-      ++factory;
-   }
+   ossimProjection* result = createNativeObjectFromRegistry(kwl, prefix);
 
    if ( (result == 0) && (prefix == 0) )
    {
@@ -140,15 +119,10 @@ ossimProjection* ossimProjectionFactoryRegistry::createProjection(
                   bFoundImageLine = true;
                   ossimString s2 = v[0];
                   s2 += ".";
-                  factory = theFactoryList.begin();
-                  while( (factory != theFactoryList.end()) && !result )
+                  ossim_uint32 idx = 0;
+                  for(;((idx < m_factoryList.size())&&!result); ++idx)
                   {
-                     if(*factory)
-                     {
-                        result = (*factory)->createProjection(kwl, s2.c_str());
-                     }
-                     
-                     ++factory;
+                     result =  m_factoryList[idx]->createProjection(kwl, s2.c_str());
                   }
                }
             }
@@ -162,79 +136,15 @@ ossimProjection* ossimProjectionFactoryRegistry::createProjection(
    return result;
 }
 
-bool ossimProjectionFactoryRegistry::registerFactory(
-   ossimProjectionFactoryBase* factory, bool pushToFrontFlag)
-{
-   if( factory && !findFactory(factory) )
-   {
-      if (pushToFrontFlag)
-      {
-         theFactoryList.insert(theFactoryList.begin(), factory);
-      }
-      else
-      {
-         theFactoryList.push_back(factory);
-      }
-      return true;
-   }
-
-   return false;
-}
-
-void ossimProjectionFactoryRegistry::unregisterFactory(ossimProjectionFactoryBase* factory)
-{
-   std::vector<ossimProjectionFactoryBase*>::iterator iter =  std::find(theFactoryList.begin(),
-                                                                        theFactoryList.end(),
-                                                                        factory);
-   if(iter != theFactoryList.end())
-   {
-      theFactoryList.erase(iter);
-   }
-}
-
-bool ossimProjectionFactoryRegistry::findFactory(ossimProjectionFactoryBase* factory)const
-{
-   return (std::find(theFactoryList.begin(),
-                     theFactoryList.end(),
-                     factory)!=theFactoryList.end());
-}
-
-ossimObject* ossimProjectionFactoryRegistry::createObject(const ossimString& typeName)const
-{
-   return createProjection(typeName);
-}
-
-ossimObject* ossimProjectionFactoryRegistry::createObject(const ossimKeywordlist& kwl,
-                                                          const char* prefix)const
-{
-   return createProjection(kwl, prefix);
-}
-
-void ossimProjectionFactoryRegistry::getTypeNameList(
-   std::vector<ossimString>& typeList)const
-{
-   std::vector<ossimProjectionFactoryBase*>::const_iterator factory =
-      theFactoryList.begin();
-
-   while(factory != theFactoryList.end())
-   {
-      if(*factory)
-      {
-         (*factory)->getTypeNameList(typeList);
-      }
-      ++factory;
-   }   
-}
-
 void ossimProjectionFactoryRegistry::initializeDefaults()
 {
+   registerFactory(ossimNitfProjectionFactory::instance());   
    registerFactory(ossimSensorModelFactory::instance());
+   registerFactory(ossimTiffProjectionFactory::instance());
    registerFactory(ossimMapProjectionFactory::instance());
    registerFactory(ossimSrsProjectionFactory::instance());
-   registerFactory(ossimTiffProjectionFactory::instance());
    registerFactory(ossimPcsCodeProjectionFactory::instance());   
    registerFactory(ossimStatePlaneProjectionFactory::instance());
-   registerFactory(ossimNitfProjectionFactory::instance());   
    registerFactory(ossimMiscProjectionFactory::instance());
 }
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimRadialDecentLensDistortion.cpp b/Utilities/otbossim/src/ossim/projection/ossimRadialDecentLensDistortion.cpp
index ec735a853c8c583bec1737819cd7fa8fd137b3d3..fd679964e7ad406dc2904f651668c5f73b9f52b7 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimRadialDecentLensDistortion.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimRadialDecentLensDistortion.cpp
@@ -10,7 +10,7 @@
 // MeanRadialLens distortion.
 //
 //*******************************************************************
-//  $Id: ossimRadialDecentLensDistortion.cpp 13010 2008-06-08 21:12:45Z dburken $
+//  $Id: ossimRadialDecentLensDistortion.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <ossim/projection/ossimRadialDecentLensDistortion.h>
@@ -114,9 +114,7 @@ bool ossimRadialDecentLensDistortion::saveState(ossimKeywordlist& kwl,
               key.c_str(),
               theRadialDistortionParameters[i],
               true,  // overwrite
-              15,    // precision
-              false, // trim zeroes
-              true); // scientific
+              15); // scientific
 
       //---
       // Decentering distortion coefficients:
@@ -127,9 +125,7 @@ bool ossimRadialDecentLensDistortion::saveState(ossimKeywordlist& kwl,
               key.c_str(),
               theDecentDistortionParameters[i],
               true,  // overwrite
-              15,    // precision
-              false, // trim zeroes
-              true); // scientific
+              15); // scientific
    }
 
    //***
diff --git a/Utilities/otbossim/src/ossim/projection/ossimRpcModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimRpcModel.cpp
index 81c4c9c16a8fddfa1a1f0419f3843a983f15d67c..5148de0cfd582830be82c14e1c041c5efa600988 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimRpcModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimRpcModel.cpp
@@ -13,7 +13,7 @@
 // LIMITATIONS: Does not support parameter adjustment (YET)
 //
 //*****************************************************************************
-//  $Id: ossimRpcModel.cpp 11522 2007-08-07 21:57:59Z dburken $
+//  $Id: ossimRpcModel.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimRpcModel.h>
 
@@ -826,22 +826,22 @@ bool ossimRpcModel::saveState(ossimKeywordlist& kwl,
       key = LINE_NUM_COEF_KW;
       key += os.str();
       kwl.add(prefix, key.c_str(), theLineNumCoef[i],
-              true, 15, false, true);
+              true, 15);
       
       key = LINE_DEN_COEF_KW;
       key += os.str();
       kwl.add(prefix, key.c_str(), theLineDenCoef[i],
-              true, 15, false, true);
+              true, 15);
 
       key = SAMP_NUM_COEF_KW;
       key += os.str();
       kwl.add(prefix, key.c_str(), theSampNumCoef[i],
-              true, 15, false, true);
+              true, 15);
 
       key = SAMP_DEN_COEF_KW;
       key += os.str();
       kwl.add(prefix, key.c_str(), theSampDenCoef[i],
-              true, 15, false, true);
+              true, 15);
    }
       
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::saveState(): returning..." << std::endl;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimRpcProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimRpcProjection.cpp
index 14fd890209b70592769b48700b3dbd4801dde9b9..134dde8e07a858ce94b9e2f262f04a3e923a2536 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimRpcProjection.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimRpcProjection.cpp
@@ -8,7 +8,7 @@
 // AUTHOR: Garrett Potts
 //
 //*****************************************************************************
-//$Id: ossimRpcProjection.cpp 13770 2008-10-22 19:33:24Z gpotts $
+//$Id: ossimRpcProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimRpcProjection.h>
@@ -16,6 +16,7 @@
 #include <ossim/base/ossimEcefPoint.h>
 #include <ossim/base/ossimEcefVector.h>
 #include <ossim/base/ossimTieGptSet.h>
+#include <ossim/imaging/ossimImageGeometry.h>
 
 RTTI_DEF3(ossimRpcProjection, "ossimRpcProjection", ossimProjection, ossimOptimizableProjection,
           ossimAdjustableParameterInterface);
@@ -1030,14 +1031,14 @@ ossimRpcProjection::optimizeFit(const ossimTieGptSet& tieSet, double* targetVari
 {
 #if 1
    //NOTE : ignore targetVariance
-   ossimRpcSolver solver(false, false); //TBD : choices should be part of setupFromString
+   ossimRefPtr<ossimRpcSolver> solver = new ossimRpcSolver(false, false); //TBD : choices should be part of setupFromString
 
    std::vector<ossimDpt> imagePoints;
    std::vector<ossimGpt> groundPoints;
    tieSet.getSlaveMasterPoints(imagePoints, groundPoints);
-   solver.solveCoefficients(imagePoints, groundPoints);
+   solver->solveCoefficients(imagePoints, groundPoints);
 
-   ossimRefPtr< ossimRpcProjection > optProj = solver.createRpcProjection();
+   ossimRefPtr< ossimImageGeometry > optProj = solver->createRpcProjection();
    if (!optProj)
    {
       ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::optimizeFit(): error when optimizing the RPC with given tie points"
@@ -1045,11 +1046,14 @@ ossimRpcProjection::optimizeFit(const ossimTieGptSet& tieSet, double* targetVari
       return -1.0;
    }
 
-   ossimKeywordlist kwl;
-   optProj->saveState(kwl);
-   this->loadState(kwl);
+   if(optProj->hasProjection())
+   {
+      ossimKeywordlist kwl;
+      optProj->getProjection()->saveState(kwl);
+      this->loadState(kwl);
+   }
 
-   return std::pow(solver.getRmsError(), 2); //variance in pixel^2
+   return std::pow(solver->getRmsError(), 2); //variance in pixel^2
 #else
    // COPIED from ossimRpcProjection
    //
diff --git a/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp b/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp
index 3dabb1b02c05d5c7a19aa63e359946d9c210aae2..b20b5fb9aa1edd7fbbafbbdfb3fb00d7ef33eb22 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp
@@ -1,16 +1,14 @@
 //*****************************************************************************
 // FILE: ossimRpcModel.h
 //
-// Copyright (C) 2004 Intelligence Data Systems, Inc.
-//
-// LICENSE: LGPL
-//
-// see top level LICENSE.txt
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR: Garrett Potts
 //
 //*****************************************************************************
-//  $Id: ossimRpcSolver.cpp 13559 2008-09-10 11:16:12Z gpotts $
+//  $Id: ossimRpcSolver.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstdlib>
 #include <ctime>
@@ -27,7 +25,8 @@
 #include <ossim/matrix/newmatio.h>
 #include <ossim/elevation/ossimElevManager.h>
 #include <ossim/support_data/ossimNitfRpcBTag.h>
-
+#include <ossim/imaging/ossimImageGeometry.h>
+#include <ossim/base/ossim2dTo2dIdentityTransform.h>
 ossimRpcSolver::ossimRpcSolver(bool useElevation,
                                bool useHeightAboveMSLFlag)
 {
@@ -53,7 +52,18 @@ ossimRpcSolver::ossimRpcSolver(bool useElevation,
 }
 
 void ossimRpcSolver::solveCoefficients(const ossimDrect& imageBounds,
-                                       const ossimProjection& proj,
+                                       ossimProjection* proj,
+                                       ossim_uint32 xSamples,
+                                       ossim_uint32 ySamples,
+                                       bool shiftTo0Flag)
+{
+   ossimRefPtr<ossimImageGeometry> geom = new ossimImageGeometry();
+   geom->setProjection(proj);
+   solveCoefficients(imageBounds, geom.get(), xSamples, ySamples, shiftTo0Flag);
+}
+
+void ossimRpcSolver::solveCoefficients(const ossimDrect& imageBounds,
+                                       ossimImageGeometry* geom,
                                        ossim_uint32 xSamples,
                                        ossim_uint32 ySamples,
                                        bool shiftTo0Flag)
@@ -101,8 +111,7 @@ void ossimRpcSolver::solveCoefficients(const ossimDrect& imageBounds,
          ossimDpt dpt(w*xnorm + ul.x,
                       h*ynorm + ul.y);
          
-         proj.lineSampleToWorld(dpt,
-                                gpt);
+         geom->localToWorld(dpt, gpt);
          gpt.changeDatum(defaultGround.datum());
 
          if(shiftTo0Flag)
@@ -386,7 +395,7 @@ void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
    theError = sqrt(sumSquareError/imagePoints.size());
 }
 
-ossimRefPtr<ossimRpcModel> ossimRpcSolver::createRpcModel()const
+ossimImageGeometry* ossimRpcSolver::createRpcModel()const
 {
    ossimRpcModel* model = new ossimRpcModel;
    
@@ -404,10 +413,10 @@ ossimRefPtr<ossimRpcModel> ossimRpcSolver::createRpcModel()const
                         theXDenCoeffs,
                         theYNumCoeffs,
                         theYDenCoeffs);
-   return model;
+   return new ossimImageGeometry(new ossim2dTo2dIdentityTransform, model);
 }
 
-ossimRefPtr<ossimRpcProjection> ossimRpcSolver::createRpcProjection()const
+ossimImageGeometry* ossimRpcSolver::createRpcProjection()const
 {
    ossimRpcProjection* proj = new ossimRpcProjection;
    
@@ -425,7 +434,7 @@ ossimRefPtr<ossimRpcProjection> ossimRpcSolver::createRpcProjection()const
                        theXDenCoeffs,
                        theYNumCoeffs,
                        theYDenCoeffs);
-   return proj;
+   return new ossimImageGeometry(new ossim2dTo2dIdentityTransform, proj);
 }
 
 const std::vector<double>& ossimRpcSolver::getImageXNumCoefficients()const
@@ -669,7 +678,7 @@ void ossimRpcSolver::setupSystemOfEquations(NEWMAT::Matrix& equations,
       equations[idx][14] = x[idx]*x[idx]*y[idx];
       equations[idx][15] = y[idx]*y[idx]*y[idx];
       equations[idx][16] = y[idx]*z[idx]*z[idx];
-      equations[idx][17] = z[idx]*x[idx]*z[idx];
+      equations[idx][17] = x[idx]*x[idx]*z[idx];
       equations[idx][18] = y[idx]*y[idx]*z[idx];
       equations[idx][19] = z[idx]*z[idx]*z[idx];
       equations[idx][20] = -f[idx]*x[idx];
@@ -688,7 +697,7 @@ void ossimRpcSolver::setupSystemOfEquations(NEWMAT::Matrix& equations,
       equations[idx][33] = -f[idx]*x[idx]*x[idx]*y[idx];
       equations[idx][34] = -f[idx]*y[idx]*y[idx]*y[idx];
       equations[idx][35] = -f[idx]*y[idx]*z[idx]*z[idx];
-      equations[idx][36] = -f[idx]*z[idx]*x[idx]*z[idx];
+      equations[idx][36] = -f[idx]*x[idx]*x[idx]*z[idx];
       equations[idx][37] = -f[idx]*y[idx]*y[idx]*z[idx];
       equations[idx][38] = -f[idx]*z[idx]*z[idx]*z[idx];
    }
@@ -725,7 +734,7 @@ void ossimRpcSolver::setupWeightMatrix(NEWMAT::DiagonalMatrix& result, // holds
        row[14] = x[idx]*x[idx]*y[idx];
        row[15] = y[idx]*y[idx]*y[idx];
        row[16] = y[idx]*z[idx]*z[idx];
-       row[17] = z[idx]*x[idx]*z[idx];
+       row[17] = x[idx]*x[idx]*z[idx];
        row[18] = y[idx]*y[idx]*z[idx];
        row[19] = z[idx]*z[idx]*z[idx];
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp
index 3429ddfc4a56e8f3c3cd3399404beaf5efbcf36f..3dcf0316926370ed771bece89ca34a5807a149d8 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp
@@ -1,7 +1,9 @@
 //*****************************************************************************
 // FILE: ossimSensorModel.cc
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR: Oscar Kramer
 //
@@ -25,7 +27,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimSensorModel.cpp 13771 2008-10-22 19:33:54Z gpotts $
+//  $Id: ossimSensorModel.cpp 14538 2009-05-18 13:31:58Z dburken $
 #include <iostream>
 #include <sstream>
 using namespace std;
@@ -439,7 +441,6 @@ std::ostream& ossimSensorModel::print(std::ostream& out) const
        << "\n        theRefGndPt: " << theRefGndPt
        << "\n        theRefImgPt: " << theRefImgPt
        << "\n theBoundGndPolygon: \n" << theBoundGndPolygon
-       << "\n theBoundGndPolygon: " << theBoundGndPolygon
        << "\n   theImageClipRect: " << theImageClipRect
        << "\n theNominalPosError: " << theNominalPosError
        << endl;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp
index b915661ca224fbc5131f7e5bff4748e81628154b..607e2a1e94a87efcdd1ce1eb3369e07678dd7802 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp
@@ -1,7 +1,9 @@
 //*****************************************************************************
 // FILE: ossimSensorModelFactory.cc
 //
-// License:  See LICENSE.txt file in the top level directory.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // AUTHOR:  Oscar Kramer
 //
@@ -9,7 +11,7 @@
 //   Contains implementation of class ossimSensorModelFactory
 //
 //*****************************************************************************
-//  $Id: ossimSensorModelFactory.cpp 13027 2008-06-15 01:37:00Z dburken $
+//  $Id: ossimSensorModelFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <fstream>
 #include <algorithm>
 #include <ossim/projection/ossimSensorModelFactory.h>
@@ -33,6 +35,7 @@ static ossimTrace traceDebug = ossimTrace("ossimSensorModelFactory:debug");
 //***
 #include <ossim/projection/ossimCoarseGridModel.h>
 #include <ossim/projection/ossimRpcModel.h>
+#include <ossim/projection/ossimRpcProjection.h>
 #include <ossim/projection/ossimIkonosRpcModel.h>
 #include <ossim/projection/ossimNitfRpcModel.h>
 #include <ossim/projection/ossimQuickbirdRpcModel.h>
@@ -71,7 +74,7 @@ ossimSensorModelFactory* ossimSensorModelFactory::theInstance = 0;
 
 //*****************************************************************************
 //  STATIC METHOD: ossimSensorModelFactory::instance()
-//
+//  
 //*****************************************************************************
 ossimSensorModelFactory*  ossimSensorModelFactory::instance()
 {
@@ -89,7 +92,7 @@ ossimSensorModelFactory*  ossimSensorModelFactory::instance()
 ossimProjection* ossimSensorModelFactory::createProjection(const ossimKeywordlist &keywordList,
                                                            const char *prefix) const
 {
-   ossimProjection *result=NULL;
+   ossimRefPtr<ossimProjection> result;
 
    //
    // Permit specification of geometry file name in lieu of type:
@@ -108,23 +111,22 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimKeywordlis
       if(value)
       {
          result = createProjection(ossimString(value));
-         if(result)
+         if(result.valid())
          {
             if(!result->loadState(keywordList, prefix))
             {
-               delete result;
-               result = NULL;
+               result = 0;
             }
-         }
+        }
       }
    }
-
-   return result;
+   
+   return result.release();
 }
 
 //*****************************************************************************
-//  METHOD:
-//
+//  METHOD: 
+//  
 //*****************************************************************************
 ossimProjection*
 ossimSensorModelFactory::createProjection(const ossimString &name) const
@@ -156,7 +158,7 @@ ossimSensorModelFactory::createProjection(const ossimString &name) const
    {
       return new ossimQuickbirdRpcModel;
    }
-
+   
    if(name == STATIC_TYPE_NAME(ossimIkonosRpcModel))
    {
      return new ossimIkonosRpcModel;
@@ -164,7 +166,11 @@ ossimSensorModelFactory::createProjection(const ossimString &name) const
 
    if(name == STATIC_TYPE_NAME(ossimNitfRpcModel))
    {
-       return new ossimNitfRpcModel;
+      return new ossimNitfRpcModel;
+   }
+   if(name == STATIC_TYPE_NAME(ossimRpcProjection))
+   {
+      return new ossimRpcProjection;
    }
    if(name == STATIC_TYPE_NAME(ossimFcsiModel))
    {
@@ -243,7 +249,7 @@ ossimSensorModelFactory::createObject(const ossimKeywordlist& kwl,
 {
    return createProjection(kwl, prefix);
 }
-
+   
 //*****************************************************************************
 //  METHOD
 //*****************************************************************************
@@ -274,32 +280,31 @@ ossimSensorModelFactory::getTypeNameList(std::vector<ossimString>& typeList)
    // ADD_MODEL: Please leave this comment for the next programmer. Add above.
    //***
    //typeList.push_back(ossimString(MY_NEW_MODEL));
-
+   
 }
 
 ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename& filename,
                                                            ossim_uint32  entryIdx) const
 {
    ossimKeywordlist kwl;
-   ossimProjection* model = 0;
+   ossimRefPtr<ossimProjection> model = 0;
 
    ossimFilename geomFile = filename;
    geomFile = geomFile.setExtension("geom");
-
+   
    if(geomFile.exists()&&
       kwl.addFile(filename.c_str()))
    {
       ossimFilename coarseGrid;
-
+      
       const char* type = kwl.find(ossimKeywordNames::TYPE_KW);
       if(type)
       {
-//          if(ossimString(type) == ossimString(STATIC_TYPE_NAME(ossimCoarseGridModel)))
-         if(ossimString(type) == STATIC_TYPE_NAME(ossimCoarseGridModel))
+         if(ossimString(type) == ossimString(STATIC_TYPE_NAME(ossimCoarseGridModel)))
          {
             findCoarseGrid(coarseGrid,
                            filename);
-
+            
             if(coarseGrid.exists() &&(coarseGrid != ""))
             {
                kwl.add("grid_file_name",
@@ -308,7 +313,7 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
                model = new ossimCoarseGridModel(kwl);
                if(!model->getErrorStatus())
                {
-                  return model;
+                  return model.release();
                }
             }
          }
@@ -317,16 +322,15 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
    }
 
    // See if there is an external geomtry.
-   ossimProjection* proj = createProjectionFromGeometryFile(filename,
+   ossimRefPtr<ossimProjection> proj = createProjectionFromGeometryFile(filename,
                                                             entryIdx);
-   if (proj)
+   if (proj.valid())
    {
-      return proj;
+      return proj.release();
    }
 
-   if(model)
+   if(model.valid())
    {
-      delete model;
       model = 0;
    }
    // first check for override
@@ -335,16 +339,16 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
    {
       model =  createProjection(kwl);
    }
-   if(model)
+   if(model.valid())
    {
-      return model;
+      return model.release();
    }
 
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModelFactory::createProjection: Testing ossimCoarsGridModel" << std::endl;
    }
-
+   
    ifstream input(geomFile.c_str());
    char ecgTest[4];
    input.read((char*)ecgTest, 3);
@@ -361,7 +365,7 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
                   true);
       return createProjection(kwlTemp);
    }
-
+   
    if(traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModelFactory::createProjection: testing ossimRpcModel" << std::endl;
@@ -378,8 +382,9 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
          << "testing ossimQuickbirdRpcModel"
          << std::endl;
    }
-
+   
    ossimQuickbirdRpcModel* qbModel = new ossimQuickbirdRpcModel;
+   model = qbModel;
    if(qbModel->parseFile(filename))
    {
       if(traceDebug())
@@ -388,20 +393,18 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
             << "DEBUG ossimSensorModelFactory::createProjection: "
             << "returning ossimQuickbirdRpcModel" << std::endl;
       }
-      model = qbModel;
-      return model;
+      return model.release();
    }
    else
    {
-      delete qbModel;
-      qbModel = NULL;
+      model = 0;
    }
-
    //---
    // Test for ikonos rpc.  Could be tiff or nitf which is handled in
    // parseFile method.
    //---
    ossimIkonosRpcModel* ikModel = new ossimIkonosRpcModel;
+   model = ikModel;
    if(ikModel->parseFile(filename))
    {
       if(traceDebug())
@@ -410,13 +413,11 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
             << "DEBUG ossimSensorModelFactory::createProjection: "
             << "returning ossimQuickbirdRpcModel" << std::endl;
       }
-      model = ikModel;
-      return model;
+      return model.release();
    }
    else
    {
-      delete ikModel;
-      ikModel = 0;
+      model = 0;
    }
 
    if(isNitf(filename))
@@ -428,36 +429,35 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
            << " testing ossimNitfRpcModel" << std::endl;
      }
 
-     model = new ossimNitfRpcModel(filename);  // filename = NITF_file
-     if(!model->getErrorStatus())
+     ossimNitfRpcModel* rpcModel = new ossimNitfRpcModel();
+      model = rpcModel;
+     if ( rpcModel->parseFile(filename, entryIdx) ) // filename = NITF_file
      {
-        return model;
+        return model.release();
      }
-     delete model;
      model = 0;
-
+     
      if(traceDebug())
      {
-        ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModelFactory::createProjection: testing ossimIkinosRpcModel" << std::endl;
+        ossimNotify(ossimNotifyLevel_DEBUG)
+           << "DEBUG ossimSensorModelFactory::createProjection: "
+           << "testing ossimIkinosRpcModel" << std::endl;
      }
-
+     
      model = new ossimNitfMapModel(filename); // filename = NITF_file
      if(!model->getErrorStatus())
      {
-        return model;
+        return model.release();
      }
-     delete model;
-     model = 0;
    }
    else if(isLandsat(filename))
    {
       model = new ossimLandSatModel(filename);
       if(!model->getErrorStatus())
-         return model;
-      delete model;
-      model = 0;
+         return model.release();
    }
-
+   model = 0;
+   
    ossimFilename spot5Test = geomFile;
    if(!spot5Test.exists())
    {
@@ -469,36 +469,28 @@ ossimProjection* ossimSensorModelFactory::createProjection(const ossimFilename&
          spot5Test = spot5Test.dirCat(ossimFilename("metadata.dim"));
       }
    }
-
    if(spot5Test.exists())
    {
-      ossimSpotDimapSupportData *meta = new ossimSpotDimapSupportData;
+      ossimRefPtr<ossimSpotDimapSupportData> meta = new ossimSpotDimapSupportData;
       if(meta->loadXmlFile(spot5Test))
       {
-         model = new ossimSpot5Model(meta);
+         model = new ossimSpot5Model(meta.get());
          if(!model->getErrorStatus())
          {
-            return model;
+            return model.release();
          }
-         delete model;
          model = 0;
       }
-      else
-      {
-         delete meta;
-         meta = 0;
-      }
    }
-
+   
    model = new ossimCoarseGridModel(geomFile);
-   if(model)
+   if(model.valid())
    {
       if(!model->getErrorStatus())
-         return model;
-      delete model;
+         return model.release();
       model = 0;
    }
-   return model;
+   return model.release();
 }
 
 bool ossimSensorModelFactory::isTileMap(const ossimFilename& filename)const
@@ -511,11 +503,11 @@ bool ossimSensorModelFactory::isTileMap(const ossimFilename& filename)const
   }
   return false;
 }
-
+   
 bool ossimSensorModelFactory::isNitf(const ossimFilename& filename)const
 {
    std::ifstream in(filename.c_str(), ios::in|ios::binary);
-
+   
    if(in)
    {
       char nitfFile[4];
@@ -532,16 +524,17 @@ bool ossimSensorModelFactory::isLandsat(const ossimFilename& filename)const
 {
    ossimFilename temp(filename);
    temp.downcase();
-   ossimFfL7* ff_headerp = 0;
+   ossimRefPtr<ossimFfL7> ff_headerp;
    if (temp.contains("header.dat"))
    {
        ff_headerp = new ossimFfL5(filename);
-   } else {
+   } 
+   else 
+   {
        ff_headerp = new ossimFfL7(filename);
    }
    bool r = !(ff_headerp->getErrorStatus());
-
-   delete ff_headerp;
+   ff_headerp = 0;
    return r;
 }
 
@@ -551,13 +544,13 @@ void ossimSensorModelFactory::findCoarseGrid(ossimFilename& result,
    result = geomFile;
    result.setFile(result.fileNoExtension()+"_ocg");
    result.setExtension("dat");
-
+   
    if(!result.exists())
    {
       result = geomFile;
       result.setExtension("dat");
    }
-
+   
    // let's find a .dat file in the current directory
    //
    if(!result.exists())
@@ -584,7 +577,7 @@ void ossimSensorModelFactory::findCoarseGrid(ossimFilename& result,
                      result = file;
                   }
                }
-
+               
             }
          }while((directoryList.getNext(file))&&(result == ""));
       }
diff --git a/Utilities/otbossim/src/ossim/projection/ossimSpot5Model.cpp b/Utilities/otbossim/src/ossim/projection/ossimSpot5Model.cpp
index 24849e0bd8c6fd20c21f1f621f68fa9af7b8cbbc..897e121db03f85fa6759e876e632cf7c6805a06d 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimSpot5Model.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimSpot5Model.cpp
@@ -9,7 +9,7 @@
 // Contains definition of class ossimSpot5Model.
 //
 //*****************************************************************************
-// $Id: ossimSpot5Model.cpp 14206 2009-04-01 12:11:20Z gpotts $
+// $Id: ossimSpot5Model.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <iostream>
 #include <iomanip>
@@ -139,25 +139,15 @@ ossimSpot5Model::~ossimSpot5Model()
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG DESTRUCTOR: ~ossimSpot5Model(): entering..." << std::endl;
 
-   if (theSupportData)
-   {
-      delete theSupportData;
-      theSupportData = NULL;
-   }
-
+   theSupportData = 0;
+   
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG DESTRUCTOR: ~ossimSpot5Model(): returning..." << std::endl;
 }
 
 ossimSpot5Model::ossimSpot5Model(const ossimSpot5Model& rhs)
    :ossimSensorModel(rhs)
 {
-   if(theSupportData)
-   {
-
-      delete theSupportData;
-      theSupportData = 0;
-   }
-   if(rhs.theSupportData)
+   if(rhs.theSupportData.valid())
    {
       theSupportData = (ossimSpotDimapSupportData*)rhs.theSupportData->dup();
    }
@@ -493,16 +483,15 @@ std::ostream& ossimSpot5Model::print(std::ostream& out) const
 bool ossimSpot5Model::saveState(ossimKeywordlist& kwl,
                           const char* prefix) const
 {
-  if(theSupportData)
-    {
-      ossimString supportPrefix = ossimString(prefix) + "support_data.";
-      theSupportData->saveState(kwl, supportPrefix);
-    }
+  if(theSupportData.valid())
+  {
+     ossimString supportPrefix = ossimString(prefix) + "support_data.";
+     theSupportData->saveState(kwl, supportPrefix);
+  }
   else
-    {
-      return false;
-    }
-
+  {
+     return false;
+  }
 
    return ossimSensorModel::saveState(kwl, prefix);
 }
@@ -727,24 +716,25 @@ ossimSpot5Model::setupOptimizer(const ossimString& init_file)
    }
    if(spot5Test.exists())
    {
-      ossimSpotDimapSupportData *meta = new ossimSpotDimapSupportData;
+      ossimRefPtr<ossimSpotDimapSupportData> meta = new ossimSpotDimapSupportData;
       if(meta->loadXmlFile(spot5Test))
       {
-         initFromMetadata(meta);
+         initFromMetadata(meta.get());
          if (getErrorStatus())
          {
             tryKwl = true;
-            delete meta;
             meta=0;
          }
+         else
+         {
+            return true;
+         }
       }
       else
       {
-         delete meta;
          meta=0;
          tryKwl = true;
       }
-      return true;
    }
    if(tryKwl)
    {
diff --git a/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionFactory.cpp
index 3551210c3e9174dea15d9ca259b848c3956e2307..45e8a0a5bb215c872bf47a95ac185bd9872d9f81 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionFactory.cpp
@@ -4,7 +4,7 @@
 //
 // Author: Garrett Potts
 //*******************************************************************
-//  $Id: ossimStatePlaneProjectionFactory.cpp 13401 2008-08-07 18:07:30Z dburken $
+//  $Id: ossimStatePlaneProjectionFactory.cpp 15080 2009-08-15 19:32:07Z dburken $
 
 #include <fstream>
 #include <sstream>
@@ -152,7 +152,7 @@ ossimProjection* ossimStatePlaneProjectionFactory::createProjection(
    return result;
 }
 
-const ossimStatePlaneProjectionInfo* ossimStatePlaneProjectionFactory::getInfo(ossim_int32 pcsCode)const
+const ossimStatePlaneProjectionInfo* ossimStatePlaneProjectionFactory::getInfo(ossim_uint32 pcsCode)const
 {
    ossimStatePlaneProjectionInfo* info = findInInfoList(pcsCode);
    if (!info)
diff --git a/Utilities/otbossim/src/ossim/projection/ossimTiffProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimTiffProjectionFactory.cpp
index d3b7ca6102181617f7e7f48a2e0025bc8c0a7171..e3752a538fe13889336103b97c88cc82bdfc1a03 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimTiffProjectionFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimTiffProjectionFactory.cpp
@@ -7,7 +7,7 @@
 //   Contains implementation of class ossimTiffProjectionFactory
 //
 //*****************************************************************************
-//  $Id: ossimTiffProjectionFactory.cpp 12082 2007-11-26 21:46:44Z dburken $
+//  $Id: ossimTiffProjectionFactory.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimTiffProjectionFactory.h>
 #include <ossim/support_data/ossimGeoTiff.h>
@@ -16,6 +16,7 @@
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/imaging/ossimTiffTileSource.h>
 #include <fstream>
 
 ossimTiffProjectionFactory* ossimTiffProjectionFactory::theInstance = 0;
@@ -43,14 +44,6 @@ ossimTiffProjectionFactory::createProjection(const ossimFilename& filename,
       return NULL;
    }
 
-   // See if there is an external geomtry.
-   ossimProjection* result = createProjectionFromGeometryFile(filename,
-                                                              entryIdx);
-   if (result)
-   {
-      return result;
-   }
-
    if(isTiff(filename))
    {
       ossimGeoTiff geotiff(filename, entryIdx);
@@ -86,6 +79,27 @@ ossimProjection* ossimTiffProjectionFactory::createProjection(const ossimString
    return NULL;
 }
 
+ossimProjection* ossimTiffProjectionFactory::createProjection(ossimImageHandler* handler)const
+{
+   ossimTiffTileSource* tiff = dynamic_cast<ossimTiffTileSource*> (handler);
+   
+   if(tiff)
+   {
+      ossimGeoTiff geotiff;
+      ossimKeywordlist kwl;
+      
+      geotiff.readTags(tiff->tiffPtr(), tiff->getCurrentEntry(), false);
+      
+      if(geotiff.addImageGeometry(kwl))
+      {
+         return ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+      }
+      
+   }
+   
+   return 0;
+}
+
 ossimObject* ossimTiffProjectionFactory::createObject(const ossimString& typeName)const
 {
    return (ossimObject*)createProjection(typeName);
diff --git a/Utilities/otbossim/src/ossim/projection/ossimWarpProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimWarpProjection.cpp
index 02f9b0cd395e27898b2d415f4c3cb11f4b9b7fba..4bf533856d60a8e7eb29dc38a9c9a31f4fc91e98 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimWarpProjection.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimWarpProjection.cpp
@@ -9,7 +9,7 @@
 //   implementation of a warping interpolation model.
 //
 //*****************************************************************************
-//  $Id: ossimWarpProjection.cpp 11806 2007-10-05 14:55:57Z dburken $
+//  $Id: ossimWarpProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/projection/ossimWarpProjection.h>
 RTTI_DEF1(ossimWarpProjection, "ossimWarpProjection", ossimProjection);
@@ -93,21 +93,9 @@ ossimWarpProjection::ossimWarpProjection(const ossimKeywordlist& geom_kwl,
 //*****************************************************************************
 ossimWarpProjection::~ossimWarpProjection()
 {
-   if(theClientProjection)
-   {
-      delete theClientProjection;
-      theClientProjection = 0;
-   }
-   if(theWarpTransform)
-   {
-      delete theWarpTransform;
-      theWarpTransform = 0;
-   }
-   if(theAffineTransform)
-   {
-      delete theAffineTransform;
-      theAffineTransform = 0;
-   }
+   theClientProjection = 0;
+   theWarpTransform = 0;
+   theAffineTransform = 0;
 }
 
 //*****************************************************************************
@@ -118,7 +106,7 @@ void ossimWarpProjection::worldToLineSample (const ossimGpt& worldPoint,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimWarpProjection::worldToLineSample: Entering..." << std::endl;
 
-   if (theClientProjection && theWarpTransform && theAffineTransform)
+   if (theClientProjection.valid() && theWarpTransform.valid() && theAffineTransform.valid())
    {
       theClientProjection->worldToLineSample(worldPoint, lineSampPt);
       theAffineTransform->inverse(lineSampPt);
@@ -140,7 +128,7 @@ void ossimWarpProjection::lineSampleToWorld(const ossimDpt& lineSampPt,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimWarpProjection::lineSampleToWorld: Entering..." << std::endl;
 
-   if (theClientProjection && theWarpTransform && theAffineTransform)
+   if (theClientProjection.valid() && theWarpTransform.valid() && theAffineTransform.valid())
    {
       ossimDpt adjustedPt;
       theWarpTransform->forward(adjustedPt);
@@ -164,7 +152,7 @@ void ossimWarpProjection::lineSampleHeightToWorld(const ossimDpt& lineSampPt,
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimWarpProjection::lineSampleHeightToWorld: Entering..." << std::endl;
 
-   if (theClientProjection && theWarpTransform && theAffineTransform)
+   if (theClientProjection.valid() && theWarpTransform.valid() && theAffineTransform.valid())
    {
       ossimDpt adjustedPt;
       theAffineTransform->forward(lineSampPt, adjustedPt);
@@ -184,7 +172,7 @@ void ossimWarpProjection::lineSampleHeightToWorld(const ossimDpt& lineSampPt,
 //*****************************************************************************
 std::ostream& ossimWarpProjection::print(std::ostream& out) const
 {
-   if (theClientProjection && theWarpTransform && theAffineTransform)
+   if (theClientProjection.valid() && theWarpTransform.valid() && theAffineTransform.valid())
    {
       out <<
          "ossimWarpProjection:\n"
@@ -218,7 +206,7 @@ bool ossimWarpProjection::saveState(ossimKeywordlist& kwl,
    ossimString affinePrefix   = ossimString(prefix) + AFFINE_PREFIX;
    ossimString quadwarpPrefix = ossimString(prefix) + QUADWARP_PREFIX;
 
-   if (theClientProjection && theWarpTransform && theAffineTransform)
+   if (theClientProjection.valid() && theWarpTransform.valid() && theAffineTransform.valid())
    {
       theClientProjection->saveState(kwl, projPrefix.c_str());
       theAffineTransform->saveState(kwl, affinePrefix.c_str());
@@ -245,8 +233,7 @@ bool ossimWarpProjection::loadState(const ossimKeywordlist& kwl,
    ossimString affinePrefix = ossimString(prefix) + AFFINE_PREFIX;
    ossimString quadwarpPrefix = ossimString(prefix) + QUADWARP_PREFIX;
 
-   if(theClientProjection) delete theClientProjection;
-   theClientProjection = (ossimProjection*)0;
+   theClientProjection = 0;
 
    if (!theWarpTransform)
       theWarpTransform = new ossimQuadTreeWarp();
@@ -257,15 +244,15 @@ bool ossimWarpProjection::loadState(const ossimKeywordlist& kwl,
    theClientProjection = ossimProjectionFactoryRegistry::instance()->createProjection(kwl, projPrefix.c_str());
 
    if(!theClientProjection)
-     {
-       result = false;
-     }
+   {
+      result = false;
+   }
    else
-     {
-       theWarpTransform->loadState(kwl,   quadwarpPrefix.c_str());
-       theAffineTransform->loadState(kwl, affinePrefix.c_str());
-     }
-
+   {
+      theWarpTransform->loadState(kwl,   quadwarpPrefix.c_str());
+      theAffineTransform->loadState(kwl, affinePrefix.c_str());
+   }
+   
    return ossimProjection::loadState(kwl, prefix);
 }
 
@@ -284,7 +271,7 @@ ossimObject* ossimWarpProjection::dup() const
 //*****************************************************************************
 ossimGpt ossimWarpProjection::origin() const
 {
-   if (theClientProjection)
+   if (theClientProjection.valid())
       return theClientProjection->origin();
    return ossimGpt(0.0, 0.0, 0.0);
 }
@@ -294,7 +281,7 @@ ossimGpt ossimWarpProjection::origin() const
 //*****************************************************************************
 ossimDpt  ossimWarpProjection::getMetersPerPixel() const
 {
-   if (theClientProjection)
+   if (theClientProjection.valid())
       return theClientProjection->getMetersPerPixel();
    return ossimDpt(ossim::nan(), ossim::nan());
 }
@@ -304,11 +291,6 @@ void ossimWarpProjection::setNewWarpTransform(ossim2dTo2dTransform* warp)
 {
    if(warp)
    {
-      if(theWarpTransform)
-      {
-         delete theWarpTransform;
-         theWarpTransform = 0;
-      }
       theWarpTransform = warp;
    }
 }
@@ -317,11 +299,6 @@ void ossimWarpProjection::setNewAffineTransform(ossim2dTo2dTransform* affine)
 {
    if(affine)
    {
-      if(theAffineTransform)
-      {
-         delete theAffineTransform;
-         theAffineTransform = 0;
-      }
       theAffineTransform = affine;
    }
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp b/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp
index 16c0df673b9b8fe0f770104e3d7db306f58d4203..0edfbbfbfcd5ec6bc9010988af4c7c85eceefbe1 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp
@@ -1,6 +1,8 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Ken Melero
 //         Orginally written by Jamie Moyers (jmoyers@geeks.com)
@@ -8,12 +10,15 @@
 // Description: This class parses a DEM header.
 //
 //********************************************************************
-// $Id: ossimDemHeader.cpp 13694 2008-10-08 20:16:02Z dburken $
+// $Id: ossimDemHeader.cpp 15327 2009-09-01 20:31:16Z dburken $
 
+#include <fstream>
 #include <iostream>
 #include <iomanip>
 #include <ossim/support_data/ossimDemHeader.h>
 #include <ossim/support_data/ossimDemUtil.h>
+
+#include <ossim/base/ossimFilename.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimConstants.h>
@@ -57,7 +62,7 @@ static const char* VERTICAL_DATUM[]
 static const int MAX_VERTICAL_DATUM_INDEX = 2;
 
 static const char* HORIZONTAL_DATUM[]
-= { "North Amercian Datum 1927 (NAD 27)",
+= { "North American Datum 1927 (NAD 27)",
     "World Geoditic System 1972 (WGS 72)",
     "WGS 84",
     "NAD 83",
@@ -365,198 +370,266 @@ operator<<(std::ostream& s, const ossimDemHeader& header)
    return header.print(s);
 }
 
-std::ostream& ossimDemHeader::print(std::ostream& s) const
+bool ossimDemHeader::open(const ossimFilename& file)
 {
-   // Note:  This is only a partial print for now...
+   bool result = ossimDemUtil::isUsgsDem(file);
+   std::ifstream is(file.c_str(), std::ios_base::in | std::ios_base::binary);
+   if ( is.good() )
+   {
+      open(is);
+      is.close();
+   }
+   else
+   {
+      result = false;
+   }
+   return result;
+}
+
+std::istream& ossimDemHeader::open(std::istream& is)
+{
+   if ( is.good() )
+   {
+      char* bufstr = new char[1024];
+      char* temp   = new char[1024];
+      ossim_int32 i;
+      
+      ossimDemUtil::getRecord(is, bufstr);
+      
+      strncpy(temp, bufstr, 40);
+      temp[40] = '\0';
+      _quadName = temp;
+      
+      strncpy(temp,bufstr+40,40);
+      temp[40] = '\0';
+      _processInfo = temp;
+      
+      ossimDemUtil::getDouble(bufstr, 109, 13, _seGeoCornerX);
+      ossimDemUtil::getDouble(bufstr, 122, 13, _seGeoCornerY);
+      _processCode = ossimDemUtil::getLong(bufstr, 135, 1);
+      
+      strncpy(temp,bufstr+137,3);
+      temp[3] = '\0';
+      _sectionIndicator = temp;
+      
+      strncpy(temp,bufstr+140,4);
+      temp[4] = '\0';
+      _mapCenterCode = temp;
+      
+      _levelCode = ossimDemUtil::getLong(bufstr, 144, 6);
+      _elevPattern = ossimDemUtil::getLong(bufstr, 150, 6);
+      _groundRefSysCode = ossimDemUtil::getLong(bufstr, 156, 6);
+      _groundRefSysZone = ossimDemUtil::getLong(bufstr, 162, 6);
+      _groundRefSysUnits = ossimDemUtil::getLong(bufstr, 528, 6);
+      _elevUnits = ossimDemUtil::getLong(bufstr, 534, 6);
+      _numPolySides = ossimDemUtil::getLong(bufstr, 540, 6);
+      
+      for (i = 0; i < 4; i++)
+      {
+         double x,y;
+         ossim_int32 pos = 546 + (i * 48);
+         ossimDemUtil::getDouble(bufstr, pos, 24, x);
+         ossimDemUtil::getDouble(bufstr, pos + 24, 24, y);
+      _demCorners.push_back(ossimDemPoint(x,y));
+      }
+      
+      ossimDemUtil::getDouble(bufstr, 738, 24, _minElevation);
+      ossimDemUtil::getDouble(bufstr, 762, 24, _maxElevation);
+      ossimDemUtil::getDouble(bufstr, 786, 24, _counterclockAngle );
+      _elevAccuracyCode = ossimDemUtil::getLong(bufstr, 810, 6);
+      ossimDemUtil::getDouble(bufstr, 816, 12, _spatialResX);
+      ossimDemUtil::getDouble(bufstr, 828, 12, _spatialResY);
+      ossimDemUtil::getDouble(bufstr, 840, 12, _spatialResZ);
+      _profileRows = ossimDemUtil::getLong(bufstr, 852, 6);
+      _profileColumns = ossimDemUtil::getLong(bufstr, 858, 6);
+      _largeContInt = ossimDemUtil::getLong(bufstr, 864, 5);
+      _maxSourceUnits = ossimDemUtil::getLong(bufstr, 869, 1);
+      _smallContInt = ossimDemUtil::getLong(bufstr, 870, 5);
+      _minSourceUnits = ossimDemUtil::getLong(bufstr, 875, 1);
+      _sourceDate = ossimDemUtil::getLong(bufstr, 876, 4);
+      _inspRevDate = ossimDemUtil::getLong(bufstr, 880, 4);
+      
+      strncpy(temp, bufstr+884,1);
+      temp[1]='\0';
+      _inspFlag = temp;
+      
+      _valFlag = ossimDemUtil::getLong(bufstr, 885, 1);
+      _suspectVoidFlg = ossimDemUtil::getLong(bufstr, 886, 2);
+      _vertDatum = ossimDemUtil::getLong(bufstr, 888, 2);
+      _horizDatum = ossimDemUtil::getLong(bufstr, 890, 2);
+      if (_horizDatum == 0)
+         _horizDatum = 1;   // Default to NAD27
+      
+      _dataEdition = ossimDemUtil::getLong(bufstr, 892, 4);
+      _perctVoid = ossimDemUtil::getLong(bufstr, 896, 4);
+      _westEdgeFlag = ossimDemUtil::getLong(bufstr, 900, 2);
+      _northEdgeFlag = ossimDemUtil::getLong(bufstr, 902, 2);
+      _eastEdgeFlag = ossimDemUtil::getLong(bufstr, 904, 2);
+      _southEdgeFlag = ossimDemUtil::getLong(bufstr, 906, 2);
+      ossimDemUtil::getDouble(bufstr, 908, 7, _vertDatumShift);
+
+      delete [] bufstr;
+      delete [] temp;
+      bufstr = 0;
+      temp = 0;
+   }
+   return is;
+}
+
+
+std::ostream& ossimDemHeader::print(std::ostream& out) const
+{
+   const int W = 24; // format width
+   const int CW = W-8; // format corner width
    
-   s << setiosflags(std::ios::fixed) << std::setprecision(10)
-     << "USGS DEM Header Info:"
-     << "\nQuadrangle name:                " << getQuadName().c_str()
-     << "\nProcess info:                   " << getProcessInfo().c_str()
-     << "\nSE Geo Corner X(SDDMMSS.SSSS):  " << getSEGeoCornerX()
-     << "\nSE Geo Corner Y(SDDMMSS.SSSS):  " << getSEGeoCornerY()
-     << "\nProcess code:                   ";
+   // Capture the original flags then set float output to full precision.
+   std::ios_base::fmtflags f = out.flags();
 
+   // Note:  This is only a partial print for now...
+   std::string prefix = "usgs_dem.";
+   
+   out << std::setiosflags(std::ios_base::fixed|std::ios_base::left)
+       << std::setprecision(10)
+      
+       << prefix << std::setw(W)
+       << "quadrangle_name:" << getQuadName().c_str() << "\n"
+       << prefix << std::setw(W)
+       << "process_info:" << getProcessInfo().c_str() << "\n"
+       << prefix << std::setw(W)
+       << "se_geo_corner_x:" << getSEGeoCornerX() << "\n"
+       << prefix << std::setw(W)
+       << "se_geo_corner_y:" << getSEGeoCornerY() << "\n"
+       << prefix << std::setw(W)
+       << "process_code:";
+   
    ossim_int32 tmpl = getProcessCode() - 1;
    if ( tmpl >= 0 && tmpl <= MAX_PROCESS_CODE_INDEX)
    {
-      s << PROCESS_CODE[tmpl];
+      out << PROCESS_CODE[tmpl] << "\n";
    }
    else
    {
-      s << "Unknown";
+      out << "unknown" << "\n";
    }
 
-   s << "\nSection Indicator:       " << getSectionIndicator().c_str()
-     << "\nMapping Center Code:     " << getMappingCenterCode().c_str()
-     << "\nLevel Code:              " << getLevelCode()
-     << "\nElev Pattern:            " << getElevPattern()
-     << "\nGround Ref Sys:          ";
-
+   out << prefix << std::setw(W)
+       << "section_indicator: " << getSectionIndicator().c_str() << "\n"
+       << prefix << std::setw(W)
+       << "mapping_center_code: " << getMappingCenterCode().c_str() << "\n"
+       << prefix << std::setw(W)
+       << "level_code: " << getLevelCode() << "\n"
+       << prefix << std::setw(W)
+       << "elev_pattern: " << getElevPattern() << "\n"
+       << prefix << std::setw(W) << "ground_ref_sys: ";
+   
    tmpl = getGroundRefSysCode();
    if ( tmpl >= 0 && tmpl <= MAX_GROUND_REF_SYSTEM_INDEX)
    {
-      s << GROUND_REF_SYSTEM[tmpl];
+      out << GROUND_REF_SYSTEM[tmpl] << "\n";
    }
    else
    {
-      s << "Unknown";
+      out << "unknown\n";
    }
-
-   s << "\nGround Ref Sys Zone:     " << getGroundRefSysZone()
-
-     << "\nGround Ref Sys Units:    ";
+   
+   out << prefix << std::setw(W)
+       << "ground_ref_sys_zone: " << getGroundRefSysZone() << "\n"
+       << prefix << std::setw(W)
+       << "ground_ref_sys_units:";
    tmpl = getGroundRefSysUnits();
    if ( tmpl >= 0 && tmpl <= MAX_GROUND_REF_SYSTEM_UNITS_INDEX)
    {
-      s << GROUND_REF_SYSTEM_UNITS[tmpl];
+      out << GROUND_REF_SYSTEM_UNITS[tmpl] << "\n";
    }
    else
    {
-      s << "Unknown";
+      out << "unknown\n";
    }
          
-   s << "\nElevation Units:         ";
+   out << prefix << std::setw(W)
+       << "elevation_units: ";
    tmpl = getElevationUnits();
    if ( tmpl >= 0 && tmpl <= MAX_GROUND_REF_SYSTEM_UNITS_INDEX)
    {
-      s << GROUND_REF_SYSTEM_UNITS[tmpl];
+      out << GROUND_REF_SYSTEM_UNITS[tmpl] << "\n";
    }
    else
    {
-      s << "Unknown";
+      out << "unknown\n";
    }
 
-   s << "\nNumber Poly Sides:       " << getNumPolySides()
-     << "\nCounterclock Angle:      " << getCounterclockAngle()
-     << "\nElev Accuracy Code:      " << getElevAccuracyCode()
-     << "\nMinimum Elevation:       " << getMinimumElev()
-     << "\nMaximum Elevation:       " << getMaximumElev()
-     << "\nSpatial Res X:           " << getSpatialResX()
-     << "\nSpatial Res Y:           " << getSpatialResY()
-     << "\nSpatial Res Z:           " << getSpatialResZ()
-     << "\nProfile Rows:            " << getProfileRows()
-     << "\nProfile Columns:         " << getProfileColumns()
-     << "\nVertical datum:          ";
-
+   out << prefix << std::setw(W)
+       << "number_poly_sides: " << getNumPolySides() << "\n"
+       << prefix << std::setw(W)
+       << "counterclock_angle: " << getCounterclockAngle()<< "\n"
+       << prefix << std::setw(W)
+       << "elev_accuracy_code: " << getElevAccuracyCode()<< "\n"
+       << prefix << std::setw(W)
+       << "minimum_elevation: " << getMinimumElev() << "\n"
+       << prefix << std::setw(W)
+       << "maximum_elevation: " << getMaximumElev() << "\n"
+       << prefix << std::setw(W)
+       << "spatial_res_x: " << getSpatialResX() << "\n"
+       << prefix << std::setw(W)
+       << "spatial_res_y: " << getSpatialResY() << "\n"
+       << prefix << std::setw(W)
+       << "spatial_res_z:" << getSpatialResZ() << "\n"
+       << prefix << std::setw(W)
+       << "profile_rows: " << getProfileRows() << "\n"
+       << prefix << std::setw(W)
+       << "profile_columns:" << getProfileColumns() << "\n"
+       << prefix << std::setw(W)
+       << "source_date:" << getSourceDate() << "\n"
+       << prefix << std::setw(W)
+       << "revision_date:" << getInspRevDate() << "\n"
+       << prefix  << std::setw(W)
+       << "vertical_datum:";
+   
    tmpl = getVertDatum() - 1;
    if ( tmpl >= 0 && tmpl <= MAX_VERTICAL_DATUM_INDEX)
    {
-      s << VERTICAL_DATUM[tmpl];
+      out << VERTICAL_DATUM[tmpl] << "\n";
    }
    else
    {
-      s << "Unknown";
+      out << "unknown\n";
    }
 
-   s << "\nVertical datum shift:    " << getVertDatumShift()
-     << "\nHorizontal datum:        ";
+   out << prefix << std::setw(W)
+       << "vertical_datum_shift:" << getVertDatumShift() << "\n"
+       << prefix << std::setw(W)
+       << "horizontal_datum:";
    tmpl = getHorizDatum() - 1;
    if ( tmpl >= 0 && tmpl <= MAX_HORIZONTAL_DATUM_INDEX)
    {
-      s << HORIZONTAL_DATUM[tmpl];
+      out << HORIZONTAL_DATUM[tmpl] << "\n";
    }
    else
    {
-      s << "Unknown";
+      out << "unknown\n";
    }
 
    const ossimDemPointVector CORNERS = getDEMCorners();
    for (unsigned int i=0; i < CORNERS.size(); ++i)
    {
-      s << "Corner[" << i << "].x:  " << CORNERS[i].getX()
-        << "\nCorner[" << i << "].y:  " << CORNERS[i].getY()
-        << std::endl;
-         
+      out << prefix << "corner[" << i
+          << std::setw(CW)<< "].x:  " << CORNERS[i].getX() << "\n"
+          << prefix << "corner[" << i
+          << std::setw(CW)<< "].y:  " << CORNERS[i].getY() << "\n"
+          << std::endl;
    }
 
-   s << std::endl;
-   
-   return s;
-}
-
-std::istream&
-operator>>(std::istream& s, ossimDemHeader& header)
-{
-   char bufstr[1024];
-   char temp[1024];
-   ossim_int32 i;
-
-   ossimDemUtil::getRecord(s,bufstr);
-
-   strncpy(temp, bufstr, 40);
-   temp[40] = '\0';
-   header._quadName = temp;
+   out << std::endl;
 
-   strncpy(temp,bufstr+40,40);
-   temp[40] = '\0';
-   header._processInfo = temp;
-   
-   ossimDemUtil::getDouble(bufstr, 109, 13, header._seGeoCornerX);
-   ossimDemUtil::getDouble(bufstr, 122, 13, header._seGeoCornerY);
-   header._processCode = ossimDemUtil::getLong(bufstr, 135, 1);
-
-   strncpy(temp,bufstr+137,3);
-   temp[3] = '\0';
-   header._sectionIndicator = temp;
+   // Reset flags.
+   out.setf(f);   
 
-   strncpy(temp,bufstr+140,4);
-   temp[4] = '\0';
-   header._mapCenterCode = temp;
-    
-   header._levelCode = ossimDemUtil::getLong(bufstr, 144, 6);
-   header._elevPattern = ossimDemUtil::getLong(bufstr, 150, 6);
-   header._groundRefSysCode = ossimDemUtil::getLong(bufstr, 156, 6);
-   header._groundRefSysZone = ossimDemUtil::getLong(bufstr, 162, 6);
-   header._groundRefSysUnits = ossimDemUtil::getLong(bufstr, 528, 6);
-   header._elevUnits = ossimDemUtil::getLong(bufstr, 534, 6);
-   header._numPolySides = ossimDemUtil::getLong(bufstr, 540, 6);
-
-   for (i = 0; i < 4; i++)
-   {
-      double x,y;
-      ossim_int32 pos = 546 + (i * 48);
-      ossimDemUtil::getDouble(bufstr, pos, 24, x);
-      ossimDemUtil::getDouble(bufstr, pos + 24, 24, y);
-      header._demCorners.push_back(ossimDemPoint(x,y));
-   }
+   return out;
+}
 
-   ossimDemUtil::getDouble(bufstr, 738, 24, header._minElevation);
-   ossimDemUtil::getDouble(bufstr, 762, 24, header._maxElevation);
-   ossimDemUtil::getDouble(bufstr, 786, 24, header._counterclockAngle );
-   header._elevAccuracyCode = ossimDemUtil::getLong(bufstr, 810, 6);
-   ossimDemUtil::getDouble(bufstr, 816, 12, header._spatialResX);
-   ossimDemUtil::getDouble(bufstr, 828, 12, header._spatialResY);
-   ossimDemUtil::getDouble(bufstr, 840, 12, header._spatialResZ);
-   header._profileRows = ossimDemUtil::getLong(bufstr, 852, 6);
-   header._profileColumns = ossimDemUtil::getLong(bufstr, 858, 6);
-   header._largeContInt = ossimDemUtil::getLong(bufstr, 864, 5);
-   header._maxSourceUnits = ossimDemUtil::getLong(bufstr, 869, 1);
-   header._smallContInt = ossimDemUtil::getLong(bufstr, 870, 5);
-   header._minSourceUnits = ossimDemUtil::getLong(bufstr, 875, 1);
-   header._sourceDate = ossimDemUtil::getLong(bufstr, 876, 4);
-   header._inspRevDate = ossimDemUtil::getLong(bufstr, 880, 4);
-   
-   strncpy(temp, bufstr+884,1);
-   temp[1]='\0';
-   header._inspFlag = temp;
-
-   header._valFlag = ossimDemUtil::getLong(bufstr, 885, 1);
-   header._suspectVoidFlg = ossimDemUtil::getLong(bufstr, 886, 2);
-   header._vertDatum = ossimDemUtil::getLong(bufstr, 888, 2);
-   header._horizDatum = ossimDemUtil::getLong(bufstr, 890, 2);
-   if (header._horizDatum == 0)
-      header._horizDatum = 1;   // Default to NAD27
-
-   header._dataEdition = ossimDemUtil::getLong(bufstr, 892, 4);
-   header._perctVoid = ossimDemUtil::getLong(bufstr, 896, 4);
-   header._westEdgeFlag = ossimDemUtil::getLong(bufstr, 900, 2);
-   header._northEdgeFlag = ossimDemUtil::getLong(bufstr, 902, 2);
-   header._eastEdgeFlag = ossimDemUtil::getLong(bufstr, 904, 2);
-   header._southEdgeFlag = ossimDemUtil::getLong(bufstr, 906, 2);
-   ossimDemUtil::getDouble(bufstr, 908, 7, header._vertDatumShift);
-
-   return s;  
+std::istream& operator>>(std::istream& s, ossimDemHeader& header)
+{
+   return header.open(s);
 }
 
 bool ossimDemHeader::getImageGeometry(ossimKeywordlist& kwl,
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimDemInfo.cpp b/Utilities/otbossim/src/ossim/support_data/ossimDemInfo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eab753c67970aa321779fe2fc065746b0eb63e71
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimDemInfo.cpp
@@ -0,0 +1,61 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: USGS DEM Info object.
+// 
+//----------------------------------------------------------------------------
+// $Id$
+
+#include <iostream>
+
+#include <ossim/support_data/ossimDemInfo.h>
+
+#include <ossim/base/ossimErrorCodes.h>
+#include <ossim/base/ossimFilename.h>
+
+#include <ossim/support_data/ossimDemHeader.h>
+#include <ossim/support_data/ossimDemUtil.h>
+
+ossimDemInfo::ossimDemInfo()
+   : theFile()
+{
+}
+
+ossimDemInfo::~ossimDemInfo()
+{
+}
+
+bool ossimDemInfo::open(const ossimFilename& file)
+{
+   bool result = ossimDemUtil::isUsgsDem(file);
+
+   if ( result )
+   {
+      theFile = file;
+   }
+   else
+   {
+      theFile = ossimFilename::NIL;
+   }
+   
+   return result;
+}
+
+std::ostream& ossimDemInfo::print(std::ostream& out) const
+{
+   if ( theFile.exists() )
+   {
+      ossimDemHeader hdr;
+      if ( hdr.open(theFile) )
+      {
+         // std::string prefix;
+         hdr.print(std::cout);
+      }
+   }
+   return out;
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimDemUtil.cpp b/Utilities/otbossim/src/ossim/support_data/ossimDemUtil.cpp
index 1da272343b11bd071bbe262ef30624629fe33960..6e7d8983bca807d9854af19ca8aa7ddf3689ccc2 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimDemUtil.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimDemUtil.cpp
@@ -11,15 +11,112 @@
 // Description: This class provides some simple utilities for DEMs.
 //
 //********************************************************************
-// $Id: ossimDemUtil.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimDemUtil.cpp 15307 2009-09-01 15:41:07Z dburken $
 
 #include <stdlib.h>
 #include <iostream>
 
 #include <ossim/support_data/ossimDemUtil.h>
 
+#include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimKeywordlist.h>
 using namespace std;
 
+static const char DEM_TYPE_KW[] = "dem_type";
+static const char USGS_DEM_KW[] = "usgs_dem";
+
+bool ossimDemUtil::isUsgsDem(const ossimFilename& file)
+{
+   bool result = false;
+
+   if ( file.exists() )
+   {
+      
+      //---
+      // Open checks:
+      // 1) Check extension for .dem
+      //
+      // 2) Look for file.omd (ossim meta data) file containing keyword
+      //    "dem_type" with value of "usgs_dem".
+      //
+      // NOTE:
+      // There is a keyword list template stored in the templates directory:
+      // "ossim/etc/templates/usgs_dem_template.kwl"
+      //---
+      
+      ossimString ext = file.ext();
+      ext.downcase();
+      if (ext == "dem")
+      {
+         result = true;
+      }
+      else
+      {
+         // Look for file.omd
+         ossimFilename kwlFile = file;
+         kwlFile.setExtension("omd");
+         if (! kwlFile.exists() )
+         {
+            kwlFile.setExtension("OMD");
+         }
+         
+         if ( kwlFile.exists() )
+         {
+            ossimKeywordlist kwl(kwlFile);
+            if (kwl.getErrorStatus() == ossimErrorCodes::OSSIM_OK)
+            {
+               const char* lookup = kwl.find(DEM_TYPE_KW);
+               if (lookup)
+               {
+                  ossimString s = lookup;
+                  s.downcase();
+                  if (s == USGS_DEM_KW)
+                  {
+                     result = true;
+                  }
+               }
+            }
+         }
+      }
+      
+      if ( result )
+      {
+         // Open up the file for reading.
+         std::ifstream is(file.c_str(),
+                          std::ios_base::in | std::ios_base::binary);
+         if ( is.good() )
+         {
+            //---
+            // SPECIAL HACK (drb):
+            // Check some bytes and make sure there is no binary data.
+            // There are files out there with .dem extension that are binary
+            // rasters.
+            //---
+            ossim_uint8* ubuf = new ossim_uint8[512];
+            is.read((char*)ubuf, 512);
+            for (int i = 0; i < 512; ++i)
+            {
+               if (ubuf[i] > 0x7f)
+               {
+                  result = false;
+                  break;
+               }
+            }
+            delete [] ubuf;
+            ubuf = 0;
+            is.close();
+         }
+         else
+         {
+            result = false;
+         }
+      }
+      
+   } // matches:  if ( file.exists() )
+
+   return result;
+}
+
 bool
 ossimDemUtil::getRecord(istream& s, string& strbuf, long reclength)
 {
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp b/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp
index 35b75a2d84cddcdace0941c140ec339d37004bf4..4cd33ecf20b9f8ed47d0eeeade4521f1ce0b0ad4 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp
@@ -3,14 +3,13 @@
 //
 // License:  See top level LICENSE.txt file.
 //
-// Author:  David Burken
-//
 // Description:
+// 
 // Class definition for ossimGeoTiff which is designed to read and hold tag
 // information.
 //
 //***************************************************************************
-// $Id: ossimGeoTiff.cpp 14369 2009-04-20 21:32:33Z dburken $
+// $Id: ossimGeoTiff.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <ossim/support_data/ossimGeoTiff.h>
 #include <ossim/base/ossimTrace.h>
@@ -45,17 +44,59 @@
 #include <sstream>
 #include <cstdlib>
 
+
 static const ossimGeoTiffCoordTransformsLut COORD_TRANS_LUT;
 static const ossimGeoTiffDatumLut DATUM_LUT;
+OpenThreads::Mutex ossimGeoTiff::theMutex;
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimGeoTiff.cpp 14369 2009-04-20 21:32:33Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimGeoTiff.cpp 15766 2009-10-20 12:37:09Z gpotts $";
 #endif
 
 //---
 // Static trace for debugging
 //---
 static ossimTrace traceDebug("ossimGeoTiff:debug");
+
+ossimGeoTiff::ossimGeoTiff()
+   :
+      theTiffPtr(0),
+      theGeoKeyOffset(0),
+      theGeoKeyLength(0),
+      theGeoKeysPresentFlag(false),
+      theZone(0),
+      theHemisphere("N"),
+      theProjectionName("unknown"),
+      theDatumName("unknown"),
+      theScale(),
+      theTiePoint(),
+      theModelTransformation(),
+      theWidth(0),
+      theLength(0),
+      theBitsPerSample(),
+      theModelType(0),
+      theRasterType(UNDEFINED),
+      theGcsCode(0),
+      theDatumCode(0),
+      theAngularUnits(0),
+      thePcsCode(0),
+      theSavePcsCodeFlag(false),
+      thePcsCitation(),
+      theProjGeoCode(0),
+      theCoorTransGeoCode(0),
+      theLinearUnitsCode(UNDEFINED),
+      theStdPar1(0.0),
+      theStdPar2(0.0),
+      theOriginLon(0.0),
+      theOriginLat(0.0),
+      theFalseEasting(0.0),
+      theFalseNorthing(0.0),
+      theScaleFactor(0.0),
+      theNormalizedDefinitions(0)
+{
+}
+
+
 ossimGeoTiff::ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx)
    :
       theTiffPtr(0),
@@ -66,15 +107,13 @@ ossimGeoTiff::ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx)
       theHemisphere("N"),
       theProjectionName("unknown"),
       theDatumName("unknown"),
-      
       theScale(),
       theTiePoint(),
       theModelTransformation(),
-      
       theWidth(0),
       theLength(0),
       theBitsPerSample(),
-      theModelType(UNKNOWN),
+      theModelType(0),
       theRasterType(UNDEFINED),
       theGcsCode(0),
       theDatumCode(0),
@@ -91,9 +130,8 @@ ossimGeoTiff::ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx)
       theOriginLat(0.0),
       theFalseEasting(0.0),
       theFalseNorthing(0.0),
-      theCenterLon(0.0),
-      theCenterLat(0.0),
-      theScaleFactor(0.0)
+      theScaleFactor(0.0),
+      theNormalizedDefinitions(0)
 {
    if (traceDebug())
    {
@@ -130,6 +168,11 @@ ossimGeoTiff::ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx)
 
 ossimGeoTiff::~ossimGeoTiff()
 {
+   if(theNormalizedDefinitions)
+   {
+      delete theNormalizedDefinitions;
+      theNormalizedDefinitions = 0;
+   }
    if(theTiffPtr)
    {
       XTIFFClose(theTiffPtr);
@@ -170,15 +213,18 @@ int ossimGeoTiff::getPcsUnitType(ossim_int32 pcsCode)
    return pcsUnits;
 }
 
+#define EPSG_CODE_MAX 32767
 bool ossimGeoTiff::writeTags(TIFF* tifPtr,
                              const ossimRefPtr<ossimMapProjectionInfo> projectionInfo,
                              bool imagineNad27Flag)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   
    const ossimMapProjection* mapProj = projectionInfo->getProjection();
    if(!mapProj) return false;
    GTIF* gtif = GTIFNew(tifPtr);
 
-    // Get some things we need thoughout.
+    // Get some things we need throughout.
    ossimGpt origin      = mapProj->origin();
    double falseEasting  =  mapProj->getFalseEasting();
    double falseNorthing =  mapProj->getFalseNorthing();
@@ -222,75 +268,520 @@ bool ossimGeoTiff::writeTags(TIFF* tifPtr,
    {
       units = getPcsUnitType(pcsCode);
    }
-//    if (isStatePlane)
-//    {
-//       if (units != getPcsUnitType(pcsCode))
-//       {
-//          //---
-//          // State plane pcs codes imply units, so if user overroad with
-//          // theLinearUnits make the projection user defined by setting the
-//          // pcs code to 0.
-//          //---
-//          pcsCode = 0;
-//       }
-//    }
 
    if (units == UNDEFINED)
    {
       units = LINEAR_METER;
    }
-   
+
    if (pcsCode)
    {
-      GTIFKeySet(gtif,
-                 ProjectedCSTypeGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 pcsCode);
+      const ossimStatePlaneProjectionInfo* info =
+         ossimStatePlaneProjectionFactory::instance()->getInfo(pcsCode);
+      if (info)
+      {
+         // ESH 05/2008 -- ArcMap 9.2 compatibility hack
+         // If the PCS code is for a HARN state plane and the implied pcs 
+         // code's units is feet (us or intl), we find the equivalent code 
+         // for units of meters.  We're doing this because ArcMap (9.2 and 
+         // less) doesn't understand the non-meters HARN codes.  However, 
+         // the units are left unchanged in this process, so the units can 
+         // be different than the user-specified pcs code. ArcMap 9.2 
+         // seems to understand the mixed definition just fine.
+         int unitType = getPcsUnitType(pcsCode);
+         if (unitType == LINEAR_FOOT_US_SURVEY || unitType == LINEAR_FOOT)
+         {
+            const ossimString& pcsCodeName = info->name();
+            if ( pcsCodeName.empty() == false )
+            {
+               if ( pcsCodeName.contains("HARN")  == true && 
+                    pcsCodeName.contains("_Feet") == true )
+               {
+                  ossimString feetStr("_Feet");
+                  ossimString newPcsCodeName( pcsCodeName.before(feetStr).c_str() );
+                  if ( newPcsCodeName.empty() == false )
+                  {
+                     info = ossimStatePlaneProjectionFactory::instance()->getInfo(newPcsCodeName);
+                     if ( info != NULL )
+                     {
+                        // pcs code for equivalent HARN/meters definition
+                        ossimString newPcsCode( ossimString::toString( info->code() ) );
+
+                        // Make sure the code can be used in the tiff file. 
+                        // It has to fit into an unsigned short.
+                        if ( info->code() < EPSG_CODE_MAX ) 
+                           pcsCode = static_cast<ossim_uint16>( info->code() );
+                     }
+                  }
+               }
+            }
+         }
+         // End pcs code switch hack
+      }
+
+      GTIFKeySet(gtif, GeographicTypeGeoKey,    TYPE_SHORT, 1, USER_DEFINED);
+      GTIFKeySet(gtif, GeogGeodeticDatumGeoKey, TYPE_SHORT, 1, USER_DEFINED);
+      GTIFKeySet(gtif, ProjectionGeoKey ,       TYPE_SHORT, 1, USER_DEFINED);
+      GTIFKeySet(gtif, GeogEllipsoidGeoKey,     TYPE_SHORT, 1, USER_DEFINED);
+      GTIFKeySet(gtif, ProjectedCSTypeGeoKey,   TYPE_SHORT, 1, pcsCode);
    }
-   
-//    if (traceDebug())
-//    {
-//       CLOG << " DEBUG:\n"
-//            << "Geotiff ProjectedCSTypeGeoKey:  "
-//            << pcsCode
-//            << std::endl;
-//    }
-   
+   else
+   {
+      ossimString datumCode = "WGE";
+      ossimString datumName = "WGE";
+      // Attemp to get the datum code
+      const ossimDatum* datum = mapProj->getDatum();
+      if(datum)
+      {
+         datumCode = datum->code();
+         datumName = datum->name();
+      }
+
+      short gcs = USER_DEFINED;
+
+      if (datumCode == "WGE") gcs = GCS_WGS_84;
+      else if (datumCode == "WGD") gcs = GCS_WGS_72;
+      else if (datumCode == "NAR-C") gcs = GCS_NAD83;
+      else if (datumCode == "NAR") gcs = GCS_NAD83;
+      else if (datumCode == "NAS-C") gcs = GCS_NAD27;
+      else if (datumCode == "NAS") gcs = GCS_NAD27;
+      else if (datumCode == "ADI-M") gcs = GCS_Adindan;
+      else if (datumCode == "ARF-M") gcs = GCS_Arc_1950;
+      else if (datumCode == "ARS-M") gcs = GCS_Arc_1960;
+      else if (datumCode == "EUR-7" || datumCode == "EUR-M") gcs = GCS_ED50;
+      else if ((datumCode == "OGB-7") ||
+               (datumCode == "OGB-M") ||
+               (datumCode == "OGB-A") ||
+               (datumCode == "OGB-B") ||
+               (datumCode == "OGB-C") ||
+               (datumCode == "OGB-D")) gcs = GCS_OSGB_1936;
+      else if (datumCode == "TOY-M") gcs = GCS_Tokyo;
+      else
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << "DATUM = " << datumCode << " tag not written " << std::endl
+               << "Please let us know so we can add it"          << std::endl;
+         }
+      }
+
+      // ***
+      // ERDAS Imagine < v8.7 has a NAD27 Conus Bug.  They are not using the
+      // proper GCS code.  They use user-defined fields and Geog cititaion tag to
+      // define.  Sucks!  It is an open issue at Leica.  This is a work around
+      // flag for this issue.
+      // ***
+      if((datumCode == "NAS-C") && imagineNad27Flag)
+      {
+         gcs = USER_DEFINED;
+
+         std::ostringstream os;
+         os << "IMAGINE GeoTIFF Support\nCopyright 1991 -  2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 15766 $ $Date: 2009-10-20 20:37:09 +0800 (Tue, 20 Oct 2009) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)";
+
+         GTIFKeySet(gtif,
+                    GeogCitationGeoKey,
+                    TYPE_ASCII,
+                    1,
+                    os.str().c_str());
+
+         // User-Defined
+         GTIFKeySet(gtif, GeogGeodeticDatumGeoKey, TYPE_SHORT, 1,
+                    KvUserDefined );
+         // User-Defined
+         GTIFKeySet(gtif, GeogEllipsoidGeoKey, TYPE_SHORT, 1,
+                    KvUserDefined );
+      }
+      else
+      {
+         GTIFKeySet( gtif, GeographicTypeGeoKey, TYPE_SHORT, 1, gcs );
+      }
+
+      // Write the projection parameters.
+
+      bool setFalseEastingNorthingFlag = false;
+      
+      if ( projName == "ossimUtmProjection" )
+      {
+         //---
+         // UTM tags needed example from the geo tiff spec page:
+         // ModelTiepointTag       = (0, 0, 0,  350807.4, 5316081.3, 0.0)
+         // ModelPixelScaleTag     = (100.0, 100.0, 0.0)
+         // GeoKeyDirectoryTag:
+         //       GTModelTypeGeoKey        =  1      (ModelTypeProjected)
+         //       GTRasterTypeGeoKey       =  1      (RasterPixelIsArea)
+         //       ProjectedCSTypeGeoKey    =  32660  (PCS_WGS84_UTM_zone_60N)
+         //       PCSCitationGeoKey        =  "UTM Zone 60 N with WGS84"
+         //
+         // NOTE:
+         // The "ProjectedCSTypeGeoKey" can be constructed using the map zone
+         // and the datum.
+         //---
+         const ossimUtmProjection* utmProjection = dynamic_cast<const ossimUtmProjection*>(mapProj);
+
+         // Attempt to get the pcs key.
+         int mapZone = utmProjection->getZone();
+         ossimString hemisphere = utmProjection->getHemisphere();
+         short projSysCode=0;
+
+         //---
+         // Use a projection code that does not imply a datum.
+         // See section "6.3.3.2 Projection Codes" for definition.
+         //---
+         if (mapZone > 0) // Northern hemisphere.
+         {
+            projSysCode = 16000 + mapZone;
+         }
+         else if (mapZone < 0) // Southern hemisphere.
+         {
+            hemisphere = "S";
+            projSysCode = 16100 + abs(mapZone);
+         }
+         
+         // Set the Projected Coordinate System Type to be user defined.
+         GTIFKeySet(gtif,
+                    ProjectedCSTypeGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    USER_DEFINED);
+         
+         // Set the geographic type to be user defined.
+         GTIFKeySet(gtif,
+                    GeographicTypeGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    USER_DEFINED);
+         
+         // Set the ProjectionGeoKey in place of the ProjectedCSTypeGeoKey.
+         GTIFKeySet(gtif,
+                    ProjectionGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    projSysCode);
+
+         std::ostringstream os;
+         os << "UTM Zone " << dec << mapZone << hemisphere.c_str()
+            << " with " << datumName << " datum";
+         
+         GTIFKeySet(gtif,
+                    PCSCitationGeoKey,
+                    TYPE_ASCII,
+                    1,
+                    os.str().c_str());
+         
+      } // End of "if ( projName == "ossimUtmProjection" )
+      
+      else if(projName == "ossimBngProjection")
+      {
+         // User-Defined
+         GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1,
+		    PCS_BRITISH_NATIONAL_GRID);//KvUserDefined );
+         
+         // User-Defined
+         GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1,
+		    KvUserDefined );
+         
+         GTIFKeySet(gtif,
+                    PCSCitationGeoKey,
+                    TYPE_ASCII,
+                    26,
+                    "PCS_British_National_Grid");
+         
+         GTIFKeySet(gtif,
+                    ProjCoordTransGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    (uint16)CT_TransverseMercator);
+         
+         GTIFKeySet(gtif,
+		    ProjNatOriginLongGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.lond());
+         
+         GTIFKeySet(gtif,
+		    ProjNatOriginLatGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.latd());
+
+         setFalseEastingNorthingFlag = true;
+
+         double scale = ossimString(scaleFactor).toDouble();
+
+         GTIFKeySet(gtif,
+                    ProjScaleAtNatOriginGeoKey,
+                    TYPE_DOUBLE,
+                    1,
+                    scale);
+      }
+      else if( projName == "ossimSinusoidalProjection")
+      {
+         GTIFKeySet(gtif,
+                    ProjCoordTransGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    (uint16)CT_Sinusoidal);
+         
+         GTIFKeySet(gtif,
+		    ProjNatOriginLongGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.lond());
+
+         GTIFKeySet(gtif,
+		    ProjNatOriginLatGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.latd());
+
+         setFalseEastingNorthingFlag = true;
+      }
+      else if( (projName == "ossimEquDistCylProjection")||
+               (projName == "ossimLlxyProjection"))
+      {
+         GTIFKeySet(gtif,
+		    ProjNatOriginLongGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.lond());
+         
+         GTIFKeySet(gtif,
+		    ProjNatOriginLatGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.latd());
+      }
+      else if ( (projName == "ossimLambertConformalConicProjection") ||
+                (projName == "ossimAlbersProjection") )
+      {
+         //---
+         // Lambert Conformal Conic:
+         // tags needed example from the geo tiff spec page:
+         // ModelTiepointTag     = (  80,  100, 0,  200000,  1500000, 0)
+         // ModelPixelScaleTag         = (1000, 1000, 0)
+         // GeoKeyDirectoryTag:
+         //       GTModelTypeGeoKey           =  1     (ModelTypeProjected)
+         //       GTRasterTypeGeoKey          =  1     (RasterPixelIsArea)
+         //       GeographicTypeGeoKey        =  4267  (GCS_NAD27)
+         //       ProjectedCSTypeGeoKey       =  32767 (user-defined)
+         //       ProjectionGeoKey            =  32767 (user-defined)
+         //       ProjLinearUnitsGeoKey       =  9001     (Linear_Meter)
+         //       ProjCoordTransGeoKey        =  8 (CT_LambertConfConic_2SP)
+         //            ProjStdParallel1GeoKey     =  41.333
+         //            ProjStdParallel2GeoKey     =  48.666
+         //            ProjCenterLongGeoKey       =-120.0
+         //            ProjNatOriginLatGeoKey     =  45.0
+         //            ProjFalseEastingGeoKey,    = 200000.0
+         //            ProjFalseNorthingGeoKey,   = 1500000.0
+         //
+         // NOTE: Albers Same as Lambert with the exception of the
+         //       ProjCoordTransGeoKey which is:  CT_AlbersEqualArea.
+         //---
+         
+         if (projName == "ossimLambertConformalConicProjection")
+         {
+            GTIFKeySet(gtif,
+                       ProjCoordTransGeoKey,
+                       TYPE_SHORT,
+                       1,
+                       (uint16)CT_LambertConfConic_2SP );
+         }
+         else // Albers
+         {
+            GTIFKeySet(gtif,
+                       ProjCoordTransGeoKey,
+                       TYPE_SHORT,
+                       1,
+                       (uint16)CT_AlbersEqualArea);
+         }
+         
+         // User-Defined
+         GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1,
+                    KvUserDefined );
+
+         // User-Defined
+         GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1,
+		    KvUserDefined );
+
+         double phi1 = ossimString(stdParallel1).toDouble();
+
+         GTIFKeySet(gtif,
+		    ProjStdParallel1GeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    phi1);  // 1st parallel
+
+         double phi2 = ossimString(stdParallel2).toDouble();
+
+         GTIFKeySet(gtif,
+		    ProjStdParallel2GeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    phi2);  // 2nd parallel
+
+         GTIFKeySet(gtif,
+		    ProjCenterLongGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.lond());  // Longitude at the origin.
+
+         GTIFKeySet(gtif,
+		    ProjNatOriginLatGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.latd());  // Origin
+
+         setFalseEastingNorthingFlag = true;
+
+      }  // End of Lambert.
+
+
+      else if ( projName == "ossimMercatorProjection" )
+      {
+         GTIFKeySet(gtif,
+                    ProjCoordTransGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    (uint16)CT_TransverseMercator);
+         
+         GTIFKeySet(gtif,
+		    ProjNatOriginLongGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.lond());
+
+         GTIFKeySet(gtif,
+		    ProjNatOriginLatGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.latd());
+
+         setFalseEastingNorthingFlag = true;
+
+         double scale = ossimString(scaleFactor).toDouble();
+
+         GTIFKeySet(gtif,
+                    ProjScaleAtNatOriginGeoKey,
+                    TYPE_DOUBLE,
+                    1,
+                    scale);
+      }
+      else if ( projName == "ossimTransMercatorProjection" )
+      {
+         //---
+         // Transverse Mercator ( no example in the geo tiff spec.
+         // Requires:
+         //    - latitude/longitude of the origin
+         //    - easting/northing of some tie point(line/sample 0,0)
+         //    - false easting/northing
+         //    - The scale factor.
+         //---
+
+         //---
+         // The easting/northing is the distance from the origin plus the
+         // false easting/northing.  In other words if line 0 is 5,000
+         // meters from the origin and the false northing is 5,000 meters,
+         // then the northing would be 10,000.  The same goes for the easting.
+         //---
+         GTIFKeySet(gtif,
+                    ProjCoordTransGeoKey,
+                    TYPE_SHORT,
+                    1,
+                    (uint16)CT_TransverseMercator);
+         
+         // User-Defined
+         GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, KvUserDefined );
+         
+         // User-Defined
+         GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1, KvUserDefined );
+         
+         GTIFKeySet(gtif,
+		    ProjNatOriginLongGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.lond());
+
+         GTIFKeySet(gtif,
+		    ProjNatOriginLatGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    origin.latd());
+
+         setFalseEastingNorthingFlag = true;
+
+         double scale = ossimString(scaleFactor).toDouble();
+
+         GTIFKeySet(gtif,
+                    ProjScaleAtNatOriginGeoKey,
+                    TYPE_DOUBLE,
+                    1,
+                    scale);
+      } // End of TM
+
+      if (setFalseEastingNorthingFlag == true)
+      {
+
+         GTIFKeySet(gtif,
+		    ProjFalseEastingGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    falseEasting);
+
+         GTIFKeySet(gtif,
+		    ProjFalseNorthingGeoKey,
+		    TYPE_DOUBLE,
+		    1,
+		    falseNorthing);
+      }
+   }
+
    //---
    // Set the model type and units.
    //---
    if (units == ossimGeoTiff::ANGULAR_DEGREE)
    {
       GTIFKeySet(gtif,
-                 GTModelTypeGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 ModelTypeGeographic);
+         GTModelTypeGeoKey,
+         TYPE_SHORT,
+         1,
+         ModelTypeGeographic);
 
       // Set the units key.
       GTIFKeySet(gtif,
-                 GeogAngularUnitsGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 units);
+         GeogAngularUnitsGeoKey,
+         TYPE_SHORT,
+         1,
+         units);
    }
    else
    {
       GTIFKeySet(gtif,
-                 GTModelTypeGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 ModelTypeProjected);
+         GTModelTypeGeoKey,
+         TYPE_SHORT,
+         1,
+         ModelTypeProjected);
 
       // Set the units key.
       GTIFKeySet(gtif,
-                 ProjLinearUnitsGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 units);
+         ProjLinearUnitsGeoKey,
+         TYPE_SHORT,
+         1,
+         units);
    }
-   
+
+   // Set the ellipsoid major/minor axis.
+   GTIFKeySet(gtif,
+              GeogSemiMajorAxisGeoKey,
+              TYPE_DOUBLE,
+              1,
+              mapProj->getA());
+
+   GTIFKeySet(gtif,
+              GeogSemiMinorAxisGeoKey,
+              TYPE_DOUBLE,
+              1,
+              mapProj->getB());
 
    // Set the pixel type.
    if (projectionInfo->getPixelType() == OSSIM_PIXEL_IS_POINT)
@@ -307,8 +798,8 @@ bool ossimGeoTiff::writeTags(TIFF* tifPtr,
    //---
    // Set the tie point and scale.
    //---
-   double   tiePoints[6]  = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
-   double   pixScale[3]   = { 0.0, 0.0, 0.0 };
+   double  tiePoints[6]  = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
+   double  pixScale[3]   = { 0.0, 0.0, 0.0 };
    switch (units)
    {
       case LINEAR_FOOT:
@@ -319,7 +810,7 @@ bool ossimGeoTiff::writeTags(TIFF* tifPtr,
          pixScale[1]   = ossim::mtrs2ft(projectionInfo->getMetersPerPixel().y);
          falseEasting  = ossim::mtrs2ft(falseEasting);
          falseNorthing = ossim::mtrs2ft(falseNorthing);
-         
+
          break;
       }
       case LINEAR_FOOT_US_SURVEY:
@@ -349,466 +840,68 @@ bool ossimGeoTiff::writeTags(TIFF* tifPtr,
          pixScale[1]  = projectionInfo->getMetersPerPixel().y;
          break;
       }
-         
-   } // End of "switch (units)"
-   
-   TIFFSetField( tifPtr, TIFFTAG_GEOTIEPOINTS, 6, tiePoints );
-   TIFFSetField( tifPtr, TIFFTAG_GEOPIXELSCALE, 3, pixScale );
 
-   
-   ossimString datumCode = "WGE";
-   ossimString datumName = "WGE";
-   // Attemp to get the datum code
-   const ossimDatum* datum = mapProj->getDatum();
-   if(datum)
-   {
-      datumCode = datum->code();
-      datumName = datum->name();
-   }
-
-   short gcs = USER_DEFINED;
-
-   if (datumCode == "WGE") gcs = GCS_WGS_84;
-   else if (datumCode == "WGD") gcs = GCS_WGS_72;
-   else if (datumCode == "NAR-C") gcs = GCS_NAD83;
-   else if (datumCode == "NAR") gcs = GCS_NAD83;
-   else if (datumCode == "NAS-C") gcs = GCS_NAD27;
-   else if (datumCode == "NAS") gcs = GCS_NAD27;
-   else if (datumCode == "ADI-M") gcs = GCS_Adindan;
-   else if (datumCode == "ARF-M") gcs = GCS_Arc_1950;
-   else if (datumCode == "ARS-M") gcs = GCS_Arc_1960;
-   else if (datumCode == "EUR-7" || datumCode == "EUR-M") gcs = GCS_ED50;
-   else if ((datumCode == "OGB-7") ||
-            (datumCode == "OGB-M") ||
-            (datumCode == "OGB-A") ||
-            (datumCode == "OGB-B") ||
-            (datumCode == "OGB-C") ||
-            (datumCode == "OGB-D")) gcs = GCS_OSGB_1936;
-   else if (datumCode == "TOY-M") gcs = GCS_Tokyo;
-   else
-   {
-      if(traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DATUM = " << datumCode << " tag not written " << std::endl
-            << "Please let us know so we can add it"          << std::endl;
-      }
-   }
-
-   // ***
-   // ERDAS Imagine < v8.7 has a NAD27 Conus Bug.  They are not using the
-   // proper GCS code.  They use user-defined fields and Geog cititaion tag to
-   // define.  Sucks!  It is an open issue at Leica.  This is a work around
-   // flag for this issue.
-   // ***
-   if((datumCode == "NAS-C") && imagineNad27Flag)
-   {
-      gcs = USER_DEFINED;
-
-      std::ostringstream os;
-      os << "IMAGINE GeoTIFF Support\nCopyright 1991 -  2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 14369 $ $Date: 2009-04-21 05:32:33 +0800 (Tue, 21 Apr 2009) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)";
-
-      GTIFKeySet(gtif,
-                 GeogCitationGeoKey,
-                 TYPE_ASCII,
-                 1,
-                 os.str().c_str());
-
-      // User-Defined
-      GTIFKeySet(gtif, GeogGeodeticDatumGeoKey, TYPE_SHORT, 1,
-                 KvUserDefined );
-      // User-Defined
-      GTIFKeySet(gtif, GeogEllipsoidGeoKey, TYPE_SHORT, 1,
-                 KvUserDefined );
-   }
-   else
-   {
-      GTIFKeySet( gtif, GeographicTypeGeoKey, TYPE_SHORT, 1, gcs );
-   }
+   } // End of "switch (units)"
 
-   // Set the ellipsoid major/minor axis.
-   GTIFKeySet(gtif,
-              GeogSemiMajorAxisGeoKey,
-              TYPE_DOUBLE,
-              1,
-              mapProj->getA());
+   TIFFSetField( tifPtr, TIFFTAG_GEOTIEPOINTS,  6, tiePoints );
+   TIFFSetField( tifPtr, TIFFTAG_GEOPIXELSCALE, 3, pixScale );
 
-   GTIFKeySet(gtif,
-              GeogSemiMinorAxisGeoKey,
-              TYPE_DOUBLE,
-              1,
-              mapProj->getB());
 
-   // Write the projection parameters.
+   GTIFWriteKeys(gtif); // Write out geotiff tags.
+   GTIFFree(gtif);
 
-   bool setFalseEastingNorthingFlag = false;
-   
-   if ( (projName == "ossimUtmProjection") && !pcsCode )
-   {
-      //---
-      // UTM tags needed example from the geo tiff spec page:
-      // ModelTiepointTag       = (0, 0, 0,  350807.4, 5316081.3, 0.0)
-      // ModelPixelScaleTag     = (100.0, 100.0, 0.0)
-      // GeoKeyDirectoryTag:
-      //       GTModelTypeGeoKey        =  1      (ModelTypeProjected)
-      //       GTRasterTypeGeoKey       =  1      (RasterPixelIsArea)
-      //       ProjectedCSTypeGeoKey    =  32660  (PCS_WGS84_UTM_zone_60N)
-      //       PCSCitationGeoKey        =  "UTM Zone 60 N with WGS84"
-      //
-      // NOTE:
-      // The "ProjectedCSTypeGeoKey" can be constructed using the map zone
-      // and the datum.
-      //---
-      const ossimUtmProjection* utmProjection = dynamic_cast<const ossimUtmProjection*>(mapProj);
+   return true;
+}
 
-      // Attempt to get the pcs key.
-      int mapZone = utmProjection->getZone();
-      ossimString hemisphere = utmProjection->getHemisphere();
-      short projSysCode=0;
+bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
+{
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
 
-      //---
-      // Use a projection code that does not imply a datum.
-      // See section "6.3.3.2 Projection Codes" for definition.
-      //---
-      if (mapZone > 0) // Northern hemisphere.
-      {
-         projSysCode = 16000 + mapZone;
-      }
-      else if (mapZone < 0) // Southern hemisphere.
-      {
-         hemisphere = "S";
-         projSysCode = 16100 + abs(mapZone);
-      }
-      
-      // Set the Projected Coordinate System Type to be user defined.
-      GTIFKeySet(gtif,
-                 ProjectedCSTypeGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 USER_DEFINED);
-      
-      // Set the geographic type to be user defined.
-      GTIFKeySet(gtif,
-                 GeographicTypeGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 USER_DEFINED);
-      
-      // Set the ProjectionGeoKey in place of the ProjectedCSTypeGeoKey.
-      GTIFKeySet(gtif,
-                 ProjectionGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 projSysCode);
-   
-//       if (traceDebug())
-//       {
-//          CLOG << " DEBUG:\n"
-//               << "Geotiff ProjectedCSTypeGeoKey:  "
-//               << pcsCode
-//               << std::endl;
-//       }
-      
-      std::ostringstream os;
-      os << "UTM Zone " << dec << mapZone << hemisphere.c_str()
-         << " with " << datumName << " datum";
-      
-      GTIFKeySet(gtif,
-                 PCSCitationGeoKey,
-                 TYPE_ASCII,
-                 1,
-                 os.str().c_str());
-      
-   } // End of "if ( (projName == "ossimUtmProjection") && !pcsCode )
+   bool result = false;
    
-   else if(projName == "ossimBngProjection")
+   TIFF* tiff = XTIFFOpen(file.c_str(), "r");
+   if(tiff)
    {
-      // User-Defined
-      GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1,
-		 PCS_BRITISH_NATIONAL_GRID);//KvUserDefined );
-      
-      // User-Defined
-      GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1,
-		 KvUserDefined );
-      
-      GTIFKeySet(gtif,
-                 PCSCitationGeoKey,
-                 TYPE_ASCII,
-                 26,
-                 "PCS_British_National_Grid");
-      
-      GTIFKeySet(gtif,
-                 ProjCoordTransGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 (uint16)CT_TransverseMercator);
-      
-      GTIFKeySet(gtif,
-		 ProjNatOriginLongGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.lond());
-      
-      GTIFKeySet(gtif,
-		 ProjNatOriginLatGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.latd());
-
-      setFalseEastingNorthingFlag = true;
-
-      double scale = ossimString(scaleFactor).toDouble();
-
-      GTIFKeySet(gtif,
-                 ProjScaleAtNatOriginGeoKey,
-                 TYPE_DOUBLE,
-                 1,
-                 scale);
+      result = readTags(tiff, entryIdx, true);
    }
-   else if( projName == "ossimSinusoidalProjection")
-   {
-      GTIFKeySet(gtif,
-                 ProjCoordTransGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 (uint16)CT_Sinusoidal);
-      
-      GTIFKeySet(gtif,
-		 ProjNatOriginLongGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.lond());
-
-      GTIFKeySet(gtif,
-		 ProjNatOriginLatGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.latd());
 
-      setFalseEastingNorthingFlag = true;
-   }
-   else if( (projName == "ossimEquDistCylProjection")||
-            (projName == "ossimLlxyProjection"))
-   {
-      GTIFKeySet(gtif,
-		 ProjNatOriginLongGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.lond());
-      
-      GTIFKeySet(gtif,
-		 ProjNatOriginLatGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.latd());
-   }
-   else if ( ( (projName == "ossimLambertConformalConicProjection") &&
-               (!pcsCode)) ||
-             (projName == "ossimAlbersProjection") )
-   {
-      //---
-      // Lambert Conformal Conic:
-      // tags needed example from the geo tiff spec page:
-      // ModelTiepointTag     = (  80,  100, 0,  200000,  1500000, 0)
-      // ModelPixelScaleTag         = (1000, 1000, 0)
-      // GeoKeyDirectoryTag:
-      //       GTModelTypeGeoKey           =  1     (ModelTypeProjected)
-      //       GTRasterTypeGeoKey          =  1     (RasterPixelIsArea)
-      //       GeographicTypeGeoKey        =  4267  (GCS_NAD27)
-      //       ProjectedCSTypeGeoKey       =  32767 (user-defined)
-      //       ProjectionGeoKey            =  32767 (user-defined)
-      //       ProjLinearUnitsGeoKey       =  9001     (Linear_Meter)
-      //       ProjCoordTransGeoKey        =  8 (CT_LambertConfConic_2SP)
-      //            ProjStdParallel1GeoKey     =  41.333
-      //            ProjStdParallel2GeoKey     =  48.666
-      //            ProjCenterLongGeoKey       =-120.0
-      //            ProjNatOriginLatGeoKey     =  45.0
-      //            ProjFalseEastingGeoKey,    = 200000.0
-      //            ProjFalseNorthingGeoKey,   = 1500000.0
-      //
-      // NOTE: Albers Same as Lambert with the exception of the
-      //       ProjCoordTransGeoKey which is:  CT_AlbersEqualArea.
-      //---
-      
-      if (projName == "ossimLambertConformalConicProjection")
-      {
-         GTIFKeySet(gtif,
-                    ProjCoordTransGeoKey,
-                    TYPE_SHORT,
-                    1,
-                    (uint16)CT_LambertConfConic_2SP );
-      }
-      else // Albers
-      {
-         GTIFKeySet(gtif,
-                    ProjCoordTransGeoKey,
-                    TYPE_SHORT,
-                    1,
-                    (uint16)CT_AlbersEqualArea);
-      }
-      
-      // User-Defined
-      GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1,
-                 KvUserDefined );
-
-      // User-Defined
-      GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1,
-		 KvUserDefined );
-
-      double phi1 = ossimString(stdParallel1).toDouble();
-
-      GTIFKeySet(gtif,
-		 ProjStdParallel1GeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 phi1);  // 1st parallel
-
-      double phi2 = ossimString(stdParallel2).toDouble();
-
-      GTIFKeySet(gtif,
-		 ProjStdParallel2GeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 phi2);  // 2nd parallel
-
-      GTIFKeySet(gtif,
-		 ProjCenterLongGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.lond());  // Longitude at the origin.
-
-      GTIFKeySet(gtif,
-		 ProjNatOriginLatGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.latd());  // Origin
-
-      setFalseEastingNorthingFlag = true;
-
-   }  // End of Lambert.
+   return result;
+}
 
+bool ossimGeoTiff::readTags(
+   TIFF* tiff, ossim_uint32 entryIdx, bool ownTiffPtrFlag)
+{
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
 
-   else if ( (projName == "ossimMercatorProjection"))// && !pcsCode )
+   if ( !tiff )
    {
-      GTIFKeySet(gtif,
-                 ProjCoordTransGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 (uint16)CT_TransverseMercator);
-      
-      GTIFKeySet(gtif,
-		 ProjNatOriginLongGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.lond());
-
-      GTIFKeySet(gtif,
-		 ProjNatOriginLatGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.latd());
-
-      setFalseEastingNorthingFlag = true;
-
-      double scale = ossimString(scaleFactor).toDouble();
-
-      GTIFKeySet(gtif,
-                 ProjScaleAtNatOriginGeoKey,
-                 TYPE_DOUBLE,
-                 1,
-                 scale);
+      return false;
    }
-   else if ( (projName == "ossimTransMercatorProjection") && !pcsCode )
-   {
-      //---
-      // Transverse Mercator ( no example in the geo tiff spec.
-      // Requires:
-      //    - latitude/longitude of the origin
-      //    - easting/northing of some tie point(line/sample 0,0)
-      //    - false easting/northing
-      //    - The scale factor.
-      //---
-
-      //---
-      // The easting/northing is the distance from the origin plus the
-      // false easting/northing.  In other words if line 0 is 5,000
-      // meters from the origin and the false northing is 5,000 meters,
-      // then the northing would be 10,000.  The same goes for the easting.
-      //---
-      GTIFKeySet(gtif,
-                 ProjCoordTransGeoKey,
-                 TYPE_SHORT,
-                 1,
-                 (uint16)CT_TransverseMercator);
-      
-      // User-Defined
-      GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, KvUserDefined );
-      
-      // User-Defined
-      GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1, KvUserDefined );
-      
-      GTIFKeySet(gtif,
-		 ProjNatOriginLongGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.lond());
-
-      GTIFKeySet(gtif,
-		 ProjNatOriginLatGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 origin.latd());
 
-      setFalseEastingNorthingFlag = true;
-
-      double scale = ossimString(scaleFactor).toDouble();
-
-      GTIFKeySet(gtif,
-                 ProjScaleAtNatOriginGeoKey,
-                 TYPE_DOUBLE,
-                 1,
-                 scale);
-   } // End of TM
-
-   if (setFalseEastingNorthingFlag == true)
+   if(!TIFFSetDirectory(tiff, (ossim_uint16)entryIdx))
    {
-
-      GTIFKeySet(gtif,
-		 ProjFalseEastingGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 falseEasting);
-
-      GTIFKeySet(gtif,
-		 ProjFalseNorthingGeoKey,
-		 TYPE_DOUBLE,
-		 1,
-		 falseNorthing);
+      return false;
    }
-  
-   
-   GTIFWriteKeys(gtif); // Write out geotiff tags.
-   GTIFFree(gtif);
    
-   return true;
-}
+   GTIF* gtif = GTIFNew(tiff);
+   if(!gtif)
+   {
+      return false;
+   }
 
-bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
-{
    if(theTiffPtr)
    {
       XTIFFClose(theTiffPtr);
-      theTiffPtr = 0;
    }
+   theTiffPtr = tiff;
    
-   theTiffPtr = XTIFFOpen(file.c_str(), "r");
-   if(!theTiffPtr) return false;
-   if(!TIFFSetDirectory(theTiffPtr, (ossim_uint16)entryIdx))
+   if(theNormalizedDefinitions)
    {
-      return false;
+      delete theNormalizedDefinitions;
    }
-   GTIF* gtif = GTIFNew(theTiffPtr);
-   if(!gtif) return false;
+   theNormalizedDefinitions = new GTIFDefn;
+   GTIFGetDefn(gtif, theNormalizedDefinitions);
+   ossim_uint32 idx = 0;
    theGeoKeysPresentFlag = true;
    if(traceDebug())
    {
@@ -826,14 +919,25 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
                     &theWidth ))
    {
    }
+   theScaleFactor     = 0.0;
+   theModelType       = theNormalizedDefinitions->Model;
+   theGcsCode         = theNormalizedDefinitions->GCS;
+   theDatumCode       = theNormalizedDefinitions->Datum;
+   theAngularUnits    = theNormalizedDefinitions->UOMAngle;
+   theProjGeoCode     = theNormalizedDefinitions->ProjCode;
+   theLinearUnitsCode = theNormalizedDefinitions->UOMLength;
+#if 0
    ossim_uint16 modelType;
    if(GTIFKeyGet(gtif, GTModelTypeGeoKey, &modelType, 0, 1))
    {
       theModelType = (ModelType)modelType;
    }
+#endif
    if(GTIFKeyGet(gtif, GTRasterTypeGeoKey, &theRasterType, 0, 1))
    {
    }
+   
+#if 0
    if(GTIFKeyGet(gtif, GeographicTypeGeoKey, &theGcsCode, 0, 1))
    {
    }
@@ -843,6 +947,7 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
    if(GTIFKeyGet(gtif, GeogAngularUnitsGeoKey, &theAngularUnits, 0, 1))
    {
    }
+#endif
    
    theSavePcsCodeFlag = false;
    if(GTIFKeyGet(gtif, ProjectedCSTypeGeoKey, &thePcsCode, 0, 1))
@@ -886,30 +991,81 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
                parsePcsCode(thePcsCode);
             }
          }
-         
       }  // End of "if(GTIFKeyGet(gtif, GTCitationGeoKey..."
    }
    
    char* buf = 0;
-   double tempDouble=0.0;
-   theCenterLon = ossim::nan();
-   theCenterLat = ossim::nan();
    theOriginLon = ossim::nan();
    theOriginLat = ossim::nan();
    if(GTIFKeyGet(gtif, PCSCitationGeoKey , &buf, 0, 1))
    {
       thePcsCitation = ossimString(buf);
    }
-   if(GTIFKeyGet(gtif, ProjectionGeoKey, &theProjGeoCode,0 ,1))
-   {
-      parseProjGeoCode(theProjGeoCode);
-   }
-   if(GTIFKeyGet(gtif, ProjCoordTransGeoKey , &theCoorTransGeoCode, 0, 1))
-   {
-   }
-   if(GTIFKeyGet(gtif, ProjLinearUnitsGeoKey, &theLinearUnitsCode, 0, 1))
+   parseProjGeoCode(theProjGeoCode);
+   GTIFKeyGet(gtif, ProjCoordTransGeoKey , &theCoorTransGeoCode, 0, 1);
+   for(idx = 0; idx < (ossim_uint32)theNormalizedDefinitions->nParms; ++idx)
    {
+      switch(theNormalizedDefinitions->ProjParmId[idx])
+      {
+         case ProjStdParallel1GeoKey:
+         {
+            theStdPar1 = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjStdParallel2GeoKey:
+         {
+            theStdPar2 = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjOriginLongGeoKey:
+         {
+            theOriginLon = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjOriginLatGeoKey:
+         {
+            theOriginLat = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjFalseEastingGeoKey:
+         {
+            theFalseEasting = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjFalseNorthingGeoKey:
+         {
+            theFalseNorthing = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjCenterLongGeoKey:
+         {
+            theOriginLon = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjCenterLatGeoKey:
+         {
+            theOriginLat = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjFalseOriginLatGeoKey:
+         {
+            theOriginLat = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjFalseOriginLongGeoKey:
+         {
+            theOriginLon = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+         case ProjScaleAtNatOriginGeoKey:
+         {
+            theScaleFactor = theNormalizedDefinitions->ProjParm[idx];
+            break;
+         }
+      }
    }
+   
+#if 0
    if(GTIFKeyGet(gtif, ProjStdParallel1GeoKey, &theStdPar1, 0, 1))
    {
    }
@@ -947,6 +1103,7 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
    if(GTIFKeyGet(gtif, ProjScaleAtNatOriginGeoKey, &theScaleFactor, 0, 1))
    {
    }
+#endif
    theScale.clear();
    ossim_uint16 pixScaleSize = 0;
    double* pixScale=0;
@@ -962,18 +1119,25 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
    {
       theTiePoint.insert(theTiePoint.begin(),
                          tiepoints, tiepoints+tiePointSize);
-      if(ossim::isnan(theOriginLon) && 
-         (pixScaleSize > 1) &&
-         (tiePointSize > 3))
-      {
-         theOriginLon = tiepoints[3] - tiepoints[0] * pixScale[0]; 
-      }
-      
-      if(ossim::isnan(theOriginLat) && 
-         (pixScaleSize > 1) &&
-         (tiePointSize > 3))
+ 
+      // ESH 05/2009 -- If the image is in a projected coordinate system, the
+      // tiepoints will be projected coordinates not lat/lon. Let's avoid setting
+      // the origin lon/lat to projected x/y. Fix for ticket #711.
+      if ( theModelType == ModelTypeGeographic )
       {
-         theOriginLat = tiepoints[4] + tiepoints[1] * fabs(pixScale[1]);
+         if(ossim::isnan(theOriginLon) && 
+            (pixScaleSize > 1) &&
+            (tiePointSize > 3))
+         {
+            theOriginLon = tiepoints[3] - tiepoints[0] * pixScale[0]; 
+         }
+         
+         if(ossim::isnan(theOriginLat) && 
+            (pixScaleSize > 1) &&
+            (tiePointSize > 3))
+         {
+            theOriginLat = tiepoints[4] + tiepoints[1] * fabs(pixScale[1]);
+         }
       }
    }
    theModelTransformation.clear();
@@ -1004,12 +1168,7 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
                             tempDoubleParam,
                             tempDoubleParam+doubleParamSize);
    }
-#if 0
-   std::copy(theDoubleParam.begin(),
-             theDoubleParam.end(),
-             std::ostream_iterator<double>(std::cout, " " ));
-   std::cout << "\n" << std::endl;
-#endif
+
    char* tempAsciiParam=0;
    theAsciiParam = "";
 	
@@ -1025,38 +1184,78 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
       setOssimProjectionName();  // Initialize the ossim projection name.
       setOssimDatumName();       // Initialize the ossim datum name.
    }
-   
-   
-   if(ossim::isnan(theOriginLon)||
-      ossim::isnan(theOriginLat))
-   {
-      
-      ossimString projName = getOssimProjectionName();
-      if(projName == "ossimLambertConformalConicProjection")
-      {
-         if(theDoubleParam.size() >= 6)
-         {
-            theOriginLat = theDoubleParam[0];
-            theOriginLon = theDoubleParam[1];
-            theStdPar1 = theDoubleParam[2];
-            theStdPar2 = theDoubleParam[3];
-            theFalseEasting = theDoubleParam[4];
-            theFalseNorthing = theDoubleParam[5];
-         }
-      }
-      else
+
+   // commenting this out.  Frank mentioned the GTIFFGetDefn which in geo_normalize
+   // this should be all we need.
+   //
+#if 0  
+   /* 
+      ESH 05/2009: Replacing badly broken code for making 
+      use of TIFFTAG_GEODOUBLEPARAMS.
+
+      Read the geokey directory tag in order to see how 
+      the TIFFTAG_GEODOUBLEPARAMS are defined.
+
+      For structure of geokey directory, see:
+      http://www.remotesensing.org/geotiff/spec/geotiff2.4.html
+   */
+   ossim_uint16  gkdParamSize = 0;
+   ossim_uint16* gkdParams = 0;
+   if(TIFFGetField(theTiffPtr, TIFFTAG_GEOKEYDIRECTORY, &gkdParamSize, &gkdParams))
+   {
+      ossim_uint16 numKeys = gkdParams ? gkdParams[3] : 0;
+      ossim_uint16 key = 0;
+      for( key=0; key<numKeys; ++key )
       {
-         if(traceDebug())
+         ossim_uint16 loc = (key+1) * 4;
+         ossim_uint16 ind = gkdParams[loc+3];
+
+         if ( gkdParams[loc+1] == TIFFTAG_GEODOUBLEPARAMS && 
+              gkdParams[loc+2] == 1 && 
+              ind >= 0 && ind < doubleParamSize )
          {
-            ossimNotify(ossimNotifyLevel_DEBUG)
-               << "Need to add double param support for projection = "
-               << projName << std::endl;
+            double dval = theDoubleParam[ind];
+            switch( gkdParams[loc] )
+            {
+               case ProjStdParallel1GeoKey:     theStdPar1       = dval; break;
+               case ProjStdParallel2GeoKey:     theStdPar2       = dval; break;
+               case ProjNatOriginLongGeoKey:    theOriginLon     = dval; break;
+               /* case ProjOriginLongGeoKey:       theOriginLon     = dval; break; (alias) */
+               case ProjNatOriginLatGeoKey:     theOriginLat     = dval; break;
+               /* case ProjOriginLatGeoKey:        theOriginLat     = dval; break; (alias) */
+               case ProjFalseEastingGeoKey:     theFalseEasting  = dval; break;
+               case ProjFalseNorthingGeoKey:    theFalseNorthing = dval; break;
+               case ProjCenterLongGeoKey:       theCenterLon     = dval; break;
+               case ProjCenterLatGeoKey:        theCenterLat     = dval; break;
+               case ProjScaleAtNatOriginGeoKey: theScaleFactor   = dval; break;
+               default: 
+                  if(traceDebug())
+                  {
+                     ossimNotify(ossimNotifyLevel_DEBUG)
+                        << "ossimGeoTiff::readTags: Unrecognized geokey directory entry."
+                        << "\ngeokey directory index = " << loc
+                        << "\ngeokey = " << gkdParams[loc]
+                        << "\ndouble array index = " << ind
+                        << "\ndval = " << dval
+                        << std::endl;
+                  }
+                  break;
+            }
          }
       }
    }
-   
+#endif
+
    GTIFFree(gtif);
 
+   if (ownTiffPtrFlag == false)
+   {
+      //---
+      // Zero out the pointer so the destructor doesn't close it on some
+      // external code.
+      //---
+      theTiffPtr = 0;
+   }
    
    return true;
 }
@@ -1129,7 +1328,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
    {
       //---
       // Should we check the model type??? (drb)
-      // if (theModelType == MODEL_TYPE_GEOGRAPHIC)
+      // if (theModelType == ModelTypeGeographic)
       //---
       if(tieCount >= 4)
       {
@@ -1159,7 +1358,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
             // create a bilinear model
 
             // Should we check the model type (drb)
-            // if (theModelType == MODEL_TYPE_GEOGRAPHIC)
+            // if (theModelType == ModelTypeGeographic)
             
             ossimRefPtr<ossimBilinearProjection> proj =
                new ossimBilinearProjection;
@@ -1184,15 +1383,18 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
          return false;
       }
    }
-   /*else if(theModelTransformation.size() == 16)
+   else if(theModelTransformation.size() == 16)
    {
-     ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimGeoTiff::addImageGeometry: Do not support rotated "
-         << "map models yet.  You should provide the image as a sample "
-         << "and we will fix it" << std::endl;
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimGeoTiff::addImageGeometry: Do not support rotated "
+            << "map models yet.  You should provide the image as a sample "
+            << "and we will fix it" << std::endl;
+      }
       
 //       return false;
-}*/
+   }
   
    if ((theRasterType == OSSIM_PIXEL_IS_AREA)&&
        (!modelTransformFlag))
@@ -1209,7 +1411,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
    {
       
       kwl.add(prefix,
-              "pcs_code",
+              ossimKeywordNames::PCS_CODE_KW,
               thePcsCode,
               true);
       if(!modelTransformFlag)
@@ -1254,7 +1456,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
    // Add the tie point and scale.  Convert to either meters or decimal
    // degrees if needed.
    //---
-   if (theModelType == MODEL_TYPE_GEOGRAPHIC)
+   if (theModelType == ModelTypeGeographic)
    {
       if (!theAngularUnits && traceDebug())
       {
@@ -1336,7 +1538,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
          }
       }  // End of switch on theAngularUnits.
    }
-   else if (theModelType == MODEL_TYPE_PROJECTED)
+   else if (theModelType == ModelTypeProjected)
    {
       if(!modelTransformFlag)
       {
@@ -1363,6 +1565,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
                  ossimKeywordNames::ORIGIN_LATITUDE_KW,
                  theOriginLat);
       }
+#if 0
       else if(ossim::isnan(theCenterLat) == false)
       {
          // origin
@@ -1370,20 +1573,21 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
                  ossimKeywordNames::ORIGIN_LATITUDE_KW,
                  theCenterLat);
       }
-
+#endif
       if(ossim::isnan(theOriginLon) == false)
       {
          kwl.add(copyPrefix.c_str(),
                  ossimKeywordNames::CENTRAL_MERIDIAN_KW,
                  theOriginLon);
       }
+#if 0
       else if(ossim::isnan(theCenterLon) == false)
       {
          kwl.add(copyPrefix.c_str(),
                  ossimKeywordNames::CENTRAL_MERIDIAN_KW,
                  theCenterLon);
       }
-
+#endif
       // std paralles for conical projections
       kwl.add(copyPrefix.c_str(),
               ossimKeywordNames::STD_PARALLEL_1_KW,
@@ -1468,17 +1672,6 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
               theScaleFactor,
               true);  // overwrite keyword if previously added...
    }
-   else if (getOssimProjectionName() == "ossimLambertConformalConicProjection")
-   {
-      if (ossim::isnan(theCenterLon) == false)
-      {
-         kwl.add(copyPrefix.c_str(),
-                 ossimKeywordNames::CENTRAL_MERIDIAN_KW,
-                 theCenterLon,
-                 true); // overwrite keyword if previously added...
-      }
-   }
-
    //---
    // Get the model transformation info if it's present.
    //---
@@ -1494,7 +1687,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
       }
       kwl.add(copyPrefix, ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW, out.str().c_str(), true);
       ossimUnitType modelTransformUnitType = OSSIM_UNIT_UNKNOWN;
-      if(theModelType == MODEL_TYPE_GEOGRAPHIC)
+      if(theModelType == ModelTypeGeographic)
       {
          switch(theAngularUnits)
          {
@@ -1517,7 +1710,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
             }
          }
       }
-      else if(theModelType == MODEL_TYPE_PROJECTED)
+      else if(theModelType == ModelTypeProjected)
       {
          switch(theLinearUnitsCode)
          {
@@ -1555,11 +1748,6 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
          << "DEBUG ossimGeoTiff::addImageGeometry: Keyword list dump:\n"
          << kwl << std::endl;
    }
-#if 0
-   std::cout << "_________________________________________________________" << std::endl;
-   std::cout << kwl << std::endl;
-   std::cout << "_________________________________________________________" << std::endl;
-#endif
    
    return true;
 }
@@ -1612,7 +1800,7 @@ void ossimGeoTiff::setOssimProjectionName()
    // If still unknown check for the model type.
    if (theProjectionName == "unknown")
    {
-      if (theModelType == MODEL_TYPE_GEOGRAPHIC)
+      if (theModelType == ModelTypeGeographic)
       {
          theProjectionName = "ossimEquDistCylProjection";
       }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimIkonosMetaData.cpp b/Utilities/otbossim/src/ossim/support_data/ossimIkonosMetaData.cpp
index 0ad6160acecb6499cef6d4e3c32b8c28fa5f5121..1e29290bb0dfcca2d3fcd883a29c51719e4d47bf 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimIkonosMetaData.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimIkonosMetaData.cpp
@@ -11,7 +11,7 @@
 // This class parses a Space Imaging Ikonos meta data file.
 //
 //********************************************************************
-// $Id: ossimIkonosMetaData.cpp 14431 2009-04-30 21:58:33Z dburken $
+// $Id: ossimIkonosMetaData.cpp 14546 2009-05-18 18:58:05Z dburken $
 
 #include <cstdio>
 #include <iostream>
@@ -65,7 +65,7 @@ bool ossimIkonosMetaData::open(const ossimFilename& imageFile)
       if(traceDebug())
       {
          ossimNotify(ossimNotifyLevel_DEBUG)
-         << MODULE << " Ikonos filename non standard" << std::endl;
+            << MODULE << " Ikonos filename non standard" << std::endl;
       }
       return false;
    }
@@ -81,7 +81,7 @@ bool ossimIkonosMetaData::open(const ossimFilename& imageFile)
       if(traceDebug())
       {
          ossimNotify(ossimNotifyLevel_WARN)
-         << MODULE << " errors parsing metadata" << std::endl;
+            << MODULE << " errors parsing metadata" << std::endl;
       }
       return false;
    }
@@ -93,7 +93,7 @@ bool ossimIkonosMetaData::open(const ossimFilename& imageFile)
       if(traceDebug())
       {
          ossimNotify(ossimNotifyLevel_WARN)
-         << MODULE << " errors parsing hdr" << std::endl;
+            << MODULE << " errors parsing hdr" << std::endl;
       }
       return false;
    }
@@ -105,7 +105,7 @@ bool ossimIkonosMetaData::open(const ossimFilename& imageFile)
       if(traceDebug())
       {
          ossimNotify(ossimNotifyLevel_WARN)
-         << MODULE << " errors parsing rpc" << std::endl;
+            << MODULE << " errors parsing rpc" << std::endl;
       }
       return false;
    }
@@ -154,7 +154,7 @@ ossimString ossimIkonosMetaData::getSensorID() const
 }
 
 bool ossimIkonosMetaData::saveState(ossimKeywordlist& kwl,
-                                          const char* prefix)const
+                                    const char* prefix)const
 {
 
   kwl.add(prefix,
@@ -216,22 +216,22 @@ bool ossimIkonosMetaData::saveState(ossimKeywordlist& kwl,
 }
 
 bool ossimIkonosMetaData::loadState(const ossimKeywordlist& kwl,
-                                          const char* prefix)
+                                    const char* prefix)
 {
-  clearFields();
+   clearFields();
 
-  const char* lookup = 0;
-  ossimString s;
+   const char* lookup = 0;
+   ossimString s;
   
-  lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
-  if (lookup)
-  {
-     s = lookup;
-     if(s != "ossimIkonosMetaData")
-     {
-        return false;
-     }
-  }
+   lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   if (lookup)
+   {
+      s = lookup;
+      if(s != "ossimIkonosMetaData")
+      {
+         return false;
+      }
+   }
 
   lookup = kwl.find(prefix, "nominal_collection_azimuth_angle");
   if (lookup)
@@ -247,39 +247,39 @@ bool ossimIkonosMetaData::loadState(const ossimKeywordlist& kwl,
      theNominalCollectionElevation = s.toFloat64();
   }
   
-  lookup = kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW);
-  if (lookup)
-  {
-     s = lookup;
-     theSunAzimuth = s.toFloat64();
-  }
+   lookup = kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW);
+   if (lookup)
+   {
+      s = lookup;
+      theSunAzimuth = s.toFloat64();
+   }
 
-  lookup = kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW);
-  if (lookup)
-  {
-     s = lookup;
-     theSunElevation = s.toFloat64();
-  }
+   lookup = kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW);
+   if (lookup)
+   {
+      s = lookup;
+      theSunElevation = s.toFloat64();
+   }
   
-  lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_BANDS_KW);
-  if (lookup)
-  {
-     s = lookup;
-     theNumBands = s.toUInt32();
-  }
+   lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_BANDS_KW);
+   if (lookup)
+   {
+      s = lookup;
+      theNumBands = s.toUInt32();
+   }
 
-  lookup = kwl.find(prefix, "band_name");
-  if (lookup)
-  {
-     theBandName = lookup;
-  }
+   lookup = kwl.find(prefix, "band_name");
+   if (lookup)
+   {
+      theBandName = lookup;
+   }
+
+   lookup = kwl.find(prefix, "production_date");
+   if (lookup)
+   {
+      theProductionDate = lookup;
+   }
 
-  lookup = kwl.find(prefix, "production_date");
-  if (lookup)
-  {
-     theProductionDate = lookup;
-  }
-  
   lookup = kwl.find(prefix, "acquisition_date");
   if (lookup)
   {
@@ -298,7 +298,7 @@ bool ossimIkonosMetaData::loadState(const ossimKeywordlist& kwl,
      theSensorID = lookup;
   }
   
-  return true;
+   return true;
 }
 
 //*****************************************************************************
@@ -309,59 +309,58 @@ bool ossimIkonosMetaData::loadState(const ossimKeywordlist& kwl,
 //*****************************************************************************
 bool ossimIkonosMetaData::parseMetaData(const ossimFilename& data_file)
 {
-  if (traceExec())
-  {
-    ossimNotify(ossimNotifyLevel_DEBUG)
-        << "DEBUG ossimIkonosRpcModel::parseMetaData(data_file): entering..."
-        << std::endl;
-  }
-
-  FILE* fptr = fopen (data_file, "r");
-  if (!fptr)
-  {
-    if (traceDebug())
-    {
+   if (traceExec())
+   {
       ossimNotify(ossimNotifyLevel_DEBUG)
-          << "ossimIkonosRpcModel::parseMetaData(data_file) DEBUG:"
-          << "\nCould not open Meta data file:  " << data_file
-          << "\nreturning with error..." << std::endl;
-    }
-    return false;
-  }
+         << "DEBUG ossimIkonosRpcModel::parseMetaData(data_file): entering..."
+         << std::endl;
+   }
 
-  char* strptr;
-   // char linebuf[80];
-  char dummy[80], name[80];
-  double value;
+   FILE* fptr = fopen (data_file, "r");
+   if (!fptr)
+   {
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "ossimIkonosRpcModel::parseMetaData(data_file) DEBUG:"
+            << "\nCould not open Meta data file:  " << data_file
+            << "\nreturning with error..." << std::endl;
+      }
+      return false;
+   }
 
-  //---
-  // Read the file into a buffer:
-  //---
-  ossim_int32 fileSize = static_cast<ossim_int32>(data_file.fileSize());
-  char* filebuf = new char[fileSize];
-  fread(filebuf, 1, fileSize, fptr);
-  fclose(fptr);
+   char* strptr;
+   char dummy[80], name[80];
+   double value;
 
-  //---
-  // Production date:
-  //---
-  strptr = strstr(filebuf, "\nCreation Date:");
-  if (!strptr)
-  {
-    if(traceDebug())
-    {
-      ossimNotify(ossimNotifyLevel_FATAL)
-          << "FATAL ossimIkonosRpcModel::parseMetaData(data_file): "
-          << "\n\tAborting construction. Error encountered parsing "
-          << "presumed meta-data file." << std::endl;
+   //---
+   // Read the file into a buffer:
+   //---
+   ossim_int32 fileSize = static_cast<ossim_int32>(data_file.fileSize());
+   char* filebuf = new char[fileSize];
+   fread(filebuf, 1, fileSize, fptr);
+   fclose(fptr);
+
+   //---
+   // Production date:
+   //---
+   strptr = strstr(filebuf, "\nCreation Date:");
+   if (!strptr)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
+            << "FATAL ossimIkonosRpcModel::parseMetaData(data_file): "
+            << "\n\tAborting construction. Error encountered parsing "
+            << "presumed meta-data file." << std::endl;
 
       delete [] filebuf;
       return false;
     }
   }
 
-  sscanf(strptr, "%15c %s", dummy, name);
-  theProductionDate = name;
+   sscanf(strptr, "%15c %s", dummy, name);
+   theProductionDate = name;
 
 
   //***
@@ -430,44 +429,44 @@ bool ossimIkonosMetaData::parseMetaData(const ossimFilename& data_file)
    //***
    // Sun Azimuth:
    //***
-  strptr = strstr(strptr, "\nSun Angle Azimuth:");
-  if (!strptr)
-  {
-    if(traceDebug())
-    {
-      ossimNotify(ossimNotifyLevel_FATAL)
-          << "FATAL ossimIkonosRpcModel::parseMetaData(data_file): "
-          << "\n\tAborting construction. Error encountered parsing "
-          << "presumed meta-data file." << std::endl;
+   strptr = strstr(strptr, "\nSun Angle Azimuth:");
+   if (!strptr)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
+            << "FATAL ossimIkonosRpcModel::parseMetaData(data_file): "
+            << "\n\tAborting construction. Error encountered parsing "
+            << "presumed meta-data file." << std::endl;
 
       delete [] filebuf;
       return false;
     }
   }
 
-  sscanf(strptr, "%19c %lf %s", dummy, &value, dummy);
-  theSunAzimuth = value;
+   sscanf(strptr, "%19c %lf %s", dummy, &value, dummy);
+   theSunAzimuth = value;
 
    //***
    // Sun Elevation:
    //***
-  strptr = strstr(strptr, "\nSun Angle Elevation:");
-  if (!strptr)
-  {
-    if(traceDebug())
-    {
-      ossimNotify(ossimNotifyLevel_FATAL)
-          << "FATAL ossimIkonosRpcModel::parseMetaData(data_file): "
-          << "\n\tAborting construction. Error encountered parsing "
-          << "presumed meta-data file." << std::endl;
+   strptr = strstr(strptr, "\nSun Angle Elevation:");
+   if (!strptr)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
+            << "FATAL ossimIkonosRpcModel::parseMetaData(data_file): "
+            << "\n\tAborting construction. Error encountered parsing "
+            << "presumed meta-data file." << std::endl;
 
       delete [] filebuf;
       return false;
     }
   }
 
-  sscanf(strptr, "%21c %lf %s", dummy, &value, name);
-  theSunElevation = value;
+   sscanf(strptr, "%21c %lf %s", dummy, &value, name);
+   theSunElevation = value;
 
   //---
   // Acquisition date and time:
@@ -491,17 +490,17 @@ bool ossimIkonosMetaData::parseMetaData(const ossimFilename& data_file)
   theAcquisitionDate = name;
   theAcquisitionTime = name2;
 
-  delete [] filebuf;
-  filebuf = 0;
+   delete [] filebuf;
+   filebuf = 0;
 
-  if (traceExec())
-  {
-    ossimNotify(ossimNotifyLevel_DEBUG)
-        << "DEBUG ossimIkonosRpcModel::parseMetaData(data_file): returning..."
-        << std::endl;
-  }
+   if (traceExec())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimIkonosRpcModel::parseMetaData(data_file): returning..."
+         << std::endl;
+   }
 
-  return true;
+   return true;
 }
 
 //*****************************************************************************
@@ -512,86 +511,86 @@ bool ossimIkonosMetaData::parseMetaData(const ossimFilename& data_file)
 //*****************************************************************************
 bool ossimIkonosMetaData::parseHdrData(const ossimFilename& data_file)
 {
-  if (traceExec())
-  {
-    ossimNotify(ossimNotifyLevel_DEBUG)
-        << "DEBUG ossimIkonosRpcModel::parseHdrData(data_file): entering..."
-        << std::endl;
-  }
+   if (traceExec())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimIkonosRpcModel::parseHdrData(data_file): entering..."
+         << std::endl;
+   }
 
-  FILE* fptr = fopen (data_file, "r");
-  if (!fptr)
-  {
-    if (traceDebug())
-    {
-      ossimNotify(ossimNotifyLevel_WARN)
-          << "ossimIkonosRpcModel::parseHdrData(data_file) WARN:"
-          << "\nCould not open hdr data file <" << data_file << ">. "
-          << "returning with error..." << std::endl;
-    }
-    return false;
-  }
+   FILE* fptr = fopen (data_file, "r");
+   if (!fptr)
+   {
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimIkonosRpcModel::parseHdrData(data_file) WARN:"
+            << "\nCould not open hdr data file <" << data_file << ">. "
+            << "returning with error..." << std::endl;
+      }
+      return false;
+   }
 
-  char* strptr;
+   char* strptr;
    // char linebuf[80];
-  char dummy[80];
-  char name[80];
-  int value=0;
+   char dummy[80];
+   char name[80];
+   int value=0;
 
    //***
    // Read the file into a buffer:
    //***
-  char filebuf[5000];
-  fread(filebuf, 1, 5000, fptr);
-  fclose(fptr);
+   char filebuf[5000];
+   fread(filebuf, 1, 5000, fptr);
+   fclose(fptr);
 
    //***
    // Band name:
    //***
-  strptr = strstr(filebuf, "\nBand:");
-  if (!strptr)
-  {
-    if(traceDebug())
-    {
-      ossimNotify(ossimNotifyLevel_WARN)
-          << "ossimIkonosRpcModel::parseHdrData(data_file):"
-          << "\n\tAborting construction. Error encountered parsing "
-          << "presumed hdr file." << std::endl;
-    }
+   strptr = strstr(filebuf, "\nBand:");
+   if (!strptr)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimIkonosRpcModel::parseHdrData(data_file):"
+            << "\n\tAborting construction. Error encountered parsing "
+            << "presumed hdr file." << std::endl;
+      }
 
-    return false;
-  }
+      return false;
+   }
 
-  sscanf(strptr, "%6c %s", dummy, name);
-  theBandName = name;
+   sscanf(strptr, "%6c %s", dummy, name);
+   theBandName = name;
 
    //***
    // Number of Bands:
    //***
-  strptr = strstr(filebuf, "\nNumber of Bands:");
-  if (!strptr)
-  {
-    if(traceDebug())
-    {
-      ossimNotify(ossimNotifyLevel_WARN)
-          << "ossimIkonosRpcModel::parseHdrData(data_file):"
-          << "\n\tAborting construction. Error encountered parsing "
-          << "presumed hdr file." << std::endl;
-    }
+   strptr = strstr(filebuf, "\nNumber of Bands:");
+   if (!strptr)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimIkonosRpcModel::parseHdrData(data_file):"
+            << "\n\tAborting construction. Error encountered parsing "
+            << "presumed hdr file." << std::endl;
+      }
 
-    return false;
-  }
+      return false;
+   }
 
-  sscanf(strptr, "%17c %d", dummy, &value);
-  theNumBands = value;
+   sscanf(strptr, "%17c %d", dummy, &value);
+   theNumBands = value;
 
-  if (traceExec())
-  {
-    ossimNotify(ossimNotifyLevel_DEBUG)
-        << "DEBUG ossimIkonosRpcModel::parseHdrData(data_file): returning..."
-        << std::endl;
-  }
-  return true;
+   if (traceExec())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimIkonosRpcModel::parseHdrData(data_file): returning..."
+         << std::endl;
+   }
+   return true;
 }
 
 //*****************************************************************************
@@ -602,5 +601,5 @@ bool ossimIkonosMetaData::parseHdrData(const ossimFilename& data_file)
 //*****************************************************************************
 bool ossimIkonosMetaData::parseRpcData(const ossimFilename& data_file)
 {
-  return true;
+   return true;
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimInfoBase.cpp b/Utilities/otbossim/src/ossim/support_data/ossimInfoBase.cpp
index da8d794621cc7a1a48f4494fae994761c283685e..0373e7708ec7ca05b362b685d47f56de4d7ca105 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimInfoBase.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimInfoBase.cpp
@@ -12,6 +12,8 @@
 // $Id$
 
 #include <ossim/support_data/ossimInfoBase.h>
+#include <ossim/base/ossimIoStream.h> /* for ossimIOMemoryStream */
+#include <ossim/base/ossimKeywordlist.h>
 
 ossimInfoBase::ossimInfoBase()
    : theOverviewFlag(true)
@@ -29,3 +31,14 @@ bool ossimInfoBase::getProcessOverviewFlag() const
 {
    return theOverviewFlag;
 }
+
+
+bool ossimInfoBase::getKeywordlist(ossimKeywordlist& kwl)
+{  
+   // Do a print to a memory stream.
+   ossimIOMemoryStream memStr;
+   print(memStr);
+
+   // Give the result to the keyword list.
+   return kwl.parseStream(memStr);
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimInfoFactory.cpp b/Utilities/otbossim/src/ossim/support_data/ossimInfoFactory.cpp
index 39a520a40e443ae20dd2013cc5c74720475e68d4..da4291a6f3abe5b3f6ce16ce0d76d12bf983d26d 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimInfoFactory.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimInfoFactory.cpp
@@ -14,7 +14,9 @@
 #include <ossim/support_data/ossimInfoFactory.h>
 #include <ossim/support_data/ossimInfoBase.h>
 #include <ossim/support_data/ossimCcfInfo.h>
+#include <ossim/support_data/ossimDemInfo.h>
 #include <ossim/support_data/ossimDtedInfo.h>
+#include <ossim/support_data/ossimJ2kInfo.h>
 #include <ossim/support_data/ossimNitfInfo.h>
 #include <ossim/support_data/ossimTiffInfo.h>
 
@@ -35,6 +37,17 @@ ossimInfoBase* ossimInfoFactory::create(const ossimFilename& file) const
 {
    ossimInfoBase* result = 0;
 
+   result = new ossimJ2kInfo();
+   if ( result->open(file) )
+   {
+      return result;
+   }
+   else
+   {
+      delete result;
+      result = 0;
+   }
+
    result = new ossimNitfInfo();
    if ( result->open(file) )
    {
@@ -57,6 +70,17 @@ ossimInfoBase* ossimInfoFactory::create(const ossimFilename& file) const
       result = 0;
    }
 
+   result = new ossimDemInfo();
+   if ( result->open(file) )
+   {
+      return result;
+   }
+   else
+   {
+      delete result;
+      result = 0;
+   }
+
    result = new ossimDtedInfo();
    if ( result->open(file) )
    {
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimInfoFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/support_data/ossimInfoFactoryRegistry.cpp
index 6d055aba88abb66b23d63b4fa13e9106697f01df..9bad48df6ab4312af5ef0cad986230cfb63238f6 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimInfoFactoryRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimInfoFactoryRegistry.cpp
@@ -9,6 +9,8 @@
 //----------------------------------------------------------------------------
 // $Id$
 
+#include <algorithm> /* for std::find */
+
 #include <ossim/base/ossimFilename.h>
 #include <ossim/support_data/ossimInfoFactoryRegistry.h>
 #include <ossim/support_data/ossimInfoFactoryInterface.h>
@@ -34,6 +36,18 @@ void ossimInfoFactoryRegistry::registerFactory(
    }
 }
 
+void ossimInfoFactoryRegistry::unregisterFactory(
+   ossimInfoFactoryInterface* factory)
+{
+   std::vector<ossimInfoFactoryInterface*>::iterator i =
+      std::find(theFactoryList.begin(), theFactoryList.end(), factory);
+   
+   if( i != theFactoryList.end() )
+   {
+      theFactoryList.erase(i);
+   }
+}
+
 ossimInfoBase* ossimInfoFactoryRegistry::create(
    const ossimFilename& file) const
 {
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimJ2kCodRecord.cpp b/Utilities/otbossim/src/ossim/support_data/ossimJ2kCodRecord.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..42e5abcbe4efb188a14e02da626a1308b620efa5
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimJ2kCodRecord.cpp
@@ -0,0 +1,93 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Container class for J2K Coding style default (COD) record.
+//
+// See document BPJ2K01.00 Table 7-7 Image and tile size (15444-1 Annex A5.1)
+// 
+//----------------------------------------------------------------------------
+// $Id: ossimJ2kCodRecord.h,v 1.5 2005/10/13 21:24:47 dburken Exp $
+
+#include <iostream>
+#include <iomanip>
+
+#include <ossim/support_data/ossimJ2kCodRecord.h>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimEndian.h>
+
+
+ossimJ2kCodRecord::ossimJ2kCodRecord()
+   :
+   theMarker(0xff52),
+   theLcod(0),
+   theScod(0),
+   theSGcod(0),
+   theSPcod(0)
+{
+}
+
+ossimJ2kCodRecord::~ossimJ2kCodRecord()
+{
+}
+
+void ossimJ2kCodRecord::parseStream(std::istream& in)
+{
+   // Get the stream posistion.
+   std::streamoff pos = in.tellg();
+
+   // Note: Marker is not read.
+   in.read((char*)&theLcod,      2);
+   in.read((char*)&theScod,      1);
+   in.read((char*)&theSGcod,     4);
+   in.read((char*)&theSPcod,     4);
+
+   if (ossim::byteOrder() == OSSIM_LITTLE_ENDIAN)
+   {
+      // Stored big endian, must swap.
+      ossimEndian s;
+      s.swap(theLcod);
+      s.swap(theSGcod);
+   }
+
+   //---
+   // Seek to next record.  This is needed because there are sometimes extra
+   // bytes.
+   //---
+   in.seekg(pos + theLcod, std::ios_base::beg);
+}
+
+std::ostream& ossimJ2kCodRecord::print(std::ostream& out,
+                                       const std::string& prefix) const
+{
+   // Capture the original flags.
+   std::ios_base::fmtflags f = out.flags();
+
+   std::string pfx = prefix;
+   pfx += "cod.";
+
+   out.setf(std::ios_base::hex, std::ios_base::basefield);
+   out << pfx << "marker: 0x" << theMarker << "\n";
+   out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
+
+   out << pfx << "Lcod:   " << theLcod       << "\n"
+       << pfx << "Scod:   " << int(theScod)  << "\n"
+       << pfx << "SGcod:  " << theSGcod      << "\n"
+       << pfx << "SPcod:  " << int(theSPcod)
+       << std::endl;
+
+   // Reset flags.
+   out.setf(f);
+
+   return out;
+}
+
+std::ostream& operator<<(std::ostream& out, const ossimJ2kCodRecord& obj)
+{
+   return obj.print(out);
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimJ2kInfo.cpp b/Utilities/otbossim/src/ossim/support_data/ossimJ2kInfo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0204119a39f75c45182c7562959f901b19436e30
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimJ2kInfo.cpp
@@ -0,0 +1,248 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: J2K Info object.
+// 
+//----------------------------------------------------------------------------
+// $Id$
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <ossim/support_data/ossimJ2kInfo.h>
+#include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimEndian.h>
+#include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/support_data/ossimJ2kCodRecord.h>
+#include <ossim/support_data/ossimJ2kSizRecord.h>
+#include <ossim/support_data/ossimJ2kSotRecord.h>
+
+// Static trace for debugging
+static ossimTrace traceDebug("ossimJ2kInfo:debug");
+static ossimTrace traceDump("ossimJ2kInfo:dump"); // This will dump offsets.
+
+static const ossim_uint16 SOC_MARKER = 0xff4f; // start of codestream marker
+static const ossim_uint16 SIZ_MARKER = 0xff51; // size maker
+static const ossim_uint16 COD_MARKER = 0xff52; // cod maker
+static const ossim_uint16 SOT_MARKER = 0xff90; // start of tile marker
+static const ossim_uint16 EOC_MARKER = 0xffd9; // End of codestream marker.
+
+ossimJ2kInfo::ossimJ2kInfo()
+   : ossimInfoBase(),
+     theFile(),
+     theEndian(0)
+{
+}
+
+ossimJ2kInfo::~ossimJ2kInfo()
+{
+   if (theEndian)
+   {
+      delete theEndian;
+      theEndian = 0;
+   }
+}
+
+bool ossimJ2kInfo::open(const ossimFilename& file)
+{
+   bool result = false;
+
+   //---
+   // Open the file.
+   //---
+   std::ifstream str(file.c_str(), std::ios_base::binary|std::ios_base::in);
+   if (str.good()) 
+   {
+      if (ossim::byteOrder() == OSSIM_LITTLE_ENDIAN)
+      {
+         if (!theEndian)
+         {
+            theEndian = new ossimEndian();
+         }
+      }
+      else if (theEndian)
+      {
+         delete theEndian;
+         theEndian = 0;
+      }
+
+      //---
+      // 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;
+      readShort(soc, str);
+      readShort(siz, str);
+
+      if ( (soc == SOC_MARKER) && (siz == SIZ_MARKER) )
+      {
+         result = true; // Is a j2k...
+      }
+   }
+
+   if (result)
+   {
+      theFile = file;
+   }
+   else
+   {
+      theFile.clear();
+      if (theEndian)
+      {
+         delete theEndian;
+         theEndian = 0;
+      }
+   }
+
+   return result;
+}
+
+std::ostream& ossimJ2kInfo::print(std::ostream& out) const
+{
+   static const char MODULE[] = "ossimJ2kInfo::print";
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " DEBUG Entered...\n";
+   }
+      
+   //---
+   // Open the tif file.
+   //---
+   std::ifstream str(theFile.c_str(), std::ios_base::binary|std::ios_base::in);
+   if (str.good())
+   {
+      ossim_uint16 marker;
+      readShort(marker, str); // SOC
+      readShort(marker, str); // SIZ
+
+      std::string prefix = "j2k.";
+
+      // SIZ marker required next.
+      printSizMarker(out, prefix, str);
+
+      readShort(marker, str);
+      
+      while ( str.good() && (marker != EOC_MARKER) ) // marker != SOT_MARKER )
+      {
+         switch(marker)
+         {
+            case COD_MARKER:
+            {
+               printCodMarker(out, prefix, str);
+               break;
+            }
+            case SOT_MARKER:
+            {
+               printSotMarker(out, prefix, str);
+               break;
+            }
+            default:
+            {
+               printUnknownMarker(out, prefix, str, marker);
+            }
+         }
+
+         readShort(marker, str);
+        
+      }
+   }
+   else
+   {
+      if (traceDebug())
+      {
+         out << MODULE << " Cannot open file:  " << theFile << std::endl;
+      }
+   }
+
+   return out;
+}
+
+void ossimJ2kInfo::readShort(ossim_uint16& s, std::ifstream& str) const
+{
+   str.read((char*)&s, sizeof(s));
+   if (theEndian)
+   {
+      theEndian->swap(s);
+   }
+}
+
+std::ostream& ossimJ2kInfo::printCodMarker(std::ostream& out,
+                                           const std::string& prefix,
+                                           std::ifstream& str) const
+{
+   ossimJ2kCodRecord siz;
+   siz.parseStream(str);
+   siz.print(out, prefix);
+   return out;
+}
+
+std::ostream& ossimJ2kInfo::printSizMarker(std::ostream& out,
+                                           const std::string& prefix,
+                                           std::ifstream& str) const
+{
+   ossimJ2kSizRecord siz;
+   siz.parseStream(str);
+   siz.print(out, prefix);
+   return out;
+}
+
+std::ostream& ossimJ2kInfo::printSotMarker(std::ostream& out,
+                                           const std::string& prefix,
+                                           std::ifstream& str) const
+{
+   // Get the stream posistion.
+   std::streamoff pos = str.tellg();
+   
+   ossimJ2kSotRecord sot;
+   sot.parseStream(str);
+   pos += sot.thePsot - 2;
+
+   // Seek past the tile to the next marker.
+   str.seekg(pos, std::ios_base::beg);
+   
+   sot.print(out,prefix);
+   return out;
+}
+
+
+std::ostream& ossimJ2kInfo::printUnknownMarker(std::ostream& out,
+                                               const std::string& prefix,
+                                               std::ifstream& str,
+                                               ossim_uint16 marker) const
+{
+   // Capture the original flags.
+   std::ios_base::fmtflags f = out.flags();
+
+   ossim_uint16 segmentLength;
+   readShort(segmentLength, str);
+
+   std::string pfx = prefix;
+   pfx += "unkown.";
+
+   out.setf(std::ios_base::hex, std::ios_base::basefield);
+   out << pfx << "marker: 0x" << std::setfill('0') << std::setw(4)
+       << marker << "\n";
+   out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
+   
+   out << pfx << "length: " << segmentLength
+       << std::endl;
+
+   // Reset flags.
+   out.setf(f);
+
+   // Seek to the next marker.
+   str.seekg( (segmentLength-2), std::ios_base::cur);
+
+   return out;
+}
+      
+
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp
index c6ad0a866ff5102e1b5ae98685a12b1d43fc6c07..91a069c39bc9244fdfa232cdfec42d230fc54390 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp
@@ -24,11 +24,11 @@
 
 ossimJ2kSizRecord::ossimJ2kSizRecord()
    :
-   theSizMarker(0xff51),
+   theMarker(0xff51),
    theLsiz(0),
    theRsiz(0),
    theXsiz(0),
-   theYziz(0),
+   theYsiz(0),
    theXOsiz(0),
    theYOsiz(0),
    theXTsiz(0),
@@ -48,11 +48,14 @@ ossimJ2kSizRecord::~ossimJ2kSizRecord()
 
 void ossimJ2kSizRecord::parseStream(std::istream& in)
 {
+   // Get the stream posistion.
+   std::streamoff pos = in.tellg();
+
    // Note: Marker is not read.
    in.read((char*)&theLsiz,      2);
    in.read((char*)&theRsiz,      2);
    in.read((char*)&theXsiz,      4);
-   in.read((char*)&theYziz,      4);
+   in.read((char*)&theYsiz,      4);
    in.read((char*)&theXOsiz,     4);
    in.read((char*)&theYOsiz,     4);
    in.read((char*)&theXTsiz,     4);
@@ -71,7 +74,7 @@ void ossimJ2kSizRecord::parseStream(std::istream& in)
       s.swap(theLsiz);
       s.swap(theRsiz);
       s.swap(theXsiz);
-      s.swap(theYziz);
+      s.swap(theYsiz);
       s.swap(theXOsiz);
       s.swap(theYOsiz);
       s.swap(theXTsiz);
@@ -80,6 +83,12 @@ void ossimJ2kSizRecord::parseStream(std::istream& in)
       s.swap(theYTOsiz);
       s.swap(theCsiz);
    }
+
+   //---
+   // Seek to next record.  This is needed because there are sometimes extra
+   // bytes.
+   //---
+   in.seekg(pos + theLsiz, std::ios_base::beg);
 }
 
 ossimScalarType ossimJ2kSizRecord::getScalarType() const
@@ -119,27 +128,33 @@ ossimScalarType ossimJ2kSizRecord::getScalarType() const
    return result;
 }
 
-std::ostream& ossimJ2kSizRecord::print(std::ostream& out) const
+std::ostream& ossimJ2kSizRecord::print(std::ostream& out,
+                                       const std::string& prefix) const
 {
    // Capture the original flags.
    std::ios_base::fmtflags f = out.flags();
 
-   out << std::setiosflags(std::ios::left) << "ossimJ2kSizRecord::print"
-       << std::setw(24) << "\ntheSizMarker:" << std::hex << theSizMarker
-       << std::setw(24) << "\ntheLsiz:"      << std::dec << theLsiz
-       << std::setw(24) << "\ntheRsiz:"   << theRsiz
-       << std::setw(24) << "\ntheXsiz:"   << theXsiz
-       << std::setw(24) << "\ntheYziz:"   << theYziz
-       << std::setw(24) << "\ntheXOsiz:"  << theXOsiz
-       << std::setw(24) << "\ntheYOsiz:"  << theYOsiz
-       << std::setw(24) << "\ntheXTsiz:"  << theXTsiz
-       << std::setw(24) << "\ntheYTsiz:"  << theYTsiz
-       << std::setw(24) << "\ntheXTOsiz:" << theXTOsiz
-       << std::setw(24) << "\ntheYTOsiz:" << theYTOsiz
-       << std::setw(24) << "\ntheCsiz:"   << theCsiz
-       << std::setw(24) << "\ntheSsiz:"   << int(theSsiz)
-       << std::setw(24) << "\ntheXRsiz:"  << int(theXRsiz)
-       << std::setw(24) << "\ntheYRsiz:"  << int(theYRsiz)
+   std::string pfx = prefix;
+   pfx += "siz.";
+
+   out.setf(std::ios_base::hex, std::ios_base::basefield);
+   out << pfx << "marker: 0x" << theMarker << "\n";
+   out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
+
+   out << pfx << "Lsiz:   " << theLsiz       << "\n"
+       << pfx << "Rsiz:   " << theRsiz       << "\n"
+       << pfx << "Xsiz:   " << theXsiz       << "\n"
+       << pfx << "Yziz:   " << theYsiz       << "\n"
+       << pfx << "XOsiz:  " << theXOsiz      << "\n"
+       << pfx << "YOsiz:  " << theYOsiz      << "\n"
+       << pfx << "XTsiz:  " << theXTsiz      << "\n"
+       << pfx << "YTsiz:  " << theYTsiz      << "\n"
+       << pfx << "XTOsiz: " << theXTOsiz     << "\n"
+       << pfx << "YTOsiz: " << theYTOsiz     << "\n"
+       << pfx << "Csiz:   " << theCsiz       << "\n"
+       << pfx << "Ssiz:   " << int(theSsiz)  << "\n"
+       << pfx << "XRsiz:  " << int(theXRsiz) << "\n"
+       << pfx << "YRsiz:  " << int(theYRsiz)
        << std::endl;
 
    // Reset flags.
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp
index 66d32d4828e8acc46bd5d4854fd02d160e81a12c..b4f0d22906c507c87b236778289a8c3b6b23cd80 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp
@@ -22,7 +22,7 @@
 
 ossimJ2kSotRecord::ossimJ2kSotRecord()
    :
-   theSotMarker(0xff90),
+   theMarker(0xff90),
    theLsot(0),
    theIsot(0),
    thePsot(0),
@@ -55,16 +55,29 @@ void ossimJ2kSotRecord::parseStream(std::istream& in)
    }
 }
 
-std::ostream& ossimJ2kSotRecord::print(std::ostream& out) const
+std::ostream& ossimJ2kSotRecord::print(std::ostream& out,
+                                       const std::string& prefix) const
 {
-   out << std::setiosflags(std::ios::left) << "ossimJ2kSotRecord::print"
-       << std::setw(24) << "\ntheLsot:"  << theLsot
-       << std::setw(24) << "\ntheIsot:"  << theIsot
-       << std::setw(24) << "\nthePsot:"  << thePsot
-       << std::setw(24) << "\ntheTpsot:" << int(theTpsot)
-       << std::setw(24) << "\ntheTnsot:" << int(theTnsot)
+   // Capture the original flags.
+   std::ios_base::fmtflags f = out.flags();
+
+   std::string pfx = prefix;
+   pfx += "sot.";
+
+   out.setf(std::ios_base::hex, std::ios_base::basefield);
+   out << pfx << "marker: 0x" << theMarker << "\n";
+   out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
+
+   out << pfx << "Lsot:   "  << theLsot      << "\n"
+       << pfx << "Isot:   "  << theIsot      << "\n"
+       << pfx << "Psot:   "  << thePsot      << "\n"
+       << pfx << "Tpsot:  " << int(theTpsot) << "\n"
+       << pfx << "Tnsot:  " << int(theTnsot)
        << std::endl;
 
+   // Reset flags.
+   out.setf(f);
+
    return out;
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfAcftbTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfAcftbTag.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1dbdc4eaf81bea0047d68b3d80b00ac465cf6611
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfAcftbTag.cpp
@@ -0,0 +1,248 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: ACFTB - Aircraft Infomation Extension Format tag class
+// declaration.
+//
+// See document STDI-0002 (version 3), Appendix E, Table E-6 for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#include <cstring>
+#include <istream>
+#include <iostream>
+#include <iomanip>
+
+#include <ossim/support_data/ossimNitfAcftbTag.h>
+
+
+RTTI_DEF1(ossimNitfAcftbTag, "ossimNitfAcftbTag", ossimNitfRegisteredTag);
+
+ossimNitfAcftbTag::ossimNitfAcftbTag()
+   : ossimNitfRegisteredTag()
+{
+   clearFields();
+}
+
+ossimNitfAcftbTag::~ossimNitfAcftbTag()
+{
+}
+
+ossimString ossimNitfAcftbTag::getRegisterTagName() const
+{
+   return "ACFTB";
+}
+
+void ossimNitfAcftbTag::parseStream(std::istream& in)
+{
+   clearFields();
+
+   in.read(theAcMsnId, AC_MSN_ID_SIZE);
+   in.read(theAcTailNo, AC_TAIL_NO_SIZE);
+   in.read(theAcTo, AC_TO_SIZE);
+   in.read(theSensorIdType, SENSOR_ID_TYPE_SIZE);
+   in.read(theSensorId, SENSOR_ID_SIZE);
+   in.read(theSceneSource, SCENE_SOURCE_SIZE);
+   in.read(theScNum, SCNUM_SIZE);
+   in.read(thePDate, PDATE_SIZE);
+   in.read(theImHostNo, IMHOSTNO_SIZE);
+   in.read(theImReqID, IMREQID_SIZE);
+   in.read(theMPlan, MPLAN_SIZE);
+   in.read(theEntLoc, ENTLOC_SIZE);
+   in.read(theLocAccy, LOC_ACCY_SIZE);
+   in.read(theEntelv, ENTELV_SIZE);
+   in.read(theElvUnit, ELV_UNIT_SIZE);
+   in.read(theExitLoc, EXITLOC_SIZE);
+   in.read(theExitElev, EXITELV_SIZE);
+   in.read(theTMap, TMAP_SIZE);
+   in.read(theRowSpacing, ROW_SPACING_SIZE);
+   in.read(theRowSpacingUnits, ROW_SPACING_UNITS_SIZE);
+   in.read(theColSpacing, COL_SPACING_SIZE);
+   in.read(theColSpacingUnits, COL_SPACING_UINTS_SIZE);
+   in.read(theFocalLength, FOCAL_LENGTH_SIZE);
+   in.read(theSenserial, SENSERIAL_SIZE);
+   in.read(theAbSwVer, ABSWVER_SIZE);
+   in.read(theCalDate, CAL_DATE_SIZE);
+   in.read(thePatchTot, PATCH_TOT_SIZE);
+   in.read(theMtiTot, MTI_TOT_SIZE);
+}
+
+void ossimNitfAcftbTag::writeStream(std::ostream& out)
+{
+   out.write(theAcMsnId, AC_MSN_ID_SIZE);
+   out.write(theAcTailNo, AC_TAIL_NO_SIZE);
+   out.write(theAcTo, AC_TO_SIZE);
+   out.write(theSensorIdType, SENSOR_ID_TYPE_SIZE);
+   out.write(theSensorId, SENSOR_ID_SIZE);
+   out.write(theSceneSource, SCENE_SOURCE_SIZE);
+   out.write(theScNum, SCNUM_SIZE);
+   out.write(thePDate, PDATE_SIZE);
+   out.write(theImHostNo, IMHOSTNO_SIZE);
+   out.write(theImReqID, IMREQID_SIZE);
+   out.write(theMPlan, MPLAN_SIZE);
+   out.write(theEntLoc, ENTLOC_SIZE);
+   out.write(theLocAccy, LOC_ACCY_SIZE);
+   out.write(theEntelv, ENTELV_SIZE);
+   out.write(theElvUnit, ELV_UNIT_SIZE);
+   out.write(theExitLoc, EXITLOC_SIZE);
+   out.write(theExitElev, EXITELV_SIZE);
+   out.write(theTMap, TMAP_SIZE);
+   out.write(theRowSpacing, ROW_SPACING_SIZE);
+   out.write(theRowSpacingUnits, ROW_SPACING_UNITS_SIZE);
+   out.write(theColSpacing, COL_SPACING_SIZE);
+   out.write(theColSpacingUnits, COL_SPACING_UINTS_SIZE);
+   out.write(theFocalLength, FOCAL_LENGTH_SIZE);
+   out.write(theSenserial, SENSERIAL_SIZE);
+   out.write(theAbSwVer, ABSWVER_SIZE);
+   out.write(theCalDate, CAL_DATE_SIZE);
+   out.write(thePatchTot, PATCH_TOT_SIZE);
+   out.write(theMtiTot, MTI_TOT_SIZE);
+}
+
+ossim_uint32 ossimNitfAcftbTag::getSizeInBytes()const
+{
+   return CEL_SIZE;
+}
+
+void ossimNitfAcftbTag::clearFields()
+{
+   // BCS-N's to '0's, BCS-A's to ' '(spaces)
+
+   // clear
+   memset(theAcMsnId, ' ', AC_MSN_ID_SIZE);
+   memset(theAcTailNo, ' ', AC_TAIL_NO_SIZE);
+   memset(theAcTo, ' ', AC_TO_SIZE);
+   memset(theSensorIdType, ' ', SENSOR_ID_TYPE_SIZE);
+   memset(theSensorId, ' ', SENSOR_ID_SIZE);
+   memset(theSceneSource, ' ', SCENE_SOURCE_SIZE);
+   memset(theScNum, ' ', SCNUM_SIZE);
+   memset(thePDate, ' ', PDATE_SIZE);
+   memset(theImHostNo, ' ', IMHOSTNO_SIZE);
+   memset(theImReqID, ' ', IMREQID_SIZE);
+   memset(theMPlan, ' ', MPLAN_SIZE);
+   memset(theEntLoc, ' ', ENTLOC_SIZE);
+   memset(theLocAccy, ' ', LOC_ACCY_SIZE);
+   memset(theEntelv, ' ', ENTELV_SIZE);
+   memset(theElvUnit, ' ', ELV_UNIT_SIZE);
+   memset(theExitLoc, ' ', EXITLOC_SIZE);
+   memset(theExitElev, ' ', EXITELV_SIZE);
+   memset(theTMap, ' ', TMAP_SIZE);
+   memset(theRowSpacing, ' ', ROW_SPACING_SIZE);
+   memset(theRowSpacingUnits, ' ', ROW_SPACING_UNITS_SIZE);
+   memset(theColSpacing, ' ', COL_SPACING_SIZE);
+   memset(theColSpacingUnits, ' ', COL_SPACING_UINTS_SIZE);
+   memset(theFocalLength, ' ', FOCAL_LENGTH_SIZE);
+   memset(theSenserial, ' ', SENSERIAL_SIZE);
+   memset(theAbSwVer, ' ', ABSWVER_SIZE);
+   memset(theCalDate, ' ', CAL_DATE_SIZE);
+   memset(thePatchTot, ' ', PATCH_TOT_SIZE);
+   memset(theMtiTot, ' ', MTI_TOT_SIZE);
+
+
+   // null terminate
+   theAcMsnId[AC_MSN_ID_SIZE] = '\0';
+   theAcTailNo[AC_TAIL_NO_SIZE] = '\0';
+   theAcTo[AC_TO_SIZE] = '\0';
+   theSensorIdType[SENSOR_ID_TYPE_SIZE] = '\0';
+   theSensorId[SENSOR_ID_SIZE] = '\0';
+   theSceneSource[SCENE_SOURCE_SIZE] = '\0';
+   theScNum[SCNUM_SIZE] = '\0';
+   thePDate[PDATE_SIZE] = '\0';
+   theImHostNo[IMHOSTNO_SIZE] = '\0';
+   theImReqID[IMREQID_SIZE] = '\0';
+   theMPlan[MPLAN_SIZE] = '\0';
+   theEntLoc[ENTLOC_SIZE] = '\0';
+   theLocAccy[LOC_ACCY_SIZE] = '\0';
+   theEntelv[ENTELV_SIZE] = '\0';
+   theElvUnit[ELV_UNIT_SIZE] = '\0';
+   theExitLoc[EXITLOC_SIZE] = '\0';
+   theExitElev[EXITELV_SIZE] = '\0';
+   theTMap[TMAP_SIZE] = '\0';
+   theRowSpacing[ROW_SPACING_SIZE] = '\0';
+   theRowSpacingUnits[ROW_SPACING_UNITS_SIZE] = '\0';
+   theColSpacing[COL_SPACING_SIZE] = '\0';
+   theColSpacingUnits[COL_SPACING_UINTS_SIZE] = '\0';
+   theFocalLength[FOCAL_LENGTH_SIZE] = '\0';
+   theSenserial[SENSERIAL_SIZE] = '\0';
+   theAbSwVer[ABSWVER_SIZE] = '\0';
+   theCalDate[CAL_DATE_SIZE] = '\0';
+   thePatchTot[PATCH_TOT_SIZE] = '\0';
+   theMtiTot[MTI_TOT_SIZE] = '\0';
+}
+
+std::ostream& ossimNitfAcftbTag::print(
+   std::ostream& out, const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+   
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"   << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "AC_MSN_ID:"
+       << theAcMsnId << "\n"
+       << pfx << std::setw(24) << "AC_TAIL_NO:"
+       << theAcTailNo << "\n"
+       << pfx << std::setw(24) << "AC_TO:"
+       << theAcTo << "\n"
+       << pfx << std::setw(24) << "SENSOR_ID_TYPE:"
+       << theSensorIdType << "\n"
+       << pfx << std::setw(24) << "SENSOR_ID:"
+       << theSensorId << "\n"
+       << pfx << std::setw(24) << "SCENE_SOURCE:"
+       << theSceneSource << "\n"
+       << pfx << std::setw(24) << "SCNUM:"
+       << theScNum << "\n"
+       << pfx << std::setw(24) << "PDATE:"
+       << thePDate << "\n"
+       << pfx << std::setw(24) << "IMHOSTNO:"
+       << theImHostNo << "\n"
+       << pfx << std::setw(24) << "IMREQID:"
+       << theImReqID << "\n"
+       << pfx << std::setw(24) << "MPLAN:"
+       << theMPlan << "\n"
+       << pfx << std::setw(24) << "ENTLOC:"
+       << theEntLoc << "\n"
+       << pfx << std::setw(24) << "LOC_ACCY:"
+       << theLocAccy << "\n"
+       << pfx << std::setw(24) << "ENTELV:"
+       << theEntelv << "\n"
+       << pfx << std::setw(24) << "ELV_UNIT:"
+       << theElvUnit << "\n"
+       << pfx << std::setw(24) << "EXITLOC:"
+       << theExitLoc << "\n"
+       << pfx << std::setw(24) << "EXITELV:"
+       << theExitElev << "\n"
+       << pfx << std::setw(24) << "TMAP:"
+       << theTMap << "\n"
+       << pfx << std::setw(24) << "ROW_SPACING:"
+       << theRowSpacing << "\n"
+       << pfx << std::setw(24) << "ROW_SPACING_UNITS:"
+       << theRowSpacingUnits << "\n"
+       << pfx << std::setw(24) << "COL_SPACING:"
+       << theColSpacing << "\n"
+       << pfx << std::setw(24) << "COL_SPACING_UINTS:"
+       << theColSpacingUnits << "\n"
+       << pfx << std::setw(24) << "FOCAL_LENGTH:"
+       << theFocalLength << "\n"
+       << pfx << std::setw(24) << "SENSERIAL:"
+       << theSenserial << "\n"
+       << pfx << std::setw(24) << "ABSWVER:"
+       << theAbSwVer << "\n"
+       << pfx << std::setw(24) << "CAL_DATE:"
+       << theCalDate << "\n"
+       << pfx << std::setw(24) << "PATCH_TOT:"
+       << thePatchTot << "\n"
+       << pfx << std::setw(24) << "MTI_TOT:"
+       << theMtiTot << "\n";
+   
+   return out;
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfAimidbTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfAimidbTag.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c15dad319b37726c20043e823ff868469f77cc5
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfAimidbTag.cpp
@@ -0,0 +1,181 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: AIMIDB - Additional Image ID Extension Format tag class
+// definition.
+//
+// See document STDI-0002 (version 3), Appendix E, Table E-3 for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#include <cstring>
+#include <istream>
+#include <iostream>
+#include <iomanip>
+
+#include <ossim/support_data/ossimNitfAimidbTag.h>
+
+
+RTTI_DEF1(ossimNitfAimidbTag, "ossimNitfAimidbTag", ossimNitfRegisteredTag);
+
+ossimNitfAimidbTag::ossimNitfAimidbTag()
+   : ossimNitfRegisteredTag()
+{
+   clearFields();
+}
+
+ossimNitfAimidbTag::~ossimNitfAimidbTag()
+{
+}
+
+ossimString ossimNitfAimidbTag::getRegisterTagName() const
+{
+   return "AIMIDB";
+}
+
+void ossimNitfAimidbTag::parseStream(std::istream& in)
+{
+   clearFields();
+
+   in.read(theAcquisitionDate, ACQUISITION_DATE_SIZE);
+   in.read(theMissionNumber, MISSION_NO_SIZE);
+   in.read(theMissionIdentification, MISSION_IDENTIFICATION_SIZE);
+   in.read(theFlightNo, FLIGHT_NO_SIZE);
+   in.read(theOpNum, OP_NUM_SIZE);
+   in.read(theCurrentSegment, CURRENT_SEGMENT_SIZE);
+   in.read(theReproNum, REPRO_NUM_SIZE);
+   in.read(theReplay, REPLAY_SIZE);
+   in.read(theReserved1, RESERVED_1_SIZE);
+   in.read(theStartTileColumn, START_TILE_COLUMN_SIZE);
+   in.read(theStartTileRow, START_TILE_ROW_SIZE);
+   in.read(theEndSegment, END_SEGMENT_SIZE);
+   in.read(theTileColumn, END_TILE_COLUMN_SIZE);
+   in.read(theTileRow, END_TILE_ROW_SIZE);
+   in.read(theCountry, COUNTRY_SIZE);
+   in.read(theReserved2, RESERVED_2_SIZE);
+   in.read(theLocation, LOCATION_SIZE);
+   in.read(theReserved3, RESERVED_3_SIZE);
+}
+
+void ossimNitfAimidbTag::writeStream(std::ostream& out)
+{
+   out.write(theAcquisitionDate, ACQUISITION_DATE_SIZE);
+   out.write(theMissionNumber, MISSION_NO_SIZE);
+   out.write(theMissionIdentification, MISSION_IDENTIFICATION_SIZE);
+   out.write(theFlightNo, FLIGHT_NO_SIZE);
+   out.write(theOpNum, OP_NUM_SIZE);
+   out.write(theCurrentSegment, CURRENT_SEGMENT_SIZE);
+   out.write(theReproNum, REPRO_NUM_SIZE);
+   out.write(theReplay, REPLAY_SIZE);
+   out.write(theReserved1, RESERVED_1_SIZE);
+   out.write(theStartTileColumn, START_TILE_COLUMN_SIZE);
+   out.write(theStartTileRow, START_TILE_ROW_SIZE);
+   out.write(theEndSegment, END_SEGMENT_SIZE);
+   out.write(theTileColumn, END_TILE_COLUMN_SIZE);
+   out.write(theTileRow, END_TILE_ROW_SIZE);
+   out.write(theCountry, COUNTRY_SIZE);
+   out.write(theReserved2, RESERVED_2_SIZE);
+   out.write(theLocation, LOCATION_SIZE);
+   out.write(theReserved3, RESERVED_3_SIZE);
+}
+
+ossim_uint32 ossimNitfAimidbTag::getSizeInBytes()const
+{
+   return CEL_SIZE;
+}
+
+void ossimNitfAimidbTag::clearFields()
+{
+   // BCS-N's to '0's, BCS-A's to ' '(spaces)
+
+   // clear
+   memset(theAcquisitionDate, ' ', ACQUISITION_DATE_SIZE);
+   memset(theMissionNumber, ' ', MISSION_NO_SIZE);
+   memset(theMissionIdentification, ' ', MISSION_IDENTIFICATION_SIZE);
+   memset(theFlightNo, ' ', FLIGHT_NO_SIZE);
+   memset(theOpNum, ' ', OP_NUM_SIZE);
+   memset(theCurrentSegment, ' ', CURRENT_SEGMENT_SIZE);
+   memset(theReproNum, ' ', REPRO_NUM_SIZE);
+   memset(theReplay, ' ', REPLAY_SIZE);
+   memset(theReserved1, ' ', RESERVED_1_SIZE);
+   memset(theStartTileColumn, ' ', START_TILE_COLUMN_SIZE);
+   memset(theStartTileRow, ' ', START_TILE_ROW_SIZE);
+   memset(theEndSegment, ' ', END_SEGMENT_SIZE);
+   memset(theTileColumn, ' ', END_TILE_COLUMN_SIZE);
+   memset(theTileRow, ' ', END_TILE_ROW_SIZE);
+   memset(theCountry, ' ', COUNTRY_SIZE);
+   memset(theReserved2, ' ', RESERVED_2_SIZE);
+   memset(theLocation, ' ', LOCATION_SIZE);
+   memset(theReserved3, ' ', RESERVED_3_SIZE);
+
+   // null terminate
+   theAcquisitionDate[ACQUISITION_DATE_SIZE] = '\0';
+   theMissionNumber[MISSION_NO_SIZE] = '\0';
+   theMissionIdentification[MISSION_IDENTIFICATION_SIZE] = '\0';
+   theFlightNo[FLIGHT_NO_SIZE] = '\0';
+   theOpNum[OP_NUM_SIZE] = '\0';
+   theCurrentSegment[CURRENT_SEGMENT_SIZE] = '\0';
+   theReproNum[REPRO_NUM_SIZE] = '\0';
+   theReplay[REPLAY_SIZE] = '\0';
+   theReserved1[RESERVED_1_SIZE] = '\0';
+   theStartTileColumn[START_TILE_COLUMN_SIZE] = '\0';
+   theStartTileRow[START_TILE_ROW_SIZE] = '\0';
+   theEndSegment[END_SEGMENT_SIZE] = '\0';
+   theTileColumn[END_TILE_COLUMN_SIZE] = '\0';
+   theTileRow[END_TILE_ROW_SIZE] = '\0';
+   theCountry[COUNTRY_SIZE] = '\0';
+   theReserved2[RESERVED_2_SIZE] = '\0';
+   theLocation[LOCATION_SIZE] = '\0';
+   theReserved3[RESERVED_3_SIZE] = '\0';
+}
+
+std::ostream& ossimNitfAimidbTag::print(
+   std::ostream& out, const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+   
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"   << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "ACQUISITION_DATE:"
+       << theAcquisitionDate << "\n"
+       << pfx << std::setw(24) << "MISSION_NO:"
+       << theMissionNumber << "\n"
+       << pfx << std::setw(24) << "MISSION_IDENTIFICATION:"
+       << theMissionIdentification<< "\n"
+       << pfx << std::setw(24) << "FLIGHT_NO:"
+       << theFlightNo << "\n"
+       << pfx << std::setw(24) << "OP_NUM:"
+       << theOpNum << "\n"
+       << pfx << std::setw(24) << "CURRENT_SEGMENT:"
+       << theCurrentSegment << "\n"
+       << pfx << std::setw(24) << "REPRO_NUM:"
+       << theReproNum<< "\n"
+       << pfx << std::setw(24) << "REPLAY:"
+       << theReplay<< "\n"
+       << pfx << std::setw(24) << "START_TILE_COLUMN:"
+       << theStartTileColumn << "\n"
+       << pfx << std::setw(24) << "START_TILE_ROW:"
+       << theStartTileRow << "\n"
+       << pfx << std::setw(24) << "END_SEGMENT:"
+       << theEndSegment << "\n"
+       << pfx << std::setw(24) << "END_TILE_COLUMN:"
+       << theTileColumn << "\n"
+       << pfx << std::setw(24) << "END_TILE_ROW:"
+       << theTileRow << "\n"
+       << pfx << std::setw(24) << "COUNTRY:"
+       << theCountry << "\n"
+       << pfx << std::setw(24) << "LOCATION:"
+       << theLocation << "\n";
+   
+   return out;
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfBlockaTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfBlockaTag.cpp
index 53b544387bf810087067e71e6b3439253e33129f..12be532bc7cb0f0764aa07953f7834f96e65f6ec 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfBlockaTag.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfBlockaTag.cpp
@@ -9,7 +9,7 @@
 // Description: BLOCKA tag class declaration.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfBlockaTag.cpp 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfBlockaTag.cpp 14754 2009-06-23 23:13:05Z dburken $
 
 #include <cstring> /* for memcpy */
 #include <sstream>
@@ -106,7 +106,7 @@ std::ostream& ossimNitfBlockaTag::print(std::ostream& out,
 {
    std::string pfx = prefix;
    pfx += getRegisterTagName();
-   pfx += "_";
+   pfx += ".";
    
    // Grab the corners parsed into points.
    ossimDpt ulPt;
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp
index c2a5b316f9cde46d40a6eb3e5030f09aaa1f18fa..35d30bf6a383de048012963cfc8c010e03467d8a 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp
@@ -1,13 +1,15 @@
 //----------------------------------------------------------------------------
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author:  David Burken
 //
 // Description: Utility class for global nitf methods.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfCommon.cpp 13619 2008-09-29 19:10:31Z gpotts $
+// $Id: ossimNitfCommon.cpp 15410 2009-09-11 19:45:38Z dburken $
 
 #include <cstring> /* for memcpy */
 #include <sstream>
@@ -16,10 +18,11 @@
 #include <stdexcept>
 #include <iostream>
 #include <ossim/support_data/ossimNitfCommon.h>
-#include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimDms.h>
-#include <ossim/base/ossimNotifyContext.h>
 #include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimIrect.h>
+#include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimTrace.h>
 
 static const ossimTrace traceDebug(ossimString("ossimNitfCommon:debug"));
 
@@ -458,3 +461,79 @@ ossimString ossimNitfCommon::encodeGeographicDecimalDegrees(const ossimDpt& ul,
    
    return ossimString(out.str());
 }
+
+ossimString ossimNitfCommon::getNitfPixelType(ossimScalarType scalarType)
+{
+   ossimString pixelType;
+   switch(scalarType)
+   {
+      case OSSIM_UCHAR:
+      case OSSIM_USHORT11:
+      case OSSIM_USHORT16:
+      {
+         pixelType = "INT";
+         break;
+      }
+      case OSSIM_SSHORT16:
+      {
+         pixelType    = "SI";
+         break;
+      }
+      case OSSIM_FLOAT:
+      case OSSIM_NORMALIZED_FLOAT:
+      case OSSIM_DOUBLE:
+      case OSSIM_NORMALIZED_DOUBLE:
+      {
+         pixelType    = "R";
+         break;
+      }
+      default:
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << __FILE__ << ":" << __LINE__
+            << "\nUnhandled scalar type:  " << scalarType << std::endl;
+         break;
+      }
+   }
+   return pixelType;
+}
+
+ossimString ossimNitfCommon::getCompressionRate(const ossimIrect& rect,
+                                                ossim_uint32 bands,
+                                                ossimScalarType scalar,
+                                                ossim_uint64 lengthInBytes)
+{
+   ossimString result("");
+   
+   ossim_float64 uncompressedSize =
+      ossim::scalarSizeInBytes(scalar) * rect.width() * rect.height() * bands;
+   ossim_float64 bitsPerPix = ossim::getBitsPerPixel(scalar);
+   ossim_float64 rate = ( bitsPerPix *
+                          (static_cast<ossim_float64>(lengthInBytes) /
+                           uncompressedSize) );
+
+   // Multiply by ten as there is an implied decimal point.
+   rate *= 10.0;
+
+   // Convert to string with zero precision.
+   ossimString s = ossimString::toString(rate, 0);
+
+   if (s.size())
+   {
+      if (s.size() <= 3)
+      {
+         result = "N";
+         if (s.size() == 2)
+         {
+            result += "0";
+         }
+         else if (s.size() == 1)
+         {
+            result += "00";
+         }
+         result += s;
+      }
+   }
+   return result;
+}
+
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfEngrdaTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfEngrdaTag.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f0c8a6e75749d30a793f57357622246587f7cffa
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfEngrdaTag.cpp
@@ -0,0 +1,262 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: ENGRDA - Engineering Data tag class declaration.
+//
+// See document STDI-0002 (version 3), Appendix N for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#include <cstring>
+#include <istream>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+
+#include <ossim/support_data/ossimNitfEngrdaTag.h>
+#include <ossim/base/ossimNotify.h>
+
+
+RTTI_DEF1(ossimNitfEngrdaTag, "ossimNitfEngrdaTag", ossimNitfRegisteredTag);
+
+ossimNitfEngrdaTag::ossimNitfEngrdaTag()
+   : ossimNitfRegisteredTag()
+{
+   clearFields();
+}
+
+ossimNitfEngrdaTag::~ossimNitfEngrdaTag()
+{
+}
+
+ossimString ossimNitfEngrdaTag::getRegisterTagName() const
+{
+   return "ENGRDA";
+}
+
+void ossimNitfEngrdaTag::parseStream(std::istream& in)
+{
+   clearFields();
+
+   // theTreLength = RETAG_SIZE + REL_SIZE;
+   
+   in.read(theReSrc, RESRC_SIZE);
+   theTreLength += RESRC_SIZE;
+   
+   in.read(theReCnt, RECNT_SIZE);
+   theTreLength += RECNT_SIZE;
+
+   const ossim_uint16 ELEMENT_COUNT = ossimString(theReCnt).toUInt16();
+   
+   for (ossim_uint16 i = 0; i < ELEMENT_COUNT; ++i)
+   {
+      ossimString os;
+      char buf[TMP_BUF_SIZE];
+      ossimEngDataElement element;
+
+      // ENGLN - label length field
+      in.read(buf, ENGLN_SIZE);
+      theTreLength += ENGLN_SIZE;
+      buf[ENGLN_SIZE] = '\n';
+      os = buf;
+
+      // ENGLBL - label field
+      ossim_uint32 size = os.toUInt16();
+      in.read(buf, size);
+      theTreLength += size;
+      buf[size] = '\0';
+      element.theEngLbl = buf;
+
+      // ENGMTXC - data column count
+      in.read(buf, ENGMTXC_SIZE);
+      theTreLength += ENGMTXC_SIZE;
+      buf[ENGMTXC_SIZE] = '\0';
+      os = buf;
+      element.theEngMtxC = os.toUInt16();
+
+      // ENGMTXR - data row count
+      in.read(buf, ENGMTXR_SIZE);
+      theTreLength += ENGMTXR_SIZE;
+      buf[ENGMTXR_SIZE] = '\0';
+      os = buf;
+      element.theEngMtxR = os.toUInt16();
+
+      // ENGTYP - Value Type of Engineering Data Element.
+      in.get( element.theEngTyp );
+      theTreLength += ENGTYP_SIZE;
+
+      // ENGDTS - Engineering Data Element Size
+      element.theEngDts = static_cast<ossim_uint8>(in.get());
+      theTreLength += ENGDTS_SIZE;
+
+      // ENGDATU - Engineering Data Units.
+      in.read(buf, ENGDATU_SIZE);
+      theTreLength += ENGDATU_SIZE;
+      buf[ENGDATU_SIZE] = '\0';
+      element.theEngDatU = buf;
+
+      // ENGDATC - Engineering Data Count
+      in.read(buf, ENGDATC_SIZE);
+      theTreLength += ENGDATC_SIZE;
+      buf[ENGDATC_SIZE] = '\n';
+      os = buf;
+      ossim_uint32 engDatC = os.toUInt32();
+
+      // ENGDATA - Engineering Data
+      element.theEngDat.resize(engDatC);
+      in.read((char*)&(element.theEngDat.front()), element.theEngDat.size());
+      theTreLength += engDatC;
+      
+      theData.push_back(element);
+
+   } // Matches: for (ossim_uint16 i = 0; i < ELEMENT_COUNT; ++i)
+}
+
+void ossimNitfEngrdaTag::writeStream(std::ostream& out)
+{
+   //out.write(theAcMsnId, AC_MSN_ID_SIZE);
+   // out.write(theAcTailNo, AC_TAIL_NO_SIZE);
+
+   out.write(theReSrc, RESRC_SIZE);
+   out.write(theReCnt, RECNT_SIZE);
+
+   const ossim_uint16 ELEMENT_COUNT = ossimString(theReCnt).toUInt16();
+   
+   for (ossim_uint16 i = 0; i < ELEMENT_COUNT; ++i)
+   {
+      // ENGLN - label length field      
+      std::string s;
+      getValueAsString(theData[i].theEngLbl.size(), ENGLN_SIZE, s);
+      out.write(s.data(), ENGLN_SIZE);
+
+      // ENGLBL - label field
+      out.write(theData[i].theEngLbl.data(), theData[i].theEngLbl.size());
+
+      // ENGMTXC - data column count
+      getValueAsString(theData[i].theEngMtxC, ENGMTXC_SIZE, s); 
+      out.write(s.data(), ENGMTXC_SIZE);
+
+      // ENGMTXR - data row count
+      getValueAsString(theData[i].theEngMtxR, ENGMTXR_SIZE, s);
+      out.write(s.data(), ENGMTXR_SIZE);
+
+      // ENGTYP - Value Type of Engineering Data Element.
+      out.write(&theData[i].theEngTyp, ENGTYP_SIZE);
+
+      // ENGDTS - Engineering Data Element Size
+      out.write((char*)(&theData[i].theEngDts), ENGDTS_SIZE);
+
+      // ENGDATU - Engineering Data Units.
+      out.write(theData[i].theEngDatU.data(), ENGDATU_SIZE);
+
+      // ENGDATC - Engineering Data Count
+      getValueAsString(theData[i].theEngDat.size(), ENGDATC_SIZE, s); 
+      out.write(s.data(), ENGDATC_SIZE);
+
+      // ENGDATA - Engineering Data NOTE: should be big endian...
+      out.write((char*)&(theData[i].theEngDat.front()),
+                theData[i].theEngDat.size());
+
+   } // Matches: for (ossim_uint16 i = 0; i < ELEMENT_COUNT; ++i)
+   
+}
+
+ossim_uint32 ossimNitfEngrdaTag::getSizeInBytes()const
+{
+   return theTreLength;
+}
+
+void ossimNitfEngrdaTag::clearFields()
+{
+   // BCS-N's to '0's, BCS-A's to ' '(spaces)
+
+   // clear
+   memset(theReSrc, ' ', RESRC_SIZE);
+   memset(theReCnt, ' ', RECNT_SIZE);
+   theData.clear();
+
+   // null terminate
+   theReSrc[RESRC_SIZE] = '\0';
+   theReCnt[RECNT_SIZE] = '\0';
+
+   theTreLength = 0;
+}
+
+std::ostream& ossimNitfEngrdaTag::print(
+   std::ostream& out, const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+   
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"   << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "RESRC:" << theReSrc << "\n"
+       << pfx << std::setw(24) << "RECNT:" << theReCnt << "\n";
+
+   for (ossim_uint32 i = 0; i < theData.size(); ++i)
+   {
+      out << pfx << "ENGLBL[" << i << std::setw(24) << "]:"
+          << theData[i].theEngLbl << "\n"
+          << pfx << "ENGMTXC[" << i << std::setw(24) << "]:"
+          << theData[i].theEngMtxC << "\n"
+          << pfx << "ENGMTXR[" << i << std::setw(24) << "]:"
+          << theData[i].theEngMtxR << "\n"
+          << pfx << "ENGTYP[" << i << std::setw(24) << "]:"
+          << theData[i].theEngTyp << "\n"
+          << pfx << "ENGDTS[" << i << std::setw(24) << "]:"
+          << theData[i].theEngDts << "\n"
+          << pfx << "ENGDATU[" << i << std::setw(24) << "]:"
+          << theData[i].theEngDatU << "\n"
+          << pfx << "ENGDATC[" << i << std::setw(24) << "]:"
+          << theData[i].theEngDat.size() << "\n";
+      
+      printData(out, theData[i], i, pfx);
+
+      
+   }
+   
+   return out;
+}
+
+std::ostream& ossimNitfEngrdaTag::printData(std::ostream& out,
+                                            const ossimEngDataElement& element,
+                                            ossim_uint32 elIndex,
+                                            const std::string& prefix) const
+{
+   if (element.theEngTyp == 'A')
+   {
+      std::vector<ossim_uint8>::const_iterator i = element.theEngDat.begin();
+      while (i != element.theEngDat.end())
+      {
+         out << static_cast<ossim_int8>(*i);
+         ++i;
+      }
+      out << "\n";
+   }
+   else
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+         << "ossimNitfEngrdaTag::printData WARNING unhandled data type."
+         << std::endl;
+   } 
+   return out;
+}
+
+template <class T>
+void ossimNitfEngrdaTag::getValueAsString(
+   T v, ossim_uint16 w, std::string& s) const
+{
+   std::ostringstream os;
+   os << std::setw(w) << std::setfill('0') << setiosflags(ios::right) << v;
+   s = os.str();
+}
+   
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFile.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFile.cpp
index f99f5730d0bce03d27f73592a64215b2dace3a79..201fc3e59a61edbbc0f7916cfab308689d85e424 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFile.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFile.cpp
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFile.cpp 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfFile.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <fstream>
 #include <iostream>
@@ -40,7 +40,8 @@ std::ostream& operator <<(std::ostream& out, const ossimNitfFile& data)
 }
 
 std::ostream& ossimNitfFile::print(std::ostream& out,
-                                   const std::string& prefix) const
+                                   const std::string& prefix,
+                                   bool printOverviews) const
 {
    if(theNitfFileHeader.valid())
    {
@@ -54,13 +55,32 @@ std::ostream& ossimNitfFile::print(std::ostream& out,
          ossimNitfImageHeader* ih = getNewImageHeader(idx);
          if(ih)
          {
-            // Add our prefix onto prefix.
-            std::string s = pfx;
-            s += "image";
-            s += ossimString::toString(idx);
-            s += ".";
+            bool printIt = true;
             
-            ih->print(out, s);
+            if ( !printOverviews )
+            {
+               // Check the IMAG field.
+               ossim_float64 imag;
+               ih->getDecimationFactor(imag);
+               if ( !ossim::isnan(imag) )
+               {
+                  if ( imag < 1.0)
+                  {
+                     printIt = false;
+                  }
+               }
+            }
+
+            if (printIt)
+            {
+               // Add our prefix onto prefix.
+               std::string s = pfx;
+               s += "image";
+               s += ossimString::toString(idx);
+               s += ".";
+               
+               ih->print(out, s);
+            }
             
             delete ih;
             ih = 0;
@@ -80,7 +100,7 @@ std::ostream& ossimNitfFile::print(std::ostream& out,
               ossimErrorCodes::OSSIM_OK )
          {
             pfx += "rpf.";
-            toc->print(out, pfx);
+            toc->print(out, pfx, printOverviews);
          }
          delete toc;
          toc = 0;
@@ -202,9 +222,14 @@ bool ossimNitfFile::parseFile(const ossimFilename& file)
    return true;
 }
 
-const ossimRefPtr<ossimNitfFileHeader> ossimNitfFile::getHeader() const
+const ossimNitfFileHeader* ossimNitfFile::getHeader() const
+{
+   return theNitfFileHeader.get();
+}
+
+ossimNitfFileHeader* ossimNitfFile::getHeader() 
 {
-   return theNitfFileHeader;
+   return theNitfFileHeader.get();
 }
 
 ossimIrect ossimNitfFile::getImageRect()const
@@ -217,74 +242,79 @@ ossimIrect ossimNitfFile::getImageRect()const
    return ossimIrect(ossimIpt(0,0), ossimIpt(0,0));
 }
 
-ossimNitfImageHeader* ossimNitfFile::getNewImageHeader(long imageNumber)const
+ossimNitfImageHeader* ossimNitfFile::getNewImageHeader(
+   ossim_uint32 imageNumber)const
 {
+   ossimNitfImageHeader* result = 0;
    if(theNitfFileHeader.valid())
    {
       std::ifstream in(theFilename.c_str(), std::ios::in|std::ios::binary);
 
-      return theNitfFileHeader->getNewImageHeader(imageNumber,
-                                                  in);
+      result = theNitfFileHeader->getNewImageHeader(imageNumber, in);
       in.close();
    }
    
-   return 0;
+   return result;
 }
 
-ossimNitfSymbolHeader* ossimNitfFile::getNewSymbolHeader(long symbolNumber)const
+ossimNitfSymbolHeader* ossimNitfFile::getNewSymbolHeader(
+   ossim_uint32 symbolNumber)const
 {
+   ossimNitfSymbolHeader* result = 0;
    if(theNitfFileHeader.valid())
    {
       std::ifstream in(theFilename.c_str(), std::ios::in|std::ios::binary);
 
-      return theNitfFileHeader->getNewSymbolHeader(symbolNumber,
-                                                   in);
+      result = theNitfFileHeader->getNewSymbolHeader(symbolNumber, in);
       in.close();
    }
    
-   return 0;
+   return result;
 }
 
-ossimNitfLabelHeader* ossimNitfFile::getNewLabelHeader(long labelNumber)const
+ossimNitfLabelHeader* ossimNitfFile::getNewLabelHeader(
+   ossim_uint32 labelNumber)const
 {
+   ossimNitfLabelHeader* result = 0;
    if(theNitfFileHeader.valid())
    {
       std::ifstream in(theFilename.c_str(), std::ios::in|std::ios::binary);
 
-      return theNitfFileHeader->getNewLabelHeader(labelNumber,
-                                                  in);
+      result = theNitfFileHeader->getNewLabelHeader(labelNumber, in);
       in.close();
    }
    
-   return 0;
+   return result;
 }
 
-ossimNitfTextHeader* ossimNitfFile::getNewTextHeader(long textNumber)const
+ossimNitfTextHeader* ossimNitfFile::getNewTextHeader(
+   ossim_uint32 textNumber)const
 {
+   ossimNitfTextHeader* result = 0;
    if(theNitfFileHeader.valid())
    {
       std::ifstream in(theFilename.c_str(), std::ios::in|std::ios::binary);
 
-      return theNitfFileHeader->getNewTextHeader(textNumber,
-                                                 in);
+      result = theNitfFileHeader->getNewTextHeader(textNumber, in);
       in.close();
    }
    
-   return 0;
+   return result;
 }
 
-ossimNitfDataExtensionSegment* ossimNitfFile::getNewDataExtensionSegment(long dataExtNumber)const
+ossimNitfDataExtensionSegment* ossimNitfFile::getNewDataExtensionSegment(
+   ossim_uint32 dataExtNumber)const
 {
+   ossimNitfDataExtensionSegment* result = 0;
    if(theNitfFileHeader.valid())
    {
       std::ifstream in(theFilename.c_str(), std::ios::in|std::ios::binary);
 
-      return theNitfFileHeader->getNewDataExtensionSegment(dataExtNumber,
-                                                           in);
+      result = theNitfFileHeader->getNewDataExtensionSegment(dataExtNumber, in);
       in.close();
    }
    
-   return 0;
+   return result;
 }
 
 ossimString ossimNitfFile::getVersion()const
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp
index b15099835d6ce5fa1bfe90d9bdadffd453d71e64..a6feb8621f00f4eb498627f6d6442110ba7384c2 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_0.cpp 14247 2009-04-08 17:51:25Z dburken $
+// $Id: ossimNitfFileHeaderV2_0.cpp 14662 2009-06-07 16:15:23Z dburken $
 
 
 #include <sstream>
@@ -48,17 +48,17 @@ std::ostream& operator <<(std::ostream& out,
               << data.theImageLength;
 }
 
-ossim_int32 ossimNitfImageInfoRecordV2_0::getHeaderLength()const
+ossim_uint32 ossimNitfImageInfoRecordV2_0::getHeaderLength()const
 {
    return ossimString(theImageSubheaderLength).toInt32();
 }
 
-ossim_int32  ossimNitfImageInfoRecordV2_0::getImageLength()const
+ossim_uint64  ossimNitfImageInfoRecordV2_0::getImageLength()const
 {
    return ossimString(theImageLength).toInt32();
 }
 
-ossim_int32  ossimNitfImageInfoRecordV2_0::getTotalLength()const
+ossim_uint64 ossimNitfImageInfoRecordV2_0::getTotalLength()const
 {
    return (getHeaderLength() + getImageLength());
 }
@@ -76,7 +76,7 @@ void ossimNitfImageInfoRecordV2_0::setSubheaderLength(ossim_uint32 length)
    theImageSubheaderLength[6] = '\0';
 }
 
-void ossimNitfImageInfoRecordV2_0::setImageLength(ossim_uint32 length)
+void ossimNitfImageInfoRecordV2_0::setImageLength(ossim_uint64 length)
 {
    ostringstream out;
    
@@ -740,14 +740,12 @@ void ossimNitfFileHeaderV2_0::replaceImageInfoRecord(ossim_uint32 i, const ossim
 }
 
 ossimNitfImageHeader*
-ossimNitfFileHeaderV2_0::getNewImageHeader(ossim_int32 imageNumber,
+ossimNitfFileHeaderV2_0::getNewImageHeader(ossim_uint32 imageNumber,
                                            std::istream& in)const
 {
    ossimNitfImageHeader *result = 0;
    
-   if((getNumberOfImages() > 0) &&
-      (imageNumber < (ossim_int32)theImageOffsetList.size()) &&
-      (imageNumber >= 0))
+   if( (getNumberOfImages() > 0) && (imageNumber < theImageOffsetList.size()) )
    {
       result = allocateImageHeader();
       in.seekg(theImageOffsetList[imageNumber].theImageHeaderOffset, std::ios::beg);
@@ -765,14 +763,13 @@ ossimNitfFileHeaderV2_0::getNewImageHeader(ossim_int32 imageNumber,
    return result;
 }
 
-ossimNitfSymbolHeader *ossimNitfFileHeaderV2_0::getNewSymbolHeader(ossim_int32 symbolNumber,
-                                                                   std::istream& in)const
+ossimNitfSymbolHeader *ossimNitfFileHeaderV2_0::getNewSymbolHeader(
+   ossim_uint32 symbolNumber, std::istream& in)const
 {
    ossimNitfSymbolHeader *result = 0;
 
-   if((getNumberOfSymbols() > 0) &&
-      (symbolNumber < (ossim_int32)theSymbolOffsetList.size()) &&
-      (symbolNumber >= 0))
+   if( (getNumberOfSymbols() > 0) &&
+       (symbolNumber < theSymbolOffsetList.size()) )
    {
       result = allocateSymbolHeader();
       in.seekg(theSymbolOffsetList[symbolNumber].theSymbolHeaderOffset, std::ios::beg);
@@ -782,14 +779,13 @@ ossimNitfSymbolHeader *ossimNitfFileHeaderV2_0::getNewSymbolHeader(ossim_int32 s
    return result;
 }
 
-ossimNitfLabelHeader *ossimNitfFileHeaderV2_0::getNewLabelHeader(ossim_int32 labelNumber,
-                                                                 std::istream& in)const
+ossimNitfLabelHeader *ossimNitfFileHeaderV2_0::getNewLabelHeader(
+   ossim_uint32 labelNumber, std::istream& in)const
 {
    ossimNitfLabelHeader *result = 0;
 
-   if((getNumberOfLabels() > 0) &&
-      (labelNumber < (ossim_int32)theLabelOffsetList.size()) &&
-      (labelNumber >= 0))
+   if( (getNumberOfLabels() > 0) &&
+       (labelNumber < theLabelOffsetList.size()) )
    {
       result = allocateLabelHeader();
       in.seekg(theLabelOffsetList[labelNumber].theLabelHeaderOffset, std::ios::beg);
@@ -799,14 +795,13 @@ ossimNitfLabelHeader *ossimNitfFileHeaderV2_0::getNewLabelHeader(ossim_int32 lab
    return result;
 }
 
-ossimNitfTextHeader *ossimNitfFileHeaderV2_0::getNewTextHeader(ossim_int32 textNumber,
-                                                               std::istream& in)const
+ossimNitfTextHeader *ossimNitfFileHeaderV2_0::getNewTextHeader(
+   ossim_uint32 textNumber, std::istream& in)const
 {
    ossimNitfTextHeader *result = 0;
 
-   if((getNumberOfTextSegments() > 0) &&
-      (textNumber < (ossim_int32)theTextOffsetList.size()) &&
-      (textNumber >= 0))
+   if( (getNumberOfTextSegments() > 0) &&
+       (textNumber < theTextOffsetList.size()) )
    {
       result = allocateTextHeader();
       in.seekg(theTextOffsetList[textNumber].theTextHeaderOffset, std::ios::beg);
@@ -816,14 +811,14 @@ ossimNitfTextHeader *ossimNitfFileHeaderV2_0::getNewTextHeader(ossim_int32 textN
    return result;
 }
 
-ossimNitfDataExtensionSegment* ossimNitfFileHeaderV2_0::getNewDataExtensionSegment(ossim_int32 dataExtNumber,
-                                                                                   std::istream& in)const
+ossimNitfDataExtensionSegment*
+ossimNitfFileHeaderV2_0::getNewDataExtensionSegment(
+    ossim_uint32 dataExtNumber, std::istream& in)const
 {
    ossimNitfDataExtensionSegment *result = 0;
 
-   if((getNumberOfDataExtSegments() > 0) &&
-      (dataExtNumber < (ossim_int32)theNitfDataExtSegInfoRecords.size()) &&
-      (dataExtNumber >= 0))
+   if( (getNumberOfDataExtSegments() > 0) &&
+       (dataExtNumber < theNitfDataExtSegInfoRecords.size()) )
    {
       result = allocateDataExtSegment();
       in.seekg(theDataExtSegOffsetList[dataExtNumber].theDataExtSegHeaderOffset, std::ios::beg);
@@ -1018,7 +1013,7 @@ ossim_int32 ossimNitfFileHeaderV2_0::getHeaderSize()const
    return theHeaderSize;
 }
 
-ossim_int32 ossimNitfFileHeaderV2_0::getFileSize()const
+ossim_int64 ossimNitfFileHeaderV2_0::getFileSize()const
 {
    ossimString temp = theFileLength;
    if(temp == "999999999999")
@@ -1027,7 +1022,7 @@ ossim_int32 ossimNitfFileHeaderV2_0::getFileSize()const
    }
    else
    {
-      return temp.toInt32();
+      return temp.toInt64();
    }
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp
index a309b4aca15d44f4268497e2b8d4bdf8ba912d51..a07c25a0481165bcec021dce227c81d87c421a44 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_1.cpp 14257 2009-04-09 21:32:08Z dburken $
+// $Id: ossimNitfFileHeaderV2_1.cpp 15411 2009-09-11 19:46:32Z dburken $
 
 #include <iostream>
 #include <iomanip>
@@ -56,17 +56,17 @@ std::ostream& operator <<(std::ostream& out,
               << std::endl;
 }
 
-ossim_int32 ossimNitfImageInfoRecordV2_1::getHeaderLength()const
+ossim_uint32 ossimNitfImageInfoRecordV2_1::getHeaderLength()const
 {
-   return ossimString(theImageSubheaderLength).toInt32();
+   return ossimString(theImageSubheaderLength).toUInt32();
 }
 
-ossim_int32 ossimNitfImageInfoRecordV2_1::getImageLength()const
+ossim_uint64 ossimNitfImageInfoRecordV2_1::getImageLength()const
 {
-   return ossimString(theImageLength).toInt32();
+   return ossimString(theImageLength).toUInt64();
 }
 
-ossim_int32 ossimNitfImageInfoRecordV2_1::getTotalLength()const
+ossim_uint64 ossimNitfImageInfoRecordV2_1::getTotalLength()const
 {
    return (getHeaderLength() + getImageLength());
 }
@@ -125,7 +125,7 @@ void ossimNitfImageInfoRecordV2_1::setSubheaderLength(ossim_uint32 length)
    theImageSubheaderLength[6] = '\0';
 }
 
-void ossimNitfImageInfoRecordV2_1::setImageLength(ossim_uint32 length)
+void ossimNitfImageInfoRecordV2_1::setImageLength(ossim_uint64 length)
 {
    ostringstream out;
 
@@ -687,7 +687,7 @@ ossim_int32 ossimNitfFileHeaderV2_1::getHeaderSize()const
    return theHeaderSize;
 }
 
-ossim_int32 ossimNitfFileHeaderV2_1::getFileSize()const
+ossim_int64 ossimNitfFileHeaderV2_1::getFileSize()const
 {
    ossimString temp = theFileLength;
 
@@ -697,7 +697,7 @@ ossim_int32 ossimNitfFileHeaderV2_1::getFileSize()const
    }
    else
    {
-      return temp.toInt32();
+      return temp.toInt64();
    }
 }
 
@@ -939,7 +939,10 @@ void ossimNitfFileHeaderV2_1::addImageInfoRecord(const ossimNitfImageInfoRecordV
 
 void ossimNitfFileHeaderV2_1::replaceImageInfoRecord(int i, const ossimNitfImageInfoRecordV2_1& recordInfo)
 {
-   theNitfImageInfoRecords[i]=recordInfo;
+   if ( i < static_cast<int>(theNitfImageInfoRecords.size()) )
+   {
+      theNitfImageInfoRecords[i] = recordInfo;
+   }
 }
 
 ossimNitfSymbolHeader *ossimNitfFileHeaderV2_1::allocateSymbolHeader()const
@@ -966,18 +969,17 @@ void ossimNitfFileHeaderV2_1::initializeAllOffsets()
       theImageOffsetList.push_back(ossimNitfImageOffsetInformation(tally,
                                                                    tally + (ossim_uint64)theNitfImageInfoRecords[idx].getHeaderLength()));
       tally += theNitfImageInfoRecords[idx].getTotalLength();
+
    }
 }
 
 ossimNitfImageHeader*
-ossimNitfFileHeaderV2_1::getNewImageHeader(ossim_int32 imageNumber,
+ossimNitfFileHeaderV2_1::getNewImageHeader(ossim_uint32 imageNumber,
                                            std::istream& in)const
 {
    ossimNitfImageHeader *result = 0;
    
-   if((getNumberOfImages() > 0) &&
-      (imageNumber < (ossim_int32)theImageOffsetList.size()) &&
-      (imageNumber >= 0))
+   if( (getNumberOfImages() > 0) && (imageNumber < theImageOffsetList.size()) )
    {
       result = allocateImageHeader();
       in.seekg(theImageOffsetList[imageNumber].theImageHeaderOffset, ios::beg);
@@ -996,7 +998,7 @@ ossimNitfFileHeaderV2_1::getNewImageHeader(ossim_int32 imageNumber,
 }
 
 ossimNitfSymbolHeader*
-ossimNitfFileHeaderV2_1::getNewSymbolHeader(ossim_int32 symbolNumber,
+ossimNitfFileHeaderV2_1::getNewSymbolHeader(ossim_uint32 symbolNumber,
                                             std::istream& in)const
 {
    // Currently not implemented...
@@ -1007,7 +1009,7 @@ ossimNitfFileHeaderV2_1::getNewSymbolHeader(ossim_int32 symbolNumber,
 }
 
 ossimNitfLabelHeader*
-ossimNitfFileHeaderV2_1::getNewLabelHeader(ossim_int32 labelNumber,
+ossimNitfFileHeaderV2_1::getNewLabelHeader(ossim_uint32 labelNumber,
                                            std::istream& in)const
 {
    // Currently not implemented...
@@ -1017,7 +1019,7 @@ ossimNitfFileHeaderV2_1::getNewLabelHeader(ossim_int32 labelNumber,
 }
 
 ossimNitfTextHeader*
-ossimNitfFileHeaderV2_1::getNewTextHeader(ossim_int32 textNumber,
+ossimNitfFileHeaderV2_1::getNewTextHeader(ossim_uint32 textNumber,
                                           std::istream& in)const
 {
    // Currently not implemented...
@@ -1027,8 +1029,8 @@ ossimNitfFileHeaderV2_1::getNewTextHeader(ossim_int32 textNumber,
 }
 
 ossimNitfDataExtensionSegment*
-ossimNitfFileHeaderV2_1::getNewDataExtensionSegment(ossim_int32 dataExtNumber,
-                                                    std::istream& in)const
+ossimNitfFileHeaderV2_1::getNewDataExtensionSegment(
+   ossim_uint32 dataExtNumber, std::istream& in)const
 {
    // Currently not implemented...
    ossimNitfDataExtensionSegment *result = 0;
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfIchipbTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfIchipbTag.cpp
index b2e6d0d6f1dc94c47096901bfd0c18e0a78e4ce2..a87d6797f808967c24ced559bb229a7ce9321477 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfIchipbTag.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfIchipbTag.cpp
@@ -11,7 +11,7 @@
 // http://164.214.2.51/ntb/baseline/docs/stdi0002/final.pdf
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfIchipbTag.cpp 13025 2008-06-13 17:06:30Z sbortman $
+// $Id: ossimNitfIchipbTag.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <cstring> /* for memcpy */
 #include <iomanip>
@@ -22,6 +22,7 @@
 #include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimStringProperty.h>
+#include <ossim/base/ossim2dBilinearTransform.h>
 
 static const ossimString XFRM_FLAG_KW = "XFRM_FLAG";
 static const ossimString SCALE_FACTOR_KW = "SCALE_FACTOR";
@@ -166,31 +167,40 @@ void ossimNitfIchipbTag::clearFields()
    theFullImageCol[FI_COL_SIZE]      = '\0';
 }
 
-std::ostream& ossimNitfIchipbTag::print(std::ostream& out) const
-{
-   out << setiosflags(std::ios::left) << "ossimNitfIchipbTag::print"
-       << std::setw(24) << "\nXFRM_FLAG:"     <<theXfrmFlag
-       << std::setw(24) << "\nSCALE_FACTOR:"  <<theScaleFactor
-       << std::setw(24) << "\nANAMRPH_CORR:"  <<theAnamrphCorr
-       << std::setw(24) << "\nSCANBLK_NUM:"   <<theScanBlock
-       << std::setw(24) << "\nOP_ROW_11:"     <<theOpRow11
-       << std::setw(24) << "\nOP_COL_11:"     <<theOpCol11
-       << std::setw(24) << "\nOP_ROW_12:"     <<theOpRow12
-       << std::setw(24) << "\nOP_COL_12:"     <<theOpCol12
-       << std::setw(24) << "\nOP_ROW_21:"     <<theOpRow21
-       << std::setw(24) << "\nOP_COL_21:"     <<theOpCol21
-       << std::setw(24) << "\nOP_ROW_22:"     <<theOpRow22
-       << std::setw(24) << "\nOP_COL_22:"     <<theOpCol22
-       << std::setw(24) << "\nFI_ROW_11:"     <<theFiRow11
-       << std::setw(24) << "\nFI_COL_11:"     <<theFiCol11
-       << std::setw(24) << "\nFI_ROW_12:"     <<theFiRow12
-       << std::setw(24) << "\nFI_COL_12:"     <<theFiCol12
-       << std::setw(24) << "\nFI_ROW_21:"     <<theFiRow21
-       << std::setw(24) << "\nFI_COL_21:"     <<theFiCol21
-       << std::setw(24) << "\nFI_ROW_22:"     <<theFiRow22
-       << std::setw(24) << "\nFI_COL_22:"     <<theFiCol22
-       << std::setw(24) << "\nFI_ROW:"        <<theFullImageRow
-       << std::setw(24) << "\nFI_COL:"        <<theFullImageCol
+std::ostream& ossimNitfIchipbTag::print(std::ostream& out,
+                                        const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"
+       << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "XFRM_FLAG:"     << theXfrmFlag << "\n"
+       << pfx << std::setw(24) << "SCALE_FACTOR:"  << theScaleFactor << "\n"
+       << pfx << std::setw(24) << "ANAMRPH_CORR:"  << theAnamrphCorr << "\n"
+       << pfx << std::setw(24) << "SCANBLK_NUM:"   << theScanBlock << "\n"
+       << pfx << std::setw(24) << "OP_ROW_11:"     << theOpRow11 << "\n"
+       << pfx << std::setw(24) << "OP_COL_11:"     << theOpCol11 << "\n"
+       << pfx << std::setw(24) << "OP_ROW_12:"     << theOpRow12 << "\n"
+       << pfx << std::setw(24) << "OP_COL_12:"     << theOpCol12 << "\n"
+       << pfx << std::setw(24) << "OP_ROW_21:"     << theOpRow21 << "\n"
+       << pfx << std::setw(24) << "OP_COL_21:"     << theOpCol21 << "\n"
+       << pfx << std::setw(24) << "OP_ROW_22:"     << theOpRow22 << "\n"
+       << pfx << std::setw(24) << "OP_COL_22:"     << theOpCol22 << "\n"
+       << pfx << std::setw(24) << "FI_ROW_11:"     << theFiRow11 << "\n"
+       << pfx << std::setw(24) << "FI_COL_11:"     << theFiCol11 << "\n"
+       << pfx << std::setw(24) << "FI_ROW_12:"     << theFiRow12 << "\n"
+       << pfx << std::setw(24) << "FI_COL_12:"     << theFiCol12 << "\n"
+       << pfx << std::setw(24) << "FI_ROW_21:"     << theFiRow21 << "\n"
+       << pfx << std::setw(24) << "FI_COL_21:"     << theFiCol21 << "\n"
+       << pfx << std::setw(24) << "FI_ROW_22:"     << theFiRow22 << "\n"
+       << pfx << std::setw(24) << "FI_COL_22:"     << theFiCol22 << "\n"
+       << pfx << std::setw(24) << "FI_ROW:"        << theFullImageRow << "\n"
+       << pfx << std::setw(24) << "FI_COL:"        << theFullImageCol
        << std::endl;
 
    return out;
@@ -306,6 +316,7 @@ ossim_uint32 ossimNitfIchipbTag::getFullImageCols() const
    return ossimString::toUInt32(theFullImageCol);
 }
  
+#if 0
 void ossimNitfIchipbTag::getImageRect(ossimDrect& rect) const
 {
    ossimDpt pt;
@@ -323,19 +334,40 @@ void ossimNitfIchipbTag::getFullImageRect(ossimDrect& rect) const
 {
    ossimDpt pt;
 
-   pt.x = getFiCol11() - 0.5;
-   pt.y = getFiRow11() - 0.5;
+   ossim_float64 minX = ossim::min(getFiCol11(), getFiCol22());
+   ossim_float64 maxX = ossim::max(getFiCol11(), getFiCol22());
+   ossim_float64 minY = ossim::min(getFiRow11(), getFiRow22());
+   ossim_float64 maxY = ossim::max(getFiRow11(), getFiRow22());
+   
+   pt.x = minX - 0.5;
+   pt.y = minY - 0.5;
    rect.set_ul(pt);
 
-   pt.x = getFiCol22() - 0.5;
-   pt.y = getFiRow22() - 0.5;
+   pt.x = maxX - 0.5;
+   pt.y = maxY - 0.5;
    rect.set_lr(pt);
 }
 
 void ossimNitfIchipbTag::getSubImageOffset(ossimDpt& pt) const
 {
-   pt.x = getFiCol11() - 0.5;
-   pt.y = getFiRow11() - 0.5;
+   ossimDrect rect;
+   
+   getFullImageRect(rect);
+   
+   pt = rect.ul();
+}
+#endif
+
+ossim2dTo2dTransform* ossimNitfIchipbTag::newTransform()const
+{
+   return new ossim2dBilinearTransform(ossimDpt(getOpCol11(), getOpRow11()),
+                                       ossimDpt(getOpCol12(), getOpRow12()),
+                                       ossimDpt(getOpCol21(), getOpRow21()),
+                                       ossimDpt(getOpCol22(), getOpRow22()),
+                                       ossimDpt(getFiCol11(), getFiRow11()),
+                                       ossimDpt(getFiCol12(), getFiRow12()),
+                                       ossimDpt(getFiCol21(), getFiRow21()),
+                                       ossimDpt(getFiCol22(), getFiRow22()));
 }
 
 void ossimNitfIchipbTag::setProperty(ossimRefPtr<ossimProperty> property)
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp
index 906b68ae739fce1e180f86f8cac47a53eeb2f8a5..335186dcc93e63c0cd87072aeb35c268d75cee8a 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeader.cpp 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfImageHeader.cpp 15436 2009-09-17 00:12:59Z dburken $
 
 #include <cmath> /* for fmod */
 #include <iomanip>
@@ -307,3 +307,47 @@ void ossimNitfImageHeader::checkForGeographicTiePointTruncation(
          << std::endl;
    }
 }
+
+void ossimNitfImageHeader::getDecimationFactor(ossim_float64& result) const
+{
+   //---
+   // Look for string like:
+   // 
+   // "/2" = 1/2
+   // "/4  = 1/4
+   // ...
+   // "/16 = 1/16
+   // 
+   // If it is full resolution it should be "1.0"
+   //
+   // or
+   //
+   // "0.5" which is the same as "/2"
+   // "0.25" which is the same as "/4"
+   //---
+   ossimString os = getImageMagnification();
+
+   // Spec says to fill with spaces so strip them.
+   os.trim(ossimString(" "));
+
+   if (os.size())
+   {
+      if ( os.contains("/") )
+      {
+         os = os.after("/");
+         result = os.toFloat64();
+         if (result)
+         {
+            result = 1.0 / result;
+         }
+      }
+      else
+      {
+         result = os.toFloat64();
+      }
+   }
+   else
+   {
+      result = ossim::nan();
+   }
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp
index 339a10466cae0b07cdc57f2fe08895edf24567a5..bd8ec1caff9ff504bff99f92b5ebeabdb68fbfcb 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_0.cpp 14251 2009-04-09 16:25:19Z dburken $
+// $Id: ossimNitfImageHeaderV2_0.cpp 15611 2009-10-08 18:50:33Z dburken $
 
 
 #include <iomanip>
@@ -22,7 +22,6 @@
 #include <ossim/base/ossimEndian.h>
 #include <ossim/support_data/ossimNitfVqCompressionHeader.h>
 #include <ossim/base/ossimTrace.h>
-#include <ossim/base/ossimDms.h>
 #include <ossim/base/ossimStringProperty.h>
 #include <stdexcept>
 #include <sstream>
@@ -720,11 +719,6 @@ ossimString ossimNitfImageHeaderV2_0::getCoordinateSystem()const
 	return theCoordinateSystem;
 }
 
-ossimString ossimNitfImageHeaderV2_0::getGeographicLocation()const
-{
-	return theGeographicLocation;
-}
-
 ossimString ossimNitfImageHeaderV2_0::getPixelValueType()const
 {
    return ossimString(thePixelValueType).trim();
@@ -969,68 +963,6 @@ void ossimNitfImageHeaderV2_0::setNumberOfCols(ossim_uint32 cols)
    ossimNitfCommon::setField(theSignificantCols, out.str(), 8, ios::right, '0');
 }
 
-void ossimNitfImageHeaderV2_0::setGeographicLocationDms(const ossimDpt& ul,
-                                                        const ossimDpt& ur,
-                                                        const ossimDpt& lr,
-                                                        const ossimDpt& ll)
-{
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-      << ossimDms(ul.y, true).toString("ddmmss.ssssC").c_str()
-      << ossimDms(ul.x, false).toString("dddmmss.ssssC").c_str()
-      << ossimDms(ur.y, true).toString("ddmmss.ssssC").c_str()
-      << ossimDms(ur.x, false).toString("dddmmss.ssssC").c_str()
-      << ossimDms(lr.y, true).toString("ddmmss.ssssC").c_str()
-      << ossimDms(lr.x, false).toString("dddmmss.ssssC").c_str()
-      << ossimDms(ll.y, true).toString("ddmmss.ssssC").c_str()
-      << ossimDms(ll.x, false).toString("dddmmss.ssssC").c_str()
-      << std::endl;
-      
-      checkForGeographicTiePointTruncation(ul);
-      checkForGeographicTiePointTruncation(ur);
-      checkForGeographicTiePointTruncation(lr);
-      checkForGeographicTiePointTruncation(ll);
-   }
-   
-   theCoordinateSystem[0] = 'G';
-   
-   memcpy(theGeographicLocation, ossimNitfCommon::encodeGeographicDms(ul,ur,lr,ll).c_str(), 60);
-}
-void ossimNitfImageHeaderV2_0::setGeographicLocationDecimalDegrees(
-                                                                   const ossimDpt& ul,
-                                                                   const ossimDpt& ur,
-                                                                   const ossimDpt& lr,
-                                                                   const ossimDpt& ll)
-{
-   theCoordinateSystem[0] = 'D';
-   memcpy(theGeographicLocation, ossimNitfCommon::encodeGeographicDecimalDegrees(ul, ur, lr, ll).c_str(), 60);
-}
-
-void ossimNitfImageHeaderV2_0::setUtmNorth(ossim_uint32 zone,
-                                           const ossimDpt& ul,
-                                           const ossimDpt& ur,
-                                           const ossimDpt& lr,
-                                           const ossimDpt& ll)
-{
-   theCoordinateSystem[0] = 'N';
-   
-   memcpy(theGeographicLocation,
-          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
-}
-
-void ossimNitfImageHeaderV2_0::setUtmSouth(ossim_uint32 zone,
-                                           const ossimDpt& ul,
-                                           const ossimDpt& ur,
-                                           const ossimDpt& lr,
-                                           const ossimDpt& ll)
-{
-   theCoordinateSystem[0] = 'S';
-   
-   memcpy(theGeographicLocation,
-          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
-}
-
 void ossimNitfImageHeaderV2_0::setProperty(ossimRefPtr<ossimProperty> property)
 {
    ossimNitfImageHeaderV2_X::setProperty(property);
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_1.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_1.cpp
index f17f59fcdd85980545816c4476887d21be1601d2..b1d52f84f4d298002b351448f97f13422e7dd0be 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_1.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_1.cpp
@@ -1,21 +1,21 @@
 //*******************************************************************
 //
-// LICENSE: See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Garrett Potts
 // 
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_1.cpp 14247 2009-04-08 17:51:25Z dburken $
+// $Id: ossimNitfImageHeaderV2_1.cpp 15611 2009-10-08 18:50:33Z dburken $
 #include <sstream>
 #include <iomanip>
 #include <cstring> // for memset
-#include <cstddef> // for NULL
 
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimString.h>
-#include <ossim/base/ossimDms.h>
 #include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimStringProperty.h>
 #include <ossim/base/ossimNotifyContext.h>
@@ -395,37 +395,45 @@ void ossimNitfImageHeaderV2_1::writeStream(std::ostream &out)
    //
    ossim_uint32 totalLength = getTotalTagLength();
 
-   totalLength += 3; // per Table A-3 of MIL-STD-2500B
-
-   if(totalLength <= 99999)
+   if (totalLength == 0)
    {
-      std::ostringstream tempOut;
-
-      tempOut << std::setw(5)
-              << std::setfill('0')
-              << std::setiosflags(ios::right)
-              << totalLength;
-      
-      memcpy(theExtendedSubheaderDataLen, tempOut.str().c_str(), 5);
-
       out.write(theExtendedSubheaderDataLen, 5);
-      memset(theExtendedSubheaderOverflow, '0', 3);
-
-      if(totalLength > 0)
+   }
+   else
+   {
+      totalLength += 3; // per Table A-3 of MIL-STD-2500B
+      
+      if(totalLength <= 99999)
       {
-         out.write(theExtendedSubheaderOverflow, 3);
+         std::ostringstream tempOut;
+         
+         tempOut << std::setw(5)
+                 << std::setfill('0')
+                 << std::setiosflags(ios::right)
+                 << totalLength;
          
-         ossim_uint32 i = 0;
+         memcpy(theExtendedSubheaderDataLen, tempOut.str().c_str(), 5);
          
-         for(i = 0; i < theTagList.size(); ++i)
+         out.write(theExtendedSubheaderDataLen, 5);
+         memset(theExtendedSubheaderOverflow, '0', 3);
+         
+         if(totalLength > 0)
          {
-            theTagList[i].writeStream(out);
+            out.write(theExtendedSubheaderOverflow, 3);
+            
+            ossim_uint32 i = 0;
+            
+            for(i = 0; i < theTagList.size(); ++i)
+            {
+               theTagList[i].writeStream(out);
+            }
          }
       }
-   }
-   else
-   {
-      ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_1::writeStream: Only support writing of total tag length < 99999" << std::endl;
+      else
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "WARNING ossimNitfFileHeaderV2_1::writeStream: Only support writing of total tag length < 99999" << std::endl;
+      }
    }
 }
 
@@ -666,12 +674,7 @@ ossimString ossimNitfImageHeaderV2_1::getRepresentation()const
 
 ossimString ossimNitfImageHeaderV2_1::getCoordinateSystem()const
 {
-	return theCoordinateSystem;
-}
-
-ossimString ossimNitfImageHeaderV2_1::getGeographicLocation()const
-{
-	return theGeographicLocation;
+   return theCoordinateSystem;
 }
 
 bool ossimNitfImageHeaderV2_1::hasBlockMaskRecords()const
@@ -989,70 +992,6 @@ void ossimNitfImageHeaderV2_1::setNumberOfCols(ossim_uint32 cols)
    ossimNitfCommon::setField(theSignificantCols, out.str(), 8, ios::right, '0');
 }
 
-void ossimNitfImageHeaderV2_1::setGeographicLocationDms(const ossimDpt& ul,
-                                                        const ossimDpt& ur,
-                                                        const ossimDpt& lr,
-                                                        const ossimDpt& ll)
-{
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << ossimDms(ul.y, true).toString("ddmmss.ssssC").c_str()
-         << ossimDms(ul.x, false).toString("dddmmss.ssssC").c_str()
-         << ossimDms(ur.y, true).toString("ddmmss.ssssC").c_str()
-         << ossimDms(ur.x, false).toString("dddmmss.ssssC").c_str()
-         << ossimDms(lr.y, true).toString("ddmmss.ssssC").c_str()
-         << ossimDms(lr.x, false).toString("dddmmss.ssssC").c_str()
-         << ossimDms(ll.y, true).toString("ddmmss.ssssC").c_str()
-         << ossimDms(ll.x, false).toString("dddmmss.ssssC").c_str()
-         << std::endl;
-
-      checkForGeographicTiePointTruncation(ul);
-      checkForGeographicTiePointTruncation(ur);
-      checkForGeographicTiePointTruncation(lr);
-      checkForGeographicTiePointTruncation(ll);
-   }
-      
-   theCoordinateSystem[0] = 'G';
-
-   memcpy(theGeographicLocation, ossimNitfCommon::encodeGeographicDms(ul, ur, lr, ll).c_str(), 60);
-}
-
-void ossimNitfImageHeaderV2_1::setGeographicLocationDecimalDegrees(
-   const ossimDpt& ul,
-   const ossimDpt& ur,
-   const ossimDpt& lr,
-   const ossimDpt& ll)
-{
-   theCoordinateSystem[0] = 'D';
-
-   memcpy(theGeographicLocation, ossimNitfCommon::encodeGeographicDecimalDegrees(ul, ur, lr, ll).c_str(), 60);
-}
-
-void ossimNitfImageHeaderV2_1::setUtmNorth(ossim_uint32 zone,
-                                           const ossimDpt& ul,
-                                           const ossimDpt& ur,
-                                           const ossimDpt& lr,
-                                           const ossimDpt& ll)
-{
-   theCoordinateSystem[0] = 'N';
-   
-   memcpy(theGeographicLocation,
-          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
-}
-
-void ossimNitfImageHeaderV2_1::setUtmSouth(ossim_uint32 zone,
-                                           const ossimDpt& ul,
-                                           const ossimDpt& ur,
-                                           const ossimDpt& lr,
-                                           const ossimDpt& ll)
-{
-   theCoordinateSystem[0] = 'S';
-   
-   memcpy(theGeographicLocation,
-          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
-}
-
 void ossimNitfImageHeaderV2_1::setSecurityClassificationSystem(const ossimString& value)
 {
    ossimNitfCommon::setField(theSecurityClassificationSys, value, 2);
@@ -1208,7 +1147,7 @@ void ossimNitfImageHeaderV2_1::setProperty(ossimRefPtr<ossimProperty> property)
 
 ossimRefPtr<ossimProperty> ossimNitfImageHeaderV2_1::getProperty(const ossimString& name)const
 {
-   ossimProperty* property = NULL;
+   ossimProperty* property = 0;
 
    if(name == ISCLSY_KW)
    {
@@ -1322,5 +1261,5 @@ const ossimRefPtr<ossimNitfImageBand> ossimNitfImageHeaderV2_1::getBandInformati
       return (ossimNitfImageBand*)theImageBands[idx].get();
    }
    
-   return NULL;
+   return 0;
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp
index ab79837927989e93e6a1d7c946fc374914f2a8d2..ce7bd174ac7d740e69ec92a3b03053cf2e6b7369 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp
@@ -4,14 +4,19 @@
 #include <iomanip>
 
 #include <ossim/base/ossimNotifyContext.h>
+#include <ossim/base/ossimDms.h>
 #include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimStringProperty.h>
-#include <ossim/base/ossimNotifyContext.h>
+#include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimTrace.h>
 #include <ossim/support_data/ossimNitfImageHeader.h>
 #include <ossim/support_data/ossimNitfCommon.h>
 
 #include <sstream>
 
+static const ossimTrace traceDebug(
+   ossimString("ossimNitfImageHeaderV2_X:debug"));
+
 const ossimString ossimNitfImageHeaderV2_X::IID1_KW = "iid1";
 const ossimString ossimNitfImageHeaderV2_X::IDATIM_KW = "idatim";
 const ossimString ossimNitfImageHeaderV2_X::TGTID_KW = "tgtid";
@@ -667,3 +672,77 @@ ossimString ossimNitfImageHeaderV2_X::getImageMagnification()const
    return ossimString(theImageMagnification).trim();
 }
 
+void ossimNitfImageHeaderV2_X::setGeographicLocationDms(const ossimDpt& ul,
+                                                        const ossimDpt& ur,
+                                                        const ossimDpt& lr,
+                                                        const ossimDpt& ll)
+{
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+      << ossimDms(ul.y, true).toString("ddmmss.ssssC").c_str()
+      << ossimDms(ul.x, false).toString("dddmmss.ssssC").c_str()
+      << ossimDms(ur.y, true).toString("ddmmss.ssssC").c_str()
+      << ossimDms(ur.x, false).toString("dddmmss.ssssC").c_str()
+      << ossimDms(lr.y, true).toString("ddmmss.ssssC").c_str()
+      << ossimDms(lr.x, false).toString("dddmmss.ssssC").c_str()
+      << ossimDms(ll.y, true).toString("ddmmss.ssssC").c_str()
+      << ossimDms(ll.x, false).toString("dddmmss.ssssC").c_str()
+      << std::endl;
+      
+      checkForGeographicTiePointTruncation(ul);
+      checkForGeographicTiePointTruncation(ur);
+      checkForGeographicTiePointTruncation(lr);
+      checkForGeographicTiePointTruncation(ll);
+   }
+   
+   theCoordinateSystem[0] = 'G';
+   
+   memcpy(theGeographicLocation,
+          ossimNitfCommon::encodeGeographicDms(ul,ur,lr,ll).c_str(), 60);
+}
+
+void ossimNitfImageHeaderV2_X::setGeographicLocationDecimalDegrees(
+   const ossimDpt& ul,
+   const ossimDpt& ur,
+   const ossimDpt& lr,
+   const ossimDpt& ll)
+{
+   theCoordinateSystem[0] = 'D';
+   memcpy(theGeographicLocation,
+          ossimNitfCommon::encodeGeographicDecimalDegrees(
+             ul, ur, lr, ll).c_str(), 60);
+}
+
+void ossimNitfImageHeaderV2_X::setUtmNorth(ossim_uint32 zone,
+                                           const ossimDpt& ul,
+                                           const ossimDpt& ur,
+                                           const ossimDpt& lr,
+                                           const ossimDpt& ll)
+{
+   theCoordinateSystem[0] = 'N';
+   
+   memcpy(theGeographicLocation,
+          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
+}
+
+void ossimNitfImageHeaderV2_X::setUtmSouth(ossim_uint32 zone,
+                                           const ossimDpt& ul,
+                                           const ossimDpt& ur,
+                                           const ossimDpt& lr,
+                                           const ossimDpt& ll)
+{
+   theCoordinateSystem[0] = 'S';
+   
+   memcpy(theGeographicLocation,
+          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
+}
+
+
+
+
+
+
+
+
+
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfInfo.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfInfo.cpp
index ea4496fbb85d7f2ba2e238fe86b8e872629c92cf..b5255e56def17659d8e180465a3215be603a740a 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfInfo.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfInfo.cpp
@@ -23,27 +23,17 @@ ossimNitfInfo::ossimNitfInfo()
 
 ossimNitfInfo::~ossimNitfInfo()
 {
-   if (theNitfFile)
-   {
-      delete theNitfFile;
-      theNitfFile = 0;
-   }
+   theNitfFile = 0;
 }
 
 bool ossimNitfInfo::open(const ossimFilename& file)
 {
-   if (theNitfFile)
-   {
-      delete theNitfFile;
-   }
-
    theNitfFile = new ossimNitfFile();
 
    bool result = theNitfFile->parseFile(file);
 
    if (result == false)
    {
-      delete theNitfFile;
       theNitfFile = 0;
    }
 
@@ -55,7 +45,7 @@ std::ostream& ossimNitfInfo::print(std::ostream& out) const
    if (theNitfFile)
    {
       std::string prefix;
-      theNitfFile->print(out, prefix);
+      theNitfFile->print(out, prefix, getProcessOverviewFlag());
    }
    return out;
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfLocalGeographicTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfLocalGeographicTag.cpp
index a05d83bce340eee49bd150f1ff13df0131059029..10ba1efa032c12dc10573b1e94aea7575ac2f4a3 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfLocalGeographicTag.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfLocalGeographicTag.cpp
@@ -9,7 +9,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfLocalGeographicTag.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfLocalGeographicTag.cpp 14713 2009-06-13 16:58:31Z dburken $
 #include <ossim/support_data/ossimNitfLocalGeographicTag.h>
 #include <iomanip>
 #include <sstream>
@@ -63,7 +63,7 @@ void ossimNitfLocalGeographicTag::clearFields()
    theLonDensity[9] = '\0';
    theLatDensity[9] = '\0';
    theLonOrigin[15] = '\0';
-   theLatOrigin[15] = '\0';
+   theLatOrigin[14] = '\0';
 }
 
 void ossimNitfLocalGeographicTag::setDegreesPerPixelLat(double deltaLat)
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfMstgtaTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfMstgtaTag.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..53732f92187ff1d99f930284a458cc44655cfe3b
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfMstgtaTag.cpp
@@ -0,0 +1,144 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: MSTGTA Mission Target Information Extension Format
+// tag class definition.
+//
+// See document STDI-0002 Table 8-16 for more info.
+// 
+//----------------------------------------------------------------------------
+// $Id
+
+#include <cstring>
+#include <istream>
+#include <iostream>
+#include <iomanip>
+
+#include <ossim/support_data/ossimNitfMstgtaTag.h>
+
+
+RTTI_DEF1(ossimNitfMstgtaTag, "ossimNitfMstgtaTag", ossimNitfRegisteredTag);
+
+ossimNitfMstgtaTag::ossimNitfMstgtaTag()
+   : ossimNitfRegisteredTag()
+{
+   clearFields();
+}
+
+ossimNitfMstgtaTag::~ossimNitfMstgtaTag()
+{
+}
+
+ossimString ossimNitfMstgtaTag::getRegisterTagName() const
+{
+   return "MSTGTA";
+}
+
+void ossimNitfMstgtaTag::parseStream(std::istream& in)
+{
+   clearFields();
+   
+   in.read(theTgtNum, TGT_NUM_SIZE);
+   in.read(theTgtId, TGT_ID_SIZE);
+   in.read(theTgtBe, TGT_BE_SIZE);
+   in.read(theTgtPri, TGT_PRI_SIZE);
+   in.read(theTgtReq, TGT_REQ_SIZE);
+   in.read(theTgtLtiov, TGT_LTIOV_SIZE);
+   in.read(theTgtType, TGT_TYPE_SIZE);
+   in.read(theTgtColl, TGT_COLL_SIZE);
+   in.read(theTgtCat, TGT_CAT_SIZE);
+   in.read(theTgtUtc, TGT_UTC_SIZE);
+   in.read(theTgtElev, TGT_ELEV_SIZE);
+   in.read(theTgtElevUnit, TGT_ELEV_UNIT_SIZE);
+   in.read(theTgtLoc, TGT_LOC_SIZE);
+}
+
+void ossimNitfMstgtaTag::writeStream(std::ostream& out)
+{
+   out.write(theTgtNum, TGT_NUM_SIZE);
+   out.write(theTgtId, TGT_ID_SIZE);
+   out.write(theTgtBe, TGT_BE_SIZE);
+   out.write(theTgtPri, TGT_PRI_SIZE);
+   out.write(theTgtReq, TGT_REQ_SIZE);
+   out.write(theTgtLtiov, TGT_LTIOV_SIZE);
+   out.write(theTgtType, TGT_TYPE_SIZE);
+   out.write(theTgtColl, TGT_COLL_SIZE);
+   out.write(theTgtCat, TGT_CAT_SIZE);
+   out.write(theTgtUtc, TGT_UTC_SIZE);
+   out.write(theTgtElev, TGT_ELEV_SIZE);
+   out.write(theTgtElevUnit, TGT_ELEV_UNIT_SIZE);
+   out.write(theTgtLoc, TGT_LOC_SIZE);
+}
+
+ossim_uint32 ossimNitfMstgtaTag::getSizeInBytes()const
+{
+   return 101;
+}
+
+void ossimNitfMstgtaTag::clearFields()
+{
+   // BCS-N's to '0's, BCS-A's to ' '(spaces)
+
+   // clear
+   memset(theTgtNum, '0', TGT_NUM_SIZE);
+   memset(theTgtId, ' ', TGT_ID_SIZE);
+   memset(theTgtBe, ' ', TGT_BE_SIZE);
+   memset(theTgtPri, ' ', TGT_PRI_SIZE);
+   memset(theTgtReq, ' ', TGT_REQ_SIZE);
+   memset(theTgtLtiov, ' ', TGT_LTIOV_SIZE);
+   memset(theTgtType, ' ', TGT_TYPE_SIZE);
+   memset(theTgtColl, '0', TGT_COLL_SIZE);
+   memset(theTgtCat, ' ', TGT_CAT_SIZE);
+   memset(theTgtUtc, ' ', TGT_UTC_SIZE);
+   memset(theTgtElev, ' ', TGT_ELEV_SIZE);
+   memset(theTgtElevUnit, ' ', TGT_ELEV_UNIT_SIZE);
+   memset(theTgtLoc, ' ', TGT_LOC_SIZE);
+
+   // null terminate
+   theTgtNum[TGT_NUM_SIZE] = '\0';
+   theTgtId[TGT_ID_SIZE] = '\0';
+   theTgtBe[TGT_BE_SIZE] = '\0';
+   theTgtPri[TGT_PRI_SIZE] = '\0';
+   theTgtReq[TGT_REQ_SIZE] = '\0';
+   theTgtLtiov[TGT_LTIOV_SIZE] = '\0';
+   theTgtType[TGT_TYPE_SIZE] = '\0';
+   theTgtColl[TGT_COLL_SIZE] = '\0';
+   theTgtCat[TGT_CAT_SIZE] = '\0';
+   theTgtUtc[TGT_UTC_SIZE] = '\0';
+   theTgtElev[TGT_ELEV_SIZE] = '\0';
+   theTgtElevUnit[TGT_ELEV_UNIT_SIZE] = '\0';
+   theTgtLoc[TGT_LOC_SIZE] = '\0';
+}
+
+std::ostream& ossimNitfMstgtaTag::print(
+   std::ostream& out, const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+   
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"   << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "TGT_NUM:" << theTgtNum << "\n"
+       << pfx << std::setw(24) << "TGT_ID:" << theTgtId << "\n"
+       << pfx << std::setw(24) << "TGT_BE:" << theTgtBe << "\n"
+       << pfx << std::setw(24) << "TGT_PRI:" << theTgtPri << "\n"
+       << pfx << std::setw(24) << "TGT_REQ:" << theTgtReq << "\n"
+       << pfx << std::setw(24) << "TGT_LTIOV:" << theTgtLtiov << "\n"
+       << pfx << std::setw(24) << "TGT_TYPE:" << theTgtType << "\n"
+       << pfx << std::setw(24) << "TGT_COLL:" << theTgtColl << "\n"
+       << pfx << std::setw(24) << "TGT_CAT:" << theTgtCat << "\n"
+       << pfx << std::setw(24) << "TGT_UTC:" << theTgtUtc << "\n"
+       << pfx << std::setw(24) << "TGT_ELEV:" << theTgtElev << "\n"
+       << pfx << std::setw(24) << "TGT_ELEV_UNIT:" << theTgtElevUnit << "\n"
+       << pfx << std::setw(24) << "TGT_LOC:" << theTgtLoc << "\n";
+   
+   return out;
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfProjectionParameterTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfProjectionParameterTag.cpp
index 69d58c1a1d6d135cee1424225b45d171329c9fe9..78a2d3e9bfdd1f698a2d3f94f073e52f42ab3478 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfProjectionParameterTag.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfProjectionParameterTag.cpp
@@ -1,21 +1,20 @@
 //*******************************************************************
-// Copyright (C) 2004 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
+// License:  LGPL
 //
-// see top level LICENSE.txt
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Garrett Potts
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfProjectionParameterTag.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfProjectionParameterTag.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/support_data/ossimNitfProjectionParameterTag.h>
 #include <sstream>
 #include <iomanip>
 
 ossimNitfProjectionParameterTag::ossimNitfProjectionParameterTag()
-      :ossimNitfRegisteredTag()
+:ossimNitfRegisteredTag()
 {
    clearFields();
 }
@@ -79,8 +78,32 @@ ossim_uint32 ossimNitfProjectionParameterTag::getSizeInBytes()const
    return (113 + theProjectionParameters.size()*15);
 }
 
-std::ostream& ossimNitfProjectionParameterTag::print(std::ostream& out)const
+std::ostream& ossimNitfProjectionParameterTag::print(
+   std::ostream& out, const std::string& prefix) const
 {
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:" << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"   << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "PRN:"   << theProjectionName << "\n"
+       << pfx << std::setw(24) << "PCO:"   << theProjectionCode << "\n"
+       << pfx << std::setw(24) << "NUM_PRJ:" << theNumberOfParameters << "\n";
+
+   for (ossim_uint32 i = 0; i < theProjectionParameters.size(); ++i)
+   {
+      ossimString s = "PRJ";
+      s += ossimString::toString(i);
+      s += ":";
+      out << pfx << std::setw(24) << s
+          << theProjectionParameters[i] << "\n";
+   }
+
+   out << pfx << std::setw(24) << "XOR:"   <<theFalseXOrigin << "\n"
+       << pfx << std::setw(24) << "YOR:"   <<theFalseYOrigin << std::endl;
+   
    return out;   
 }
     
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfRegisteredTagFactory.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfRegisteredTagFactory.cpp
index 3a22ea1c73c3e0f82955d99ba819bc297e06aedf..3efbde441e47a5f1d926dc52fa4720f15ec66022 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfRegisteredTagFactory.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfRegisteredTagFactory.cpp
@@ -9,20 +9,28 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfRegisteredTagFactory.cpp 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimNitfRegisteredTagFactory.cpp 14691 2009-06-10 15:56:10Z dburken $
+
 #include <ossim/support_data/ossimNitfRegisteredTagFactory.h>
+
+#include <ossim/support_data/ossimNitfAcftbTag.h>
+#include <ossim/support_data/ossimNitfAimidbTag.h>
 #include <ossim/support_data/ossimNitfBlockaTag.h>
 #include <ossim/support_data/ossimNitfCscrnaTag.h>
 #include <ossim/support_data/ossimNitfCsdidaTag.h>
 #include <ossim/support_data/ossimNitfCsexraTag.h>
+#include <ossim/support_data/ossimNitfCsexraTag.h>
+#include <ossim/support_data/ossimNitfEngrdaTag.h>
 #include <ossim/support_data/ossimNitfGeoPositioningTag.h>
 #include <ossim/support_data/ossimNitfIchipbTag.h>
 #include <ossim/support_data/ossimNitfLocalGeographicTag.h>
 #include <ossim/support_data/ossimNitfLocalCartographicTag.h>
+#include <ossim/support_data/ossimNitfMstgtaTag.h>
 #include <ossim/support_data/ossimNitfPiaimcTag.h>
 #include <ossim/support_data/ossimNitfProjectionParameterTag.h>
 #include <ossim/support_data/ossimNitfRpcBTag.h>
 #include <ossim/support_data/ossimNitfRpcATag.h>
+#include <ossim/support_data/ossimNitfSensraTag.h>
 #include <ossim/support_data/ossimNitfStdidcTag.h>
 #include <ossim/support_data/ossimNitfUse00aTag.h>
 
@@ -31,18 +39,23 @@ RTTI_DEF1(ossimNitfRegisteredTagFactory, "ossimNitfRegisteredTagFactory", ossimN
 
 ossimNitfRegisteredTagFactory* ossimNitfRegisteredTagFactory::theInstance = NULL;
 
+static const char ACFTB_TAG[]                = "ACFTB";
+static const char AIMIDB_TAG[]               = "AIMIDB";
 static const char BLOCKA_TAG[]               = "BLOCKA";
 static const char CSCRNA_TAG[]               = "CSCRNA";
 static const char CSDIDA_TAG[]               = "CSDIDA";
 static const char CSEXRA_TAG[]               = "CSEXRA";
+static const char ENGRDA_TAG[]               = "ENGRDA";
 static const char GEO_POSITIONING_TAG[]      = "GEOPSB";
 static const char ICHIPB_TAG[]               = "ICHIPB";
 static const char LOCAL_GEOGRAPHIC_TAG[]     = "GEOLOB";
 static const char LOCAL_CARTOGRAPHIC_TAG[]   = "MAPLOB";
+static const char MSTGTA_TAG[]               = "MSTGTA";
 static const char PIAIMC_TAG[]               = "PIAIMC";
 static const char PROJECTION_PARAMETER_TAG[] = "PRJPSB";
 static const char RPCB_TAG[]                 = "RPC00B";
 static const char RPCA_TAG[]                 = "RPC00A";
+static const char SENSRA_TAG[]               = "SENSRA";
 static const char STDIDC_TAG[]               = "STDIDC";
 static const char USE00A_TAG[]               = "USE00A";
 
@@ -71,7 +84,15 @@ ossimRefPtr<ossimNitfRegisteredTag> ossimNitfRegisteredTagFactory::create(
 {
    ossimString name = ossimString(tagName).trim().upcase();
    
-   if(tagName == BLOCKA_TAG)
+   if(tagName == ACFTB_TAG)
+   {
+      return new ossimNitfAcftbTag;
+   }
+   else if(tagName == AIMIDB_TAG)
+   {
+      return new ossimNitfAimidbTag;
+   }
+   else if(tagName == BLOCKA_TAG)
    {
       return new ossimNitfBlockaTag;
    }
@@ -87,6 +108,10 @@ ossimRefPtr<ossimNitfRegisteredTag> ossimNitfRegisteredTagFactory::create(
    {
       return new ossimNitfCsexraTag;
    }
+   else if(tagName == ENGRDA_TAG)
+   {
+      return new ossimNitfEngrdaTag;
+   }
    else if(tagName == GEO_POSITIONING_TAG)
    {
       return new ossimNitfGeoPositioningTag;
@@ -103,6 +128,10 @@ ossimRefPtr<ossimNitfRegisteredTag> ossimNitfRegisteredTagFactory::create(
    {
       return new ossimNitfLocalCartographicTag;
    }
+   else if(tagName == MSTGTA_TAG)
+   {
+      return new ossimNitfMstgtaTag;
+   }
    else if(tagName == PIAIMC_TAG)
    {
       return new ossimNitfPiaimcTag;
@@ -119,6 +148,10 @@ ossimRefPtr<ossimNitfRegisteredTag> ossimNitfRegisteredTagFactory::create(
    {
       return new ossimNitfRpcATag;
    }
+   else if (tagName == SENSRA_TAG)
+   {
+      return new ossimNitfSensraTag;
+   }
    else if (tagName == STDIDC_TAG)
    {
       return new ossimNitfStdidcTag;
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfRpcBase.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfRpcBase.cpp
index 916236e8f312b030cec6694f7d90c77a1d09818d..a73b6dbcde34937fd8d02aa09d9e644a75fca6cd 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfRpcBase.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfRpcBase.cpp
@@ -1,9 +1,8 @@
 //*******************************************************************
-// Copyright (C) 2000 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
-//
-// see top level LICENSE.txt
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
 // 
 // Author: Garrett Potts
 //
@@ -11,10 +10,11 @@
 // Rational Polynomial Coefficient extension.
 //
 //********************************************************************
-// $Id: ossimNitfRpcBase.cpp 12772 2008-05-02 14:45:33Z gpotts $
+// $Id: ossimNitfRpcBase.cpp 14576 2009-05-20 13:58:45Z dburken $
 
 #include <algorithm>
 #include <iostream>
+#include <iomanip>
 #include <vector>
 #include <ossim/support_data/ossimNitfRpcBase.h>
 #include <ossim/support_data/ossimNitfCommon.h>
@@ -697,60 +697,86 @@ void ossimNitfRpcBase::setSampleDenominatorCoeff(
   theSampleDenominatorCoefficient[idx] = s;  
 }
 
-std::ostream& ossimNitfRpcBase::print(std::ostream& out) const
-{
-   out << "ossimNitfRpcBase::print"
-       << "\ntheSuccess:               " << theSuccess
-       << "\ntheErrorBias:             " << theErrorBias
-       << "\ntheErrRand:               " << theErrRand
-       << "\ntheLineOffset:            " << theLineOffset
-       << "\ntheSampleOffset:          " << theSampleOffset
-       << "\ntheGeodeticLatOffset:     " << theGeodeticLatOffset
-       << "\ntheGeodeticLonOffset:     " << theGeodeticLonOffset
-       << "\ntheGeodeticHeightOffset:  " << theGeodeticHeightOffset
-       << "\ntheLineScale:             " <<theLineScale
-       << "\ntheSampleScale:           " << theSampleScale
-       << "\ntheGeodeticLatScale:      " << theGeodeticLatScale
-       << "\ntheGeodeticLonScale:      " << theGeodeticLonScale
-       << "\ntheGeodeticHeightScale:   " << theGeodeticHeightScale
-       << std::endl;
+std::ostream& ossimNitfRpcBase::print(std::ostream& out,
+                                      const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+
+   out << setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:"
+       << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "SUCCESS:"
+       << theSuccess << "\n" 
+       << pfx << std::setw(24) << "ERR_BIAS:"
+       << theErrorBias << "\n"
+       << pfx << std::setw(24) << "ERR_RAND:"
+       <<theErrRand  << "\n" 
+       << pfx << std::setw(24) << "LINE_OFF:"
+       << theLineOffset << "\n"
+       << pfx << std::setw(24) << "SAMP_OFF:"
+       << theSampleOffset << "\n" 
+       << pfx << std::setw(24) << "LAT_OFF:"
+       << theGeodeticLatOffset << "\n"
+       << pfx << std::setw(24) << "LONG_OFF:"
+       << theGeodeticLonOffset << "\n" 
+       << pfx << std::setw(24) << "HEIGHT_OFF:"
+       << theGeodeticHeightOffset << "\n"
+       << pfx << std::setw(24) << "LINE_SCALE:"
+       << theLineScale  << "\n" 
+       << pfx << std::setw(24)
+       << "SAMP_SCALE:" << theSampleScale << "\n"
+       << pfx << std::setw(24) << "LAT_SCALE:"
+       << theGeodeticLatScale << "\n" 
+       << pfx << std::setw(24) << "LONG_SCALE:"
+       << theGeodeticLonScale << "\n"
+       << pfx << std::setw(24) << "HEIGHT_SCALE:"
+       << theGeodeticHeightScale << "\n";
 
    ossim_int32 i;
+   ossimString s;
    
    for (i=0; i<LINE_NUMERATOR_COEFFICIENT_COUNT; ++i)
    {
-      out << "\ntheLineNumeratorCoefficient[" << i << "]: "
-          << theLineNumeratorCoefficient[i];
+      s = "LINE_NUM_COEFF_";
+      s += ossimString::toString(i);
+      s += ":";
+      out << pfx << std::setw(24) << s
+          << theLineNumeratorCoefficient[i] << "\n";
    }
 
-   out << std::endl;
-   
    for (i=0; i<LINE_DENOMINATOR_COEFFICIENT_COUNT; ++i)
    {
-      out << "\ntheLineDenominatorCoefficient[" << i << "]: "
-          << theLineDenominatorCoefficient[i];
+      s = "LINE_DEN_COEFF_";
+      s += ossimString::toString(i);
+      s += ":";
+      out << pfx << std::setw(24) << s
+          << theLineDenominatorCoefficient[i] << "\n";
    }
 
-   out << std::endl;
-   
-
-   for (i=0; i<SAMPLE_NUMERATOR_COEFFICIENT_COUNT; ++i)
+   for (i=0; i<LINE_NUMERATOR_COEFFICIENT_COUNT; ++i)
    {
-      out << "\ntheSampleNumeratorCoefficient[" << i << "]: "
-          << theSampleNumeratorCoefficient[i];
+      s = "SAMP_NUM_COEFF_";
+      s += ossimString::toString(i);
+      s += ":";
+      out << pfx << std::setw(24) << s
+          << theSampleNumeratorCoefficient[i] << "\n";
    }
 
-   out << std::endl;
-   
-
-   for (i=0; i<SAMPLE_DENOMINATOR_COEFFICIENT_COUNT; ++i)
+   for (i=0; i<LINE_DENOMINATOR_COEFFICIENT_COUNT; ++i)
    {
-      out << "\ntheSampleDenominatorCoefficient[" << i << "]: "
-          << theSampleDenominatorCoefficient[i];
+      s = "SAMP_DEN_COEFF_";
+      s += ossimString::toString(i);
+      s += ":";
+      out << pfx << std::setw(24) << s
+          << theSampleDenominatorCoefficient[i] << "\n";
    }
 
-   out << std::endl;
-      
+   out.flush();
+   
    return out;
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfSensraTag.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfSensraTag.cpp
index 7ab3037dc9a7c8fe96713d0c423d3a17cd21fbc8..a617aad6772b7ec55a7c16ade477eabe7a0b1dd7 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfSensraTag.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfSensraTag.cpp
@@ -9,9 +9,10 @@
 // Description: Nitf support class for SENSRA - Sensor parameters extension.
 // 
 //********************************************************************
-// $Id: ossimNitfSensraTag.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimNitfSensraTag.cpp 14659 2009-06-05 17:37:39Z dburken $
 
 #include <istream>
+#include <iomanip>
 #include <ossim/support_data/ossimNitfSensraTag.h>
 
 RTTI_DEF1(ossimNitfSensraTag, "ossimNitfSensraTag", ossimNitfRegisteredTag);
@@ -147,6 +148,45 @@ void ossimNitfSensraTag::clearFields()
    theSpotNum[SPOT_NUM_SIZE] = '\0';
 }
 
+std::ostream& ossimNitfSensraTag::print(
+   std::ostream& out, const std::string& prefix) const
+{
+   std::string pfx = prefix;
+   pfx += getRegisterTagName();
+   pfx += ".";
+   
+   out << std::setiosflags(std::ios::left)
+       << pfx << std::setw(24) << "CETAG:"
+       << getRegisterTagName() << "\n"
+       << pfx << std::setw(24) << "CEL:" << getSizeInBytes() << "\n"
+       << pfx << std::setw(24) << "REFROW:" << theRefRow << "\n"
+       << pfx << std::setw(24) << "REFCOL:" << theRefCol << "\n"
+       << pfx << std::setw(24) << "SENSORMODEL:" << theSensorModel<< "\n"
+       << pfx << std::setw(24) << "SENSORMOUNT:" << theSensorMount << "\n"
+       << pfx << std::setw(24) << "SENSORLOC:" << theSensorLoc << "\n"
+       << pfx << std::setw(24) << "SENSORALTSRC:" << theSensorAltSrc<< "\n"
+       << pfx << std::setw(24) << "SENSORALT:" << theSensorAlt << "\n"
+       << pfx << std::setw(24) << "SENSORALTUNIT:" << theSensorAltUnit << "\n"
+       << pfx << std::setw(24) << "SENSORAGL:" << theSensorAgl << "\n"
+       << pfx << std::setw(24) << "SENSORPITCH:" << theSensorPitch << "\n"
+       << pfx << std::setw(24) << "SENSORROLL:" << theSensorRoll<< "\n"
+       << pfx << std::setw(24) << "SENSORYAW:" << theSensorYaw << "\n"
+       << pfx << std::setw(24) << "PLATFORMPITCH:" << thePlatformPitch << "\n"
+       << pfx << std::setw(24) << "PLATFORMROLL:" << thePlatformRoll << "\n"
+       << pfx << std::setw(24) << "PLATFORMHDG:" << thePlatformHdg << "\n"
+       << pfx << std::setw(24) << "GROUNDSPDSRC:" << theGroundSpdSrc << "\n"
+       << pfx << std::setw(24) << "GROUNDSPEED:" << theGroundSpeed << "\n"
+       << pfx << std::setw(24) << "GROUNDSPDUNIT:" << theGroundSpdUnit << "\n"
+       << pfx << std::setw(24) << "GROUNDTRACK:" << theGroundTrack << "\n"
+       << pfx << std::setw(24) << "VERTICALVEL:" << theVerticalVel<< "\n"
+       << pfx << std::setw(24) << "VERTVELUNIT:" << theVertVelUnit << "\n"
+       << pfx << std::setw(24) << "SWATHFRAMES:" << theSwathFrames<< "\n"
+       << pfx << std::setw(24) << "NSWATHS:" << theNSwaths << "\n"
+       << pfx << std::setw(24) << "SPOTNUM:" << theSpotNum << "\n";
+   
+   return out;
+}
+
 ossimString ossimNitfSensraTag::getRefRow()const
 {
    return theRefRow;
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimRpfFrame.cpp b/Utilities/otbossim/src/ossim/support_data/ossimRpfFrame.cpp
index dfc313b762df4d5b2e91c24e7cd07b147820a835..554f46e7c02c29b46b66fe82ada46563b27dc82e 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimRpfFrame.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimRpfFrame.cpp
@@ -10,7 +10,7 @@
 //              rpf file.
 //
 //********************************************************************
-// $Id: ossimRpfFrame.cpp 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimRpfFrame.cpp 15766 2009-10-20 12:37:09Z gpotts $
 
 #include <istream>
 #include <ostream>
@@ -222,7 +222,7 @@ ossimErrorCode ossimRpfFrame::parseFile(const ossimFilename& filename)
    deleteAll();
 
 
-   ossimNitfFile *nitfFile = new ossimNitfFile;
+   ossimRefPtr<ossimNitfFile> nitfFile = new ossimNitfFile;
    nitfFile->parseFile(filename);
    
    const ossimRefPtr<ossimNitfFileHeader> nitfFileHeader =
@@ -230,8 +230,7 @@ ossimErrorCode ossimRpfFrame::parseFile(const ossimFilename& filename)
       
    if(!nitfFileHeader)
    {
-      delete nitfFile;
-      nitfFile = NULL;
+      nitfFile = 0;
       
       return ossimErrorCodes::OSSIM_ERROR;
    }
@@ -239,8 +238,7 @@ ossimErrorCode ossimRpfFrame::parseFile(const ossimFilename& filename)
    nitfFileHeader->getTag(info, "RPFHDR");
       
    // we no longer need access to the nitf header.  We got what we needed
-   delete nitfFile;
-   nitfFile = NULL;
+   nitfFile = 0;
    
    theFilename = filename;
    if(info.getTagName() == "RPFHDR")
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimRpfFrameFileReader.cpp b/Utilities/otbossim/src/ossim/support_data/ossimRpfFrameFileReader.cpp
index 5a518bfa7ba7978fad56b119f6c7fa6ab85d9dcf..c7ff18c54a00552ee5e5a5bda2900a7b4c0da506 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimRpfFrameFileReader.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimRpfFrameFileReader.cpp
@@ -8,7 +8,7 @@
 // Description: Rpf support class
 // 
 //********************************************************************
-// $Id: ossimRpfFrameFileReader.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRpfFrameFileReader.cpp 15766 2009-10-20 12:37:09Z gpotts $
 #include <ossim/support_data/ossimRpfFrameFileReader.h>
 #include <ossim/support_data/ossimRpfHeader.h>
 #include <ossim/support_data/ossimRpfImageDescriptionSubheader.h>
@@ -51,7 +51,7 @@ ossimRpfFrameFileReader::~ossimRpfFrameFileReader()
 ossimErrorCode ossimRpfFrameFileReader::parseFile(const ossimFilename& fileName)
 {
    ifstream in(fileName, ios::in | ios::binary);
-   ossimNitfFile *nitfFile = new ossimNitfFile;
+   ossimRefPtr<ossimNitfFile> nitfFile = new ossimNitfFile;
 
    if(!in)
    {
@@ -63,9 +63,7 @@ ossimErrorCode ossimRpfFrameFileReader::parseFile(const ossimFilename& fileName)
       nitfFile->getHeader();
    if(!nitfFileHeader)
    {
-      delete nitfFile;
-      nitfFile = NULL;
-      
+      nitfFile = 0;
       return ossimErrorCodes::OSSIM_ERROR;
    }
    if(theRpfHeader)
@@ -76,8 +74,7 @@ ossimErrorCode ossimRpfFrameFileReader::parseFile(const ossimFilename& fileName)
    ossimNitfTagInformation info; 
    nitfFileHeader->getTag(info, "RPFHDR");
    // we no longer need access to the nitf header.  We got what we needed
-   delete nitfFile;
-   nitfFile = NULL;
+   nitfFile = 0;
    theFilename = fileName;
    if(info.getTagName() == "RPFHDR")
    {      
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimRpfToc.cpp b/Utilities/otbossim/src/ossim/support_data/ossimRpfToc.cpp
index a7bef7e662300b1a7f28beb241bdd75e905b5fdd..8cada97275312699d32c6561a7bdfc386930eff6 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimRpfToc.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimRpfToc.cpp
@@ -9,7 +9,7 @@
 // Description: Rpf support class
 // 
 //********************************************************************
-// $Id: ossimRpfToc.cpp 14241 2009-04-07 19:59:23Z dburken $
+// $Id: ossimRpfToc.cpp 15810 2009-10-24 14:54:27Z dburken $
 
 #include <iostream>
 
@@ -56,25 +56,25 @@ ossimErrorCode ossimRpfToc::parseFile(const ossimFilename &fileName)
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << "ossimRpfToc::parseFile: entered....." << std::endl;
    }
-   ossimNitfFile *nitfFile = new ossimNitfFile;
+
+   ossimRefPtr<ossimNitfFile> nitfFile = new ossimNitfFile;
 
    clearAll();
 
    nitfFile->parseFile(fileName);
 
-   const ossimRefPtr<ossimNitfFileHeader> nitfFileHeader =
+   ossimRefPtr<const ossimNitfFileHeader> nitfFileHeader =
       nitfFile->getHeader();
    
    if(theRpfHeader)
    {
       delete theRpfHeader;
-      theRpfHeader = NULL;
+      theRpfHeader = 0;
    }
    
    if(!nitfFileHeader)
    {
-      delete nitfFile;
-      nitfFile = NULL;
+      nitfFile = 0;
       
       if(traceDebug())
       {
@@ -86,9 +86,10 @@ ossimErrorCode ossimRpfToc::parseFile(const ossimFilename &fileName)
    ossimNitfTagInformation info; 
    nitfFileHeader->getTag(info, "RPFHDR");
    
-   // we no longer need access to the nitf header.  We got what we needed
-   delete nitfFile;
-   nitfFile = NULL;
+   // we no longer need access to the nitf header.  We got what we needed.
+   nitfFileHeader = 0;
+   nitfFile = 0;
+   
    theFilename = fileName;
 
    if(info.getTagName() == "RPFHDR")
@@ -148,7 +149,8 @@ ossimErrorCode ossimRpfToc::parseFile(const ossimFilename &fileName)
 }
 
 std::ostream& ossimRpfToc::print(std::ostream& out,
-                                 const std::string& prefix) const
+                                 const std::string& prefix,
+                                 bool printOverviews) const
 {
    if(theRpfHeader)
    {
@@ -173,8 +175,8 @@ std::ostream& ossimRpfToc::print(std::ostream& out,
                (*tocEntry)->getBoundaryInformation();
 
             ossimString scale = REC.getScale();
-            
-            if (scale.contains("OVERVIEW") == false)
+            if ( (scale.contains("OVERVIEW")) == false ||
+                 printOverviews )
             {
                std::string entryPrefix = prefix;
                entryPrefix += "image";
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimTiffInfo.cpp b/Utilities/otbossim/src/ossim/support_data/ossimTiffInfo.cpp
index 20e3ffe528c77831d4be3daede6fb8f2ac1b613d..aa5468cc91e38c5c9cc30614661eb953ead3602a 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimTiffInfo.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimTiffInfo.cpp
@@ -14,12 +14,26 @@
 #include <iostream>
 #include <iomanip>
 #include <sstream>
+
 #include <ossim/support_data/ossimTiffInfo.h>
+
 #include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimEndian.h>
+#include <ossim/base/ossimGeoTiffCoordTransformsLut.h>
+#include <ossim/base/ossimIoStream.h> /* for ossimIOMemoryStream */
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimTieGptSet.h>
 #include <ossim/base/ossimTrace.h>
 
+#include <ossim/projection/ossimBilinearProjection.h>
+#include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimPcsCodeProjectionFactory.h>
+#include <ossim/projection/ossimStatePlaneProjectionInfo.h>
+#include <ossim/projection/ossimStatePlaneProjectionFactory.h>
+
 // Static trace for debugging
 static ossimTrace traceDebug("ossimTiffInfo:debug");
 static ossimTrace traceDump("ossimTiffInfo:dump"); // This will dump offsets.
@@ -36,11 +50,30 @@ static const std::string PHOTO_INTERP[] =
    "CIELAB"
 };
 
+static const std::string ANGULAR_UNITS_KW = "angular_units";
+static const std::string CENTER_LATITUDE__KW = "center_latitude";
+static const std::string CENTER_LONGITUDE_KW = "center_longitude";
+static const std::string COORD_TRANS_CODE_KW = "coord_trans_code";
+static const std::string FALSE_ORIGIN_LONGITUDE_KW = "false_origin_longitude";
+static const std::string FALSE_ORIGIN_LATITUDE_KW = "false_origin_latitude";
+static const std::string FALSE_ORIGIN_EASTING_KW = "false_origin_easting";
+static const std::string FALSE_ORIGIN_NORTHING_KW = "false_origin_northing";
+static const std::string IMAGE_LENGTH_KW = "image_length";
+static const std::string IMAGE_WIDTH_KW = "image_width";
+static const std::string LINEAR_UNITS_KW = "linear_units";
+static const std::string MODEL_PIXEL_SCALE_KW = "model_pixel_scale";
+static const std::string MODEL_TIE_POINT_KW = "model_tie_point";
+static const std::string MODEL_TRANSFORM_KW = "model_transform";
+static const std::string MODEL_TYPE_KW = "model_type";
+static const std::string ORIGIN_LATITUDE_KW = "origin_latitude";
+static const std::string ORIGIN_LONGITUDE_KW = "origin_longitude";
+static const std::string RASTER_TYPE_KW = "raster_type";
+
+
 ossimTiffInfo::ossimTiffInfo()
    : ossimInfoBase(),
      theFile(),
-     theEndian(0),
-     theVersion(0)
+     theEndian(0)
 {
 }
 
@@ -93,10 +126,11 @@ bool ossimTiffInfo::open(const ossimFilename& file)
       // Get the version. Note theEndian must be set/unset before calling
       // "readShort".
       //---
-      readShort(theVersion, str);
+      ossim_uint16 version;
+      readShort(version, str);
 
       if ( ( (byteOrder[0] == 'M') || (byteOrder[0] == 'I') ) &&
-           ( (theVersion == 42) || (theVersion == 43) ) )
+           ( (version == 42) || (version == 43) ) )
       {
          result = true;  // is a tif...
       }
@@ -207,7 +241,7 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
    }
 
    // Get the offset.
-   if (getOffset(seekOffset, str) == false)
+   if (getOffset(seekOffset, str, version) == false)
    {
      ossimNotify(ossimNotifyLevel_WARN) 
         << MODULE << " FATAL ERROR - "
@@ -257,7 +291,7 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
       // Get the number of directories within the IFD.
       //---
       ossim_uint64 nTags; // Number of tags in an IFD.
-      if (getValue(nTags, str, TWO_OR_EIGHT) == false)
+      if (getValue(nTags, str, TWO_OR_EIGHT, version) == false)
       {
          ossimNotify(ossimNotifyLevel_WARN)
             << MODULE << " FATAL error reading number of direcories."
@@ -315,7 +349,7 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
          // type.  So if the type is a short and the count is one then
          // read "sizeof(short"(2) bytes.
          //---
-         getValue(count, str, FOUR_OR_EIGHT);
+         getValue(count, str, FOUR_OR_EIGHT, version);
          if (!str)
          {
             ossimNotify(ossimNotifyLevel_WARN)
@@ -330,7 +364,7 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
          if (arraySizeInBytes == 0)
          {
             // Could be an unhandle type.  Gobble the value.
-            eatValue(str);
+            eatValue(str, version);
          }
          else
          {
@@ -353,7 +387,7 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
             else // Data to big for field.  Stored elsewhere...
             {
                // Get the offset to the data.
-               getOffset(seekOffset, str);
+               getOffset(seekOffset, str, version);
 
                // Capture the seek position to come back to.
                streamPosition = str.tellg();
@@ -383,19 +417,19 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
                << "\n";
 	 }
 
-         if (tag == GEO_KEY_DIRECTORY_TAG)
+         if (tag == OGEO_KEY_DIRECTORY_TAG)
          {
             // tag 34735 save for printGeoKeys
             geoKeyBlock = reinterpret_cast<ossim_uint16*>(valueArray);
             geoKeyLength = count;
          }
-         else if (tag == GEO_DOUBLE_PARAMS_TAG)
+         else if (tag == OGEO_DOUBLE_PARAMS_TAG)
          {
             // tag 34736 save for printGeoKeys
             geoDoubleBlock  = reinterpret_cast<ossim_float64*>(valueArray);
             geoDoubleLength = count;
          }
-         else if (tag == GEO_ASCII_PARAMS_TAG)
+         else if (tag == OGEO_ASCII_PARAMS_TAG)
          {
             // tag 34737 save for printGeoKeys
             geoAsciiBlock   = reinterpret_cast<ossim_int8*>(valueArray);
@@ -456,7 +490,7 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
       // Get the next IFD offset.  Continue this loop until the offset is
       // zero.
       //---
-      if (getOffset(seekOffset, str) == false)
+      if (getOffset(seekOffset, str, version) == false)
       {
          ossimNotify(ossimNotifyLevel_WARN)
             << MODULE << " No offset to an image file directory found.\n"
@@ -503,647 +537,1335 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
    return out;
 }
 
-void ossimTiffInfo::readShort(ossim_uint16& s, std::ifstream& str) const
-{
-   str.read((char*)&s, sizeof(s));
-   if (theEndian)
-   {
-      theEndian->swap(s);
-   }
-}
-
-void ossimTiffInfo::readLong(ossim_uint32& l, std::ifstream& str) const
+std::ostream& ossimTiffInfo::print(std::ifstream& inStr,
+                                   std::ostream& outStr) const
 {
-   str.read((char*)&l, sizeof(l));
-   if (theEndian)
-   {
-      theEndian->swap(l);
-   }
-}
+   static const char MODULE[] =
+      "ossimTiffInfo::print(std::ifstream&, std::ostream&)";
 
-void ossimTiffInfo::readLongLong(ossim_uint64& l, std::ifstream& str) const
-{
-   str.read((char*)&l, sizeof(l));
-   if (theEndian)
+   if (traceDebug())
    {
-      theEndian->swap(l);
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " DEBUG Entered...\n";
    }
-}
 
+   std::streampos startPosition = inStr.tellg();
+   
+   //---
+   // Get the byte order.  The data member "theTiffByteOrder" was set to
+   // BIG_END in the initialization list.  This will be changed if
+   // byte order is LITTLE_END(IBM, DEC).
+   //---
+   char byteOrder[2];
+   inStr.read(byteOrder, 2); // Read the byte order.
 
+   // Get the version:
+   ossim_uint16 version;
+   readShort(version, inStr);
 
-bool ossimTiffInfo::getOffset(std::streamoff& offset, std::ifstream& str) const
-{
-   bool status = true;
-   if  (theVersion == 42)
+   // Set the tag value length.
+   ossim_uint64 tagValueLength;
+   if (version == 42)
    {
-      ossim_uint32   littleOffset;
-      readLong(littleOffset, str);
-      offset = littleOffset;
+      tagValueLength = 4;
    }
    else
    {
-      ossim_uint64 bigOffset;
-      readLongLong(bigOffset, str);
-      offset = bigOffset;
+      tagValueLength = 8;
    }
-   if (!str)
+
+   outStr << "tiff.version: " << int(version)
+          << ((version==42)?"(classic)\n":"(big)\n")
+          << "tiff.byte_order: ";
+   
+   if (byteOrder[0] == 'M')
    {
-      status = false;
+      outStr << "big_endian\n";
+   }
+   else // OSSIM_LITTLE_ENDIAN
+   {
+      outStr  << "little_endian\n";
    }
-   return status;
-}
 
-bool ossimTiffInfo::getValue(ossim_uint64& value,
-                            std::ifstream& str,
-                            WordType type) const
-{
-   bool status = true;
-   if  (theVersion == 42)
+   if (traceDebug())
    {
-      if (type == TWO_OR_EIGHT)
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "system_byte_order: ";
+      if (ossim::byteOrder() == OSSIM_BIG_ENDIAN)
       {
-         ossim_uint16 i;
-         readShort(i, str);
-         value = i;
+         ossimNotify(ossimNotifyLevel_DEBUG)<< "big_endian\n";
       }
-      else
+      else // OSSIM_LITTLE_ENDIAN
       {
-         ossim_uint32 i;
-         readLong(i, str);
-         value = i;
+         ossimNotify(ossimNotifyLevel_DEBUG)<< "little_endian\n";
       }
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "tiff.tag_value_length: " << tagValueLength << "\n";
    }
-   else
-   {
-      ossim_uint64 i;
-      readLongLong(i, str);
-      value = i;
-   }
-   if (!str)
-   {
-      status = false;
-   }
-   return status;
-}
 
-ossim_uint64 ossimTiffInfo::getArraySizeInBytes(ossim_uint64 length,
-                                              ossim_uint16 type) const
-{
-   return length * getTypeByteSize(type);
-}
+   //---
+   // Variables used within the loop.
+   //---
+   std::streamoff seekOffset;      // used throughout
+   std::streampos streamPosition;  // used throughout
 
-ossim_uint16 ossimTiffInfo::getTypeByteSize(ossim_uint16 type) const
-{
-   switch (type)
+   if (version == 43)
    {
-      case TIFF_BYTE:
-      case TIFF_ASCII:
-      case TIFF_SBYTE:
-      case TIFF_UNDEFINED:
-         return 1;
-         
-      case TIFF_SHORT:
-      case TIFF_SSHORT:
-         return 2;
-         
-      case TIFF_LONG:
-      case TIFF_SLONG:
-      case TIFF_IFD:
-         return 4;
-         
-      case TIFF_RATIONAL:
-      case TIFF_SRATIONAL:
-      case TIFF_FLOAT:
-      case TIFF_DOUBLE:
-      case 16:             // TIFF_LONG8 defined in big tiff only.
-      case 17:             // TIFF_SLONG8 defined in big tiff only.
-      case 18:             // TIFF_IFD8 defined in big tiff only.
-         return 8;
-
-      default:
-      {
-         if (traceDebug())
-         {
-            ossimNotify(ossimNotifyLevel_DEBUG)
-               << "ossimTiffInfo::getTypeByteSize DEBUG:"
-               << "\nUnhandled type: " << int(type) << "\n";
-         }
-         break;
-      }
+      // We must skip the first four bytes.
+      ossim_uint32 offsetSize;
+      readLong(offsetSize, inStr);
    }
-   return 0;
-}
 
-void ossimTiffInfo::eatValue(std::ifstream& str) const
-{
-   if (theVersion == 42)
+   // Get the offset.
+   if (getOffset(seekOffset, inStr, version) == false)
    {
-      ossim_uint32 dummy;
-      readLong(dummy, str);
+     ossimNotify(ossimNotifyLevel_WARN) 
+        << MODULE << " FATAL ERROR - "
+        << "No offset to an image file directory found.\n"
+        << "Returning with error."
+        << std::endl;
+     inStr.close();
+     return outStr;
    }
-   else
+   
+   if (traceDebug())
    {
-      ossim_uint64 dummy;
-      readLongLong(dummy, str);
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " DEBUG: "
+         << "Offset to first ifd:  " << seekOffset
+         << "\n";
    }
-}
 
-void ossimTiffInfo::swapBytes(ossim_uint8* v,
-                             ossim_uint16 type,
-                             ossim_uint64 count) const
-{
-   if (theEndian)
+   // Capture the original flags then set float output to full precision.
+   std::ios_base::fmtflags f = outStr.flags();
+   outStr << setiosflags(std::ios::fixed) << std::setprecision(15);
+   
+   // Image File Directory (IFD) loop.
+   ossim_int32 ifdIndex = 0;
+   while(seekOffset)
    {
-      ossim_uint32 byteSize = getTypeByteSize(type);
-      switch(byteSize)
-      {
-         case 2:
-            theEndian->swapTwoBytes(v, count);
-            break;
-         case 4:
-            theEndian->swapFourBytes(v, count);
-            break;
-         case 8:
-            theEndian->swapEightBytes(v, count);
-            break;
-         default:
-            break;
-      }
-   }
-}
+      outStr << "tiff.directory_offset: " << seekOffset << "\n";
 
-template <class T> void ossimTiffInfo::getArrayValue(
-   T& v,
-   ossim_uint8* array,
-   ossim_uint64 position) const
-{
-   T* p = (T*)array;
-   v = p[position]; // +position);
-}
+      // Seek to the image file directory.
+      inStr.seekg(startPosition+seekOffset, std::ios_base::beg);  
 
-std::ostream& ossimTiffInfo::print(std::ostream& out,
-                                  const std::string& prefix,
-                                  ossim_uint64 tagIdx,
-                                  ossim_uint16 tag,
-                                  ossim_uint16 type,
-                                  ossim_uint64 count,
-                                  ossim_uint64 arraySizeInBytes,
-                                  ossim_uint8* valueArray) const
-{
-   switch(tag)
-   {
-      case TIFFTAG_SUBFILETYPE: // tag 254
-      {
-         out << prefix << "sub_file_type: ";
-         printValue(out, type, valueArray);
-         break;
-      }
-      case TIFFTAG_IMAGEWIDTH: // tag 256
+      // directory prefix for prints.
+      std::string prefix = "tiff.";
+      getDirPrefix(ifdIndex, prefix);
+
+      //---
+      // Things we need to save for printGeoKeys:
+      //---
+      ossim_uint16*  geoKeyBlock     = 0;
+      ossim_uint64   geoKeyLength    = 0;
+      ossim_float64* geoDoubleBlock  = 0;
+      ossim_uint64   geoDoubleLength = 0;
+      ossim_int8*    geoAsciiBlock   = 0;
+      ossim_uint64   geoAsciiLength  = 0;
+      
+      //---
+      // Get the number of directories within the IFD.
+      //---
+      ossim_uint64 nTags; // Number of tags in an IFD.
+      if (getValue(nTags, inStr, TWO_OR_EIGHT, version) == false)
       {
-         out << prefix << "image_width: ";
-         printValue(out, type, valueArray);
-         break;
+         ossimNotify(ossimNotifyLevel_WARN)
+            << MODULE << " FATAL error reading number of direcories."
+            << std::endl;
+         inStr.close();
+         return outStr;
       }
-      
-      case TIFFTAG_IMAGELENGTH: // tag 257
+
+      if (traceDebug())
       {
-         out << prefix << "image length: ";
-         printValue(out, type, valueArray);
-         break;
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << MODULE << " DEBUG:\n"
+            << "ifd:  " << seekOffset
+            << "\ntags in directory:  " << nTags<< "\n";
       }
 
-      case TIFFTAG_BITSPERSAMPLE: // tag 258
+      // Tag loop:
+      for (ossim_uint64 tagIdx = 0; tagIdx < nTags; ++tagIdx)
       {
-         out << prefix << "bits_per_sample: ";
-         if (count == 1)
+         // Variables used within the loop.
+         ossim_uint16   tag              = 0; // Tag number
+         ossim_uint16   type             = 0; // Type(short, long...)
+         ossim_uint64   count            = 0;
+         ossim_uint64   arraySizeInBytes = 0; // 
+         ossim_uint8*   valueArray       = 0; // To hold value.
+         
+         //---
+         // Get the tag.
+         //---
+         readShort(tag, inStr);
+         if (!inStr)
          {
-            printValue(out, type, valueArray);
+            ossimNotify(ossimNotifyLevel_WARN)
+               << MODULE << " FATAL error reading tag number."
+               << std::endl;
+            inStr.close();
+            return outStr;
          }
-         else if (valueArray)
-         {
-            printArray(out, type, count, valueArray);
-         }
-         break;
-      }
-         
-      case TIFFTAG_COMPRESSION: // tag 259
-      {
-         if ( (count == 1) && (type == TIFF_SHORT) )
+
+         //---
+         // Get the type (byte, ascii, short...)
+         //---
+         readShort(type, inStr);
+         if (!inStr)
          {
-            out << prefix << "compression: ";
-            
-            ossim_uint16 s;
-            getArrayValue(s, valueArray, 0);
-            if (s == 1)
-            {
-               out << "false\n";
-            }
-            else
-            {
-               out << "true\n";
-            }
+            ossimNotify(ossimNotifyLevel_WARN)
+               << MODULE << " FATAL error reading type number."
+               << std::endl;
+            inStr.close();
+            return outStr;
          }
-         break;
-      }
 
-      case TIFFTAG_PHOTOMETRIC: // tag 262
-      {
-         out << prefix << "photo_interpretation: ";
+         //---
+         // Get the count.  This is not in bytes.  It is based on the
+         // type.  So if the type is a short and the count is one then
+         // read "sizeof(short"(2) bytes.
+         //---
+         getValue(count, inStr, FOUR_OR_EIGHT, version);
+         if (!inStr)
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
+               << MODULE << " FATAL error reading count."
+               << std::endl;
+            inStr.close();
+            return outStr;
+         }
 
-         if ( (count == 1) && (type == TIFF_SHORT) )
+         // Get the array size in bytes.
+         arraySizeInBytes = getArraySizeInBytes(count, type);
+         if (arraySizeInBytes == 0)
          {
-            ossim_uint16 s;
-            getArrayValue(s, valueArray, 0);
-            if (s <= PHOTO_CIELAB)
+            // Could be an unhandle type.  Gobble the value.
+            eatValue(inStr, version);
+         }
+         else
+         {
+            // Allocate array.
+            if (valueArray) delete [] valueArray;
+            valueArray = new ossim_uint8[arraySizeInBytes];
+
+            if (arraySizeInBytes <= tagValueLength)
             {
-               out << PHOTO_INTERP[s] << "\n";
+               // Read in the value(s).
+               inStr.read((char*)valueArray, arraySizeInBytes);
+
+               // Skip any byes left in the field.
+               if (arraySizeInBytes < tagValueLength)
+               {
+                  // Skip these bytes.
+                  inStr.ignore(tagValueLength-arraySizeInBytes);
+               }
             }
-            else
+            else // Data to big for field.  Stored elsewhere...
             {
-               out <<"range error!\n";
+               // Get the offset to the data.
+               getOffset(seekOffset, inStr, version);
+
+               // Capture the seek position to come back to.
+               streamPosition = inStr.tellg();
+
+               // Seek to the data.
+               inStr.seekg(startPosition+seekOffset, std::ios_base::beg);
+
+               // Read in the value(s).
+               inStr.read((char*)valueArray, arraySizeInBytes);
+
+               // Seek back.
+               inStr.seekg(streamPosition);
             }
-            break;
+
+            // Swap the bytes if needed.
+            swapBytes(valueArray, type, count);
          }
-      }
 
-      case TIFFTAG_IMAGEDESCRIPTION: // tag 270
-      {
-         out << prefix << "image_description: ";
-         printArray(out, type, count, valueArray);
-         break;
-      }
+         if( traceDebug() )
+	 {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << MODULE << " DEBUG:"
+               << "\ntag[" << tagIdx << "]:" << tag
+               << "\ntype:                " << type
+               << "\ncount:        " << count
+               << "\narray size in bytes: " << arraySizeInBytes
+               << "\n";
+	 }
 
-      case TIFFTAG_STRIPOFFSETS: // tag 273
-      {
-         if (traceDump())
+         if (tag == OGEO_KEY_DIRECTORY_TAG)
          {
-            out << prefix << "bytes_per_strip: ";
+            // tag 34735 save for printGeoKeys
+            geoKeyBlock = reinterpret_cast<ossim_uint16*>(valueArray);
+            geoKeyLength = count;
+         }
+         else if (tag == OGEO_DOUBLE_PARAMS_TAG)
+         {
+            // tag 34736 save for printGeoKeys
+            geoDoubleBlock  = reinterpret_cast<ossim_float64*>(valueArray);
+            geoDoubleLength = count;
+         }
+         else if (tag == OGEO_ASCII_PARAMS_TAG)
+         {
+            // tag 34737 save for printGeoKeys
+            geoAsciiBlock   = reinterpret_cast<ossim_int8*>(valueArray);
+            geoAsciiLength  = count;
+         }
+         else
+         {
+            print(outStr,
+                  prefix,
+                  tagIdx,
+                  tag,
+                  type,
+                  count,
+                  arraySizeInBytes,
+                  valueArray);
             
-            if (count == 1)
-            {
-               printValue(out, type, valueArray);
-            }
-            else
+            // Free memory if allocated...
+            if (valueArray)
             {
-               printArray(out, type, count, valueArray);
+               delete [] valueArray;
+               valueArray = 0;
             }
          }
-         break;
-      }
-      case TIFFTAG_ORIENTATION: // tag 274
-      {
-         ossim_uint16 code;
-         getArrayValue(code, valueArray, 0);
-         printOrientation(out, prefix, code);
-         break;
-      }
-      
-      case TIFFTAG_SAMPLESPERPIXEL: // tag 277
-      {
-         out << prefix << "samples_per_pixel: ";
-         printValue(out, type, valueArray);
-         break;
-      }
+         
+      } // End of tag loop.
 
-      case TIFFTAG_ROWSPERSTRIP: // tag 278
+      //---
+      // If Geotiff Keys read them.
+      // This had to done last since the keys could
+      // have references to tags GEO_DOUBLE_PARAMS_TAG and
+      // GEO_ASCII_PARAMS_TAG.
+      //---
+      if (geoKeyBlock)
       {
-         out << prefix << "rows_per_strip: ";
-         printValue(out, type, valueArray);
-         break;
+         printGeoKeys(outStr, prefix, geoKeyLength, geoKeyBlock,
+                      geoDoubleLength,geoDoubleBlock,
+                      geoAsciiLength,geoAsciiBlock);
+
+         delete [] geoKeyBlock;
+         geoKeyBlock = 0;
       }
 
-      case TIFFTAG_STRIPBYTECOUNTS: // tag 279
+      if (geoDoubleBlock)
       {
-         if (traceDump())
-         {
-            out << prefix << "bytes_per_strip: ";
-            
-            if (count == 1)
-            {
-               printValue(out, type, valueArray);
-            }
-            else
-            {
-               printArray(out, type, count, valueArray);
-            }
-         }
-         break;
+         delete [] geoDoubleBlock;
+         geoDoubleBlock = 0;
       }
-      
-      case TIFFTAG_MINSAMPLEVALUE: // tag 280
+      if (geoAsciiBlock)
       {
-         out << prefix << "min_sample_value: ";
-         printValue(out, type, valueArray);
-         break;
+         delete [] geoAsciiBlock;
+         geoAsciiBlock = 0;
       }
-      case TIFFTAG_MAXSAMPLEVALUE: // tag 281
+      geoKeyLength = 0;
+      geoDoubleLength = 0;
+      geoAsciiLength = 0;
+
+      //---
+      // Get the next IFD offset.  Continue this loop until the offset is
+      // zero.
+      //---
+      if (getOffset(seekOffset, inStr, version) == false)
       {
-         out << prefix << "max_sample_value: ";
-         printValue(out, type, valueArray);
-         break;
+         ossimNotify(ossimNotifyLevel_WARN)
+            << MODULE << " No offset to an image file directory found.\n"
+            << "Returning with error."
+            << std::endl;
+         inStr.close();
+         return outStr;
       }
       
-      case TIFFTAG_XRESOLUTION: // tag 282
+      if (traceDebug())
       {
-         out << prefix << "xresolution: ";
-         printValue(out, type, valueArray);
-         break;
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "DEBUG ossimTiffInfo::readTags: "
+            << "Next Image File Directory(IFD) offset = "
+            << seekOffset << "\n";
       }
-      case TIFFTAG_YRESOLUTION: // tag 283
+
+      ++ifdIndex; // next ifd
+
+      //---
+      // Note this does NOT check to see if sub_file_type is '1' simply
+      // skips all directories past the first if theOverviewFlag is false.
+      //---
+      if ( ifdIndex && !theOverviewFlag) // Don't process overviews...
       {
-         out << prefix << "yresolution: ";
-         printValue(out, type, valueArray);
          break;
       }
       
-      case TIFFTAG_PLANARCONFIG: // tag 284
-      {
-         if ( (count == 1) && (type == TIFF_SHORT) )
-         {
-            out << prefix << "planar_configuration: ";
-            ossim_uint16 v;
-            getArrayValue(v, valueArray, 0);
-            if (v == 1)
-            {
-               out << "single image plane\n";
-            }
-            else if (v == 2)
-            {
-               out << "separate image planes\n";
-            }
-            else
-            {
-               out << "unknown planar value!\n";
-            }
-         }
-         break;
-      }
+   } // End of loop through the IFD's.
+   
+   outStr << std::endl;
+    
+   inStr.close();
 
-      case TIFFTAG_RESOLUTIONUNIT: // tag 296
-      {
-         out << prefix << "resolution_units: ";
-         ossim_uint16 v;
-         getArrayValue(v, valueArray, 0);
-         if (v == 2) 
-         {
-            out << "inch\n";
-         }
-         else if (v == 3)
-         {
-            out << "cm\n";
-         }
-         else
-         {
-            out << "none\n";
-         }
-         break;
+   // Reset flags.
+   outStr.setf(f);
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " DEBUG Exited..." << std::endl;
+   }
+   
+   return outStr;
+}
+
+bool ossimTiffInfo::getImageGeometry(ossimKeywordlist& geomKwl,
+                                     ossim_uint32 entryIndex) const
+{
+   static const char MODULE[] = "ossimTiffInfo::getImageGeometry #1";
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << " entered...\n";
+   }
+   
+   bool result = false;
+
+   // Open the file.
+   std::ifstream str;
+   str.open(theFile.c_str(), ios::in | ios::binary);
+   
+   if ( str.is_open() )
+   {
+      result = getImageGeometry(str, geomKwl, entryIndex);
+
+      str.close();
+   }
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "geomKwl:\n"
+         << geomKwl
+         << MODULE << " exit status = " << (result?"true":"false") << "\n";
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getImageGeometry(std::ifstream& inStr,
+                                     ossimKeywordlist& geomKwl,
+                                     ossim_uint32 entryIndex) const
+{
+   static const char MODULE[] = "ossimTiffInfo::getImageGeometry #2";
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << " entered...\n";
+   }
+   
+   bool result = false;
+
+   // Do a print to a memory stream.
+   ossimIOMemoryStream memStr;
+   print(inStr, memStr);
+
+   // Since the print is in key:value format we can pass to a keyword list.
+   ossimKeywordlist gtiffKwl;
+   if ( gtiffKwl.parseStream(memStr) )
+   {
+      //---
+      // Start with a return status of true and set to false if something bad
+      // happens.
+      //---
+      result = true;
+
+      
+      if ( traceDebug() )
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "tiffinfo dump to kwl:\n" << gtiffKwl << "\n";
       }
-      case TIFFTAG_DATETIME: // tag 306
+      
+      ossimString gtiffPrefix = "tiff.image";
+      gtiffPrefix += ossimString::toString(entryIndex);
+      gtiffPrefix += ".";
+      ossimString geomPrefix = "image";
+      geomPrefix += ossimString::toString(entryIndex);
+      geomPrefix += ".";
+
+      // Get the units first.
+      ossimString units = "";
+      getUnits(gtiffPrefix, gtiffKwl, units);
+      
+      // Get the pixel type.
+      ossimString pixelType;
+      if ( getPixelType(gtiffPrefix, gtiffKwl, pixelType) == false )
       {
-         out << prefix << "date_time: ";
-         printArray(out, type, count, valueArray);
-         break;
+         pixelType = "pixel_is_point"; // Not an error we'll make assumption?
       }
-      case TIFFTAG_TILEWIDTH: // tag 322
+      geomKwl.add(geomPrefix.c_str(),
+                  ossimKeywordNames::PIXEL_TYPE_KW,
+                  pixelType.c_str());
+      
+      // Get the lines.
+      ossim_uint32 height = getLines(gtiffPrefix, gtiffKwl);
+      if (height)
       {
-         out << prefix << "tile_width: ";
-         printValue(out, type, valueArray);
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::NUMBER_LINES_KW,
+                     height);
       }
-
-      case TIFFTAG_TILELENGTH: // tag 323
+      else
       {
-         out << prefix << "tile_length: ";
-         printValue(out, type, valueArray);
-         break;
+         result = false;
       }
 
-      case TIFFTAG_TILEOFFSETS: // tag 324
+      // Get the samples.
+      ossim_uint32 width = getSamples(gtiffPrefix, gtiffKwl);
+      if (width)
       {
-         if (traceDump())
-         {
-            out << prefix << "tile_offsets: ";
-            if (count == 1)
-            {
-               printValue(out, type, valueArray);
-            }
-            else
-            {
-               printArray(out, type, count, valueArray);
-            }
-         }
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::NUMBER_SAMPLES_KW,
+                     width);
       }
-      
-      case TIFFTAG_TILEBYTECOUNTS: // tag 325
+      else
       {
-         if (traceDump())
-         {
-            out << prefix << "tile_byte_counts: ";
-            if (count == 1)
-            {
-               printValue(out, type, valueArray);
-            }
-            else
-            {
-               printArray(out, type, count, valueArray);
-            }
-         }
-         break;
+         result = false;
       }
 
-      case TIFFTAG_SUBIFD: // tag 330
+      // Add the pixel type.
+      geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::PIXEL_TYPE_KW,
+                     pixelType.c_str());
+
+      // Get the pixel scale.
+      ossimDpt scale;
+      bool hasScale = getPixelScale(gtiffPrefix, gtiffKwl, scale);
+
+      // Get the tie point.
+      std::vector<ossim_float64> ties;
+      getTiePoint(gtiffPrefix, gtiffKwl, ties);
+
+      //---
+      // Tie count:
+      // NOTE: It takes six doubles to make one tie point ie:
+      // x,y,z,longitude,latitude,height or x,y,z,easting,northing,height
+      //--- 
+      ossim_uint32 tieCount = ties.size()/6;
+      
+      // Get the model transform.
+      std::vector<ossim_float64> xfrm;
+      getModelTransform(gtiffPrefix, gtiffKwl, xfrm);
+
+      bool useXfrm = false;
+      if ( xfrm.size() == 16 )
       {
-         if ( (count == 1) && (type == TIFF_IFD8) )
+         // Need at least 24 (which is four ties) to use bilinear.
+         if ( !hasScale && ties.size() < 24 )
          {
-            out << prefix << "subimage_descriptor: ";
-            ossim_uint64 v;
-            getArrayValue(v, valueArray, 0);
-            out << v << "\n";
+            useXfrm = true;
          }
-         else
+      }
+      if (useXfrm)
+      {
+         std::ostringstream out;
+         ossim_uint32 idx = 0;
+         for(idx =0; idx < 16; ++idx)
          {
-            out << prefix << "tag 330 unhandled condition.\n";
+            out << xfrm[idx] << " ";
          }
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW,
+                     out.str().c_str(), true);
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::IMAGE_MODEL_TRANSFORM_UNIT_KW,
+                     units.c_str(), true);
       }
-      
-      case TIFFTAG_EXTRASAMPLES: // tag 338
+      else // Use tie points.
       {
-         out << prefix << "extra_samples: ";
-         ossim_uint16 v;
-         getArrayValue(v, valueArray, 0);
-         switch (v)
+         if ( hasScale && (tieCount == 1) )
          {
-            case 1:
-            {
-               out << "associated_alpha_data\n";
-               break;
-            }
-            case 2:
+            // Shift the tile to 0,0 pixel of image if not already there.
+            ossimDpt tie;
+            tie.x = ties[3] - ties[0] * scale.x;
+            tie.y = ties[4] - ties[1] * scale.y;
+            geomKwl.add(geomPrefix.c_str(),
+                        ossimKeywordNames::TIE_POINT_XY_KW,
+                        tie.toString().c_str());
+            geomKwl.add(geomPrefix.c_str(),
+                        ossimKeywordNames::TIE_POINT_UNITS_KW,
+                        units.c_str());
+
+            // Add the scale.
+            geomKwl.add(geomPrefix.c_str(),
+                        ossimKeywordNames::PIXEL_SCALE_XY_KW,
+                        scale.toString().c_str());
+            geomKwl.add(geomPrefix.c_str(),
+                        ossimKeywordNames::PIXEL_SCALE_UNITS_KW,
+                        units.c_str());
+         }
+         else if (tieCount > 1) // four or better tie points.
+         {
+            ossimTieGptSet tieSet;
+            getTieSets(ties, width, height, tieSet);
+
+            if(tieCount >= 4)
             {
-               out << "unassociated_alpha_data\n";
-               break;
+               ossimRefPtr<ossimBilinearProjection> proj =
+                  new ossimBilinearProjection;
+               proj->optimizeFit(tieSet);
+               proj->saveState(geomKwl, geomPrefix.c_str());
+               if(traceDebug())
+               {
+                  ossimNotify(ossimNotifyLevel_DEBUG)
+                     << MODULE
+                     << "Creating a bilinear projection"
+                     << std::endl;
+               }
+               
             }
-            default:
+            else  // Need at least four ties.
             {
-               out << "unspecified_data\n";
-               break;
+               result = false;
             }
          }
-         break;
-      }
-
-      case TIFFTAG_SAMPLEFORMAT: // tag 339
-      {
-         if ( (count == 1) && (type == TIFF_SHORT) )
+         else
          {
-            out << prefix << "sample_format: ";
-            ossim_uint16 v;
-            getArrayValue(v, valueArray, 0);
-            switch (v)
-            {
-               case SAMPLEFORMAT_UINT:
-                  out << "unsigned integer data\n";
-                  break;
-               case SAMPLEFORMAT_INT:
-                  out << "signed integer data\n";
-                  break;
-               case SAMPLEFORMAT_IEEEFP:
-                  out << "IEEE floating point data\n";
-                  break;
-               case SAMPLEFORMAT_COMPLEXINT:
-                  out << "complex signed int\n";
-                  break;
-               case SAMPLEFORMAT_COMPLEXIEEEFP:
-                  out << "complex ieee floating\n";
-                  break;
-               case SAMPLEFORMAT_VOID:
-               default:
-                  out << "untyped data\n";
-                  break;
-            }
+            result = false;
          }
-         break;
-      }
+         
+      } // matches: else Use tie points block.
+      
+      ossimString pcsCode;
+      bool hasPcsCode = getPcsCode(gtiffPrefix, gtiffKwl, pcsCode);
 
-      case TIFFTAG_SMINSAMPLEVALUE: // tag 340
+      // Set the projection type.
+      if (hasPcsCode)
       {
-         out << prefix << "smin_sample_value: ";
-         printValue(out, type, valueArray);
-         break;
+         // Add the pcs code.
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::PCS_CODE_KW,
+                     pcsCode.c_str());
       }
-
-      case TIFFTAG_SMAXSAMPLEVALUE: // tag 341
+      else
       {
-         out << prefix << "smax_sample_value: ";
-         printValue(out, type, valueArray);
-         break;
+         ossimString ossimProjectionName = "";
+         if ( getOssimProjectionName(gtiffPrefix, gtiffKwl,
+                                     ossimProjectionName) == false )
+         {
+            ossimProjectionName = "ossimEquDistCylProjection";
+         }
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::TYPE_KW,
+                     ossimProjectionName);
       }
-
-      case TIFFTAG_COPYRIGHT: // tag 33432
+      ossimString tmpStr;
+      if ( getStdParallelOne(gtiffPrefix, gtiffKwl, tmpStr) )
       {
-         out << prefix << "copyright: ";
-         printArray(out, type, count, valueArray);
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::STD_PARALLEL_1_KW,
+                     tmpStr);
       }
       
-      case MODEL_PIXEL_SCALE_TAG: // tag 33550
-      {
-         out << prefix << "model_pixel_scale: ";
-         printArray(out, type, count, valueArray);
-         break;
-      }
-
-      case MODEL_TIE_POINT_TAG: // tag 33992
-      {
-         out << prefix << "model_tie_point: ";
-         printArray(out, type, count, valueArray);
-         break;
-      }
-
-      case MODEL_TRANSFORM_TAG: // tag 34264
+      if ( getStdParallelTwo(gtiffPrefix, gtiffKwl, tmpStr) )
       {
-         out << prefix << "model_transform: ";
-         printArray(out, type, count, valueArray);
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::STD_PARALLEL_2_KW,
+                     tmpStr);
       }
-
-      case TIFFTAG_PHOTOSHOP:  // tag 34377
+      
+      ossimDpt eastingNorthing;
+      if ( getFalseEastingNorthing(gtiffPrefix, gtiffKwl,
+                                   eastingNorthing) )
       {
-         out << prefix << "photoshop_image_resource_blocks: found\n";
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::FALSE_EASTING_NORTHING_KW,
+                     eastingNorthing.toString());
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::
+                     FALSE_EASTING_NORTHING_UNITS_KW, units);
       }
       
-      case GEO_DOUBLE_PARAMS_TAG: // tag 34736
+      ossim_float64 tmpDbl;
+      
+      if ( getOriginLat(gtiffPrefix, gtiffKwl, tmpDbl) )
       {
-         out << prefix << "double_params: ";
-         printArray(out, type, count, valueArray);
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::ORIGIN_LATITUDE_KW,
+                     tmpDbl);
       }
-      case GEO_ASCII_PARAMS_TAG: // tag 34737
+      if ( getCentralMeridian(gtiffPrefix, gtiffKwl, tmpDbl) )
       {
-         out << prefix << "ascii_params: ";
-         printArray(out, type, count, valueArray);
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::CENTRAL_MERIDIAN_KW,
+                     tmpDbl);
       }
- 
-      default:
+      
+      if ( getScaleFactor(gtiffPrefix, gtiffKwl, tmpDbl) )
       {
-         out << prefix << "unhandled_tag: " << tag << "\n";
-         if (traceDebug())
-         {
-             ossimNotify(ossimNotifyLevel_DEBUG)
-                << "generic:"
-                << "\ntag[" << tagIdx << "]:         " << tag
-                << "\ntype:                " << type
-                << "\ncount:        " << count
-                << "\narray size in bytes: " << arraySizeInBytes
-                << "\n";
-            printArray(out, type, count, valueArray);
-         }
-         break;
+         geomKwl.add(geomPrefix.c_str(),
+                     ossimKeywordNames::SCALE_FACTOR_KW,
+                     tmpDbl);
       }
+      
+   } // matches: if ( gtiffKwl.parseStream(memStr) )
 
-   } // end of switch on tag...
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "geomKwl:\n"
+         << geomKwl
+         << MODULE << " exit status = " << (result?"true":"false") << "\n";
+   }
 
-   return out;
+   return result;
+}
 
-} // end of print
+void ossimTiffInfo::readShort(ossim_uint16& s, std::ifstream& str) const
+{
+   str.read((char*)&s, sizeof(s));
+   if (theEndian)
+   {
+      theEndian->swap(s);
+   }
+}
 
-std::ostream& ossimTiffInfo::printValue(std::ostream& out,
-                                       ossim_uint16 type,
-                                       ossim_uint8* valueArray) const
+void ossimTiffInfo::readLong(ossim_uint32& l, std::ifstream& str) const
 {
-   switch (type)
+   str.read((char*)&l, sizeof(l));
+   if (theEndian)
    {
-      case TIFF_SHORT:
-      {
-         ossim_uint16 v;
-         getArrayValue(v, valueArray, 0);
-         out << v << "\n";
-         break;
-      }
-      case TIFF_SSHORT:
-      {
-         ossim_sint16 v;
-         getArrayValue(v, valueArray, 0);
-         out << v << "\n";
-         break;
-      }
-      case TIFF_LONG:
-      {
-         ossim_uint32 v;
-         getArrayValue(v, valueArray, 0);
-         out << v << "\n";
-         break;
-      }
-      case TIFF_RATIONAL: // two longs first=numerator, second=denominator
-      {
-         ossim_uint32 num;
-         ossim_uint32 den;
-         
+      theEndian->swap(l);
+   }
+}
+
+void ossimTiffInfo::readLongLong(ossim_uint64& l, std::ifstream& str) const
+{
+   str.read((char*)&l, sizeof(l));
+   if (theEndian)
+   {
+      theEndian->swap(l);
+   }
+}
+
+
+
+bool ossimTiffInfo::getOffset(
+   std::streamoff& offset, std::ifstream& str, ossim_uint16 version) const
+{
+   bool status = true;
+   if  (version == 42)
+   {
+      ossim_uint32   littleOffset;
+      readLong(littleOffset, str);
+      offset = littleOffset;
+   }
+   else
+   {
+      ossim_uint64 bigOffset;
+      readLongLong(bigOffset, str);
+      offset = bigOffset;
+   }
+   if (!str)
+   {
+      status = false;
+   }
+   return status;
+}
+
+bool ossimTiffInfo::getValue(ossim_uint64& value,
+                             std::ifstream& str,
+                             WordType type,
+                             ossim_uint16 version) const
+{
+   bool status = true;
+   if  (version == 42)
+   {
+      if (type == TWO_OR_EIGHT)
+      {
+         ossim_uint16 i;
+         readShort(i, str);
+         value = i;
+      }
+      else
+      {
+         ossim_uint32 i;
+         readLong(i, str);
+         value = i;
+      }
+   }
+   else
+   {
+      ossim_uint64 i;
+      readLongLong(i, str);
+      value = i;
+   }
+   if (!str)
+   {
+      status = false;
+   }
+   return status;
+}
+
+ossim_uint64 ossimTiffInfo::getArraySizeInBytes(ossim_uint64 length,
+                                              ossim_uint16 type) const
+{
+   return length * getTypeByteSize(type);
+}
+
+ossim_uint16 ossimTiffInfo::getTypeByteSize(ossim_uint16 type) const
+{
+   switch (type)
+   {
+      case OTIFF_BYTE:
+      case OTIFF_ASCII:
+      case OTIFF_SBYTE:
+      case OTIFF_UNDEFINED:
+         return 1;
+         
+      case OTIFF_SHORT:
+      case OTIFF_SSHORT:
+         return 2;
+         
+      case OTIFF_LONG:
+      case OTIFF_SLONG:
+      case OTIFF_IFD:
+         return 4;
+         
+      case OTIFF_RATIONAL:
+      case OTIFF_SRATIONAL:
+      case OTIFF_FLOAT:
+      case OTIFF_DOUBLE:
+      case 16:             // TIFF_LONG8 defined in big tiff only.
+      case 17:             // TIFF_SLONG8 defined in big tiff only.
+      case 18:             // TIFF_IFD8 defined in big tiff only.
+         return 8;
+
+      default:
+      {
+         if (traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << "ossimTiffInfo::getTypeByteSize DEBUG:"
+               << "\nUnhandled type: " << int(type) << "\n";
+         }
+         break;
+      }
+   }
+   return 0;
+}
+
+void ossimTiffInfo::eatValue(std::ifstream& str, ossim_uint16 version) const
+{
+   if (version == 42)
+   {
+      ossim_uint32 dummy;
+      readLong(dummy, str);
+   }
+   else
+   {
+      ossim_uint64 dummy;
+      readLongLong(dummy, str);
+   }
+}
+
+void ossimTiffInfo::swapBytes(ossim_uint8* v,
+                             ossim_uint16 type,
+                             ossim_uint64 count) const
+{
+   if (theEndian)
+   {
+      ossim_uint32 byteSize = getTypeByteSize(type);
+      switch(byteSize)
+      {
+         case 2:
+            theEndian->swapTwoBytes(v, count);
+            break;
+         case 4:
+            theEndian->swapFourBytes(v, count);
+            break;
+         case 8:
+            theEndian->swapEightBytes(v, count);
+            break;
+         default:
+            break;
+      }
+   }
+}
+
+template <class T> void ossimTiffInfo::getArrayValue(
+   T& v,
+   ossim_uint8* array,
+   ossim_uint64 position) const
+{
+   T* p = (T*)array;
+   v = p[position]; // +position);
+}
+
+std::ostream& ossimTiffInfo::print(std::ostream& out,
+                                  const std::string& prefix,
+                                  ossim_uint64 tagIdx,
+                                  ossim_uint16 tag,
+                                  ossim_uint16 type,
+                                  ossim_uint64 count,
+                                  ossim_uint64 arraySizeInBytes,
+                                  ossim_uint8* valueArray) const
+{
+   switch(tag)
+   {
+      case OTIFFTAG_SUBFILETYPE: // tag 254
+      {
+         out << prefix << "sub_file_type: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+      case OTIFFTAG_IMAGEWIDTH: // tag 256
+      {
+         out << prefix << IMAGE_WIDTH_KW << ": ";
+         printValue(out, type, valueArray);
+         break;
+      }
+      
+      case OTIFFTAG_IMAGELENGTH: // tag 257
+      {
+         out << prefix << IMAGE_LENGTH_KW << ": ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_BITSPERSAMPLE: // tag 258
+      {
+         out << prefix << "bits_per_sample: ";
+         if (count == 1)
+         {
+            printValue(out, type, valueArray);
+         }
+         else if (valueArray)
+         {
+            printArray(out, type, count, valueArray);
+         }
+         break;
+      }
+         
+      case OTIFFTAG_COMPRESSION: // tag 259
+      {
+         if ( (count == 1) && (type == OTIFF_SHORT) )
+         {
+            out << prefix << "compression: ";
+            
+            ossim_uint16 s;
+            getArrayValue(s, valueArray, 0);
+            if (s == 1)
+            {
+               out << "false\n";
+            }
+            else
+            {
+               out << "true\n";
+            }
+         }
+         break;
+      }
+
+      case OTIFFTAG_PHOTOMETRIC: // tag 262
+      {
+         out << prefix << "photo_interpretation: ";
+
+         if ( (count == 1) && (type == OTIFF_SHORT) )
+         {
+            ossim_uint16 s;
+            getArrayValue(s, valueArray, 0);
+            if (s <= OPHOTO_CIELAB)
+            {
+               out << PHOTO_INTERP[s] << "\n";
+            }
+            else
+            {
+               out <<"range error!\n";
+            }
+            break;
+         }
+      }
+
+      case OTIFFTAG_IMAGEDESCRIPTION: // tag 270
+      {
+         out << prefix << "image_description: ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_STRIPOFFSETS: // tag 273
+      {
+         if (traceDump())
+         {
+            out << prefix << "bytes_per_strip: ";
+            
+            if (count == 1)
+            {
+               printValue(out, type, valueArray);
+            }
+            else
+            {
+               printArray(out, type, count, valueArray);
+            }
+         }
+         break;
+      }
+      case OTIFFTAG_ORIENTATION: // tag 274
+      {
+         ossim_uint16 code;
+         getArrayValue(code, valueArray, 0);
+         printOrientation(out, prefix, code);
+         break;
+      }
+      
+      case OTIFFTAG_SAMPLESPERPIXEL: // tag 277
+      {
+         out << prefix << "samples_per_pixel: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_ROWSPERSTRIP: // tag 278
+      {
+         out << prefix << "rows_per_strip: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_STRIPBYTECOUNTS: // tag 279
+      {
+         if (traceDump())
+         {
+            out << prefix << "bytes_per_strip: ";
+            
+            if (count == 1)
+            {
+               printValue(out, type, valueArray);
+            }
+            else
+            {
+               printArray(out, type, count, valueArray);
+            }
+         }
+         break;
+      }
+      
+      case OTIFFTAG_MINSAMPLEVALUE: // tag 280
+      {
+         out << prefix << "min_sample_value: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+      case OTIFFTAG_MAXSAMPLEVALUE: // tag 281
+      {
+         out << prefix << "max_sample_value: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+      
+      case OTIFFTAG_XRESOLUTION: // tag 282
+      {
+         out << prefix << "xresolution: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+      case OTIFFTAG_YRESOLUTION: // tag 283
+      {
+         out << prefix << "yresolution: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+      
+      case OTIFFTAG_PLANARCONFIG: // tag 284
+      {
+         if ( (count == 1) && (type == OTIFF_SHORT) )
+         {
+            out << prefix << "planar_configuration: ";
+            ossim_uint16 v;
+            getArrayValue(v, valueArray, 0);
+            if (v == 1)
+            {
+               out << "single image plane\n";
+            }
+            else if (v == 2)
+            {
+               out << "separate image planes\n";
+            }
+            else
+            {
+               out << "unknown planar value!\n";
+            }
+         }
+         break;
+      }
+
+      case OTIFFTAG_RESOLUTIONUNIT: // tag 296
+      {
+         out << prefix << "resolution_units: ";
+         ossim_uint16 v;
+         getArrayValue(v, valueArray, 0);
+         if (v == 2) 
+         {
+            out << "inch\n";
+         }
+         else if (v == 3)
+         {
+            out << "cm\n";
+         }
+         else
+         {
+            out << "none\n";
+         }
+         break;
+      }
+      case OTIFFTAG_SOFTWARE: // tag 305
+      {
+         out << prefix << "software: ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+      case OTIFFTAG_DATETIME: // tag 306
+      {
+         out << prefix << "date_time: ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+      case OTIFFTAG_TILEWIDTH: // tag 322
+      {
+         out << prefix << "tile_width: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_TILELENGTH: // tag 323
+      {
+         out << prefix << "tile_length: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_TILEOFFSETS: // tag 324
+      {
+         if (traceDump())
+         {
+            out << prefix << "tile_offsets: ";
+            if (count == 1)
+            {
+               printValue(out, type, valueArray);
+            }
+            else
+            {
+               printArray(out, type, count, valueArray);
+            }
+         }
+         break;
+      }
+      
+      case OTIFFTAG_TILEBYTECOUNTS: // tag 325
+      {
+         if (traceDump())
+         {
+            out << prefix << "tile_byte_counts: ";
+            if (count == 1)
+            {
+               printValue(out, type, valueArray);
+            }
+            else
+            {
+               printArray(out, type, count, valueArray);
+            }
+         }
+         break;
+      }
+
+      case OTIFFTAG_SUBIFD: // tag 330
+      {
+         if ( (count == 1) && (type == OTIFF_IFD8) )
+         {
+            out << prefix << "subimage_descriptor: ";
+            ossim_uint64 v;
+            getArrayValue(v, valueArray, 0);
+            out << v << "\n";
+         }
+         else
+         {
+            out << prefix << "tag 330 unhandled condition.\n";
+         }
+         break;
+      }
+      
+      case OTIFFTAG_EXTRASAMPLES: // tag 338
+      {
+         out << prefix << "extra_samples: ";
+         ossim_uint16 v;
+         getArrayValue(v, valueArray, 0);
+         switch (v)
+         {
+            case 1:
+            {
+               out << "associated_alpha_data\n";
+               break;
+            }
+            case 2:
+            {
+               out << "unassociated_alpha_data\n";
+               break;
+            }
+            default:
+            {
+               out << "unspecified_data\n";
+               break;
+            }
+         }
+         break;
+      }
+
+      case OTIFFTAG_SAMPLEFORMAT: // tag 339
+      {
+         if ( (count == 1) && (type == OTIFF_SHORT) )
+         {
+            out << prefix << "sample_format: ";
+            ossim_uint16 v;
+            getArrayValue(v, valueArray, 0);
+            switch (v)
+            {
+               case OSAMPLEFORMAT_UINT:
+                  out << "unsigned integer data\n";
+                  break;
+               case OSAMPLEFORMAT_INT:
+                  out << "signed integer data\n";
+                  break;
+               case OSAMPLEFORMAT_IEEEFP:
+                  out << "IEEE floating point data\n";
+                  break;
+               case OSAMPLEFORMAT_COMPLEXINT:
+                  out << "complex signed int\n";
+                  break;
+               case OSAMPLEFORMAT_COMPLEXIEEEFP:
+                  out << "complex ieee floating\n";
+                  break;
+               case OSAMPLEFORMAT_VOID:
+               default:
+                  out << "untyped data\n";
+                  break;
+            }
+         }
+         break;
+      }
+
+      case OTIFFTAG_SMINSAMPLEVALUE: // tag 340
+      {
+         out << prefix << "smin_sample_value: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_SMAXSAMPLEVALUE: // tag 341
+      {
+         out << prefix << "smax_sample_value: ";
+         printValue(out, type, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_COPYRIGHT: // tag 33432
+      {
+         out << prefix << "copyright: ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+      
+      case OMODEL_PIXEL_SCALE_TAG: // tag 33550
+      {
+         out << prefix << MODEL_PIXEL_SCALE_KW << ": ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+
+      case OMODEL_TIE_POINT_TAG: // tag 33992
+      {
+         out << prefix << MODEL_TIE_POINT_KW << ": ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+
+      case OMODEL_TRANSFORM_TAG: // tag 34264
+      {
+         out << prefix << MODEL_TRANSFORM_KW << ": ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+
+      case OTIFFTAG_PHOTOSHOP:  // tag 34377
+      {
+         out << prefix << "photoshop_image_resource_blocks: found\n";
+         break;
+      }
+      
+      case OGEO_DOUBLE_PARAMS_TAG: // tag 34736
+      {
+         out << prefix << "double_params: ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+      case OGEO_ASCII_PARAMS_TAG: // tag 34737
+      {
+         out << prefix << "ascii_params: ";
+         printArray(out, type, count, valueArray);
+         break;
+      }
+ 
+      default:
+      {
+         out << prefix << "unhandled_tag: " << tag << "\n";
+         if (traceDebug())
+         {
+             ossimNotify(ossimNotifyLevel_DEBUG)
+                << "generic:"
+                << "\ntag[" << tagIdx << "]:         " << tag
+                << "\ntype:                " << type
+                << "\ncount:        " << count
+                << "\narray size in bytes: " << arraySizeInBytes
+                << "\n";
+            printArray(out, type, count, valueArray);
+         }
+         break;
+      }
+
+   } // end of switch on tag...
+
+   return out;
+
+} // end of print
+
+std::ostream& ossimTiffInfo::printValue(std::ostream& out,
+                                       ossim_uint16 type,
+                                       ossim_uint8* valueArray) const
+{
+   switch (type)
+   {
+      case OTIFF_SHORT:
+      {
+         ossim_uint16 v;
+         getArrayValue(v, valueArray, 0);
+         out << v << "\n";
+         break;
+      }
+      case OTIFF_SSHORT:
+      {
+         ossim_sint16 v;
+         getArrayValue(v, valueArray, 0);
+         out << v << "\n";
+         break;
+      }
+      case OTIFF_LONG:
+      {
+         ossim_uint32 v;
+         getArrayValue(v, valueArray, 0);
+         out << v << "\n";
+         break;
+      }
+      case OTIFF_RATIONAL: // two longs first=numerator, second=denominator
+      {
+         ossim_uint32 num;
+         ossim_uint32 den;
+         
          getArrayValue(num, valueArray, 0);
          getArrayValue(den, valueArray, 1);
          
@@ -1153,7 +1875,7 @@ std::ostream& ossimTiffInfo::printValue(std::ostream& out,
          break;
          
       }
-      case TIFF_SLONG:
+      case OTIFF_SLONG:
       {
          ossim_sint32 v;
          getArrayValue(v, valueArray, 0);
@@ -1178,7 +1900,7 @@ std::ostream& ossimTiffInfo::printArray(std::ostream& out,
    {
       switch (type)
       {
-         case TIFF_BYTE:
+         case OTIFF_BYTE:
          {
             for (ossim_uint64 i = 0; i < arraySizeInBytes; ++i)
             {
@@ -1188,7 +1910,7 @@ std::ostream& ossimTiffInfo::printArray(std::ostream& out,
             break;
          }
 
-         case TIFF_ASCII:
+         case OTIFF_ASCII:
          {
             for (ossim_uint64 i = 0; i < arraySizeInBytes; ++i)
             {
@@ -1197,7 +1919,7 @@ std::ostream& ossimTiffInfo::printArray(std::ostream& out,
             out << "\n";
             break;
          }
-         case TIFF_SHORT:
+         case OTIFF_SHORT:
           {
              ossim_uint16* p = (ossim_uint16*)valueArray;
              for (ossim_uint64 i = 0; i < arraySizeInBytes; ++i)
@@ -1207,7 +1929,7 @@ std::ostream& ossimTiffInfo::printArray(std::ostream& out,
             out << "\n";
             break;
          }
-         case TIFF_LONG:
+         case OTIFF_LONG:
           {
              ossim_uint32* p = (ossim_uint32*)valueArray;
              for (ossim_uint64 i = 0; i < arraySizeInBytes; ++i)
@@ -1217,7 +1939,7 @@ std::ostream& ossimTiffInfo::printArray(std::ostream& out,
             out << "\n";
             break;
          }
-         case TIFF_DOUBLE:
+         case OTIFF_DOUBLE:
           {
              ossim_float64* p = (ossim_float64*)valueArray;
              for (ossim_uint64 i = 0; i < arraySizeInBytes; ++i)
@@ -1297,18 +2019,18 @@ std::ostream& ossimTiffInfo::printGeoKeys(
 
          switch (key)
          {
-            case GT_MODEL_TYPE_GEO_KEY:  // key 1024 Section 6.3.1.1 Codes
+            case OGT_MODEL_TYPE_GEO_KEY:  // key 1024 Section 6.3.1.1 Codes
             {
                printModelType(out, prefix, code);
                break;
             }               
-            case GT_RASTER_TYPE_GEO_KEY:  // key 1025 Section 6.3.1.2 Code
+            case OGT_RASTER_TYPE_GEO_KEY:  // key 1025 Section 6.3.1.2 Code
             {
                printRasterType(out, prefix, code);
                break;
             }
 
-            case GT_CITATION_GEO_KEY: // key 1026
+            case OGT_CITATION_GEO_KEY: // key 1026
             {
                if (tag == 34737) // using ascii array
                {
@@ -1327,13 +2049,13 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                break;
             }
 
-            case GEOGRAPHIC_TYPE_GEO_KEY:  // key 2048  Section 6.3.2.1 Codes
+            case OGEOGRAPHIC_TYPE_GEO_KEY:  // key 2048  Section 6.3.2.1 Codes
             {
                out << prefix << "gcs_type: " << code << "\n";
                break;
             }
 
-            case GEOG_CITATION_GEO_KEY: // key 2049
+            case OGEOG_CITATION_GEO_KEY: // key 2049
             {
                if (tag == 34737) // using ascii array
                {
@@ -1352,33 +2074,33 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                break;
             }
 
-            case GEOG_GEODETIC_DATUM_GEO_KEY:// key 2050  Section 6.3.2.2 Codes
+            case OGEOG_GEODETIC_DATUM_GEO_KEY:// key 2050 Section 6.3.2.2 Codes
             {
                out << prefix << "geodetic_datum: " << code << "\n";
                break;
             }
             
-            case GEOG_LINEAR_UNITS_GEO_KEY:// key 2052  Section 6.3.1.3 Codes
+            case OGEOG_LINEAR_UNITS_GEO_KEY:// key 2052  Section 6.3.1.3 Codes
             {
                out << prefix << "linear_units_code: " << code << "\n";
                printLinearUnits(out, prefix, code);
                break;
             }
             
-            case GEOG_ANGULAR_UNITS_GEO_KEY:// key 2054  Section 6.3.1.4 Codes
+            case OGEOG_ANGULAR_UNITS_GEO_KEY:// key 2054  Section 6.3.1.4 Codes
             {
                out << prefix << "angular_units_code: " << code << "\n";
                printAngularUnits(out, prefix, code);
                break;
             }
             
-            case GEOG_ELLIPSOID_GEO_KEY:// key 2056  Section 6.3.23 Codes
+            case OGEOG_ELLIPSOID_GEO_KEY:// key 2056  Section 6.3.23 Codes
             {
                out << prefix << "ellipsoid_code: " << code << "\n";
                break;
             }
             
-            case GEOG_SEMI_MAJOR_AXIS: // key 2057
+            case OGEOG_SEMI_MAJOR_AXIS: // key 2057
             {
                if (tag == 34736) // using double array
                {
@@ -1392,7 +2114,7 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                }
                break;
             }
-            case GEOG_SEMI_MINOR_AXIS: // key 2058
+            case OGEOG_SEMI_MINOR_AXIS: // key 2058
             {
                if (tag == 34736) // using double array
                {
@@ -1407,13 +2129,13 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                break;
             }
 
-            case PROJECTED_CS_TYPE_GEO_KEY: // key 3072 Section 6.3.3.1 codes
+            case OPROJECTED_CS_TYPE_GEO_KEY: // key 3072 Section 6.3.3.1 codes
             {
                out << prefix << "pcs_code: " << code << "\n";
                break;
             }
 
-            case PCS_CITATION_GEO_KEY: // key 3073 ascii
+            case OPCS_CITATION_GEO_KEY: // key 3073 ascii
             {
                if (tag == 34737) // using ascii array
                {
@@ -1433,27 +2155,27 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                break;
             }
       
-            case PROJECTION_GEO_KEY: // key 3074 Section 6.3.3.2 codes
+            case OPROJECTION_GEO_KEY: // key 3074 Section 6.3.3.2 codes
             {
                out << prefix << "proj_code: " << code << "\n";
                break;
             }
             
-            case PROJ_COORD_TRANS_GEO_KEY:  // key 3075 Section 6.3.3.3 codes
+            case OPROJ_COORD_TRANS_GEO_KEY:  // key 3075 Section 6.3.3.3 codes
             {
-               out << prefix << "coord_trans_code: " << code << "\n";
+               out << prefix << COORD_TRANS_CODE_KW << ": " << code << "\n";
                printCoordTrans(out, prefix, code);
                break;
             }
          
-            case LINEAR_UNITS_GEO_KEY:  // key 3076 Section 6.3.1.3 codes
+            case OLINEAR_UNITS_GEO_KEY:  // key 3076 Section 6.3.1.3 codes
             {
                out << prefix << "linear_units_code: " << code << "\n";
                printLinearUnits(out, prefix, code);
                break;
             }
 
-            case PROJ_STD_PARALLEL1_GEO_KEY:  // key 3078
+            case OPROJ_STD_PARALLEL1_GEO_KEY:  // key 3078
             {
                if (tag == 34736) // using double array
                {
@@ -1461,14 +2183,15 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && (code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "std_parallel1: "
+                     out << prefix
+                         << ossimKeywordNames::STD_PARALLEL_1_KW << ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
                break;
             }
          
-            case PROJ_STD_PARALLEL2_GEO_KEY:  // key 3079
+            case OPROJ_STD_PARALLEL2_GEO_KEY:  // key 3079
             {
                if (tag == 34736) // using double array
                {
@@ -1476,14 +2199,15 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && ( code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "std_parallel2: "
+                     out << prefix
+                         << ossimKeywordNames::STD_PARALLEL_2_KW << ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
                break;
             }
          
-            case PROJ_NAT_ORIGIN_LONG_GEO_KEY:  // key 3080
+            case OPROJ_NAT_ORIGIN_LONG_GEO_KEY:  // key 3080
             {
                if (tag == 34736) // using double array
                {
@@ -1491,14 +2215,14 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && ( code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "origin_longitude: "
+                     out << prefix << ORIGIN_LONGITUDE_KW << ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
                break;
             }
                
-            case PROJ_NAT_ORIGIN_LAT_GEO_KEY:  // key 3081
+            case OPROJ_NAT_ORIGIN_LAT_GEO_KEY:  // key 3081
             {
                if (tag == 34736) // using double array
                {
@@ -1506,14 +2230,14 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && ( code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "origin_latitude: "
+                     out << prefix << ORIGIN_LATITUDE_KW << ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
                break;
             }
 
-            case PROJ_FALSE_EASTING_GEO_KEY:  // key 3082
+            case OPROJ_FALSE_EASTING_GEO_KEY:  // key 3082
             {
                if (tag == 34736) // using double array
                {
@@ -1521,14 +2245,64 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && ( code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "false_easting: "
+                     out << prefix
+                         << ossimKeywordNames::FALSE_EASTING_KW<< ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
                break;
             }
 
-            case PROJ_FALSE_NORTHING_GEO_KEY:  // key 3083
+            case OPROJ_FALSE_NORTHING_GEO_KEY:  // key 3083
+            {
+               if (tag == 34736) // using double array
+               {
+                  // Code is index into array.
+                  if ( geoDoubleBlock && ( code < geoDoubleLength) )
+                  {
+                     // Always count of one.
+                     out << prefix
+                         << ossimKeywordNames::FALSE_NORTHING_KW
+                         << ": "
+                         << geoDoubleBlock[code] << "\n";
+                  }
+               }
+               break;
+            }
+            
+            case OPROJ_FALSE_ORIGIN_LONG_GEO_KEY:  // key 3084
+            {
+               if (tag == 34736) // using double array
+               {
+                  // Code is index into array.
+                  if ( geoDoubleBlock && ( code < geoDoubleLength) )
+                  {
+                     // Always count of one.
+                     out << prefix
+                         << FALSE_ORIGIN_LONGITUDE_KW << ": "
+                         << geoDoubleBlock[code] << "\n";
+                  }
+               }
+               break;
+            }
+            
+            case OPROJ_FALSE_ORIGIN_LAT_GEO_KEY:  // key 3085
+            {
+               if (tag == 34736) // using double array
+               {
+                  // Code is index into array.
+                  if ( geoDoubleBlock && ( code < geoDoubleLength) )
+                  {
+                     // Always count of one.
+                     out << prefix
+                         << FALSE_ORIGIN_LATITUDE_KW << ": "
+                         << geoDoubleBlock[code] << "\n";
+                  }
+               }
+               break;
+            }
+            
+            case OPROJ_FALSE_ORIGIN_EASTING_GEO_KEY:  // key 3086
             {
                if (tag == 34736) // using double array
                {
@@ -1536,14 +2310,31 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && ( code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "false_northing: "
+                     out << prefix
+                         <<  FALSE_ORIGIN_EASTING_KW<< ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
                break;
             }
             
-            case PROJ_CENTER_LONG_GEO_KEY:  // key 3088
+            case OPROJ_FALSE_ORIGIN_NORTHING_GEO_KEY:  // key 3087
+            {
+               if (tag == 34736) // using double array
+               {
+                  // Code is index into array.
+                  if ( geoDoubleBlock && ( code < geoDoubleLength) )
+                  {
+                     // Always count of one.
+                     out << prefix
+                         <<  FALSE_ORIGIN_NORTHING_KW<< ": "
+                         << geoDoubleBlock[code] << "\n";
+                  }
+               }
+               break;
+            }
+           
+            case OPROJ_CENTER_LONG_GEO_KEY:  // key 3088
             {
                if (tag == 34736) // using double array
                {
@@ -1558,7 +2349,7 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                break;
             }
 
-            case PROJ_CENTER_LAT_GEO_KEY:  // key 3089
+            case OPROJ_CENTER_LAT_GEO_KEY:  // key 3089
             {
                if (tag == 34736) // using double array
                {
@@ -1573,7 +2364,7 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                break;
             }
 
-            case PROJ_SCALE_AT_NAT_ORIGIN_GEO_KEY:  // key 3092
+            case OPROJ_SCALE_AT_NAT_ORIGIN_GEO_KEY:  // key 3092
             {
                if (tag == 34736) // using double array
                {
@@ -1581,7 +2372,8 @@ std::ostream& ossimTiffInfo::printGeoKeys(
                   if ( geoDoubleBlock && ( code < geoDoubleLength) )
                   {
                      // Always count of one.
-                     out << prefix << "scale_factor: "
+                     out << prefix << ossimKeywordNames::SCALE_FACTOR_KW
+                         << ": "
                          << geoDoubleBlock[code] << "\n";
                   }
                }
@@ -1626,7 +2418,7 @@ std::ostream& ossimTiffInfo::printModelType(std::ostream& out,
                                            ossim_uint16 code) const
 {
    // key 1024 Section 6.3.1.1 Codes
-   out << prefix << "model_type: ";
+   out << prefix << MODEL_TYPE_KW << ": ";
    if (code == 1)
    {
       out << "projected\n";
@@ -1651,7 +2443,7 @@ std::ostream& ossimTiffInfo::printRasterType(std::ostream& out,
                                             ossim_uint16 code) const
 {
    // key 1025 Section 6.3.1.2 Codes
-   out << prefix << "raster_type: ";
+   out << prefix << RASTER_TYPE_KW << ": ";
    if (code == 1)
    {
       out << "pixel_is_area\n";
@@ -1672,7 +2464,7 @@ std::ostream& ossimTiffInfo::printAngularUnits(std::ostream& out,
                                               ossim_uint16 code) const
 {
    // key 2054 Section 6.3.1.4 Codes
-   out << prefix << "angular_units: ";
+   out << prefix << ANGULAR_UNITS_KW << ": ";
    switch (code)
    {
       case 9101:
@@ -1881,7 +2673,7 @@ std::ostream& ossimTiffInfo::printLinearUnits(std::ostream& out,
                                              ossim_uint16 code) const
 {
    // key 3076 Section 6.3.1.3 Codes
-   out << prefix << "linear_units: ";
+   out << prefix << LINEAR_UNITS_KW << ": ";
    switch (code)
    {
       case 9001:
@@ -1946,91 +2738,675 @@ std::ostream& ossimTiffInfo::printLinearUnits(std::ostream& out,
       }
       case 9013:
       {
-         out << "yard_indian\n";
-         break;
+         out << "yard_indian\n";
+         break;
+      }
+      case 9014:
+      {
+         out << "fathom\n";
+         break;
+      }
+      case 9015:
+      {
+         out << "mile_international_nautical\n";
+         break;
+      }
+      default:
+      {
+         out << code << " unknown\n";
+         break;
+      }
+   }
+   return out;
+}
+
+std::ostream& ossimTiffInfo::printOrientation(std::ostream& out,
+                                              const std::string& prefix,
+                                              ossim_uint16 code) const
+{
+   // Tag 274:
+   out << prefix << "orientation: ";
+   switch (code)
+   {
+      case 1:
+      {
+         out << "top_left\n";
+         break;
+      }
+      case 2:
+      {
+         out << "top_right\n";
+         break;
+      }
+      case 3:
+      {
+         out << "bottom_right\n";
+         break;
+      }
+      case 4:
+      {
+         out << "bottom_left\n";
+         break;
+      }
+      case 5:
+      {
+         out << "left_top\n";
+         break;
+      }
+      case 6:
+      {
+         out << "right_top\n";
+         break;
+      }
+      case 7:
+      {
+         out << "right_bottom\n";
+         break;
+      }
+      case 8:
+      {
+         out << "left_bottom\n";
+         break;
+      }
+      default:
+      {
+         out << code << " unknown\n";
+         break;
+      }
+   }
+   return out;
+}
+
+void ossimTiffInfo::getDirPrefix(ossim_int32 index,
+                                 std::string& prefix) const
+{
+   prefix += "image";
+   std::ostringstream s;
+   s << index;
+   prefix += s.str();
+   prefix += ".";
+}
+
+bool ossimTiffInfo::getPixelScale(const ossimString& gtiffPrefix,
+                                  const ossimKeywordlist& gtiffKwl,
+                                  ossimDpt& scale) const
+{
+   bool result = false;
+
+   std::vector<ossim_float64> floats;
+   if ( getFloats(gtiffPrefix, MODEL_PIXEL_SCALE_KW, gtiffKwl, floats) )
+   {
+      if ( floats.size() == 3 )
+      {
+         scale.x = floats[0];
+         scale.y = floats[1];
+         result = true;
+      }
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getTiePoint(const ossimString& gtiffPrefix,
+                                const ossimKeywordlist& gtiffKwl,
+                                std::vector<ossim_float64>& ties) const
+{
+   return getFloats(gtiffPrefix, MODEL_TIE_POINT_KW, gtiffKwl, ties);
+}
+
+bool ossimTiffInfo::getModelTransform(const ossimString& gtiffPrefix,
+                                      const ossimKeywordlist& gtiffKwl,
+                                      std::vector<ossim_float64>& xfrm) const
+{
+   return getFloats(gtiffPrefix, MODEL_TRANSFORM_KW, gtiffKwl, xfrm);
+}
+
+bool ossimTiffInfo::getFloats(const ossimString& gtiffPrefix,
+                              const ossimString& key,
+                              const ossimKeywordlist& gtiffKwl,
+                              std::vector<ossim_float64>& floats) const
+{
+   bool result = false;
+   
+   const char* lookup = gtiffKwl.find(gtiffPrefix.c_str(), key.c_str());
+   if ( lookup )
+   {
+      ossimString line = lookup;
+      result  = getFloats(line, floats);
+   }
+
+   return result; 
+}
+
+bool ossimTiffInfo::getFloats(const ossimString& line,
+                              std::vector<ossim_float64>& floats) const
+{
+   bool result = false;
+   
+   floats.clear();
+   
+   if (line.size())
+   {
+      ossim_float64 f;
+      std::istringstream is(line);
+
+      is >> f; // Get the first double.
+      while ( ! is.fail() )
+      {
+         floats.push_back(f);
+         is >> f;
+      }
+   }
+
+   if ( floats.size() )
+   {
+      result = true;
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getPcsCode(const ossimString& gtiffPrefix,
+                               const ossimKeywordlist& gtiffKwl,
+                               ossimString& pcsCode) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ossimKeywordNames::PCS_CODE_KW);
+
+   if (lookup)
+   {
+      pcsCode = lookup;
+
+      // See if we handle this code in our projection factories.
+      
+      ossim_uint32 code = pcsCode.toUInt32();
+
+      if ( code != OUSER_DEFINED )
+      {
+         const ossimStatePlaneProjectionInfo* info =
+            ossimStatePlaneProjectionFactory::instance()->getInfo(code);
+         if ( info )
+         {
+            result = true;
+            delete info;
+            info = 0;
+         }
+         else
+         {
+            ossimRefPtr<ossimProjection> proj = ossimPcsCodeProjectionFactory::instance()->
+               createProjection(pcsCode);
+            if (proj.valid())
+            {
+               result = true;
+            }
+            proj = 0;
+        }
+      }
+   }
+   
+   return result;
+}
+
+bool ossimTiffInfo::getUnits(const ossimString& gtiffPrefix,
+                             const ossimKeywordlist& gtiffKwl,
+                             ossimString& units) const
+{
+   bool result = true;
+   
+   ossimString linearUnits = "";
+   getLinearUnits(gtiffPrefix, gtiffKwl, linearUnits);
+      
+   ossimString angularUnits = "";
+   getAngularUnits(gtiffPrefix, gtiffKwl, angularUnits);
+
+   ossimString modelType;
+   getModelType(gtiffPrefix, gtiffKwl, modelType);
+   
+   if (modelType == "geographic")
+   {
+      if (angularUnits.size())
+      {
+         units = angularUnits;
       }
-      case 9014:
+      else
       {
-         out << "fathom\n";
-         break;
+         units = "degrees";
       }
-      case 9015:
+   }
+   else if (modelType == "projected")
+   {
+      if (linearUnits.size())
       {
-         out << "mile_international_nautical\n";
-         break;
+         units = linearUnits;
       }
-      default:
+      else
       {
-         out << code << " unknown\n";
-         break;
+         units = "meters";
       }
    }
-   return out;
+   else
+   {
+      units = "meters";
+   }
+
+   return result;
 }
 
-std::ostream& ossimTiffInfo::printOrientation(std::ostream& out,
-                                              const std::string& prefix,
-                                              ossim_uint16 code) const
+
+bool ossimTiffInfo::getLinearUnits(const ossimString& gtiffPrefix,
+                                   const ossimKeywordlist& gtiffKwl,
+                                   ossimString& linearUnits) const
 {
-   // Tag 274:
-   out << prefix << "orientation: ";
-   switch (code)
+   bool result = false;
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), LINEAR_UNITS_KW.c_str());
+   if (lookup)
    {
-      case 1:
-      {
-         out << "top_left\n";
-         break;
-      }
-      case 2:
-      {
-         out << "top_right\n";
-         break;
-      }
-      case 3:
-      {
-         out << "bottom_right\n";
-         break;
-      }
-      case 4:
+      linearUnits = lookup;
+      result = true;
+   }
+   return result;
+}
+
+bool ossimTiffInfo::getAngularUnits(const ossimString& gtiffPrefix,
+                                    const ossimKeywordlist& gtiffKwl,
+                                    ossimString& angularUnits) const
+{
+   bool result = false;
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ANGULAR_UNITS_KW.c_str());
+   if (lookup)
+   {
+      angularUnits = lookup;
+      result = true;
+   }
+   return result;
+}
+
+bool ossimTiffInfo::getPixelType(const ossimString& gtiffPrefix,
+                                 const ossimKeywordlist& gtiffKwl,
+                                 ossimString& pixelType) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), RASTER_TYPE_KW.c_str());
+   if (lookup)
+   {
+      pixelType = lookup;
+      result = true;
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getModelType(const ossimString& gtiffPrefix,
+                                 const ossimKeywordlist& gtiffKwl,
+                                 ossimString& modelType) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), MODEL_TYPE_KW.c_str());
+   if (lookup)
+   {
+      modelType = lookup;
+      result = true;
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getOssimProjectionName(const ossimString& gtiffPrefix,
+                                           const ossimKeywordlist& gtiffKwl,
+                                           ossimString& ossimProj) const
+{
+   bool result = false;
+
+   ossimProj.clear();
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), COORD_TRANS_CODE_KW.c_str());
+   
+   if (lookup)
+   {
+      ossim_uint32 code = ossimString(lookup).toUInt32();
+
+      ossimGeoTiffCoordTransformsLut lut;
+
+      ossimProj = lut.getEntryString(code);
+      
+      if (ossimProj.size())
       {
-         out << "bottom_left\n";
-         break;
+         result = true;
       }
-      case 5:
+   }
+
+   return result;
+}
+
+ossim_uint32 ossimTiffInfo::getLines(const ossimString& gtiffPrefix,
+                                     const ossimKeywordlist& gtiffKwl) const
+{
+   ossim_uint32 result = 0;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), IMAGE_LENGTH_KW.c_str());
+
+   if (lookup)
+   {
+      result = ossimString(lookup).toUInt32();
+   }
+
+   return result;
+}
+
+ossim_uint32 ossimTiffInfo::getSamples(const ossimString& gtiffPrefix,
+                                       const ossimKeywordlist& gtiffKwl) const
+{
+   ossim_uint32 result = 0;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), IMAGE_WIDTH_KW.c_str());
+
+   if (lookup)
+   {
+      result = ossimString(lookup).toUInt32();
+   }   
+
+   return result;
+}
+
+bool ossimTiffInfo::getStdParallelOne(const ossimString& gtiffPrefix,
+                                      const ossimKeywordlist& gtiffKwl,
+                                      ossimString& value) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ossimKeywordNames::STD_PARALLEL_1_KW);
+   
+   if (lookup)
+   {
+      value = lookup;
+      result = true;
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getStdParallelTwo(const ossimString& gtiffPrefix,
+                                      const ossimKeywordlist& gtiffKwl,
+                                      ossimString& value) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ossimKeywordNames::STD_PARALLEL_2_KW);
+   
+   if (lookup)
+   {
+      value = lookup;
+      result = true;
+   }
+
+   return result;
+}
+
+bool ossimTiffInfo::getFalseEasting(const ossimString& gtiffPrefix,
+                                    const ossimKeywordlist& gtiffKwl,
+                                    ossimString& value) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ossimKeywordNames::FALSE_EASTING_KW);
+   
+   if (lookup)
+   {
+      value = lookup;
+      result = true;
+   }
+
+   return result; 
+}
+
+bool ossimTiffInfo::getFalseNorthing(const ossimString& gtiffPrefix,
+                                     const ossimKeywordlist& gtiffKwl,
+                                     ossimString& value) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ossimKeywordNames::FALSE_NORTHING_KW);
+   
+   if (lookup)
+   {
+      value = lookup;
+      result = true;
+   }
+
+   return result; 
+}
+
+bool ossimTiffInfo::getFalseEastingNorthing(const ossimString& gtiffPrefix,
+                                            const ossimKeywordlist& gtiffKwl,
+                                            ossimDpt& eastingNorthing) const
+{
+   bool result = false;
+   ossimString value;
+   if ( getFalseEasting(gtiffPrefix, gtiffKwl, value) )
+   {
+      eastingNorthing.x = value.toFloat64();
+
+      if ( getFalseNorthing(gtiffPrefix, gtiffKwl, value) )
       {
-         out << "left_top\n";
-         break;
+         eastingNorthing.y = value.toFloat64();
+         result = true;
       }
-      case 6:
+   }
+   return result;
+}
+      
+bool ossimTiffInfo::getScaleFactor(const ossimString& gtiffPrefix,
+                                   const ossimKeywordlist& gtiffKwl,
+                                   ossim_float64& value) const
+{
+   bool result = false;
+
+   const char* lookup =
+      gtiffKwl.find(gtiffPrefix.c_str(), ossimKeywordNames::SCALE_FACTOR_KW);
+   
+   if (lookup)
+   {
+      value = ossimString(lookup).toFloat64();
+      result = true;
+   }
+
+   return result; 
+}
+
+bool ossimTiffInfo::getOriginLat(const ossimString& gtiffPrefix,
+                                 const ossimKeywordlist& gtiffKwl,
+                                 ossim_float64& value) const
+{
+   bool result = false;
+
+   //---
+   // Not sure of the order of precidence here.
+   //---
+   const char* projOriginLatGeoKey =
+      gtiffKwl.find(gtiffPrefix.c_str(), ORIGIN_LATITUDE_KW.c_str());
+
+   //---
+   // Go for this key first as it is used in geotiff spec example:
+   // http://www.remotesensing.org/geotiff/spec/geotiff3.html#3.1.3.
+   //---
+   if (projOriginLatGeoKey)
+   {
+      value = ossimString(projOriginLatGeoKey).toFloat64();
+      result = true;
+   }
+   else
+   {
+      const char* projCenterLatGeoKey =
+         gtiffKwl.find(gtiffPrefix.c_str(), CENTER_LATITUDE__KW.c_str());
+
+      if (projCenterLatGeoKey)
       {
-         out << "right_top\n";
-         break;
+         value = ossimString(projCenterLatGeoKey).toFloat64();
+         result = true;
       }
-      case 7:
+      else
       {
-         out << "right_bottom\n";
-         break;
+         const char* projFalseOriginLatGeoKey =
+            gtiffKwl.find(gtiffPrefix.c_str(),
+                          FALSE_ORIGIN_LATITUDE_KW.c_str());
+
+         if (projFalseOriginLatGeoKey)
+         {
+            //---
+            // Seems the term "false" implies it should be added to the real
+            // origin?
+            //---
+            value = ossimString(projFalseOriginLatGeoKey).toFloat64();
+            result = true;
+         }
       }
-      case 8:
+   }
+   
+   return result;
+}
+
+bool ossimTiffInfo::getCentralMeridian(const ossimString& gtiffPrefix,
+                                       const ossimKeywordlist& gtiffKwl,
+                                       ossim_float64& value) const
+{
+   bool result = false;
+
+   //---
+   // Not sure of the order of precidence here.
+   //---
+   const char* projCenterLongGeoKey =
+      gtiffKwl.find(gtiffPrefix.c_str(), CENTER_LONGITUDE_KW.c_str());
+
+   //---
+   // Go for this key first as it is used in geotiff spec example:
+   // http://www.remotesensing.org/geotiff/spec/geotiff3.html#3.1.3.
+   //---
+   if (projCenterLongGeoKey)
+   {
+      value = ossimString(projCenterLongGeoKey).toFloat64();
+      result = true;
+   }
+   else
+   {
+      const char* projOriginLongGeoKey =
+         gtiffKwl.find(gtiffPrefix.c_str(), ORIGIN_LONGITUDE_KW.c_str());
+
+      if (projOriginLongGeoKey)
       {
-         out << "left_bottom\n";
-         break;
+         value = ossimString(projOriginLongGeoKey).toFloat64();
+         result = true;
       }
-      default:
+      else
       {
-         out << code << " unknown\n";
-         break;
+         const char* projFalseOriginLongGeoKey =
+            gtiffKwl.find(gtiffPrefix.c_str(),
+                          FALSE_ORIGIN_LONGITUDE_KW.c_str());
+
+         if (projFalseOriginLongGeoKey)
+         {
+            //---
+            // Seems the term "false" implies it should be added to the real
+            // origin?
+            //---
+            value = ossimString(projFalseOriginLongGeoKey).toFloat64();
+            result = true;
+         }
       }
    }
-   return out;
+   
+   return result;
 }
 
-void ossimTiffInfo::getDirPrefix(ossim_int32 index,
-                                 std::string& prefix) const
+void ossimTiffInfo::getTieSets(const std::vector<ossim_float64>& ties,
+                               ossim_uint32 width,
+                               ossim_uint32 height,
+                               ossimTieGptSet& tieSet) const
 {
-   prefix += "image";
-   std::ostringstream s;
-   s << index;
-   prefix += s.str();
-   prefix += ".";
+   ossim_uint32 idx = 0;
+   ossim_uint32 tieCount = ties.size()/6;
+   const double* tiePointsPtr = &ties.front();
+   double offset = 0;
+   if (hasOneBasedTiePoints(ties, width, height))
+   {
+      offset = -1.0;
+   }
+   
+   for(idx = 0; idx < tieCount; ++idx)
+   {
+      ossimDpt xyPixel(tiePointsPtr[0]+offset, tiePointsPtr[1]+offset);
+      // tie[3] = x, tie[4]
+      ossimGpt gpt(tiePointsPtr[4], tiePointsPtr[3], tiePointsPtr[5]);
+      
+      tieSet.addTiePoint(new ossimTieGpt(gpt, xyPixel, .5));
+      tiePointsPtr+=6;
+   }
+}
+
+bool ossimTiffInfo::hasOneBasedTiePoints(
+   const std::vector<ossim_float64>& ties,
+   ossim_uint32 width, ossim_uint32 height) const
+{
+   bool result = false;
+   
+   // Assuming ties of (x,y,z,lat,lon,hgt) so size should be divide by 3.
+   if (ties.size()%6)
+   {
+      return result;
+   }
+   
+   ossim_float64 minX = 999999.0;
+   ossim_float64 minY = 999999.0;
+   ossim_float64 maxX = 0.0;
+   ossim_float64 maxY = 0.0;
+
+   const ossim_uint32 SIZE = ties.size();
+   ossim_uint32 tieIndex = 0;
+
+   while (tieIndex < SIZE)
+   {
+      if ( ties[tieIndex]   < minX ) minX = ties[tieIndex];
+      if ( ties[tieIndex]   > maxX ) maxX = ties[tieIndex];
+      if ( ties[tieIndex+1] < minY ) minY = ties[tieIndex+1];
+      if ( ties[tieIndex+1] > maxY ) maxY = ties[tieIndex+1];
+      tieIndex += 6;
+   }
+
+   if ( (minX == 1) && (maxX == width) &&
+        (minY == 1) && (maxY == height) )
+   {
+      result = true;
+   }
+
+#if 0
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "ossimGeoTiff::hasOneBasedTiePoints DEBUG:"
+         << "\nminX:       " << minX
+         << "\nmaxX:       " << maxX
+         << "\nminY:       " << minY
+         << "\nmaxY:       " << maxY
+         << "\ntheWidth:   " << theWidth
+         << "\ntheLength:  " << theLength
+         << "\none based:  " << (result?"true":"false")
+         << std::endl;
+   }
+#endif
+   
+   return result;
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimTiffWorld.cpp b/Utilities/otbossim/src/ossim/support_data/ossimTiffWorld.cpp
index fc849454a4058ce1d5fc47f546c8a6e28aff46f8..860a156312dd0c0149dcbac76afe03a439074a00 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimTiffWorld.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimTiffWorld.cpp
@@ -1,13 +1,15 @@
 //*******************************************************************
 //
-// License:  See top level LICENSE.txt file.
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Ken Melero
 // 
 // Description: Container class for a tiff world file data.
 //
 //********************************************************************
-// $Id: ossimTiffWorld.cpp 9464 2006-08-28 18:53:04Z dburken $
+// $Id: ossimTiffWorld.cpp 14777 2009-06-25 14:43:52Z dburken $
 
 #include <iostream>
 #include <fstream>
@@ -15,6 +17,7 @@
 using namespace std;
 
 #include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimDirectory.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimUnitConversionTool.h>
@@ -54,9 +57,33 @@ ossimTiffWorld::ossimTiffWorld(const char* file,
    ifstream is;
    is.open(file);
 
-   if(!is)
+   if( !is.is_open() )
    {
-      return;
+      // ESH 07/2008, Trac #234: OSSIM is case sensitive 
+      // when using worldfile templates during ingest
+      // -- If first you don't succeed with the user-specified
+      // filename, try again with the results of a case insensitive search.
+      ossimFilename fullName(file);
+      ossimDirectory directory(fullName.path());
+      ossimFilename filename(fullName.file());
+      
+      std::vector<ossimFilename> result;
+      bool bSuccess = directory.findCaseInsensitiveEquivalents(
+         filename, result );
+      if ( bSuccess == true )
+      {
+         int numResults = result.size();
+         int i;
+         for ( i=0; i<numResults && !is.is_open(); ++i )
+         {
+            is.open( result[i].c_str() );
+         }
+      }
+      
+      if ( !is.is_open() )
+      {
+         return;
+      }
    }
 
    is >> theXScale
diff --git a/Utilities/otbossim/src/ossim/version-config.cpp b/Utilities/otbossim/src/ossim/version-config.cpp
index a0c89e65450d6e95aeb5f7f52ee4e727a7bba6c5..1ea8ccb2c2cd34ae38f43e7773517815c6fa9fb5 100644
--- a/Utilities/otbossim/src/ossim/version-config.cpp
+++ b/Utilities/otbossim/src/ossim/version-config.cpp
@@ -13,7 +13,7 @@
 //
 // $Id$
 //----------------------------------------------------------------------------
-#include <cstdlib>
+
 #include <ctime>
 #include <fstream>   
 #include <string>
@@ -29,15 +29,21 @@
  */
 int main(int argc, char* argv[])
 {
+   enum
+   {
+      OK=0,
+      ERROR=1
+   };
+   
    if (argc != 3)
    {
-      exit(1);
+      return ERROR;
    }
 
    std::ofstream os(argv[1]);
    if (!os)
    {
-      exit(1);
+      return ERROR;
    }
 
    // Get the version.  This is now passed in from the make file.
@@ -104,5 +110,5 @@ int main(int argc, char* argv[])
    
    std::cout << "wrote file: " << argv[1] << std::endl;
 
-   exit(0);
+   return OK;
 }
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c b/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c
index bf271a2d32459ce7d2663380720c83a7a923be61..c319cc8e919e962922ea6c4e4825ad64b6969666 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c
@@ -251,11 +251,11 @@ static char *get_token( char *expression,
 {
    register int i, stopflag;
 
-   *token_type = (int)NULL;
+   *token_type = 0;
 
    if (*expression == '\0') {
       *token_type = FINISHED;
-      *token_value = (int)NULL;
+      *token_value = 0;
       return expression;
    }
 
@@ -346,7 +346,7 @@ static char *get_token( char *expression,
    }
 
    *token_type = VALUE;
-   *token_value = (int)NULL;
+   *token_value = 0;
    return expression;
 }
 
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfread.c b/Utilities/otbossim/src/ossim/vpfutil/vpfread.c
index 6486205ce003e688d02c601b151a1b2242c35d4d..1fc007d7bfccb5f78878e0f4e118f893e138c0e1 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfread.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfread.c
@@ -566,7 +566,7 @@ long int index_pos( long int row_number,
 		    vpf_table_type table )
 {
    long int   recsize;
-   unsigned long int pos;
+   unsigned long int pos=0;
 
    STORAGE_BYTE_ORDER = table.byte_order;
 
diff --git a/Utilities/otbossimplugins/gdal/ossimOgcWktTranslator.cpp b/Utilities/otbossimplugins/gdal/ossimOgcWktTranslator.cpp
index 0f1340953894d72fe829559b57179d8fea96292d..6b86a5f8fdc71958bcd138a4865bb6891e385cf2 100644
--- a/Utilities/otbossimplugins/gdal/ossimOgcWktTranslator.cpp
+++ b/Utilities/otbossimplugins/gdal/ossimOgcWktTranslator.cpp
@@ -15,7 +15,7 @@
 // accomplish the translation. 
 //
 //*******************************************************************
-//  $Id: ossimOgcWktTranslator.cpp 14589 2009-05-20 23:51:14Z dburken $
+//  $Id: ossimOgcWktTranslator.cpp 14729 2009-06-16 18:14:59Z gpotts $
 
 #include <cstdio>
 #include <gdal.h>
@@ -706,6 +706,7 @@ bool ossimOgcWktTranslator::toOssimKwl( const ossimString& wktString,
              << "to be added to the transaltion to OSSIM\n"
              << wkt << endl;
        }
+	  return false;
     }
 
     // extract out the datum
diff --git a/Utilities/otbossimplugins/ossim/erssar/ErsSarFacilityData.cpp b/Utilities/otbossimplugins/ossim/erssar/ErsSarFacilityData.cpp
index 5b9c4d3c7764bbe45b7c2e440a95df631aff244a..d60842cc59f5c07552c898aabe43ac888c6a1aa1 100644
--- a/Utilities/otbossimplugins/ossim/erssar/ErsSarFacilityData.cpp
+++ b/Utilities/otbossimplugins/ossim/erssar/ErsSarFacilityData.cpp
@@ -793,7 +793,7 @@ std::istream& operator>>(std::istream& is, ErsSarFacilityData& data)
   data._range_spread_loss_comp_flag = atoi(buf4);
 
   is.read(buf1,1);
-  data._datation_flag = atoi(buf1) != 0;
+  data._datation_flag = (atoi(buf1)==0)?false:true;
 
   is.read(buf7,7);
   data._max_error_range_line_timing = atoi(buf7);
@@ -802,7 +802,7 @@ std::istream& operator>>(std::istream& is, ErsSarFacilityData& data)
   data._form_num_range_line_used = atoi(buf7);
 
   is.read(buf1,1);
-  data._autom_look_scal_gain_flag = atoi(buf1) != 0;
+  data._autom_look_scal_gain_flag = (atoi(buf1)==0)?false:true;
 
   is.read(buf4,4);
   data._max_value_look_scalar_gain = atoi(buf4);
diff --git a/Utilities/otbossimplugins/ossim/ossimPluginInit.cpp b/Utilities/otbossimplugins/ossim/ossimPluginInit.cpp
index e56b274aab97f2cecc206ec1d0afa5d1f7e69dbe..72bdd99cda0e04f2b5e984524344d33c2dae0036 100644
--- a/Utilities/otbossimplugins/ossim/ossimPluginInit.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimPluginInit.cpp
@@ -73,7 +73,7 @@ extern "C"
 
       /** Register the projection factory. */
       ossimProjectionFactoryRegistry::instance()->
-         registerFactory(ossimPluginProjectionFactory::instance(), true);
+         registerFactory(ossimPluginProjectionFactory::instance());
 
      setDescription(theDescription);
   }
diff --git a/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp b/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp
index 1035b3bf7a26078d2ae568b8943153e14d2ca194..b7dd070e24f6620bfa146749b0b70579f20be399 100644
--- a/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp
@@ -12,6 +12,7 @@
 
 #include "ossimPluginProjectionFactory.h"
 #include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimRefPtr.h>
 #include <ossim/projection/ossimProjection.h>
 #include "ossimRadarSatModel.h"
 #include "ossimEnvisatAsarModel.h"
@@ -26,59 +27,57 @@ namespace ossimplugins
 
 ossimPluginProjectionFactory* ossimPluginProjectionFactory::instance()
 {
-   static ossimPluginProjectionFactory* factoryInstance = new ossimPluginProjectionFactory();
+   static ossimPluginProjectionFactory* factoryInstance =
+      new ossimPluginProjectionFactory();
 
    return factoryInstance;
 }
 
-ossimProjection* ossimPluginProjectionFactory::createProjection(const ossimFilename& filename,
-                                                                ossim_uint32 /*entryIdx*/)const
+ossimProjection* ossimPluginProjectionFactory::createProjection(
+   const ossimFilename& filename, ossim_uint32 /*entryIdx*/)const
 {
-   ossimProjection* result = 0;
+   ossimRefPtr<ossimProjection> result = 0;
 
    if ( !result )
    {
-      ossimRadarSat2Model* model = new ossimRadarSat2Model();
+      ossimRefPtr<ossimRadarSat2Model> model = new ossimRadarSat2Model();
       if ( model->open(filename) )
       {
-         result = model;
+         result = model.get();
       }
       else
       {
-         delete model;
          model = 0;
       }
    }
 
    if ( !result )
    {
-      ossimTerraSarModel* model = new ossimTerraSarModel();
+      ossimRefPtr<ossimTerraSarModel> model = new ossimTerraSarModel();
       if ( model->open(filename) )
       {
-         result = model;
+         result = model.get();
       }
       else
       {
-         delete model;
          model = 0;
       }
    }
 
    if ( !result )
    {
-      ossimErsSarModel* model = new ossimErsSarModel();
+      ossimRefPtr<ossimErsSarModel> model = new ossimErsSarModel();
       if ( model->open(filename) )
       {
-         result = model;
+         result = model.get();
       }
       else
       {
-         delete model;
          model = 0;
       }
    }
 
-   return result;
+   return result.release();
 }
 
 ossimProjection* ossimPluginProjectionFactory::createProjection(
@@ -118,7 +117,7 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
 ossimProjection* ossimPluginProjectionFactory::createProjection(
    const ossimKeywordlist& kwl, const char* prefix)const
 {
-   ossimProjection* result = 0;
+   ossimRefPtr<ossimProjection> result = 0;
 
    const char* lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
    if (lookup)
@@ -130,7 +129,6 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
          result = new ossimRadarSat2Model();
          if ( !result->loadState(kwl, prefix) )
          {
-            delete result;
             result = 0;
          }
       }
@@ -139,7 +137,6 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
          result = new ossimTerraSarModel();
          if ( !result->loadState(kwl, prefix) )
          {
-            delete result;
             result = 0;
          }
       }
@@ -148,13 +145,12 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
          result = new ossimErsSarModel();
          if ( !result->loadState(kwl, prefix) )
          {
-            delete result;
             result = 0;
          }
       }
    }
 
-   return result;
+   return result.release();
 }
 
 ossimObject* ossimPluginProjectionFactory::createObject(
diff --git a/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp b/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp
index 0dba9d7df6a12e53ddf87f10e0f4afec7849545f..464bd90138a94946d167eab5f5fd33f3fdc8abba 100644
--- a/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp
@@ -14,6 +14,7 @@
 #include <ossimPluginReaderFactory.h>
 #include <ossimTerraSarTiffReader.h>
 #include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimRefPtr.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/base/ossimTrace.h>
@@ -56,10 +57,9 @@ ossimImageHandler* ossimPluginReaderFactory::open(
          << std::endl;
    }
 
-   ossimImageHandler* reader = new ossimTerraSarTiffReader();
+   ossimRefPtr<ossimImageHandler> reader = new ossimTerraSarTiffReader();
    if(reader->open(fileName) == false)
    {
-      delete reader;
       reader = 0;
    }
 
@@ -70,7 +70,7 @@ ossimImageHandler* ossimPluginReaderFactory::open(
          << std::endl;
    }
 
-   return reader;
+   return reader.release();
 }
 
 ossimImageHandler* ossimPluginReaderFactory::open(const ossimKeywordlist& kwl,
@@ -84,10 +84,9 @@ ossimImageHandler* ossimPluginReaderFactory::open(const ossimKeywordlist& kwl,
          << std::endl;
    }
 
-   ossimImageHandler* reader = new ossimTerraSarTiffReader;
+   ossimRefPtr<ossimImageHandler> reader = new ossimTerraSarTiffReader;
    if(reader->loadState(kwl, prefix) == false)
    {
-      delete reader;
       reader = 0;
    }
 
@@ -98,26 +97,28 @@ ossimImageHandler* ossimPluginReaderFactory::open(const ossimKeywordlist& kwl,
          << std::endl;
    }
 
-   return reader;
+   return reader.release();
 }
 
 ossimObject* ossimPluginReaderFactory::createObject(
    const ossimString& typeName)const
 {
+   ossimRefPtr<ossimObject> result = 0;
    if(typeName == "ossimTerraSarTiffReader")
    {
-      return new ossimTerraSarTiffReader;
+      result = new ossimTerraSarTiffReader;
    }
-   return 0;
+   return result.release();
 }
 
-ossimObject* ossimPluginReaderFactory::createObject(const ossimKeywordlist& kwl,
-                                                 const char* prefix)const
+ossimObject* ossimPluginReaderFactory::createObject(
+   const ossimKeywordlist& kwl, const char* prefix)const
 {
    return this->open(kwl, prefix);
 }
 
-void ossimPluginReaderFactory::getTypeNameList(std::vector<ossimString>& typeList)const
+void ossimPluginReaderFactory::getTypeNameList(
+   std::vector<ossimString>& typeList)const
 {
    typeList.push_back(ossimString("ossimTerraSarTiffReader"));
 }
diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.cpp b/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.cpp
index c69a5581352dd18300d5b94d9cfbb4a78f048bf0..133cb14dbed70b67e9f899573143fcff1fa4f078 100644
--- a/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.cpp
@@ -4,8 +4,6 @@
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
-// Author:  David Burken
-//
 // Description: Utility class to encapsulate parsing RadarSat2 product.xml
 // file.
 //
@@ -33,6 +31,12 @@
 #include <ossim/base/ossimXmlDocument.h>
 #include <ossim/base/ossimXmlNode.h>
 
+#include <sstream>
+#include <vector>
+
+using namespace std;
+
+
 namespace ossimplugins
 {
 
@@ -614,10 +618,248 @@ bool ossimRadarSat2ProductDoc::initTiePoints(const ossimXmlDocument* xdoc,
    return result;
 }
 
+
+RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) const
+{
+   ossimString path = "/product/imageAttributes/geographicInformation/rationalFunctions/satellite";
+
+   RPCModel model;
+
+   ossimString searchbiasError = "/product/imageAttributes/geographicInformation/rationalFunctions/biasError";				//the line (y-coordinate)
+   ossimString searchrandomError = "/product/imageAttributes/geographicInformation/rationalFunctions/randomError";			//the line (y-coordinate)
+   ossimString searchlineFitQuality = "/product/imageAttributes/geographicInformation/rationalFunctions/lineFitQuality";				//the line (y-coordinate)
+   ossimString searchpixelFitQuality = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelFitQuality";				//the line (y-coordinate)
+   ossimString searchlineOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/lineOffset";						//the line (y-coordinate)
+   ossimString searchpixelOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelOffset";						//the line (y-coordinate)
+   ossimString searchlatitudeOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/latitudeOffset";				//the line (y-coordinate)
+   ossimString searchlongitudeOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/longitudeOffset";				//the line (y-coordinate)
+   ossimString searchheightOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/heightOffset";						//the line (y-coordinate)
+   ossimString searchlineScale = "/product/imageAttributes/geographicInformation/rationalFunctions/lineScale";						//the line (y-coordinate)
+   ossimString searchpixelScale = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelScale";						//the line (y-coordinate)
+   ossimString searchlatitudeScale = "/product/imageAttributes/geographicInformation/rationalFunctions/latitudeScale";						//the line (y-coordinate)
+   ossimString searchlongitudeScale = "/product/imageAttributes/geographicInformation/rationalFunctions/longitudeScale";						//the line (y-coordinate)
+   ossimString searchheightScale = "/product/imageAttributes/geographicInformation/rationalFunctions/heightScale";						//the line (y-coordinate)
+
+   ossimString searchlineNumeratorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/lineNumeratorCoefficients";						//the line (y-coordinate)
+   ossimString searchlineDenominatorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/lineDenominatorCoefficients";						//the line (y-coordinate)
+   ossimString searchpixelNumeratorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelNumeratorCoefficients";						//the line (y-coordinate)
+   ossimString searchpixelDenominatorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelDenominatorCoefficients";						//the line (y-coordinate)
+
+
+   // strings to hold values found
+   ossimString biasErrorStr;;
+   ossimString randomErrorStr;
+   ossimString lineFitQualityStr;
+   ossimString pixelFitQualityStr;
+   ossimString lineOffsetStr;
+   ossimString pixelOffsetStr;
+   ossimString latitudeOffsetStr;
+   ossimString longitudeOffsetStr;
+   ossimString heightOffsetStr;
+   ossimString lineScaleStr;
+   ossimString pixelScaleStr;
+   ossimString latitudeScaleStr;
+   ossimString longitudeScaleStr;
+   ossimString heightScaleStr;
+
+   std::vector<ossimString> lineNumeratorCoefficientsStr;
+   std::vector<ossimString> lineDenominatorCoefficientsStr;
+   std::vector<ossimString> pixelNumeratorCoefficientsStr;
+   std::vector<ossimString> pixelDenominatorCoefficientsStr;
+
+
+   // doubles to hold values found
+   double biasError = 0;
+   double randomError = 0;
+   double lineFitQuality = 0;
+   double pixelFitQuality = 0;
+   double lineOffset = 0;
+   double pixelOffset = 0;
+   double latitudeOffset = 0;
+   double longitudeOffset = 0;
+   double heightOffset = 0;
+   double lineScale = 0;
+   double pixelScale = 0;
+   double latitudeScale = 0;
+   double longitudeScale = 0;
+   double heightScale = 0;
+
+   vector<double> lineNumeratorCoefficients = vector<double>(20,0);
+   vector<double> lineDenominatorCoefficients = vector<double>(20,0);
+   vector<double> pixelNumeratorCoefficients = vector<double>(20,0);
+   vector<double> pixelDenominatorCoefficients = vector<double>(20,0);
+
+   //the final string outputs to the text file
+
+   //check if this function is being called on the correct SAR data type
+   //function is only applicable for RS2 product.xml files
+   bool rs2Check = isRadarSat2(xdoc);
+   if (rs2Check)
+   {
+      if (!ossim::getPath(searchbiasError, xdoc, biasErrorStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      biasError = biasErrorStr.toDouble();
+
+      if (!ossim::getPath(searchrandomError, xdoc, randomErrorStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      randomError = randomErrorStr.toDouble();
+
+      if (!ossim::getPath(searchlineFitQuality, xdoc, lineFitQualityStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      lineFitQuality = lineFitQualityStr.toDouble();
+
+      if (!ossim::getPath(searchpixelFitQuality, xdoc, pixelFitQualityStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      pixelFitQuality = pixelFitQualityStr.toDouble();
+
+      if (!ossim::getPath(searchlineOffset, xdoc, lineOffsetStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      lineOffset = lineOffsetStr.toDouble();
+
+      if (!ossim::getPath(searchpixelOffset, xdoc, pixelOffsetStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      pixelOffset = pixelOffsetStr.toDouble();
+
+      if (!ossim::getPath(searchlatitudeOffset, xdoc, latitudeOffsetStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      latitudeOffset = latitudeOffsetStr.toDouble();
+
+      if (!ossim::getPath(searchlongitudeOffset, xdoc, longitudeOffsetStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      longitudeOffset = longitudeOffsetStr.toDouble();
+
+      if (!ossim::getPath(searchheightOffset, xdoc, heightOffsetStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      heightOffset = heightOffsetStr.toDouble();
+
+      // --------------
+
+      if (!ossim::getPath(searchlineScale, xdoc, lineScaleStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      lineScale = lineScaleStr.toDouble();
+
+
+      if (!ossim::getPath(searchpixelScale, xdoc, pixelScaleStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      pixelScale = pixelScaleStr.toDouble();
+
+
+      if (!ossim::getPath(searchlatitudeScale, xdoc, latitudeScaleStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      latitudeScale = latitudeScaleStr.toDouble();
+
+      // -----------------------
+
+      if (!ossim::getPath(searchlongitudeScale, xdoc, longitudeScaleStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      longitudeScale = longitudeScaleStr.toDouble();
+
+
+      if (!ossim::getPath(searchheightScale, xdoc, heightScaleStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+      heightScale = heightScaleStr.toDouble();
+
+      // ---- parameters for reading in coeefs ------------
+
+      double val=0;
+
+      // -------------------------------------
+
+
+      if (!ossim::getPath(searchlineNumeratorCoefficients, xdoc, lineNumeratorCoefficientsStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+
+
+      string lineNumeratorCoefficientsStr_N = lineNumeratorCoefficientsStr[0];
+      // place into a stream
+      std::stringstream LNstream(lineNumeratorCoefficientsStr_N);
+
+      for (int i=0; i < 20; i ++)
+      {
+         LNstream >> val;
+         lineNumeratorCoefficients[i] = val;
+      }
+
+      // ------------------
+
+      if (!ossim::getPath(searchlineDenominatorCoefficients, xdoc, lineDenominatorCoefficientsStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+
+
+      string lineDenominatorCoefficientsStr_N = lineDenominatorCoefficientsStr[0];
+
+      // place into a stream
+      std::stringstream LDstream(lineDenominatorCoefficientsStr_N);
+
+      for (int i=0; i < 20; i ++)
+      {
+         LDstream >> val;
+         lineDenominatorCoefficients[i] = val;
+      }
+
+      // ------------------
+
+      if (!ossim::getPath(searchpixelNumeratorCoefficients, xdoc, pixelNumeratorCoefficientsStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+
+      string pixelNumeratorCoefficientsStr_N = pixelNumeratorCoefficientsStr[0];
+
+      // place into a stream
+      std::stringstream PNstream(pixelNumeratorCoefficientsStr_N);
+
+      for (int i=0; i < 20; i ++)
+      {
+         PNstream >> val;
+         pixelNumeratorCoefficients[i] = val;
+      }
+
+      // ------------------
+
+      if (!ossim::getPath(searchpixelDenominatorCoefficients, xdoc, pixelDenominatorCoefficientsStr))
+         ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
+
+      string pixelDenominatorCoefficientsStr_N = pixelDenominatorCoefficientsStr[0];
+
+      // place into a stream
+      std::stringstream PDstream(pixelDenominatorCoefficientsStr_N);
+
+      for (int i=0; i < 20; i ++)
+      {
+         PDstream >> val;
+         pixelDenominatorCoefficients[i] = val;
+      }
+
+      // end character search term
+
+      model.biasError = biasError;
+      model.randomError = randomError;
+      model.lineFitQuality = lineFitQuality;
+      model.pixelFitQuality = pixelFitQuality;
+      model.lineOffset = lineOffset;
+      model.pixelOffset = pixelOffset;
+      model.latitudeOffset = latitudeOffset;
+      model.longitudeOffset = longitudeOffset;
+      model.heightOffset = heightOffset;
+      model.lineScale = lineScale;
+      model.pixelScale = pixelScale;
+      model.latitudeScale = latitudeScale;
+      model.longitudeScale = longitudeScale;
+      model.heightScale = heightScale;
+      model.lineNumeratorCoefficients = lineNumeratorCoefficients;
+      model.lineDenominatorCoefficients = lineDenominatorCoefficients;
+      model.pixelNumeratorCoefficients = pixelNumeratorCoefficients;
+      model.pixelDenominatorCoefficients = pixelDenominatorCoefficients;
+   }
+
+   return model;
+}
+
 bool ossimRadarSat2ProductDoc::getSatellite(const ossimXmlDocument* xdoc,
                                             ossimString& s) const
 {
    ossimString path = "/product/sourceAttributes/satellite";
+   // The saved File is an ossimKeywordlist
+
    return ossim::getPath(path, xdoc, s);
 }
 
diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.h b/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.h
index d2e162f34fa5b98ead524bb407d5315c059c0868..a3b435eb574ae2182afe005c3c9487cc13656c36 100644
--- a/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.h
+++ b/Utilities/otbossimplugins/ossim/ossimRadarSat2ProductDoc.h
@@ -4,8 +4,6 @@
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
-// Author:  David Burken
-//
 // Description: Utility class to encapsulate parsing RadarSat2 product.xml
 // file.
 //
@@ -16,6 +14,9 @@
 
 #include <list>
 #include <vector>
+#include <sstream>
+#include <vector>
+
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimRefPtr.h>
 
@@ -26,9 +27,34 @@ class ossimXmlDocument;
 class ossimXmlNode;
 class ossimString;
 
-namespace ossimplugins
+
+using namespace std;
+
+typedef struct
 {
+   double biasError;
+   double randomError;
+   double lineFitQuality;
+   double pixelFitQuality;
+   double lineOffset;
+   double pixelOffset;
+   double latitudeOffset;
+   double longitudeOffset;
+   double heightOffset;
+   double lineScale;
+   double pixelScale;
+   double latitudeScale;
+   double longitudeScale;
+   double heightScale;
+   vector<double> lineNumeratorCoefficients;
+   vector<double> lineDenominatorCoefficients;
+   vector<double> pixelNumeratorCoefficients;
+   vector<double> pixelDenominatorCoefficients;
+   
+}RPCModel;
 
+namespace ossimplugins
+{
 class PlatformPosition;
 class RefPoint;
 class SensorParams;
@@ -50,7 +76,9 @@ public:
     * @return true if present, false if not.
     */
    bool isRadarSat2(const ossimXmlDocument* xdoc) const;
-
+      
+   RPCModel getRpcData(const ossimXmlDocument* xdoc) const;
+      
    /**
     * @brief Method to initialize PlatformPosition object from
     * RadarSat "product.xml" file.
diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSat2RPCModel.cpp b/Utilities/otbossimplugins/ossim/ossimRadarSat2RPCModel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4ffba698d891ea3fdd904979d1164e24546d857c
--- /dev/null
+++ b/Utilities/otbossimplugins/ossim/ossimRadarSat2RPCModel.cpp
@@ -0,0 +1,665 @@
+//----------------------------------------------------------------------------
+//
+// "Copyright Centre National d'Etudes Spatiales"
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+//----------------------------------------------------------------------------
+// $Id$
+
+#include <cmath>
+
+#include <ossimRadarSat2RPCModel.h>
+#include <ossimPluginCommon.h>
+#include <ossimRadarSat2ProductDoc.h>
+#include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/base/ossimString.h>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/base/ossimXmlDocument.h>
+#include <ossim/base/ossimXmlNode.h>
+
+#include <ossim/base/ossimException.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimNotifyContext.h>
+
+#include <otb/GalileanEphemeris.h>
+#include <otb/GeographicEphemeris.h>
+#include <otb/GMSTDateTime.h>
+
+#include <otb/SensorParams.h>
+#include <otb/SarSensor.h>
+
+namespace ossimplugins
+{
+
+// Keyword constants:
+static const char LOAD_FROM_PRODUCT_FILE_KW[] = "load_from_product_file_flag";
+static const char PRODUCT_XML_FILE_KW[] = "product_xml_filename";
+
+// Static trace for debugging
+static ossimTrace traceDebug("ossimRadarSat2RPCModel:debug");
+
+
+RTTI_DEF1(ossimRadarSat2RPCModel, "ossimRadarSat2RPCModel", ossimRpcModel);
+
+ossimRadarSat2RPCModel::ossimRadarSat2RPCModel()
+   :
+   ossimRpcModel(),
+   theDecimation(1.0),
+   theProductXmlFile(ossimFilename::NIL)
+{
+}
+   
+ossimRadarSat2RPCModel::ossimRadarSat2RPCModel(const ossimRadarSat2RPCModel& rhs)
+   :
+   ossimRpcModel(rhs),
+   theDecimation(1.0),
+   theProductXmlFile(rhs.theProductXmlFile)
+{
+   
+}
+
+
+//*****************************************************************************
+//  CONSTRUCTOR: ossimRadarSat2RPCModel
+//  
+//  Constructs given filename for RS2 product.xml file
+//  
+//*****************************************************************************
+
+ossimRadarSat2RPCModel::ossimRadarSat2RPCModel(const ossimFilename& RS2File)
+   :ossimRpcModel(), theDecimation(1.0)
+{
+   
+   // Open the XML file, and read the RPC values in.
+   if (!open(RS2File))
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimRadarSat2RPCModel::ossimRadarSat2RPCModel(RS2File): Unable to parse file " << RS2File
+           << std::endl;
+   }
+
+}
+   
+ossimRadarSat2RPCModel::~ossimRadarSat2RPCModel()
+{
+}
+
+ossimString ossimRadarSat2RPCModel::getClassName() const
+{
+   return ossimString("ossimRadarSat2RPCModel");
+}
+   
+// ------ DUPLICATE RS2 MODEL OBJECT ----------
+   
+ossimObject* ossimRadarSat2RPCModel::dup() const
+{
+   return new ossimRadarSat2RPCModel(*this);
+}
+
+bool ossimRadarSat2RPCModel::open(const ossimFilename& file)
+{
+   static const char MODULE[] = "ossimRadarSat2RPCModel::open";
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< MODULE << " entered...\n";
+   }
+   
+   bool result = false;
+   
+   // Get the xml file.
+   ossimFilename xmlFile;
+   
+   if (file.ext().downcase() == "xml")
+   {
+      xmlFile = file;
+   }
+   else if (file.isFile())
+   {
+      xmlFile = file.expand().path().dirCat("product.xml");
+   }
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "product xml file: " << xmlFile << "\n";
+   }
+   
+   if ( xmlFile.exists() )
+   {
+      //---
+      // Instantiate the XML parser:
+      //---
+      ossimXmlDocument* xdoc = new ossimXmlDocument();
+      if ( xdoc->openFile(xmlFile) )
+      {
+         ossimRadarSat2ProductDoc rsDoc;
+         
+         result = rsDoc.isRadarSat2(xdoc);
+         
+         if (result)
+         {
+            if (traceDebug())
+            {
+               ossimNotify(ossimNotifyLevel_DEBUG)
+                  << "isRadarSat2...\n";
+               ossimString s;
+               if ( rsDoc.getBeamModeMnemonic(xdoc, s) )
+               {
+                  ossimNotify(ossimNotifyLevel_DEBUG)
+                     << "beam_mode_mnemonic: " << s << "\n";
+               }
+               if ( rsDoc.getAcquisitionType(xdoc, s) )
+               {
+                  ossimNotify(ossimNotifyLevel_DEBUG)
+                     << "acquisition_type: " << s << "\n";
+               }
+            }
+            
+            // Set the base class number of lines and samples
+            result = rsDoc.initImageSize(xdoc, theImageSize);
+            
+            
+            //---
+            // Fetch Image Size:
+            //---
+
+            theImageSize.line = theImageSize.x;
+            theImageSize.samp =theImageSize.y;
+
+
+            //***
+                 // Assign the bounding image space rectangle:
+                 //***
+
+                      if (result)
+                   {
+                      // Set the base class clip rect.
+                      theImageClipRect = ossimDrect(
+                         0, 0,
+                         theImageSize.x-1, theImageSize.y-1);
+                   }
+
+            // Set the sub image offset. tmp hard coded (drb).
+            theSubImageOffset.x = 0.0;
+            theSubImageOffset.y = 0.0;
+
+            // Set the image id.
+            if (result)
+            {
+               result = rsDoc.getImageId(xdoc, theImageID);
+            }
+
+            // Set the sensor ID.
+            if (result)
+            {
+               result = rsDoc.getSatellite(xdoc, theSensorID);
+            }
+
+            // Set the base class gsd:
+            result = rsDoc.initGsd(xdoc, theGSD);
+            if (result)
+            {
+               theMeanGSD = (theGSD.x + theGSD.y)/2.0;
+            }
+
+
+         }
+
+         thePolyType = B;
+
+
+         RPCModel model;
+         model = rsDoc.getRpcData(xdoc);
+
+
+         theBiasError  = model.biasError;
+         theRandError  = model.randomError;
+         theLineOffset = model.lineOffset;
+         theSampOffset = model.pixelOffset;
+         theLatOffset  = model.latitudeOffset;
+         theLonOffset  = model.longitudeOffset;
+         theHgtOffset  = model.heightOffset;
+         theLineScale  = model.lineScale;
+         theSampScale  = model.pixelScale;
+         theLatScale   = model.latitudeScale;
+         theLonScale   = model.longitudeScale;
+         theHgtScale   = model.heightScale;
+
+
+         if (traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)
+               << "All parameters RPC : "
+               << theBiasError << ", "
+               << theRandError << ", "
+               << theLineOffset << ", "
+               << theSampOffset << ", "
+               << theLatOffset << ", "
+               << theLonOffset << ", "
+               << theHgtOffset << ", "
+               << theLineScale << ", "
+               << theSampScale << ", "
+               << theLatScale << ", "
+               << theLonScale << ", "
+               << theHgtScale << ", " << std::endl;
+         }
+
+         // Parse coefficients:
+         ossim_uint32 i;
+
+         for (i=0; i<20; ++i)
+         {
+
+            theLineNumCoef[i] = model.lineNumeratorCoefficients[i];
+            theLineDenCoef[i] = model.lineDenominatorCoefficients[i];
+            theSampNumCoef[i] = model.pixelNumeratorCoefficients[i];
+            theSampDenCoef[i] = model.pixelDenominatorCoefficients[i];
+         }
+
+         // Assign other data members to default values:
+         theNominalPosError = sqrt(theBiasError*theBiasError +
+                                   theRandError*theRandError); // meters
+
+
+
+
+      } // matches: if ( xdoc->openFile(xmlFile) )
+
+      delete xdoc;
+      xdoc = 0;
+
+   } // matches: if ( xmlFile.exists() )
+
+   if (result)
+   {
+      theProductXmlFile = xmlFile;
+   }
+   else
+   {
+      theProductXmlFile = ossimFilename::NIL;
+   }
+
+   if (result)
+   {
+      theProductXmlFile = xmlFile;
+   }
+   else
+   {
+      theProductXmlFile = ossimFilename::NIL;
+   }
+
+   if (result)
+   {
+      // Assign the ossimSensorModel::theBoundGndPolygon
+      ossimGpt ul;
+      ossimGpt ur;
+      ossimGpt lr;
+      ossimGpt ll;
+      lineSampleToWorld(theImageClipRect.ul(), ul);
+      lineSampleToWorld(theImageClipRect.ur(), ur);
+      lineSampleToWorld(theImageClipRect.lr(), lr);
+      lineSampleToWorld(theImageClipRect.ll(), ll);
+      setGroundRect(ul, ur, lr, ll);  // ossimSensorModel method.
+   }
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " exit status = " << (result?"true":"false\n")
+         << std::endl;
+   }
+
+
+
+   //---
+   // Get the decimation if any from the header "IMAG" field.
+   //
+   // Look for string like:
+   // "/2" = 1/2
+   // "/4  = 1/4
+   // ...
+   // "/16 = 1/16
+   // If it is full resolution it should be "1.0"
+   //---
+
+   theDecimation = 1.0;
+
+
+
+   //***
+        // Assign other data members:
+        //***
+             thePolyType = B; 					// This may not be true for early RPC imagery
+   theRefImgPt.line = theImageSize.line/2.0;
+   theRefImgPt.samp = theImageSize.samp/2.0;
+   theRefGndPt.lat  = theLatOffset;
+   theRefGndPt.lon  = theLonOffset;
+   theRefGndPt.hgt  = theHgtOffset;
+
+
+   //---
+   // Assign the bounding ground polygon:
+   //
+   // NOTE:  We will use the base ossimRpcModel for transformation since all
+   // of our calls are in full image space (not decimated).
+   //---
+
+   ossimGpt v0, v1, v2, v3;
+   ossimDpt ip0 (0.0, 0.0);
+   ossimRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0);
+   ossimDpt ip1 (theImageSize.samp-1.0, 0.0);
+   ossimRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1);
+   ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0);
+   ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2);
+   ossimDpt ip3 (0.0, theImageSize.line-1.0);
+   ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3);
+
+   theBoundGndPolygon
+      = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3));
+
+   updateModel();
+
+   // Set the ground reference point.
+   ossimRpcModel::lineSampleHeightToWorld(theRefImgPt,
+                                          theHgtOffset,
+                                          theRefGndPt);
+
+   if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() )
+   {
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:"
+            << "\nGround Reference Point not valid."
+            << " Aborting with error..."
+            << std::endl;
+      }
+      setErrorStatus();
+      return false;
+   }
+
+
+   return true;
+}
+
+   
+void ossimRadarSat2RPCModel::worldToLineSample(const ossimGpt& world_point,
+                                               ossimDpt&       image_point) const
+{
+   // Get the full res (not decimated) point.
+   ossimRpcModel::worldToLineSample(world_point, image_point);
+   
+   // Apply decimation.
+   image_point.x = image_point.x * theDecimation;
+   image_point.y = image_point.y * theDecimation;
+}
+   
+void ossimRadarSat2RPCModel::lineSampleHeightToWorld(
+   const ossimDpt& image_point,
+   const double&   heightEllipsoid,
+   ossimGpt&       worldPoint) const
+{
+   
+   // Convert image point to full res (not decimated) point.
+   ossimDpt pt;
+   pt.x = image_point.x / theDecimation;
+   pt.y = image_point.y / theDecimation;
+   
+   // Call base...
+   ossimRpcModel::lineSampleHeightToWorld(pt, heightEllipsoid, worldPoint);
+}
+
+std::ostream& ossimRadarSat2RPCModel::print(std::ostream& out) const
+{
+   // Capture the original flags.
+   std::ios_base::fmtflags f = out.flags();
+   
+   ossimRpcModel::print(out);
+   
+   // Reset flags.
+   out.setf(f);
+   
+   return out;
+}
+   
+bool ossimRadarSat2RPCModel::InitSensorParams(const ossimKeywordlist &kwl,
+                                              const char *prefix)
+{
+   
+   // sensor frequencies
+   const char* central_freq_str = kwl.find(prefix,"central_freq");
+   double central_freq = 0.0;
+   if (central_freq_str)
+   {
+      central_freq = ossimString::toDouble(central_freq_str);
+   }
+   const char* fr_str = kwl.find(prefix,"fr");
+   double fr = 0.0;
+   if (fr_str)
+   {
+      fr = ossimString::toDouble(fr_str);
+   }
+   const char* fa_str = kwl.find(prefix,"fa");
+   double fa = 0.0;
+   if (fa_str)
+   {
+      fa = ossimString::toDouble(fa_str);
+   }
+   
+   //number of different looks
+   const char* n_azilok_str = kwl.find(prefix,"n_azilok");
+   double n_azilok = 0.0;
+   if (n_azilok_str)
+   {
+      n_azilok = ossimString::toDouble(n_azilok_str);
+   }
+   const char* n_rnglok_str = kwl.find(prefix,"n_rnglok");
+   double n_rnglok = 0.0;
+   if (n_rnglok_str)
+   {
+      n_rnglok = ossimString::toDouble(n_rnglok_str);
+   }
+   
+   //ellipsoid parameters
+   const char* ellip_maj_str = kwl.find(prefix,"ellip_maj");
+   double ellip_maj = 0.0;
+   if (ellip_maj_str)
+   {
+      ellip_maj = ossimString::toDouble(ellip_maj_str) * 1000.0;// km -> m
+   }
+   const char* ellip_min_str = kwl.find(prefix,"ellip_min");
+   double ellip_min = 0.0;
+   if (ellip_min_str)
+   {
+      ellip_min = ossimString::toDouble(ellip_min_str) * 1000.0;// km -> m
+   }
+   
+   if(_sensor != 0)
+   {
+      delete _sensor;
+   }
+   
+   _sensor = new SensorParams();
+   
+   const char* lineTimeOrdering_str = kwl.find(prefix,"lineTimeOrdering");
+   std::string lineTimeOrdering(lineTimeOrdering_str) ;
+   const char* pixelTimeOrdering_str = kwl.find(prefix,"pixelTimeOrdering");
+   std::string pixelTimeOrdering(pixelTimeOrdering_str) ;
+   if (pixelTimeOrdering == "Increasing") _sensor->set_col_direction(1);
+   else _sensor->set_col_direction(- 1);
+   if (lineTimeOrdering == "Increasing") _sensor->set_lin_direction(1);
+   else _sensor->set_lin_direction(- 1);
+   
+   const char* lookDirection_str = kwl.find(prefix,"lookDirection");
+   std::string lookDirection(lookDirection_str) ;
+   if ((lookDirection == "Right")||(lookDirection == "RIGHT")) _sensor->set_sightDirection(SensorParams::Right) ;
+   else _sensor->set_sightDirection(SensorParams::Left) ;
+   
+   _sensor->set_sf(fr);
+   const double CLUM        = 2.99792458e+8 ;
+   double wave_length = CLUM / central_freq ;
+   _sensor->set_rwl(wave_length);
+   _sensor->set_nAzimuthLook(n_azilok);
+   _sensor->set_nRangeLook(n_rnglok);
+   
+   // fa is the processing PRF
+   _sensor->set_prf(fa * n_azilok);
+   
+   _sensor->set_semiMajorAxis(ellip_maj) ;
+   _sensor->set_semiMinorAxis(ellip_min) ;
+   
+   return true;
+}
+   
+bool ossimRadarSat2RPCModel::initSensorParams(
+   const ossimXmlDocument* xdoc, const ossimRadarSat2ProductDoc& rsDoc)
+{
+   static const char MODULE[] = "ossimRadarSat2RPCModel::initSensorParams";
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< MODULE << " entered...\n";
+   }
+   
+   if (_sensor )
+   {
+      delete _sensor;
+   }
+   _sensor =  new SensorParams();
+   
+   bool result = rsDoc.initSensorParams(xdoc, _sensor);
+   
+   if (!result)
+   {
+      delete _sensor;
+      _sensor = 0;
+   }
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " exit status = " << (result?"true":"false\n")
+         << std::endl;
+   }
+   
+   return result;
+}
+
+bool ossimRadarSat2RPCModel::saveState(ossimKeywordlist& kwl,
+                                       const char* prefix) const
+{
+   static const char MODULE[] = "ossimRadarSat2RPCModel::saveState";
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< MODULE << " entered...\n";
+   }
+   
+   bool result = true;
+   
+   kwl.add(prefix, "decimation", theDecimation);
+   
+   // Save our state:
+   kwl.add(prefix, PRODUCT_XML_FILE_KW, theProductXmlFile.c_str());
+   
+   if (result)
+   {
+      // Call base save state:
+      result = ossimRpcModel::saveState(kwl, prefix);
+   }
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " exit status = " << (result?"true":"false\n")
+         << std::endl;
+   }
+   
+   return result;
+}
+
+
+bool ossimRadarSat2RPCModel::loadState (const ossimKeywordlist &kwl,
+                                        const char *prefix)
+{
+   static const char MODULE[] = "ossimRadarSat2RPCModel::loadState";
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
+   }
+   
+   const char* lookup = 0;
+   ossimString s;
+   
+   // Check the type first.
+   lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   if (lookup)
+   {
+      s = lookup;
+      if (s != getClassName())
+      {
+         return false;
+      }
+   }
+   
+   // Get the product.xml file name.
+   lookup = kwl.find(prefix, PRODUCT_XML_FILE_KW);
+   if (lookup)
+   {
+      theProductXmlFile = lookup;
+      
+      // See if caller wants to load from xml vice keyword list.
+      lookup = kwl.find(prefix, LOAD_FROM_PRODUCT_FILE_KW);
+      if (lookup)
+      {
+         s = lookup;
+         if ( s.toBool() )
+         {
+            // Loading from product.xml file.
+            return open(theProductXmlFile);
+         }
+      }
+   }
+   
+   
+   // Call base.
+   bool result = ossimRpcModel::loadState(kwl, prefix);
+
+   // Lookup decimation.
+   const char* value = kwl.find(prefix, "decimation");
+   if (value)
+   {
+      theDecimation = ossimString(value).toFloat64();
+      if (theDecimation <= 0.0)
+      {
+         // Do not allow negative or "0.0"(divide by zero).
+         theDecimation = 1.0;
+      }
+   }
+   
+   
+   //---
+   // Temp:  This must be cleared or you end up with a bounding rect of all
+   // zero's.
+   //---
+   theBoundGndPolygon.clear();
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " exit status = " << (result?"true":"false\n")
+         << std::endl;
+   }
+   
+   return result;
+}
+}
diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSat2RPCModel.h b/Utilities/otbossimplugins/ossim/ossimRadarSat2RPCModel.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a120d27323bcb46882101d8adfb9b9afb8a0727
--- /dev/null
+++ b/Utilities/otbossimplugins/ossim/ossimRadarSat2RPCModel.h
@@ -0,0 +1,152 @@
+//----------------------------------------------------------------------------
+//
+// "Copyright Centre National d'Etudes Spatiales"
+//
+// License:  LGPL
+//
+// See LICENSE.txt file in the top level directory for more details.
+//
+//----------------------------------------------------------------------------
+// $Id$
+
+#ifndef ossimRadarSat2RPCModel_H
+#define ossimRadarSat2RPCModel_H
+
+#include <ossim/base/ossimConstants.h>
+#include <ossim/projection/ossimRpcModel.h>
+#include <ossim/projection/ossimMapProjection.h>
+#include <ossim/base/ossimIpt.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimGpt.h>
+#include <ossim/base/ossimDpt.h>
+#include <iostream>
+#include <list>
+#include <otb/PlatformPosition.h>
+#include <otb/SensorParams.h>
+#include <otb/RefPoint.h>
+#include <otb/SarSensor.h>
+
+#include <otb/CivilDateTime.h>
+
+class ossimFilename;
+class ossimString;
+class ossimXmlDocument;
+
+namespace ossimplugins
+{
+
+class ossimRadarSat2ProductDoc;
+class SensorParams;
+
+/**
+ * @brief This class allows for direct localisation and indirect localisation
+ * using the RadarSat2 sensor model
+ */
+class ossimRadarSat2RPCModel : public ossimRpcModel
+{
+public:
+   /** @brief default constructor */
+   ossimRadarSat2RPCModel();
+
+   /** @brief copy constructor */
+   ossimRadarSat2RPCModel(const ossimRadarSat2RPCModel& rhs);
+
+    ossimRadarSat2RPCModel(const ossimFilename& RS2File);
+
+
+   /** @brief Destructor */
+   virtual ~ossimRadarSat2RPCModel();
+
+   /**
+    * @brief Method to return the class name.
+    * @return The name of this class.
+    */
+   virtual ossimString getClassName()   const;
+
+   /**
+    * @brief Returns pointer to a new instance, copy of this.
+    */
+   virtual ossimObject* dup() const;
+
+
+	   /**
+    * @brief Method to parse an nitf file and initialize model.
+    * @param entryIndex The entry to get model for.  Note the nitf's can have
+    * multiple entries; each with a different projection.
+    * @return true on success, false on error.
+    */
+    bool open(const ossimFilename& file);
+
+
+   /**
+    * @brief Method to save object state to a keyword list.
+    * @param kwl Keyword list to save to.
+    * @param prefix added to keys when saved.
+    * @return true on success, false on error.
+    */
+   virtual bool saveState(ossimKeywordlist& kwl,
+                          const char* prefix=0) const;
+
+   /**
+    * @brief Method to the load (recreate) the state of the object from a
+    * keyword list. Return true if ok or false on error.
+    * @return true if load OK, false on error
+    */
+   virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0);
+
+   /*!
+    * METHOD: print()
+    * Fulfills base-class pure virtual. Dumps contents of object to ostream.
+    */
+   virtual std::ostream& print(std::ostream& out) const;
+
+
+   /**
+    * @brief worldToLineSample()
+    * Calls ossimRpcModel::worldToLineSample(), then applies (if needed)
+    * decimation.
+    * This is a temp work around for decimation RPC NITFs.
+    */
+   virtual void  worldToLineSample(const ossimGpt& world_point,
+                                   ossimDpt&       image_point) const;
+
+   /**
+    * @brief lineSampleHeightToWorld()
+    * Backs out decimation of image_point (if needed) then calls:
+    * ossimRpcModel::lineSampleHeightToWorld
+    * This is a temp work around for decimation RPC NITFs.
+    */
+   virtual void lineSampleHeightToWorld(const ossimDpt& image_point,
+                                        const double&   heightEllipsoid,
+                                        ossimGpt&       worldPoint) const;
+
+
+private:
+
+
+   bool InitSensorParams(const ossimKeywordlist &kwl,
+                                 const char *prefix);
+
+
+   bool initSensorParams(const ossimXmlDocument* xdoc,
+                         const ossimRadarSat2ProductDoc& rsDoc);
+
+
+   /**
+    * Stored from header field "IMAG".  This is a temp work around to handle
+    * decimated rpc nitf's.
+    */
+   ossim_float64 theDecimation;
+
+   SensorParams * _sensor;
+
+
+
+   ossimFilename theProductXmlFile;
+
+TYPE_DATA
+
+};
+}
+
+#endif
diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp b/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp
index 5af80985e7dd05c2eac54fb7e89ba3392e8c7e07..1f9d754896d875cd30f8cc799f43b2ed98991d7c 100644
--- a/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp
@@ -59,8 +59,8 @@ static ossimTrace traceDebug("ossimTerraSarModel:debug");
 namespace ossimplugins
 {
 RTTI_DEF1(ossimTerraSarModel,
-          "ossimTerraSarModel",
-          ossimGeometricSarSensorModel);
+		"ossimTerraSarModel",
+		ossimGeometricSarSensorModel);
 }
 
 ossimplugins::ossimTerraSarModel::ossimTerraSarModel()
@@ -141,6 +141,11 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
 {
    static const char MODULE[] = "ossimplugins::ossimTerraSarModel::open";
 
+   bool debug = false;
+
+   if (debug)
+      cout << "Opening file" << endl;
+
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -158,10 +163,14 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
       ossimXmlDocument* xdoc = new ossimXmlDocument();
       if ( xdoc->openFile(file) )
       {
+
          ossimTerraSarProductDoc tsDoc;
 
          result = tsDoc.isTerraSarX(xdoc);
-        
+         if (debug)
+            cout << "result of IsTSX " << result << endl;
+
+
          if (result)
          {
             if (traceDebug())
@@ -172,9 +181,14 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
 
             // Set the base class number of lines and samples
             result = tsDoc.initImageSize(xdoc, theImageSize);
-            
+
+            if (debug)
+               cout << "result of initImageSize" << result << endl;
+
+
             if (result)
             {
+
                // Set the base class clip rect.
                theImageClipRect = ossimDrect(
                   0, 0,
@@ -189,6 +203,8 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
             if (result)
             {
                result = tsDoc.getSceneId(xdoc, theImageID);
+               if (debug)
+                  cout << "result of getting SceneIDe" << result << endl;
             }
 
             // Set the sensor ID to the mission ID.
@@ -197,8 +213,15 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
                result = tsDoc.getMission(xdoc, theSensorID);
             }
 
+            if (debug)
+               cout << "result of getting MissionID...." << result << endl;
+
             // Set the base class gsd:
             result = tsDoc.initGsd(xdoc, theGSD);
+
+            if (debug)
+               cout << "result of getting GSD...." << result << endl;
+
             if (result)
             {
                theMeanGSD = (theGSD.x + theGSD.y)/2.0;
@@ -208,17 +231,28 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
             {
                /*result = */initSRGR(xdoc, tsDoc);
 
+               if (debug)
+                  cout << "result of initSRGR.... " << result << endl;
+
                if (result)
                {
                   result = initPlatformPosition(xdoc, tsDoc);
 
+                  if (debug)
+                     cout << "result of initPlatformPosition.... " << result << endl;
+
                   if (result)
                   {
                      result = initSensorParams(xdoc, tsDoc);
 
+                     if (debug)
+                        cout << "result of initSensorParams.... " << result << endl;
+
                      if (result)
                      {
                         result = initRefPoint(xdoc, tsDoc);
+                        if (debug)
+                           cout << "result of initRefPoint.... " << result << endl;
 
                         if (result)
                         {
@@ -260,10 +294,18 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
       
    } // matches: if ( file.exists() )
 
+
+   if (debug)
+      cout << "Initialized values...." << endl;
+
+
    if (result)
    {
       theProductXmlFile = file;
-      
+
+      if (debug)
+         cout << "theProductXmlFile : " << file << endl;
+
       // Assign the ossimSensorModel::theBoundGndPolygon
       ossimGpt ul;
       ossimGpt ur;
@@ -273,6 +315,14 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file)
       lineSampleToWorld(theImageClipRect.ur(), ur);
       lineSampleToWorld(theImageClipRect.lr(), lr);
       lineSampleToWorld(theImageClipRect.ll(), ll);
+
+      if (debug)
+      {
+         cout << "4 corners from Projection: " << endl;
+         cout << ul << ", " << ur << ", " << lr << ", " << ll << endl;
+      }
+
+
       setGroundRect(ul, ur, lr, ll);  // ossimSensorModel method.
    }
    else
@@ -765,45 +815,52 @@ double ossimplugins::ossimTerraSarModel::getSlantRangeFromGeoreferenced(double c
   int maxIter = 50, nIter=0 ;
   double estimatedGroundRange, estimatedSlantRangeTime, actualGroundRange, estimatedSlantRange ; 
 
-  
-  // actual ground range computation relative to the image near side
-  // in the case of Georeferenced images, _refPoint->get_distance() contains the ground range
-  actualGroundRange = _refPoint->get_distance() - _sensor->get_col_direction() * (col-_refPoint->get_pix_col()) * _SrToGr_scaling_factor ; 
-
-  estimatedSlantRangeTime = _sceneCenterRangeTime ;
-  while ((fabs(iterError)>EPSILON)&& (nIter<maxIter)) {
-    // estimated ground range computation from SrToGr
-    estimatedGroundRange = 0.0 ; 
-    for (int i=0; i<_SrToGr_coeffs.size(); i++) {
-      estimatedGroundRange += _SrToGr_coeffs[i]*pow(estimatedSlantRangeTime-_SrToGr_R0,_SrToGr_exponent[i]);
-    }
-    
-    // comparison between the estimated ground range and the actual ground range
-    iterError = actualGroundRange - estimatedGroundRange ;
 
-    // estimated slant range update
-    estimatedSlantRangeTime += iterError * 2.0 / CLUM ; 
+// actual ground range computation relative to the image near side
+// in the case of Georeferenced images, _refPoint->get_distance() contains the ground range
+actualGroundRange = _refPoint->get_distance() - _sensor->get_col_direction() * (col-_refPoint->get_pix_col()) * _SrToGr_scaling_factor ; 
 
-    nIter++;
-  }
+estimatedSlantRangeTime = _sceneCenterRangeTime ;
+while ((fabs(iterError)>EPSILON)&& (nIter<maxIter)) {
+// estimated ground range computation from SrToGr
+estimatedGroundRange = 0.0 ; 
+for (int i=0; i<_SrToGr_coeffs.size(); i++) {
+estimatedGroundRange += _SrToGr_coeffs[i]*pow(estimatedSlantRangeTime-_SrToGr_R0,_SrToGr_exponent[i]);
+}
+
+// comparison between the estimated ground range and the actual ground range
+iterError = actualGroundRange - estimatedGroundRange ;
+
+// estimated slant range update
+estimatedSlantRangeTime += iterError * 2.0 / CLUM ; 
+
+nIter++;
+}
 
-  estimatedSlantRange = estimatedSlantRangeTime* CLUM / 2.0 ;
+estimatedSlantRange = estimatedSlantRangeTime* CLUM / 2.0 ;
 
-  return  estimatedSlantRange  ;
+return  estimatedSlantRange  ;
 }
 */
 
 bool ossimplugins::ossimTerraSarModel::InitSensorParams(
    const ossimKeywordlist &kwl, const char *prefix)
 {
+
+
+
+
    const char* central_freq_str = kwl.find(prefix,"central_freq");
    double central_freq = atof(central_freq_str);
    const char* fr_str = kwl.find(prefix,"fr");
    double fr = atof(fr_str);
    const char* fa_str = kwl.find(prefix,"fa");
    double fa = atof(fa_str);
-   
-   //number of different looks 
+
+
+
+
+   //number of different looks
    // const char* n_azilok_str = kwl.find(prefix,"n_azilok");
    // double n_azilok = atof(n_azilok_str);
    const char* n_rnglok_str = kwl.find(prefix,"n_rnglok");
@@ -1314,23 +1371,33 @@ bool ossimplugins::ossimTerraSarModel::initPlatformPosition(const ossimXmlDocume
 }
 
 bool ossimplugins::ossimTerraSarModel::initSensorParams(const ossimXmlDocument* xdoc,
-                                          const ossimTerraSarProductDoc& tsDoc)
+                                                        const ossimTerraSarProductDoc& tsDoc)
 {
    static const char MODULE[] = "ossimplugins::ossimTerraSarModel::initSensorParams";
-   
+   bool debug=true;
+
+
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)<< MODULE << " entered...\n";
    }
-   
+
+   if (debug)
+      cout << "Entering initSensorParams ...." << endl;
+
+
    if (_sensor )
    {
       delete _sensor;
    }
    _sensor =  new SensorParams();
-   
+
+
    bool result = tsDoc.initSensorParams(xdoc, _sensor);
 
+   if (debug)
+      cout << "result for  tsDoc.initSensorParams " << result << endl;
+
    if (!result)
    {
       delete _sensor;
diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp b/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp
index ccec450c49877b4cf27073077ad2f7a3bf1d6a40..aabb8e3e81e497e58c1960c2690f2c35fde259c8 100644
--- a/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp
@@ -4,8 +4,6 @@
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
-// Author:  David Burken
-//
 // Description: Utility class to encapsulate parsing TerraSAR-X product.xml
 // file.
 // 
@@ -730,9 +728,26 @@ bool ossimplugins::ossimTerraSarProductDoc::getReferencePoint(
 bool ossimplugins::ossimTerraSarProductDoc::getImageDataStrartWith(
    const ossimXmlDocument* xdoc, ossimString& s) const
 {
-   ossimString path =
-      "/level1Product/productSpecific/complexImageInfo/imageDataStartWith";
-   return ossim::getPath(path, xdoc, s);
+   bool result = true;
+   ossimString path = "/level1Product/productSpecific/complexImageInfo";
+   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
+   xdoc->findNodes(path, xnodes);
+   if ( xnodes.size() )
+   {
+      for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
+      {
+         if (xnodes[i].valid())
+         {
+            result = ossim::findFirstNode(ossimString("imageDataStartWith"),
+                                          xnodes[i], s);
+         }
+      }
+   }
+   else
+   {
+      result=false;
+   }
+   return result;
 }
 
 bool ossimplugins::ossimTerraSarProductDoc::getOrbitDirection(
@@ -849,33 +864,101 @@ bool ossimplugins::ossimTerraSarProductDoc::getAzimuthStopTime(
 bool ossimplugins::ossimTerraSarProductDoc::getCommonPrf(
    const ossimXmlDocument* xdoc, ossimString& s) const
 {
-   ossimString path =
-         "/level1Product/productSpecific/complexImageInfo/commonPRF";
-   return ossim::getPath(path, xdoc, s);
+   bool result = true;
+   ossimString path = "/level1Product/productSpecific/complexImageInfo";
+   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
+   xdoc->findNodes(path, xnodes);
+   if ( xnodes.size() )
+   {
+      for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
+      {
+         if (xnodes[i].valid())
+         {
+            result = ossim::findFirstNode(ossimString("commonPRF"),
+                                          xnodes[i], s);
+         }
+      }
+   }
+   else
+   {
+      result=false;
+   }
+   return result;
 }
 
 bool ossimplugins::ossimTerraSarProductDoc::getCommonRsf(
    const ossimXmlDocument* xdoc, ossimString& s) const
 {
-   ossimString path
-      = "/level1Product/productSpecific/complexImageInfo/commonRSF";
-   return ossim::getPath(path, xdoc, s);
+   bool result = true;
+   ossimString path = "/level1Product/productSpecific/complexImageInfo";
+   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
+   xdoc->findNodes(path, xnodes);
+   if ( xnodes.size() )
+   {
+      for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
+      {
+         if (xnodes[i].valid())
+         {
+            result = ossim::findFirstNode(ossimString("commonRSF"),
+                                          xnodes[i], s);
+         }
+      }
+   }
+   else
+   {
+      result=false;
+   }
+   return result;
 }
 
 bool ossimplugins::ossimTerraSarProductDoc::getNumberOfRangeLooks(
    const ossimXmlDocument* xdoc, ossimString& s) const
 {
-   ossimString path =
-      "/level1Product/processing/processingParameter/rangeLooks";
-   return ossim::getPath(path, xdoc, s);
+   bool result = true;
+   ossimString path = "/level1Product/processing/processingParameter";
+   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
+   xdoc->findNodes(path, xnodes);
+   if ( xnodes.size() )
+   {
+      for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
+      {
+         if (xnodes[i].valid())
+         {
+            result = ossim::findFirstNode(ossimString("rangeLooks"),
+                                          xnodes[i], s);
+         }
+      }
+   }
+   else
+   {
+      result=false;
+   }
+   return result;
 }
 
 bool ossimplugins::ossimTerraSarProductDoc::getNumberOfAzimuthLooks(
    const ossimXmlDocument* xdoc, ossimString& s) const
 {
-   ossimString path =
-      "/level1Product/processing/processingParameter/azimuthLooks";
-   return ossim::getPath(path, xdoc, s);
+   bool result = true;
+   ossimString path = "/level1Product/processing/processingParameter";
+   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
+   xdoc->findNodes(path, xnodes);
+   if ( xnodes.size() )
+   {
+      for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
+      {
+         if (xnodes[i].valid())
+         {
+            result = ossim::findFirstNode(ossimString("azimuthLooks"),
+                                          xnodes[i], s);
+         }
+      }
+   }
+   else
+   {
+      result=false;
+   }
+   return result;
 }
 
 bool ossimplugins::ossimTerraSarProductDoc::getNumberOfColumns(
diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.cpp b/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.cpp
index 88b7c5593f82e1664d3072a6fd7d508c25613e96..84a40b4ed0549d58e93308feea068d76696ad84c 100644
--- a/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.cpp
@@ -21,6 +21,8 @@
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimNotify.h>
 #include <ossim/base/ossimXmlDocument.h>
+#include <ossim/imaging/ossimImageGeometryRegistry.h>
+#include <ossim/projection/ossimProjection.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/support_data/ossimGeoTiff.h>
 
@@ -169,13 +171,15 @@ bool ossimplugins::ossimTerraSarTiffReader::open(const ossimFilename& file)
             {
                ossimFilename imageFile = file.expand().path();
                imageFile = imageFile.dirCat(s);
+
                setFilename(imageFile);
-               
-               result = ossimTiffTileSource::open();
 
+               result = ossimTiffTileSource::open();
                if (result)
                {
                   theProductXmlFile = file;
+
+                  completeOpen();
                }
             }
          }
@@ -201,120 +205,125 @@ void ossimplugins::ossimTerraSarTiffReader::close()
    ossimTiffTileSource::close();
 }
 
-bool ossimplugins::ossimTerraSarTiffReader::getImageGeometry(
-   ossimKeywordlist& kwl, const char* prefix)
+ossimImageGeometry* ossimplugins::ossimTerraSarTiffReader::getImageGeometry()
 {
-   static const char MODULE[] = "ossimplugins::ossimTerraSarTiffReader::getImageGeometry";
-   
-   if (traceDebug())
+   if ( !theGeometry.valid() )
    {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << MODULE << " entered...\n";
+      //---
+      // Check for external geom:
+      //---
+      getExternalImageGeometry();
+      
+      if ( !theGeometry.valid() )
+      {
+         //---
+         // Check the internal geometry first to avoid a factory call.
+         //---
+         getInternalImageGeometry();
+
+         // At this point it is assured theGeometry is set.
+
+         // Check for set projection.
+         if ( !theGeometry->getProjection() )
+         {
+            // Try factories for projection.
+            ossimImageGeometryRegistry::instance()->extendGeometry(this);
+         }
+      }
    }
    
-   if (theGeometryKwl.getSize())
+   // Lastly check for set decimation levels.  First time through...
+   if( getNumberOfDecimationLevels() != theGeometry->getNumberOfDecimations() )
    {
-      kwl.add(prefix, theGeometryKwl);
-      //kwl = theGeometryKwl;
-      return true;
+      std::vector<ossimDpt> decimationList;
+      getDecimationFactors(decimationList);
+      theGeometry->setDiscreteDecimation(decimationList);
    }
+
+   return theGeometry.get();
+}
+
+ossimImageGeometry*
+ossimplugins::ossimTerraSarTiffReader::getInternalImageGeometry()
+{
+   static const char MODULE[] =
+      "ossimplugins::ossimTerraSarTiffReader::getInternalImageGeometry";
    
-   bool result = false;
-   ossimRefPtr<ossimProjection> proj = 0;
-   ossimFilename filename = getFilenameWithThisExtension(ossimString(".geom"));
-   if(!filename.exists())
+   if (traceDebug())
    {
-      // Try tacking on the entry like "foo_e0.hdf".
-      filename = getFilenameWithThisExtension(ossimString(".geom"), true);
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << MODULE << " entered...\n";
    }
-   if(filename.exists())
-   {
-      if(kwl.addFile(filename))
-      {
-         ossimString tempPrefix =
-            "image"+ossimString::toString(getCurrentEntry())+".";
-         kwl.stripPrefixFromAll(tempPrefix);
-         
-         if(kwl.find(ossimKeywordNames::TYPE_KW))
-         {
-            ossimKeywordlist kwlTemp(kwl);
-            
-            kwlTemp.add(ossimKeywordNames::GEOM_FILE_KW,
-                        filename.c_str(),
-                        true);
 
-            proj = ossimProjectionFactoryRegistry::instance()->
-               createProjection(kwlTemp);
-            if(proj.valid())
-            {
-               result = true;
-               kwl.add(prefix, kwlTemp);//kwl = kwlTemp;
-            }
-         }
-      }
+   if ( !theGeometry )
+   {
+      theGeometry = new ossimImageGeometry();
    }
    
-   if(!result)
+   ossimXmlDocument* xdoc = new ossimXmlDocument();
+   if ( xdoc->openFile(theProductXmlFile) )
    {
-      ossimXmlDocument* xdoc = new ossimXmlDocument();
-      if ( xdoc->openFile(theProductXmlFile) )
+      ossimTerraSarProductDoc helper;
+      ossimString s;
+      if ( helper.getProjection(xdoc, s) )
       {
-         ossimTerraSarProductDoc helper;
-         ossimString s;
-         if ( helper.getProjection(xdoc, s) )
+         s.upcase();
+         if ( s == "GROUNDRANGE" )
          {
-            s.upcase();
-            if ( s == "GROUNDRANGE" )
+            ossimRefPtr<ossimTerraSarModel> model =
+               new ossimTerraSarModel();
+            if ( model->open(theProductXmlFile) )
             {
-               ossimTerraSarModel* model = new ossimTerraSarModel();
-               if ( model->open(theProductXmlFile) )
-               {
-                  result = model->saveState(kwl, prefix);
-               }
-               delete model;
-               model = 0;
+               // Assign the model to our ossimImageGeometry object.
+               theGeometry->setProjection( model.get() );
             }
-            else if (s == "MAP")
+         }
+         else if ( (s == "MAP") && theTiffPtr )
+         {
+            ossimGeoTiff geotiff;
+
+            //---
+            // Note: must pass false to readTags so it doesn't close our
+            // tiff pointer.
+            //---
+            geotiff.readTags(theTiffPtr, getCurrentEntry(), false);
+            ossimKeywordlist kwl;
+            if(geotiff.addImageGeometry(kwl))
             {
-               ossimGeoTiff* gtiff = new ossimGeoTiff( getFilename() );
-               if (gtiff->getErrorStatus() == ossimErrorCodes::OSSIM_OK)
+               ossimRefPtr<ossimProjection> proj =
+                  ossimProjectionFactoryRegistry::instance()->
+                     createProjection(kwl);
+            
+               if ( proj.valid() )
                {
-                  result = gtiff->addImageGeometry(kwl, prefix);
+                  // Assign projection to our ossimImageGeometry object.
+                  theGeometry->setProjection( proj.get() );
                }
-               delete gtiff;
-               gtiff = 0;
             }
-            else
+         }
+         else
+         {
+            if (traceDebug())
             {
-               if (traceDebug())
-               {
-                  ossimNotify(ossimNotifyLevel_DEBUG)
-                     << "WARNING: Unhandled projection: " << s << std::endl;
-                  
-               }
+               ossimNotify(ossimNotifyLevel_DEBUG)
+                  << "WARNING: Unhandled projection: " << s << std::endl;
+               
             }
          }
       }
-
-      delete xdoc;
-      xdoc = 0;
-   }
+      
+   } // matches: if ( xdoc->openFile(theProductXmlFile) )
    
-   if (result == true)
-   {
-      // Capture the geometry for next time.
-      theGeometryKwl.clear();
-      theGeometryKwl.add(kwl, prefix, true);
-   }
+   delete xdoc;
+   xdoc = 0;
 
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
-         << MODULE << " exit status = " << (result?"true":"false\n")
-         << std::endl;
+         << MODULE << " exited..." << std::endl;
    }
    
-   return result;
+   return theGeometry.get();
 }
 
 bool ossimplugins::ossimTerraSarTiffReader::isTerraSarProductFile(
diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.h b/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.h
index bb7411e4dba1996301782093c6e62b2c7ec0a750..15a46cca998e1149d8b6586ba21fba264d613056 100644
--- a/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.h
+++ b/Utilities/otbossimplugins/ossim/ossimTerraSarTiffReader.h
@@ -67,18 +67,17 @@ namespace ossimplugins
       virtual void close();
       
       /**
-       *  Populates the keyword list with image geometry information.  This
-       *  method is used to relay projection/model information to users.
-       *
-       *  @param kwl Keyword list that will be initialized with geometry info.
-       *  Returns true if geometry info is present, false if not.
-       *
-       *  @param prefix The prefix is added to the resulting keyword list
-       *  keywords.  So is you if you pass in a prefix of "image01.", the
-       *  keyword ul_lat will be like:  "image01.ul_lat:  -40.00000"
+       * Returns the image geometry object associated with this tile source or
+       * NULL if non defined.  The geometry contains full-to-local image
+       * transform as well as projection (image-to-world).
+       */
+      virtual ossimImageGeometry* getImageGeometry();
+
+      /**
+       * @param Method to get geometry from the xml file or internal geotiff
+       * tags.
        */
-      virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                    const char* prefix=0);   
+      virtual ossimImageGeometry* getInternalImageGeometry();
       
    private: