diff --git a/Testing/Code/VisuRefac/otbImageViewerEndToEndSingleLayer.cxx b/Testing/Code/VisuRefac/otbImageViewerEndToEndSingleLayer.cxx
index d6b78dba77985211981cfced35b7340f0c79454b..b5e29ec5592869c85069ad26eadaf0d42a5fad92 100644
--- a/Testing/Code/VisuRefac/otbImageViewerEndToEndSingleLayer.cxx
+++ b/Testing/Code/VisuRefac/otbImageViewerEndToEndSingleLayer.cxx
@@ -23,7 +23,7 @@ PURPOSE.  See the above copyright notices for more information.
 #include "otbImageLayerGenerator.h"
 #include "otbImageLayer.h"
 #include "otbImageView.h"
-#include <FL/Fl.h>
+#include <FL/Fl.H>
 #include "otbImageWidgetController.h"
 #include "otbWidgetResizingActionHandler.h"
 #include "otbChangeScaledExtractRegionActionHandler.h"
diff --git a/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h b/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h
index ad173488a227876bebd41fd23413f217225fe9aa..559eaa002844aa95e6c51adbee1497cf29660684 100644
--- a/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h
+++ b/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h
@@ -24,7 +24,7 @@
 
 namespace itk
 {
-/** /class FFTComplexConjugateToRealImageFilter
+/** \class FFTComplexConjugateToRealImageFilter
  * /brief 
  *
  * \ingroup 
diff --git a/Utilities/ITK/Code/Algorithms/itkFFTRealToComplexConjugateImageFilter.h b/Utilities/ITK/Code/Algorithms/itkFFTRealToComplexConjugateImageFilter.h
index 542001511740d9fb79669d51ffb61ae46749b57f..a22d3faa2c632f19e55655079afc1daa52713361 100644
--- a/Utilities/ITK/Code/Algorithms/itkFFTRealToComplexConjugateImageFilter.h
+++ b/Utilities/ITK/Code/Algorithms/itkFFTRealToComplexConjugateImageFilter.h
@@ -24,7 +24,7 @@
 
 namespace itk
 {
-/** /class FFTRealToComplexConjugateImageFilter
+/** \class FFTRealToComplexConjugateImageFilter
  * /brief 
  *
  * \ingroup 
diff --git a/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h b/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h
index ba6163d4409d567ded415c08abf7c8005e7c9472..358aea5d8214b746dd2372f71ed6b375ebfa1af5 100644
--- a/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h
+++ b/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h
@@ -23,7 +23,7 @@
 
 namespace itk
 {
-/** /class FFTWRealToComplexConjugateImageFilter
+/** \class FFTWRealToComplexConjugateImageFilter
  * /brief
  *
  * \ingroup
diff --git a/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h b/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h
index 0dfd3c109097762c3c4715a8c2d7fdaf34c591e7..ad7eba27c4abb34b189befc4046880d4b1f163be 100644
--- a/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h
+++ b/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h
@@ -24,7 +24,7 @@
 
 namespace itk{
 
-/** /class IsolatedWatershedImageFilter
+/** \class IsolatedWatershedImageFilter
  * \brief Isolate watershed basins using two seeds
  *
  * IsolatedWatershedImageFilter labels pixels with ReplaceValue1 that
diff --git a/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h b/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h
index 9a5d8c44cc9f1e6481cef8223a385e5f7f5a75d8..dc8ef1bf10e5606369e166433ca916d6e83f10f0 100644
--- a/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h
+++ b/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h
@@ -25,7 +25,7 @@
 
 namespace itk
 {
-/** /class FFTWComplexToComplexImageFilter
+/** \class FFTWComplexToComplexImageFilter
  *  /brief Implements an API to enable the Fourier transform or the inverse
  *  Fourier transform of images with complex valued voxels to be computed using
  *  either FFTW from MIT or the FFTW interface in Intel MKL.
@@ -34,7 +34,7 @@ namespace itk
  *
  * \author Simon K. Warfield simon.warfield@childrens.harvard.edu
  *
- * \note Attribution Notice. This research work was made possible by 
+ * \note Attribution Notice. This research work was made possible by
  * Grant Number R01 RR021885 (PI Simon K. Warfield, Ph.D.) from
  * the National Center for Research Resources (NCRR), a component of the
  * National Institutes of Health (NIH).  Its contents are solely the
@@ -95,8 +95,8 @@ protected:
       fftwf_destroy_plan(m_Plan);
       }
     }
-  
-  /** 
+
+  /**
    * these methods should be defined in every FFT filter class
    */
   virtual void GenerateData();  // generates output from input
diff --git a/Utilities/otbossim/CMakeLists.txt b/Utilities/otbossim/CMakeLists.txt
index 69179e93455f365881f802be38274cfcf64d5b1f..c9bd0d92ddbade040c686f3b478042734142b205 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 "9")
+SET(OSSIM_PATCH_VERSION_NUMBER "15")
 SET(OSSIM_RELEASE_NUMBER "?")
 SET(OSSIM_VERSION "${OSSIM_MAJOR_VERSION_NUMBER}-${OSSIM_MINOR_VERSION_NUMBER}-${OSSIM_PATCH_VERSION_NUMBER}" )
 
diff --git a/Utilities/otbossim/include/ossim/base/ossimConstants.h b/Utilities/otbossim/include/ossim/base/ossimConstants.h
index 0e7483689112d843d097448ec64a27272fd5db38..81087031c10e0abd05bcd4c9f5771af1a115dbb5 100644
--- a/Utilities/otbossim/include/ossim/base/ossimConstants.h
+++ b/Utilities/otbossim/include/ossim/base/ossimConstants.h
@@ -3,11 +3,11 @@
  * License:  See top level LICENSE.txt file.
  *
  * Author: Ken Melero
- * 
+ *
  * Description: Common file for global constants.
  *
  **************************************************************************
- * $Id$
+ * $Id: ossimConstants.h 13590 2008-09-24 12:35:43Z gpotts $
  */
 #ifndef ossimConstants_HEADER
 #define ossimConstants_HEADER
@@ -16,7 +16,7 @@
 extern "C" {
 #endif
 
-#ifdef __cplusplus   
+#ifdef __cplusplus
 #include <cfloat>
 #else
 #include <float.h>
@@ -48,7 +48,7 @@ extern "C" {
 #  define OSSIM_DLL
 #  define OSSIMDLLEXPORT_DATA(type) type
 #  define OSSIM_DLL_DATA(type) type
-#  define OSSIMDLLEXPORT_CTORFN 
+#  define OSSIMDLLEXPORT_CTORFN
 #elif defined(__MINGW32__) || defined(__CYGWIN__) || defined(_MSC_VER) || defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
 #  define OSSIMEXPORT __declspec(dllexport)
 #  define OSSIMIMPORT __declspec(dllimport)
@@ -242,7 +242,7 @@ typedef double                 ossim_float64;
 typedef long long              ossim_int64;
 typedef unsigned long long     ossim_uint64;
 typedef signed long long       ossim_sint64;
-   
+
 typedef ossim_int32            ossimErrorCode;
 
 enum ossimVertexOrdering
@@ -268,7 +268,7 @@ enum ossimPixelType
 */
 enum ossimScalarType
 {
-   OSSIM_SCALAR_UNKNOWN    =  0, 
+   OSSIM_SCALAR_UNKNOWN    =  0,
    OSSIM_UINT8             =  1, /**< 8 bit unsigned integer        */
    OSSIM_SINT8             =  2, /**< 8 bit signed integer          */
    OSSIM_UINT16            =  3, /**< 16 bit unsigned integer       */
diff --git a/Utilities/otbossim/include/ossim/base/ossimDate.h b/Utilities/otbossim/include/ossim/base/ossimDate.h
index d788fb0a362e1c0f2b419f516fcda0aa3948566c..6e51437f085ebdc6d82623bfe5139c446fecde41 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDate.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDate.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimDate.h 12992 2008-06-05 18:09:11Z gpotts $
+// $Id: ossimDate.h 13732 2008-10-17 19:47:43Z gpotts $
 #ifndef ossimDate_HEADER
 #define ossimDate_HEADER
 #include <ctime>
@@ -162,7 +162,8 @@ public:
     double getFractionalSecond()const;
     ossimLocalTm& setHour(int h);
     ossimLocalTm& setMin(int m);
-    ossimLocalTm& setSec(int s);
+   ossimLocalTm& setSec(int s);
+   ossimLocalTm& setFloatSec(double s);
     ossimLocalTm& setFractionalSecond(double fractS);
 
     /**
@@ -172,15 +173,15 @@ public:
     time_t getTicks()const;
     time_t getEpoc()const;
     
-    void addSeconds(ossim_float64 n);
-    void addMinutes(ossim_float64 n);
-    void addHours(ossim_float64 n);
-    void addDays(ossim_float64 n);
-    
-    ossim_float64 deltaInSeconds(const ossimLocalTm& d)const;
-    ossim_float64 deltaInMinutes(const ossimLocalTm& d)const;
-    ossim_float64 delatInHours(const ossimLocalTm& d)const;
-    ossim_float64 deltaInDays(const ossimLocalTm& d)const;
+   void addSeconds(ossim_float64 n);
+   void addMinutes(ossim_float64 n);
+   void addHours(ossim_float64 n);
+   void addDays(ossim_float64 n);
+   
+   ossim_float64 deltaInSeconds(const ossimLocalTm& d)const;
+   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.
      */ 
@@ -191,6 +192,8 @@ public:
      */ 
     void setTimeGivenEpoc(time_t ticks);
     
+   bool setIso8601(const std::string& timeString, bool shiftToGmtOffsetZero=false);
+   
     ossimRefPtr<ossimXmlNode> saveXml()const;
     bool loadXml(ossimRefPtr<ossimXmlNode> dateNode);
     
diff --git a/Utilities/otbossim/include/ossim/base/ossimDatum.h b/Utilities/otbossim/include/ossim/base/ossimDatum.h
index 4870d09606a211dab5df1d59d9d64fdac22be87c..903f8a404ad19b12773dabfa0ebeb3254a7b8b18 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDatum.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDatum.h
@@ -10,7 +10,7 @@
 // for Geotrans datum.  For more thorough description of each function
 // look at the datum.h file.
 //*******************************************************************
-//  $Id: ossimDatum.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimDatum.h 13560 2008-09-10 11:42:57Z gpotts $
 #ifndef ossimDatum_HEADER
 #define ossimDatum_HEADER
 #include <ossim/base/ossimConstants.h>
@@ -21,7 +21,18 @@
 class OSSIMDLLEXPORT ossimDatum
 {
 public:
-   ossimDatum(const ossimString &code, const ossimString &name,
+   /**
+    *   @param code           new datum code.                               (input)
+    *   @param name           Name of the new datum                         (input)
+    *   @param SigmaX         Standard error in X in meters                 (input)
+    *   @param SigmaY         Standard error in Y in meters                 (input)
+    *   @param SigmaZ         Standard error in Z in meters                 (input)
+    *   @param southLatitude  Southern edge of validity rectangle in radians(input)
+    *   @param northLatitude  Northern edge of validity rectangle in radians(input)
+    *   @param westLongitude  Western edge of validity rectangle in radians (input)
+    *   @param eastLongitude  Eastern edge of validity rectangle in radians (input)
+    */
+    ossimDatum(const ossimString &code, const ossimString &name,
               const ossimEllipsoid* anEllipsoid,
               ossim_float64 sigmaX, ossim_float64 sigmaY, ossim_float64 sigmaZ,
               ossim_float64 westLongitude, ossim_float64 eastLongitude,
diff --git a/Utilities/otbossim/include/ossim/base/ossimDatumFactory.h b/Utilities/otbossim/include/ossim/base/ossimDatumFactory.h
index 4d9952d5c7c96a86643bad6ded4400106bb493ab..a762245fb15a23804b68ce347e7fb1edcef9b2a0 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDatumFactory.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDatumFactory.h
@@ -9,11 +9,11 @@
 // This is the DatumFactory class.  You give it a code and it will
 // construct a Datum class.  It returns NULL if no code was found.
 //*******************************************************************
-//  $Id: ossimDatumFactory.h 12078 2007-11-26 14:35:57Z dburken $
+//  $Id: ossimDatumFactory.h 13302 2008-07-25 19:10:39Z gpotts $
 
 #ifndef ossimDatumFactory_HEADER
 #define ossimDatumFactory_HEADER
-#include <list>
+#include <vector>
 #include <map>
 
 #include <ossim/base/ossimDatumFactoryInterface.h>
@@ -45,8 +45,8 @@ public:
    static ossimDatumFactory* instance();
    const ossimDatum* wgs84()const{return theWgs84Datum;}
    const ossimDatum* wgs72()const{return theWgs72Datum;}
-   std::list<ossimString> getList()const;
-   virtual void getList(std::list<ossimString>& list)const;
+   std::vector<ossimString> getList()const;
+   virtual void getList(std::vector<ossimString>& list)const;
    void writeCStructure(const ossimFilename& file);
 protected:
    static ossimDatumFactory*       theInstance;
diff --git a/Utilities/otbossim/include/ossim/base/ossimDatumFactoryInterface.h b/Utilities/otbossim/include/ossim/base/ossimDatumFactoryInterface.h
index 0fea949a1d773f09be6a9a795f9709cf4e0a09e0..541463b803efa217aa67ed468be339bba9adce85 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDatumFactoryInterface.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDatumFactoryInterface.h
@@ -40,7 +40,7 @@ public:
     *
     * @param list The list to add to.
     */
-   virtual void getList(std::list<ossimString>& list) const = 0;
+   virtual void getList(std::vector<ossimString>& list) const = 0;
 };
 
 #endif /* #ifndef ossimDatumFactoryInterface_HEADER */
diff --git a/Utilities/otbossim/include/ossim/base/ossimDatumFactoryRegistry.h b/Utilities/otbossim/include/ossim/base/ossimDatumFactoryRegistry.h
index 6ab8a96e230cec72bf9c891c093a44346db773f9..149838a96069f735764c20fb9a90233fe7bc4fd8 100644
--- a/Utilities/otbossim/include/ossim/base/ossimDatumFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/base/ossimDatumFactoryRegistry.h
@@ -13,7 +13,6 @@
 #define ossimDatumFactoryRegistry_HEADER
 
 #include <vector>
-#include <list>
 #include <ossim/base/ossimConstants.h> /* for OSSIM_DLL macro */
 #include <OpenThreads/ReadWriteMutex>
 
@@ -57,9 +56,9 @@ public:
     *
     * @param list The list to add to.
     */
-   void getList(std::list<ossimString>& list) const;
+   void getList(std::vector<ossimString>& list) const;
    
-private:
+protected:
 
    /** hidden from use default constructor */
    ossimDatumFactoryRegistry();
@@ -72,7 +71,7 @@ private:
       const ossimDatumFactoryRegistry& rhs);
 
    /** Single static instance of this class. */
-   static ossimDatumFactoryRegistry* theInstance;
+   //static ossimDatumFactoryRegistry* theInstance;
 
    mutable OpenThreads::ReadWriteMutex theFactoryListMutex;
    std::vector<ossimDatumFactoryInterface*> theFactoryList;
diff --git a/Utilities/otbossim/include/ossim/base/ossimDrect.h b/Utilities/otbossim/include/ossim/base/ossimDrect.h
index 502f8d7f28153e0c64424b954038bec84e3d57cd..6e719fbc52a87524d84919f67b2e6f94b5fe3b99 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 11346 2007-07-23 12:59:48Z gpotts $
+//  $Id: ossimDrect.h 13672 2008-10-03 15:06:47Z gpotts $
 
 #ifndef ossimDrect_HEADER
 #define ossimDrect_HEADER
@@ -451,15 +451,16 @@ public:
 
    /*!
     * Returns true if "pt" falls within rectangle.  Fall on an edge is also
-    * considered to be within.
+    * considered to be within.  The edge is expanded by epsilon value so any value
+    * within epsilon is inside
     */
-   bool pointWithin(const ossimDpt& pt) const;
+   bool pointWithin(const ossimDpt& pt, double epsilon=0.0) const;
 
    /*!
     * Returns true if "pt" falls within rectangle.  Fall on an edge is also
     * considered to be within.
     */
-   bool pointWithin(const ossimFpt& pt) const;
+   bool pointWithin(const ossimFpt& pt, double epsilon=0.0) const;
 
    /*!
     * Returns true if any portion of an input rectangle "rect" intersects
@@ -695,36 +696,37 @@ inline void ossimDrect::set_lly(ossim_float64 y)
 //*******************************************************************
 // Inline Method: ossimDrect::pointWithin(const ossimDpt& pt) 
 //*******************************************************************
-inline bool ossimDrect::pointWithin(const ossimDpt& pt) const
+inline bool ossimDrect::pointWithin(const ossimDpt& pt, double epsilon) const
 {
    if (theOrientMode == OSSIM_LEFT_HANDED)
-      return ((pt.x >= ul().x) &&
-              (pt.x <= ur().x) &&
-              (pt.y >= ul().y) &&
-              (pt.y <= ll().y));
-   else
-      return ((pt.x >= ul().x) &&
-              (pt.x <= ur().x) &&
-              (pt.y <= ul().y) &&
-              (pt.y >= ll().y));
+   {
+      return ((pt.x >= (ul().x-epsilon)) &&
+              (pt.x <= (ur().x+epsilon)) &&
+              (pt.y >= (ul().y-epsilon)) &&
+              (pt.y <= (ll().y+epsilon)));
+   }
+   return ((pt.x >= (ul().x-epsilon)) &&
+           (pt.x <= (ur().x+epsilon)) &&
+           (pt.y <= (ul().y+epsilon)) &&
+           (pt.y >= (ll().y-epsilon)));
 }
 
 //*******************************************************************
 // Inline Method: ossimDrect::pointWithin(const ossimFpt& pt)
 //*******************************************************************
-inline bool ossimDrect::pointWithin(const ossimFpt& pt) const
+inline bool ossimDrect::pointWithin(const ossimFpt& pt, double epsilon) const
 {
    if (theOrientMode == OSSIM_LEFT_HANDED)
    {
-      return ( (pt.x >= ul().x) &&
-               (pt.x <= ur().x) &&
-               (pt.y >= ul().y) &&
-               (pt.y <= ll().y) );
+      return ((pt.x >= (ul().x-epsilon)) &&
+              (pt.x <= (ur().x+epsilon)) &&
+              (pt.y >= (ul().y-epsilon)) &&
+              (pt.y <= (ll().y+epsilon)));
    }
-   return ((pt.x >= ul().x) &&
-           (pt.x <= ur().x) &&
-           (pt.y <= ul().y) &&
-           (pt.y >= ll().y));
+   return ((pt.x >= (ul().x-epsilon)) &&
+           (pt.x <= (ur().x+epsilon)) &&
+           (pt.y <= (ul().y+epsilon)) &&
+           (pt.y >= (ll().y-epsilon)));
 }
 
 //*******************************************************************
diff --git a/Utilities/otbossim/include/ossim/base/ossimEvent.h b/Utilities/otbossim/include/ossim/base/ossimEvent.h
index 86631a5d10658b8f79fa645dcb818316b8635fda..a828d043502932902a465730aabe4d3705263c79 100644
--- a/Utilities/otbossim/include/ossim/base/ossimEvent.h
+++ b/Utilities/otbossim/include/ossim/base/ossimEvent.h
@@ -7,7 +7,7 @@
 //
 //
 //*************************************************************************
-// $Id: ossimEvent.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimEvent.h 13362 2008-08-01 14:02:32Z gpotts $
 #ifndef ossimEvent_HEADER
 #define ossimEvent_HEADER
 #include <ossim/base/ossimEventIds.h>
@@ -16,7 +16,12 @@
 class OSSIMDLLEXPORT ossimEvent : public ossimObject
 {
 public:
-
+   enum PropagationType
+   {
+      PROPAGATION_NONE = 0,
+      PROPAGATION_INPUT = 1,
+      PROPAGATION_OUTPUT = 2
+   };
    /**
     * @param object The object associated with the event if any.
     *
@@ -34,15 +39,27 @@ public:
    void setConsumedFlag(bool flag=true);
    void consume();
 
+   /**
+    * This is the originating object that originally 
+    * produced the event.
+    */
    const ossimObject* getObject()const;
    ossimObject*       getObject();
+   const ossimObject* getCurrentObject()const;
+   ossimObject*       getCurrentObject();
 
    void setObject(ossimObject* object);
+   void setCurrentObject(ossimObject* object);
 
+   void setPropagationType(PropagationType type);
+   bool isPropagatingToOutputs()const;
+   bool isPropagatingToInputs()const;
 protected:
    ossimObject* theObject;
+   ossimObject* theCurrentObject;
    long         theId;
    bool         theIsConsumedFlag;
+   PropagationType thePropagationType;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/base/ossimGpt.h b/Utilities/otbossim/include/ossim/base/ossimGpt.h
index 8ca40830e2f3894726c0a1fdd7a1aabeb9dd222a..559da82a66aa4d33a0e9017a553e59eafeea9b9d 100644
--- a/Utilities/otbossim/include/ossim/base/ossimGpt.h
+++ b/Utilities/otbossim/include/ossim/base/ossimGpt.h
@@ -13,7 +13,7 @@
 // Height is relative to the ellipsoid in meters.
 //
 //*******************************************************************
-//  $Id: ossimGpt.h 11495 2007-08-06 09:16:43Z dburken $
+//  $Id: ossimGpt.h 13238 2008-07-25 01:14:42Z gpotts $
 
 #ifndef gpt_HEADER
 #define gpt_HEADER
@@ -24,10 +24,10 @@
 #include <ossim/base/ossimDatumFactory.h>
 #include <ossim/base/ossimString.h>
 
-class OSSIMDLLEXPORT ossimDatum;
-class OSSIMDLLEXPORT ossimEcefPoint;
+class  ossimDatum;
+class  ossimEcefPoint;
 
-class OSSIMDLLEXPORT ossimGpt
+class OSSIM_DLL ossimGpt
 {
 public:
    /**
diff --git a/Utilities/otbossim/include/ossim/base/ossimGrect.h b/Utilities/otbossim/include/ossim/base/ossimGrect.h
index 3bd53e4d1dc701a8dd3c30f96e94ffcffcade9c0..1b3f2c853354d72a8b8faba36a2cd22dfa41a411 100644
--- a/Utilities/otbossim/include/ossim/base/ossimGrect.h
+++ b/Utilities/otbossim/include/ossim/base/ossimGrect.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGrect.h 11955 2007-10-31 16:10:22Z gpotts $
+// $Id: ossimGrect.h 13357 2008-07-31 12:45:29Z gpotts $
 #ifndef ossimGrect_HEADER
 #define ossimGrect_HEADER
 #include <vector>
@@ -64,10 +64,10 @@ public:
     * Takes the upper left and lower right ground
     * points
     */
-   ossimGrect(const double ulLat,
-              const double ulLon,
-              const double lrLat,
-              const double lrLon,
+   ossimGrect(double ulLat,
+              double ulLon,
+              double lrLat,
+              double lrLon,
               const ossimDatum* aDatum=ossimDatumFactory::instance()->wgs84())
       : 
          theUlCorner(ulLat, ulLon,0, aDatum),
diff --git a/Utilities/otbossim/include/ossim/base/ossimGzStream.h b/Utilities/otbossim/include/ossim/base/ossimGzStream.h
index 8ba688c073484e3da21700d18d199b6c292fb067..f338cbb0d6a2027eae5926a1f57440f2d9201a73 100644
--- a/Utilities/otbossim/include/ossim/base/ossimGzStream.h
+++ b/Utilities/otbossim/include/ossim/base/ossimGzStream.h
@@ -19,7 +19,7 @@
 //
 // File          : gzstream.h
 // Revision      : $Revision: 13050 $
-// Revision_date : $Date: 2008-06-19 20:07:35 +0200 (Thu, 19 Jun 2008) $
+// Revision_date : $Date: 2008-06-20 02:07:35 +0800 (Fri, 20 Jun 2008) $
 // Author(s)     : Deepak Bandyopadhyay, Lutz Kettner
 // 
 // Standard streambuf implementation following Nicolai Josuttis, "The 
@@ -68,7 +68,7 @@ public:
 /*                              std::ios_base::out); */
    
 private:
-   struct PrivateData;
+	struct PrivateData;
    int flush_buffer();
 
    static const int bufferSize = 303; // 47+256 size of data buff
diff --git a/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h b/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h
index 18846b6aa1edb5a2e257b88d2a88094bc7108b20..ffd14323e16dc26e39f040d9d4160a936e03d446 100644
--- a/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/base/ossimObjectFactoryRegistry.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimObjectFactoryRegistry.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimObjectFactoryRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
 #ifndef ossimObjectFactoryRegistry_HEADER
 #define ossimObjectFactoryRegistry_HEADER
 #include <vector>
@@ -57,11 +57,10 @@ public:
                                 const ossimString& baseType)const;
    
 protected:
-   ossimObjectFactoryRegistry(){}//hide
+   ossimObjectFactoryRegistry();//hide
    ossimObjectFactoryRegistry(const ossimObjectFactoryRegistry&):ossimObject(){}//hide
    void operator =(const ossimObjectFactoryRegistry&){}//hide
    
-   static ossimObjectFactoryRegistry* theInstance;
    std::vector<ossimObjectFactory*>   theFactoryList;
 
    ossimObjectFactory* findFactory(ossimObjectFactory* factory)const;
diff --git a/Utilities/otbossim/include/ossim/base/ossimReferenced.h b/Utilities/otbossim/include/ossim/base/ossimReferenced.h
index 9258737446ebf4a87456fe6762e81dba0d5361ec..db20a8063f3f6acd925906a0ab8ac6dea6281815 100644
--- a/Utilities/otbossim/include/ossim/base/ossimReferenced.h
+++ b/Utilities/otbossim/include/ossim/base/ossimReferenced.h
@@ -5,24 +5,27 @@
 #ifndef ossimReferenced_HEADER
 #define ossimReferenced_HEADER
 #include <ossim/base/ossimConstants.h>
+#include <OpenThreads/ScopedLock>
+#include <OpenThreads/Mutex>
 
 class OSSIMDLLEXPORT ossimReferenced
 {
  public:
    ossimReferenced()
-      : theRefCount(0)
+   : theRefMutex(new OpenThreads::Mutex),
+     theRefCount(0)
       {}
    
    ossimReferenced(const ossimReferenced&)
-      : theRefCount(0)
-      {}
-   
+   : theRefMutex(new OpenThreads::Mutex),
+   theRefCount(0)
+   {}
    inline ossimReferenced& operator = (const ossimReferenced&) { return *this; }
    
 
    /*! increment the reference count by one, indicating that 
        this object has another pointer which is referencing it.*/
-   inline void ref() const { ++theRefCount; }
+   inline void ref() const;
    
    /*! decrement the reference count by one, indicating that 
        a pointer to this object is referencing it.  If the
@@ -36,7 +39,18 @@ class OSSIMDLLEXPORT ossimReferenced
        should only be called if the user knows exactly who will
        be resonsible for, one should prefer unref() over unref_nodelete() 
        as the later can lead to memory leaks.*/
-   inline void unref_nodelete() const { --theRefCount; }
+   inline void unref_nodelete() const 
+   { 
+      if (theRefMutex)
+      {
+         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*theRefMutex); 
+         --theRefCount;
+      }
+      else
+      {
+         --theRefCount;
+      }
+   }
    
    /*! return the number pointers currently referencing this object. */
    inline int referenceCount() const { return theRefCount; }
@@ -44,16 +58,50 @@ class OSSIMDLLEXPORT ossimReferenced
    
  protected:
    virtual ~ossimReferenced();
+   mutable OpenThreads::Mutex*     theRefMutex;
    mutable int theRefCount;
 };
 
+inline void ossimReferenced::ref() const
+{
+   if (theRefMutex)
+   {
+      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*theRefMutex); 
+      ++theRefCount;
+   }
+   else
+   {
+      ++theRefCount;
+   }
+}
+
 inline void ossimReferenced::unref() const
 {
+   bool needDelete = false;
+   if (theRefMutex)
+   {
+      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*theRefMutex); 
+      --theRefCount;
+      needDelete = theRefCount<=0;
+   }
+   else
+   {
+      --theRefCount;
+      needDelete = theRefCount<=0;
+   }
+   
+   if (needDelete)
+   {
+      delete this;
+   }
+   
+#if 0
     --theRefCount;
     if (theRefCount==0)
     {
         delete this;
     }
+#endif
 }
 
 #endif
diff --git a/Utilities/otbossim/include/ossim/base/ossimRegExp.h b/Utilities/otbossim/include/ossim/base/ossimRegExp.h
index 2f219624498a561ea12e6c0d3c4987948cfde21c..ad769c51e816bb0b8d963d8cfaf37130cd8fcf20 100644
--- a/Utilities/otbossim/include/ossim/base/ossimRegExp.h
+++ b/Utilities/otbossim/include/ossim/base/ossimRegExp.h
@@ -159,7 +159,11 @@ inline ossimRegExp::ossimRegExp (const char* s) {
 
 inline ossimRegExp::~ossimRegExp () {
 //#ifndef WIN32
-  delete [] this->program;
+   if(program)
+   {
+      delete [] this->program;
+      this->program = 0;
+   }
 //#endif
 }
 
diff --git a/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h b/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h
index 86e225a5be7b11cdc9780a9a8e43f20aee505cda..ad4cd63629667f96e39c99ede252ccfe22130d30 100644
--- a/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h
+++ b/Utilities/otbossim/include/ossim/base/ossimSevenParamDatum.h
@@ -9,7 +9,7 @@
 // SevenParamDatum. This is a base class for all
 // seven param datums.
 //*******************************************************************
-//  $Id: ossimSevenParamDatum.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimSevenParamDatum.h 13560 2008-09-10 11:42:57Z gpotts $
 
 #ifndef ossimSevenParamDatum_HEADER
 #define ossimSevenParamDatum_HEADER
@@ -19,6 +19,24 @@ class OSSIMDLLEXPORT ossimEllipsoid;
 class OSSIM_DLL ossimSevenParamDatum : public ossimDatum
 {
 public:
+   /**
+    *   @param code           new datum code.                               (input)
+    *   @param name           Name of the new datum                         (input)
+    *   @param SigmaX         Standard error in X in meters                 (input)
+    *   @param SigmaY         Standard error in Y in meters                 (input)
+    *   @param SigmaZ         Standard error in Z in meters                 (input)
+    *   @param southLatitude  Southern edge of validity rectangle in radians(input)
+    *   @param northLatitude  Northern edge of validity rectangle in radians(input)
+    *   @param westLongitude  Western edge of validity rectangle in radians (input)
+    *   @param eastLongitude  Eastern edge of validity rectangle in radians (input)
+    *   @param param1         X translation
+    *   @param param2         Y translation
+    *   @param param3         Z translation
+    *   @param param4         X Rotation
+    *   @param param5         Y Rotation
+    *   @param param6         Z Rotation
+    *   @param param7         x,y,z Scale
+    */
    ossimSevenParamDatum(const ossimString &code, const ossimString &name,
                         const ossimEllipsoid* anEllipsoid,
                         ossim_float64 sigmaX,
diff --git a/Utilities/otbossim/include/ossim/base/ossimString.h b/Utilities/otbossim/include/ossim/base/ossimString.h
index 52f2525cc3980e9ae024c27de254063130e06aea..0695a6b654c9c9b7cc60c2ef80699d71cd81e5e6 100644
--- a/Utilities/otbossim/include/ossim/base/ossimString.h
+++ b/Utilities/otbossim/include/ossim/base/ossimString.h
@@ -7,7 +7,7 @@
 // Description: This class extends the stl's string class.
 //
 //********************************************************************
-// $Id: ossimString.h 13141 2008-07-06 20:19:03Z dburken $
+// $Id: ossimString.h 13586 2008-09-17 01:35:25Z gpotts $
 #ifndef ossimString_HEADER
 #define ossimString_HEADER 1
 
@@ -43,7 +43,7 @@ public:
    ossimString(char aChar):std::string(1, aChar){}
    
    template <class Iter>
-	   ossimString(Iter start, Iter end):std::string(start, end){}
+	   ossimString(Iter startIter, Iter endIter):std::string(startIter, endIter){}
 
    bool contains(const ossimString& aString) const {return find(aString)!=npos;}
    bool contains(const char*   aString) const {return find(aString)!=npos;}
@@ -398,7 +398,7 @@ public:
    ossimString urlEncode()const;
    /**
     * If OSSIM_ID_ENABLED returns the OSSIM_ID which currently is the
-    * expanded cvs $Id: ossimString.h 13141 2008-07-06 20:19:03Z dburken $ macro; else, an empty string.
+    * expanded cvs $Id: ossimString.h 13586 2008-09-17 01:35:25Z gpotts $ macro; else, an empty string.
     */
    ossimString getOssimId() const;
 };
diff --git a/Utilities/otbossim/include/ossim/base/ossimThreeParamDatum.h b/Utilities/otbossim/include/ossim/base/ossimThreeParamDatum.h
index d9dcd9d8391fa712bcbb2b322ec8d10d5322396b..3ff373137d3394dab7771f699b830cfaa1b07d0d 100644
--- a/Utilities/otbossim/include/ossim/base/ossimThreeParamDatum.h
+++ b/Utilities/otbossim/include/ossim/base/ossimThreeParamDatum.h
@@ -9,7 +9,7 @@
 // ossimThreeParamDatum. This is a base class for all
 // three param datums.
 //*******************************************************************
-//  $Id: ossimThreeParamDatum.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimThreeParamDatum.h 13560 2008-09-10 11:42:57Z gpotts $
 
 #ifndef ossimThreeParamDatum_HEADER
 #define ossimThreeParamDatum_HEADER
@@ -18,6 +18,20 @@
 class OSSIMDLLEXPORT ossimThreeParamDatum : public ossimDatum
 {
 public:
+   /**
+    *   @param code           new datum code.                               (input)
+    *   @param name           Name of the new datum                         (input)
+    *   @param SigmaX         Standard error in X in meters                 (input)
+    *   @param SigmaY         Standard error in Y in meters                 (input)
+    *   @param SigmaZ         Standard error in Z in meters                 (input)
+    *   @param southLatitude  Southern edge of validity rectangle in radians(input)
+    *   @param northLatitude  Northern edge of validity rectangle in radians(input)
+    *   @param westLongitude  Western edge of validity rectangle in radians (input)
+    *   @param eastLongitude  Eastern edge of validity rectangle in radians (input)
+    *   @param param1         X translation
+    *   @param param2         Y translation
+    *   @param param3         Z translation
+    */
    ossimThreeParamDatum(const ossimString &code, const ossimString &name,
                         const ossimEllipsoid* anEllipsoid,
                         ossim_float64 sigmaX,
diff --git a/Utilities/otbossim/include/ossim/base/ossimWms.h b/Utilities/otbossim/include/ossim/base/ossimWms.h
index c3e2e24fa83ce5415e652bcf39282e236a70c25b..4e70acba8641851673bb92d894f615c3f74d0d97 100644
--- a/Utilities/otbossim/include/ossim/base/ossimWms.h
+++ b/Utilities/otbossim/include/ossim/base/ossimWms.h
@@ -34,7 +34,7 @@ public:
    {
       return theFormatTypes;
    }
-   bool hasFomrats()const
+   bool hasFormats()const
    {
       return theFormatTypes.size() > 0;
    }
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimElevSourceFactory.h b/Utilities/otbossim/include/ossim/elevation/ossimElevSourceFactory.h
index d3b1d38b6138994884c8847893e09f7b5fdd6c42..28c87ec3493d554d5828573e6b081e8684e24737 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimElevSourceFactory.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimElevSourceFactory.h
@@ -21,7 +21,7 @@
 // new'd from the method.
 // 
 //----------------------------------------------------------------------------
-// $Id: ossimElevSourceFactory.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimElevSourceFactory.h 13269 2008-07-25 14:27:36Z dburken $
 
 #ifndef ossimElevSourceFactory_HEADER
 #define ossimElevSourceFactory_HEADER
@@ -54,7 +54,6 @@ public:
     *  allocated.
     */
    virtual ossimElevSource* getNewElevSource(const ossimGpt& gpt)const=0;
-   virtual void createIndex()=0;
 
    /**
     * @return The directory the factory returns data from.
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimElevationShapeIdx.h b/Utilities/otbossim/include/ossim/elevation/ossimElevationShapeIdx.h
deleted file mode 100644
index 6f55b6b5c31e9430709338ad78223a08fb592b96..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/elevation/ossimElevationShapeIdx.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef ossimElevationShapeIdx_HEADER
-#define ossimElevationShapeIdx_HEADER
-#include <exception>
-#include <ossim/base/ossimObject.h>
-#include <ossim/base/ossimRefPtr.h>
-#include <ossim/base/ossimFilename.h>
-
-class ossimElevationShapeIdxPrivate;
-
-class ossimElevationShapeIdx : public ossimObject
-{
-public:
-   ossimElevationShapeIdx(const ossimFilename& shapeFilename = "",
-                          bool overWriteFlag = false);
-   virtual ~ossimElevationShapeIdx();
-   void setFilename(const ossimFilename& file, bool overWriteFlag=false);
-
-   void add(const ossimFilename& filename,
-            ossim_float64 minx,  // decimal degrees
-            ossim_float64 miny,  // decimal degrees
-            ossim_float64 minz,  // height in meters meters 
-            ossim_float64 maxx,  // decimal degrees
-            ossim_float64 maxy,  // decimal degrees
-            ossim_float64 maxz); // height in meters meters
-
-   void buildQuadTree(int maxDepth=0);
-   static const ossimString& defaultName();
-
-protected:
-   static ossimString theDefaultName;
-   ossimElevationShapeIdxPrivate* thePrivateData;
-
-   ossimFilename theShapeFilename;
-   ossim_float64 theGlobalMinx;
-   ossim_float64 theGlobalMiny;
-   ossim_float64 theGlobalMaxx;
-   ossim_float64 theGlobalMaxy;
-   
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevFactory.h b/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevFactory.h
index 025281c0854346ab722e4da993fe493b1293e659..111ba31735ff4d8e3a544ef06feed386bf56252d 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevFactory.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevFactory.h
@@ -10,12 +10,11 @@
 // elevation handler for general raster elevation files.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimGeneralRasterElevFactory.h 11441 2007-07-30 15:17:55Z gpotts $
+// $Id: ossimGeneralRasterElevFactory.h 13269 2008-07-25 14:27:36Z dburken $
 #ifndef ossimGeneralRasterElevFactory_HEADER
 #define ossimGeneralRasterElevFactory_HEADER
 
 #include <ossim/elevation/ossimElevSourceFactory.h>
-#include <ossim/elevation/ossimElevationShapeIdx.h>
 #include <ossim/base/ossimDrect.h>
 #include <ossim/elevation/ossimGeneralRasterElevHandler.h>
 
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevHandler.h b/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevHandler.h
index 7bf65a50d914cceb086f7d012f068f9e98d97ddd..0377c0fd1537f48cfdec95692ad0f353e9b3d76b 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevHandler.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimGeneralRasterElevHandler.h
@@ -8,7 +8,7 @@
 // 
 //
 //----------------------------------------------------------------------------
-// $Id: ossimGeneralRasterElevHandler.h 12874 2008-05-17 01:12:54Z gpotts $
+// $Id: ossimGeneralRasterElevHandler.h 13524 2008-09-02 16:22:15Z gpotts $
 #ifndef ossimGeneralRasterElevHandler_HEADER
 #define ossimGeneralRasterElevHandler_HEADER
 #include <list>
@@ -19,55 +19,65 @@
 #include <ossim/base/ossimDatum.h>
 #include <ossim/elevation/ossimElevCellHandler.h>
 #include <ossim/imaging/ossimGeneralRasterInfo.h>
-#include <OpenThreads/ReentrantMutex>
-
+#include <ossim/imaging/ossimImageHandlerRegistry.h>
+#include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/imaging/ossimImageSource.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/projection/ossimMapProjection.h>
+#include <ossim/projection/ossimImageViewTransform.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimGpt.h>
+class ossimProjection;
 /**
  * @class ossimGeneralRasterElevHandler Elevation source for an srtm file.
  */
-class OSSIM_DLL ossimGeneralRasterElevHandler : public ossimElevCellHandler
+class  OSSIM_DLL ossimGeneralRasterElevHandler : public ossimElevCellHandler
 {
 public:
-      class GeneralRasterInfo
-   {
-   public:
-      GeneralRasterInfo()
-         :thePostSpacing(0.0,0.0),
-         theNumberOfSamples(0),
-         theNumberOfLines(0),
+   class GeneralRasterInfo
+      {
+      public:
+         GeneralRasterInfo()
+         :theWidth(0),
+         theHeight(0),
          theNullHeightValue(ossim::nan()),
          theScalarType(OSSIM_SCALAR_UNKNOWN),
          theBytesPerRawLine(0),
-         theDatum(0)
-      {
-      }
-      GeneralRasterInfo(const  ossimGeneralRasterElevHandler::GeneralRasterInfo& src)
+         theDatum(0),
+         theProjection(0)
+         {
+         }
+         GeneralRasterInfo(const  ossimGeneralRasterElevHandler::GeneralRasterInfo& src)
          :theFilename(src.theFilename),
-         theBounds(src.theBounds),
-         thePostSpacing(src.thePostSpacing),
-         theUlGpt(src.theUlGpt),
-         theLrGpt(src.theLrGpt),
-         theNumberOfSamples(src.theNumberOfSamples),
-         theNumberOfLines(src.theNumberOfLines),
+         theImageRect(src.theImageRect),
+         theUl(src.theUl),
+         theLr(src.theLr),
+         theWidth(src.theWidth),
+         theHeight(src.theHeight),
+         theWgs84GroundRect(src.theWgs84GroundRect),
          theNullHeightValue(src.theNullHeightValue),
          theByteOrder(src.theByteOrder),
          theScalarType(src.theScalarType),
          theBytesPerRawLine(src.theBytesPerRawLine),
-         theDatum(src.theDatum)
-      {
-      }
-      ossimFilename     theFilename;
-      ossimDrect        theBounds;
-      ossimDpt          thePostSpacing;
-      ossimGpt          theUlGpt;
-      ossimGpt          theLrGpt;
-      ossim_int32       theNumberOfSamples;
-      ossim_int32       theNumberOfLines;
-      ossim_float64     theNullHeightValue;
-      ossimByteOrder    theByteOrder;
-      ossimScalarType   theScalarType;
-      ossim_uint32      theBytesPerRawLine;
-      const ossimDatum* theDatum; 
-   };
+         theDatum(src.theDatum),
+         theProjection(src.theProjection)
+         {
+         }
+         ossimFilename     theFilename;
+         ossimIrect        theImageRect;
+         ossimIpt          theUl;
+         ossimIpt          theLr;
+         ossim_uint32      theWidth;
+         ossim_uint32      theHeight;
+         ossimDrect        theWgs84GroundRect;
+         ossim_float64     theNullHeightValue;
+         ossimByteOrder    theByteOrder;
+         ossimScalarType   theScalarType;
+         ossim_uint32      theBytesPerRawLine;
+         const ossimDatum* theDatum;
+         ossimRefPtr<ossimProjection> theProjection;  //add by simbla
+      };
    ossimGeneralRasterElevHandler(const ossimFilename& file="");
    ossimGeneralRasterElevHandler(const ossimGeneralRasterElevHandler::GeneralRasterInfo& generalRasterInfo);
    ossimGeneralRasterElevHandler(const ossimGeneralRasterElevHandler& rhs);
@@ -132,7 +142,6 @@ public:
    const ossimGeneralRasterElevHandler::GeneralRasterInfo& generalRasterInfo()const;
    
 private:
-	OpenThreads::ReentrantMutex theMutex;
    template <class T>
    double getHeightAboveMSLTemplate(T dummy,
                                     const ossimGeneralRasterElevHandler::GeneralRasterInfo& info,
@@ -141,6 +150,7 @@ private:
    
    ossimGeneralRasterElevHandler::GeneralRasterInfo theGeneralRasterInfo;
    mutable ossimRefPtr<ossimIFStream> theInputStream;
+
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/elevation/ossimSrtmFactory.h b/Utilities/otbossim/include/ossim/elevation/ossimSrtmFactory.h
index dfee3148dacf6908dfdf59e0b86b11d1ccbecbb9..026bc9576d3de732c584e9311cdac860cdab6b5c 100644
--- a/Utilities/otbossim/include/ossim/elevation/ossimSrtmFactory.h
+++ b/Utilities/otbossim/include/ossim/elevation/ossimSrtmFactory.h
@@ -13,7 +13,7 @@
 // ossimSrtmElevSource given a ground point.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimSrtmFactory.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimSrtmFactory.h 13269 2008-07-25 14:27:36Z dburken $
 #ifndef ossimSrtmFactory_HEADER
 #define ossimSrtmFactory_HEADER
 
@@ -48,8 +48,6 @@ public:
     * for the point.
     */
    virtual ossimElevSource* getNewElevSource(const ossimGpt& gpt) const;
-
-   virtual void createIndex();
    
 protected:
 
diff --git a/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h b/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h
index 6cabf358f71e3197145afdec30840250d7335068..59b02701b1facc35115000eb12a0d08368f4c11d 100644
--- a/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/font/ossimFontFactoryRegistry.h
@@ -6,7 +6,7 @@
 // Description: 
 // 
 //********************************************************************
-// $Id: ossimFontFactoryRegistry.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimFontFactoryRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
 #ifndef ossimFontFactoryRegistry_HEADER
 #define ossimFontFactoryRegistry_HEADER
 #include <vector>
@@ -54,7 +54,7 @@ public:
 protected:
    mutable ossimFont* theDefaultFont;
 
-   static ossimFontFactoryRegistry* theInstance;
+   //static ossimFontFactoryRegistry* theInstance;
 
    std::vector<ossimFontFactoryBase*> theFactoryList;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationFontObject.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationFontObject.h
index 5feedf480bcc752ce3c770818484c36b5b25a7e0..f705d98d32ab345c71fc0ce879f6673eec7040fe 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimAnnotationFontObject.h 13967 2009-01-14 16:32:01Z gpotts $
 #ifndef ossimAnnotationFontObject_HEADER
 #define ossimAnnotationFontObject_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
@@ -57,7 +57,8 @@ public:
    virtual bool isPointWithin(const ossimDpt& imagePoint)const;
    virtual void setFont(ossimFont* font,
                         bool ownsFontFlag=true);
-   virtual void setPositionCenter(const ossimIpt& position);
+   virtual void setCenterPosition(const ossimIpt& position);
+   virtual void setUpperLeftPosition(const ossimIpt& position);
    virtual void setPointSize(const ossimIpt& size);
    virtual void setRotation(double rotation);
    virtual void setScale(const ossimDpt& scale);
@@ -68,7 +69,7 @@ public:
 protected:
    mutable ossimFont*   theFont;
    bool                 theOwnsFontFlag;
-   ossimIpt             theCenterPosition;
+   ossimIpt             thePosition;
    ossimString          theString;
    ossimIpt             thePixelSize;
    double               theRotation;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h
index f166fc6fce41e49108d8eab079cbe30599e36ad6..8598101bb167b47bdc61d62e1b18e991c863da6e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimAnnotationSource.h
@@ -17,13 +17,14 @@
 //    the fourth band will not be drawn to.
 //
 //*************************************************************************
-// $Id: ossimAnnotationSource.h 11831 2007-10-10 13:37:29Z dburken $
+// $Id: ossimAnnotationSource.h 13330 2008-07-28 18:04:40Z dburken $
 #ifndef ossimAnnotationSource_HEADER
 #define ossimAnnotationSource_HEADER
 
 #include <vector>
 #include <ossim/imaging/ossimImageSourceFilter.h>
 #include <ossim/base/ossimIrect.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/imaging/ossimRgbImage.h>
 
 class ossimAnnotationObject;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBandSelector.h b/Utilities/otbossim/include/ossim/imaging/ossimBandSelector.h
index 1788106c51b71e1f2c20a887dd7c08e1098bde15..b0cb8d8caa551a54481d4db8499768df078f24eb 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimBandSelector.h 13486 2008-08-22 17:07:13Z gpotts $
 #ifndef ossimBandSelector_HEADER
 #define ossimBandSelector_HEADER
 
@@ -121,6 +121,7 @@ private:
    ossimRefPtr<ossimImageData> theTile;
    vector<ossim_uint32>        theOutputBandList;
    mutable ossimBandSelectorWithinRangeFlagState theWithinRangeFlag;
+   bool theOrderedCorrectlyFlag;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimBumpShadeTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimBumpShadeTileSource.h
index 80711cb7274ae6c9bb3145c2f632fae777504f8e..7180a8a503d45c6ed9c64eef4abab17264bf53ca 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimBumpShadeTileSource.h 13382 2008-08-04 18:53:26Z gpotts $
 #ifndef ossimBumpShadeTileSource_HEADER
 #define ossimBumpShadeTileSource_HEADER
 #include <ossim/imaging/ossimImageCombiner.h>
@@ -232,7 +232,14 @@ public:
     */
    void computeLightDirection();
 
+   /* ------------------- PROPERTY INTERFACE -------------------- */
+   virtual void setProperty(ossimRefPtr<ossimProperty> property);
+   virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
+   virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
+   /* ------------------ PROPERTY INTERFACE END ------------------- */
+   
 protected:
+   void allocate();
    /**
     * The result of the illumination equation is stored in
     * here.  This is populated on each call to getTile.
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimEsriShapeFileCutter.h b/Utilities/otbossim/include/ossim/imaging/ossimEsriShapeFileCutter.h
deleted file mode 100644
index 0d64ed4a23b18fe93a89721f27a802587e13fc88..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/imaging/ossimEsriShapeFileCutter.h
+++ /dev/null
@@ -1,200 +0,0 @@
-//*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
-//
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
-//
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimEsriShapeFileCutter.h 9094 2006-06-13 19:12:40Z dburken $
-#ifndef ossimEsriShapeFileCutter_HEADER
-#define ossimEsriShapeFileCutter_HEADER
-#include <ossim/imaging/ossimImageSourceFilter.h>
-#include <ossim/base/ossimViewInterface.h>
-#include <ossim/imaging/ossimMaskFilter.h>
-#include <ossim/imaging/ossimEsriShapeFileFilter.h>
-
-/**
- * This class wraps the ossimEsriShapeFileFilter and ossimMaskFilter to implement
- * a composite cutter.
- *
- * the ossimEsriShapeFileFilter is saved with a shape_file_filter. prefix and the
- * ossimMaskFilter is saved with a mask. prefix.  Please see ossimEsriShapeFileFilter
- * and ossimMaskFilter classes for their keywords. theborder size has an optional units
- * associated with it. 
- * <pre>
- *
- * The border size can be us-feet, feet, meters, or degrees and is only applied
- * to polygons.
- *
- * Example keyword list
- *
- * shape_file_filter.brush_color:  255 255 255
- * shape_file_filter.feature_name:  
- * shape_file_filter.filename:  
- * shape_file_filter.fill_flag:  0
- * shape_file_filter.max_quadtree_levels:  10
- * shape_file_filter.pen_color:  255 255 255
- * shape_file_filter.point_width_height:  1 1 
- * shape_file_filter.thickness:  1
- * shape_file_filter.border_size: 50 meters
- * shape_file_filter.type:  ossimEsriShapeFileFilter
- * mask.mask_type: select
- * mask.type: ossimMaskFilter
- 
- * </pre>
- *
- */
-class ossimEsriShapeFileCutter : public ossimImageSourceFilter,
-                                 public ossimViewInterface
-{
-public:
-   /**
-    * allocates the mask and esri loader
-    */
-   ossimEsriShapeFileCutter();
-   
-   /**
-    * destroys the data members
-    */
-   virtual ~ossimEsriShapeFileCutter();
-   
-   /**
-    * Sent to the input
-    */
-   virtual void getDecimationFactor(ossim_uint32 resLevel,
-                                    ossimDpt& result)const;
-
-   /**
-    * The bounding rect call is passed to the mask filter
-    */
-   virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const;
-
-   /**
-    * The get tile call is passed to the mask filter
-    */
-   virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
-                                               ossim_uint32 resLevel=0);
-
-   /**
-    * is passed to the filter and the shape file loader
-    */
-   virtual void initialize();
-
-   /**
-    * passed to the input source.
-    */
-   virtual void getDecimationFactors(vector<ossimDpt>& decimations)const;
-
-   /**
-    * passed to the input source.
-    */
-   virtual ossim_uint32 getNumberOfDecimationLevels()const;
-
-   /**
-    * passed to the input source.
-    */
-   virtual ossim_uint32 getNumberOfOutputBands() const;
-   
-   /**
-    * passed to the input source.
-    */
-   virtual ossimScalarType getOutputScalarType() const;
-
-   /**
-    * passed to the input source.
-    */
-   virtual void getValidImageVertices(
-      vector<ossimIpt>& validVertices,
-      ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER,
-      ossim_uint32 resLevel=0)const;
-
-   /**
-    * passed to the input source.
-    */
-   virtual ossim_uint32 getTileWidth() const;
-
-   /**
-    * passed to the input source.
-    */
-   virtual ossim_uint32 getTileHeight() const;
-
-   /**
-    * passed to the input source.
-    */
-   virtual double getNullPixelValue(ossim_uint32 band)const;
-   
-   /**
-    * passed to the input source.
-    */
-   virtual double getMinPixelValue(ossim_uint32 band=0)const;
-   
-   /**
-    * passed to the input source.
-    */
-   virtual double getMaxPixelValue(ossim_uint32 band=0)const;
-
-   /**
-    * passed to the shape file to load the shape file that will be used
-    * by the mask filter as input.
-    */
-   void loadFile(const ossimFilename& filename);
-
-   /**
-    * this is here to support the view interface of the esri shape file.
-    * it passes view calls to the esri filter
-    */
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
-   
-   /**
-    * this is here to support the view interface of the esri shape file.
-    * Will return the view setting for the esri shape file.
-    */
-   virtual ossimObject* getView();
-
-   /**
-    * this is here to support the view interface of the esri shape file.
-    * Will return the view setting for the esri shape file.
-    */
-   virtual const ossimObject* getView()const;
-
-   /**
-    * Return the current esri shape file being used
-    */
-   ossimFilename getFilename()const;
-
-   /**
-    * Sets the mask type.  Passes the call to the Mask filter.
-    */
-   void setMaskType(ossimMaskFilter::ossimFileSelectionMaskType type);
-
-   /**
-    * returns the mask type from the maks filter.
-    */
-   ossimMaskFilter::ossimFileSelectionMaskType getMaskType()const;
-
-   /**
-    * Passes load state call to the esri shape file loader with prefix
-    * shape_file_filter.  Then passes the load state cll to the mask
-    * filter with prefix = mask.
-    */
-   virtual bool loadState(const ossimKeywordlist& kwl,
-                          const char* prefix=0);
-
-   /**
-    * Passes save state call to the esri shape file loader with prefix
-    * shape_file_filter.  Then passes the load state cll to the mask
-    * filter with prefix = mask.
-    */
-   virtual bool saveState(ossimKeywordlist& kwl,
-                          const char* prefix=0)const;
-protected:
-   ossimEsriShapeFileFilter* theEsriShapeFile;
-   ossimMaskFilter*          theMaskFilter;
-TYPE_DATA
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimEsriShapeFileFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimEsriShapeFileFilter.h
deleted file mode 100644
index 18c3f85b05f1fb2d9a778d4da0b98fe108d66a11..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/imaging/ossimEsriShapeFileFilter.h
+++ /dev/null
@@ -1,270 +0,0 @@
-//*******************************************************************
-//
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
-//
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimEsriShapeFileFilter.h 9094 2006-06-13 19:12:40Z dburken $
-
-#ifndef ossimEsriShapeFileFilter_HEADER
-#define ossimEsriShapeFileFilter_HEADER
-#include <map>
-#include <ossim/imaging/ossimGeoAnnotationSource.h>
-#include <ossim/base/ossimViewInterface.h>
-#include <ossim/vec/shapefil.h>
-#include <ossim/vec/ossimShapeFile.h>
-#include <ossim/base/ossimRgbVector.h>
-
-class ossimGeoAnnotationObject;
-class ossimAnnotationObject;
-
-/*!
- * class ossimEsriShapeFileFilter
- *
- * This class is used to render shape files.  Iif this filter has
- * an input connection to an ossimImageSourceInterface then it will
- * draw any vectors over the input tile.  If it is not connected
- * it will just render its vector data to a tile and return it.
- * <pre>
- * supported keywords:
- *
- *   max_quadtree_levels:    // number of levels for faster hit testing
- *                           // defaults to 10
- *
- *   fill_flag:              // 1 for true 0 for false.  Default is false
- *                           // and specifies how all closed surfaces are
- *                           // to be drawn
- *
- *   feature_name:           // currently not used.
- *
- *   pen_color:              // specified in Red Green Blue and is the color used
- *                           // if the fill flag is not specified.  Future changes
- *                           // might be to include this as an outline color for
- *                           // filled objects.  Default is white. Example: 255 255 255
- *
- *   brush_color:            // Color used by objects that have the fill flag enabled
- *                           // format is Red Green Blue. Default is white.
- *
- *   line_thickness:         // line drawing thickness in pixels.
- *
- *   border_size:            // can be us feet, feet, meters, degrees,
- *                           // will automatically expand all polygons by the
- *                           // specified size.  Uses the centroid to estimate
- *                           // non degree units when converting to degrees.
- *
- *   point_width_height:     // Specifies the width and height of a point object in
- *                           // pixels.  Default is 1 and has the following format
- *                           // w h.  Example 1 1
- *
- *   filename:               // The esri shape file to be used
- *
- * example Keyword list:  See ossimAnnotationSource for any additional keywords
- *
- *
- * brush_color:  255 255 255
- * feature_name:
- * filename:
- * fill_flag:  0
- * max_quadtree_levels:  10
- * pen_color:  255 255 255
- * point_width_height:  1 1
- * thickness:  1
- * border_size: 25 meters
- * type:  ossimEsriShapeFileFilter
- *
- * </pre>
- */
-class ossimEsriShapeFileFilter : public ossimAnnotationSource,
-                                 public ossimViewInterface
-{
-public:
-   ossimEsriShapeFileFilter(ossimImageSource* inputSource=NULL);
-   ~ossimEsriShapeFileFilter();
-
-   virtual bool setView(ossimObject* baseObject,
-                        bool ownsTheView = false);
-
-   virtual ossimObject*       getView();
-   virtual const ossimObject* getView()const;
-
-   virtual bool addObject(ossimAnnotationObject* anObject);
-   virtual void transformObjects(ossimProjection* projection=0);
-   virtual void setProjection(ossimProjection* projection,
-                              bool ownsProjectionFlag=false);
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix = 0);
-   virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const;
-   virtual void computeBoundingRect();
-
-   virtual void drawAnnotations(ossimRefPtr<ossimImageData> tile);
-   /*!
-    * Will delete the current objects within the layer and add all
-    * objects in the passed in file.
-    */
-   virtual bool loadShapeFile(const ossimFilename& shapeFile);
-
-   virtual ossimFilename getFilename()const
-      {
-         return theShapeFile.getFilename();
-      }
-   virtual ossim_int32 getMaxQuadTreeLevels()const
-      {
-         return theMaxQuadTreeLevels;
-      }
-
-   virtual void setMaxQuadTreeLevels(ossim_int32 levels)
-      {
-         theMaxQuadTreeLevels = (levels>0?levels:10);
-      }
-
-   virtual void setBrushColor(const ossimRgbVector& brushColor)
-      {
-         theBrushColor = brushColor;
-      }
-
-   virtual void setPenColor(const ossimRgbVector& penColor)
-      {
-         thePenColor = penColor;
-      }
-
-   virtual ossimRgbVector getPenColor()const
-      {
-         return thePenColor;
-      }
-
-   virtual ossimRgbVector getBrushColor()const
-      {
-         return theBrushColor;
-      }
-
-   virtual bool getFillFlag()const
-      {
-         return theFillFlag;
-      }
-
-   virtual void setFillFlag(bool flag)
-      {
-         theFillFlag=flag;
-      }
-   virtual ossimString getFeatureName()const
-      {
-         return theFeatureName;
-      }
-   virtual void setFeatureName(const ossimString& name)
-      {
-         theFeatureName = name;
-      }
-
-   virtual void setThickness(ossim_int32 thickness)
-      {
-         theThickness = thickness >= 0? thickness:1;
-      }
-   virtual ossim_int32 getThickness()const
-      {
-         return theThickness;
-      }
-   virtual void setPointRadius(double r)
-      {
-         thePointWidthHeight = ossimDpt(fabs(r)*2, fabs(r)*2);
-      }
-   virtual double getPointRadius()const
-      {
-         return thePointWidthHeight.x/2.0;
-      }
-
-   virtual ossimAnnotationObject* nextObject(bool restart=false)
-      {
-         if(restart)
-         {
-            theCurrentObject = theShapeCache.begin();
-         }
-         else
-         {
-            if(theCurrentObject != theShapeCache.end())
-            {
-               ++theCurrentObject;
-            }
-
-         }
-
-         if(theCurrentObject == theShapeCache.end())
-         {
-            return (ossimAnnotationObject*)NULL;
-         }
-         return (*theCurrentObject).second;
-      }
-
-
-   virtual bool saveState(ossimKeywordlist& kwl,
-                          const char* prefix=NULL)const;
-
-   virtual bool loadState(const ossimKeywordlist& kwl,
-                          const char* prefix=NULL);
-protected:
-
-   /*!
-    *  This holds the output projection.  This is used to transform
-    * the objects to the projection plane.
-    */
-   ossimProjection* theViewProjection;
-
-   /*!
-    * If the shape file is projected we must know the projector.
-    * This will allow us to define the geographic objects correctly.
-    */
-   ossimProjection* theShapeFileProjection;
-
-   /*!
-    * Flag that indicates if we own the view projection.
-    */
-   bool             theOwnsViewProjectionFlag;
-
-   /*!
-    * Specifies if its image/pixel space, Geographic, projected ...etc.
-    */
-   ossimCoordinateSystemType theCoordinateSystem;
-
-   /*!
-    * If its projected this spceifies the type of unit.  We
-    * need to know if the projection is in meters, feet, us survey feet
-    * ... etc.
-    */
-   ossimUnitType             theUnitType;
-
-   ossim_SHPTree*                  theTree;
-
-   ossimShapeFile            theShapeFile;
-
-   double                    theMinArray[4];
-   double                    theMaxArray[4];
-
-   int                       theMaxQuadTreeLevels;
-   ossimRgbVector            thePenColor;
-   ossimRgbVector            theBrushColor;
-   bool                      theFillFlag;
-   ossim_int32               theThickness;
-   ossimString               theFeatureName;
-   ossimDpt                  thePointWidthHeight;
-   double                    theBorderSize;
-   ossimUnitType             theBorderSizeUnits;
-
-   mutable std::multimap<int, ossimAnnotationObject*>::iterator theCurrentObject;
-
-   std::multimap<int, ossimAnnotationObject*> theShapeCache;
-   ossimDrect theBoundingRect;
-
-   void removeViewProjection();
-   void deleteCache();
-   void checkAndSetDefaultView();
-
-   virtual void loadPolygon(ossimShapeObject& obj);
-   virtual void loadPoint(ossimShapeObject& obj);
-   virtual void loadArc(ossimShapeObject& obj);
-
-TYPE_DATA
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFixedTileCache.h b/Utilities/otbossim/include/ossim/imaging/ossimFixedTileCache.h
index b696b5bb9c84a4b97f314990a39093e745c195bd..1be27120e1c02ab91d8a9f70f8bffe41ca066630 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 9641 2006-10-03 19:27:00Z gpotts $
+// $Id: ossimFixedTileCache.h 13485 2008-08-22 17:06:20Z gpotts $
 #ifndef ossimFixedTileCache_HEADER
 #define ossimFixedTileCache_HEADER
 #include <map>
@@ -19,6 +19,7 @@
 #include <ossim/base/ossimReferenced.h>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/imaging/ossimImageData.h>
+#include <OpenThreads/ReentrantMutex>
 
 class  ossimFixedTileCacheInfo
 {
@@ -127,6 +128,7 @@ public:
    virtual ossim_int32 computeId(const ossimIpt& tileOrigin)const;
    virtual void setTileSize(const ossimIpt& tileSize);
 protected:
+   OpenThreads::ReentrantMutex theMutex;
    ossimIrect   theTileBoundaryRect;
    ossimIpt     theTileSize;
    ossimIpt     theBoundaryWidthHeight;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimFusionCombiner.h b/Utilities/otbossim/include/ossim/imaging/ossimFusionCombiner.h
index 529234ac9ed7b232a51d5cdf934294d062da8e35..32e72b31f0c0206fd735dc9bbd26b5975179ab68 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimFusionCombiner.h 13312 2008-07-27 01:26:52Z gpotts $
 #ifndef ossimFusionCombiner_HEADER
 #define ossimFusionCombiner_HEADER
 
@@ -34,8 +34,8 @@ protected:
   ossimRefPtr<ossimImageData> theTile;
   ossimRefPtr<ossimImageData> theNormTile;
   ossimRefPtr<ossimImageData> theNormIntensity;
-  ossimImageSourceInterface*  theInputConnection;
-  ossimImageSourceInterface*  theIntensityConnection;
+  ossimImageSource*  theInputConnection;
+  ossimImageSource*  theIntensityConnection;
   
   ossimRefPtr<ossimImageData> getNormIntensity(const ossimIrect& rect,
                                                ossim_uint32 resLevel);
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationBitmap.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationBitmap.h
index 7cbc2a095801f8e9e7addd2cd91460d44adf9592..117cbfce7c421a57c6ceaf1829ff6366e41c52fd 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationBitmap.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationBitmap_HEADER
 #define ossimGeoAnnotationBitmap_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -18,7 +18,7 @@ class OSSIMDLLEXPORT ossimGeoAnnotationBitmap: public ossimGeoAnnotationObject
 public:
 
    ossimGeoAnnotationBitmap(const ossimGpt& center= ossimGpt(0,0,0),
-                            ossimRefPtr<ossimImageData> imageData=NULL,
+                            ossimRefPtr<ossimImageData> imageData=0,
                             unsigned char r = 255,
                             unsigned char g = 255,
                             unsigned char b = 255);
@@ -27,36 +27,33 @@ public:
 
    virtual ~ossimGeoAnnotationBitmap();
    
-   virtual ossimObject* dup()const
-      {
-         return new ossimGeoAnnotationBitmap(*this);
-      }
-   virtual bool intersects(const ossimDrect& rect) const
-      {
-         if(theImageData.valid())
-         {
-            return theImageData->getImageRectangle().intersects(rect);
-         }
+   virtual ossimObject* dup()const;
 
-         return false;
-      }
-   virtual ossimGeoAnnotationBitmap* getNewClippedObject(const ossimDrect& rect)const
-      {
-         ossimGeoAnnotationBitmap* result = (ossimGeoAnnotationBitmap*)dup();
+   virtual bool intersects(const ossimDrect& rect) const;
+
+   virtual ossimGeoAnnotationBitmap* getNewClippedObject(const ossimDrect& rect)const;
+
+   virtual void applyScale(double x, double y);
 
-         ossimNotify(ossimNotifyLevel_WARN) << "ossimGeoAnnotationBitmap::getNewClippedObject WRNING: not implemented" << std::endl;
-         
-         return result;
-      }
-   virtual void applyScale(double x,
-                           double y)
-      {
-         
-      }
    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);
+
+   /**
+    * @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();
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h
index 67dea719cffda0d26bd81cdc2398f90b5128b4fb..f484d23044c3c4a5614046ce48015880d00dc8b9 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationEllipseObject.h
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationEllipseObject.h 11389 2007-07-25 18:47:59Z dburken $
+// $Id: ossimGeoAnnotationEllipseObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationEllipseObject_HEADER
 #define ossimGeoAnnotationEllipseObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -43,6 +43,20 @@ public:
    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);
+
    /**
     * Saves the current state of this object.
     *
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationFontObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationFontObject.h
index e1b5a85c1adf42b4feed6713e847a955b357160e..416c830aaf5f8bf5bff63e7f372c59a62c8f9cb3 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationFontObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationFontObject_HEADER
 #define ossimGeoAnnotationFontObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -52,6 +52,20 @@ public:
                          ossim_uint8 b);
 
    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 setCenterGround(const ossimGpt& gpt);
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationGdBitmapFont.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationGdBitmapFont.h
index ed2e0c056c3b4af8c4a45e73c82bc460a1124e10..0df6ed16fd8c5ef70fda2843e1381c0ab1e59cde 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 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimGeoAnnotationGdBitmapFont.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationGdBitmapFont_HEADER
 #define ossimGeoAnnotationGdBitmapFont_HEADER
 
@@ -27,10 +27,7 @@ public:
                                   long thickness = 1);
    ossimGeoAnnotationGdBitmapFont(const ossimGeoAnnotationGdBitmapFont& rhs);
    virtual ~ossimGeoAnnotationGdBitmapFont();
-   virtual ossimObject* dup()const
-      {
-         return new ossimGeoAnnotationGdBitmapFont(*this);
-      }
+   virtual ossimObject* dup()const;
    virtual void applyScale(double x, double y);
    virtual std::ostream& print(std::ostream& out)const;
    virtual void draw(ossimRgbImage& anImage)const;
@@ -44,6 +41,20 @@ public:
     */
    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 setText(const ossimString& text);
    virtual void setFont(ossimGdFontPtr font);
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h
index a51043be245679d467df26ad54870d94fc45b5a0..615295655a628a8a983de7fe611288f5812a7223 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationLineObject.h
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationLineObject.h 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimGeoAnnotationLineObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationLineObject_HEADER
 #define ossimGeoAnnotationLineObject_HEADER
 #include <ossim/base/ossimGpt.h>
@@ -26,13 +26,25 @@ public:
    ossimGeoAnnotationLineObject(const ossimGeoAnnotationLineObject& rhs);
    virtual ~ossimGeoAnnotationLineObject();
 
-   virtual ossimObject* dup()const
-      {
-         return new ossimGeoAnnotationLineObject(*this);
-      }
+   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 std::ostream& print(std::ostream& out)const;
    virtual bool intersects(const ossimDrect& rect)const;
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h
index cf1cc418c62908c29855f3020fe20d738a458840..eb8b25edf338085f44427b3e8e5cb406bdf8bfed 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 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimGeoAnnotationMultiEllipseObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationMultiEllipseObject_HEADER
 #define ossimGeoAnnotationMultiEllipseObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -36,6 +36,20 @@ public:
 
    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 applyScale(double x, double y);
 
    virtual void draw(ossimRgbImage& anImage)const;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h
index d2e1894e7ea234005478fddb58bafa1aa5dfc137..cd57191523a432b9f859e4cc3222d5234b8f6dd4 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationMultiPolyLineObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationMultiPolyLineObject_HEADER
 #define ossimGeoAnnotationMultiPolyLineObject_HEADER
 
@@ -33,6 +33,21 @@ public:
 
    virtual ~ossimGeoAnnotationMultiPolyLineObject();
    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 applyScale(double x, double y);
    virtual void draw(ossimRgbImage& anImage)const;
    virtual bool intersects(const ossimDrect& rect)const;
@@ -77,12 +92,12 @@ public:
                           const char* prefix=0);
    
 protected:
-  vector<ossimPolyLine>               theMultiPolyLine;
-  ossimDrect                          theBoundingRect;
-  const ossimDatum*                   theDatum;
-  ossimAnnotationMultiPolyLineObject* theProjectedPolyLineObject;
-  
-  void allocateProjectedPolyLine();
+   std::vector<ossimPolyLine>          theMultiPolyLine;
+   ossimDrect                          theBoundingRect;
+   const ossimDatum*                   theDatum;
+   ossimAnnotationMultiPolyLineObject* theProjectedPolyLineObject;
+   
+   void allocateProjectedPolyLine();
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationMultiPolyObject.h
index fc5b5124048609b76e1c5818b3f06ea8b5b5c210..4b386751a4d5b0887efe192e036e68d6841d0d56 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 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimGeoAnnotationMultiPolyObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationMultiPolyObject_HEADER
 #define ossimGeoAnnotationMultiPolyObject_HEADER
 #include <ossim/imaging/ossimGeoAnnotationObject.h>
@@ -26,12 +26,25 @@ public:
                                      long thickness=1);
    
    ossimGeoAnnotationMultiPolyObject(const ossimGeoAnnotationMultiPolyObject& rhs);
-   virtual ossimObject* dup()const
-      {
-         return new ossimGeoAnnotationMultiPolyObject(*this);
-      }
+   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 applyScale(double x,
                                 double y);
    virtual void draw(ossimRgbImage& anImage)const;
@@ -40,50 +53,14 @@ public:
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
    virtual std::ostream& print(std::ostream& out)const;
    virtual void getBoundingRect(ossimDrect& rect)const;
-   virtual void addPoint(ossim_uint32 polygonIndex,
-                         const ossimGpt& pt)
-      {
-         if(polygonIndex < theMultiPolygon.size())
-         {
-            theMultiPolygon[polygonIndex].addPoint(pt);
-
-            // we will have to reset the projected polygon
-            if(theProjectedPolyObject)
-            {
-               delete theProjectedPolyObject;
-               theProjectedPolyObject = NULL;
-            }
-         }
-      }
+   virtual void addPoint(ossim_uint32 polygonIndex, const ossimGpt& pt);
    
-   virtual void setMultiPolygon(const vector<ossimGeoPolygon>& multiPoly)
-      {
-         theMultiPolygon = multiPoly;
-         if(theProjectedPolyObject)
-         {
-            delete theProjectedPolyObject;
-            theProjectedPolyObject = NULL;
-         }
-      }
-   virtual void setColor(unsigned char r,
-                         unsigned char g,
-                         unsigned char b)
-      {
-         ossimAnnotationObject::setColor(r, g, b);
-         if(theProjectedPolyObject)
-         {
-            theProjectedPolyObject->setColor(r, g, b);
-         }
-      }
+   virtual void setMultiPolygon(const vector<ossimGeoPolygon>& multiPoly);
+
+   virtual void setColor(unsigned char r, unsigned char g, unsigned char b);
    
-   virtual void setThickness(ossim_uint8 thickness)
-      {
-         ossimAnnotationObject::setThickness(thickness);
-         if(theProjectedPolyObject)
-         {
-            theProjectedPolyObject->setThickness(thickness);
-         }
-      }
+   virtual void setThickness(ossim_uint8 thickness);
+
    virtual void computeBoundingRect();
    virtual bool isPointWithin(const ossimDpt& imagePoint)const;
    virtual void setFillFlag(bool flag);
@@ -92,9 +69,9 @@ public:
    std::vector<ossimGeoPolygon>& getMultiPolygon(){return theMultiPolygon;}
    
 protected:
-   vector<ossimGeoPolygon> theMultiPolygon;
-   ossimDrect              theBoundingRect;
-   bool                   theFillEnabled;
+   std::vector<ossimGeoPolygon>    theMultiPolygon;
+   ossimDrect                      theBoundingRect;
+   bool                            theFillEnabled;
    ossimAnnotationMultiPolyObject* theProjectedPolyObject;
    
    void allocateProjectedPolygon();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h
index b957730b13056c3e4ab0352f05e83e774204b706..8af66b77408f752f5070cd79b66f0e063269cb3b 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationObject.h
@@ -6,13 +6,14 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationObject.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationObject_HEADER
 #define ossimGeoAnnotationObject_HEADER
 #include <ossim/imaging/ossimAnnotationObject.h>
 #include <ossim/base/ossimGpt.h>
 
 class ossimProjection;
+class ossimImageProjectionModel;
 
 class OSSIM_DLL ossimGeoAnnotationObject : public ossimAnnotationObject
 {
@@ -32,6 +33,20 @@ public:
     */
    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;
+
    /**
     * Saves the current state of this object.
     */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyLineObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyLineObject.h
index c20af6170e30c97d7939d0d378e64025736497d9..77e55467fcb7ee3b0912bb5ba56646f37d5e4d82 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationPolyLineObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationPolyLineObject_HEADER
 #define ossimGeoAnnotationPolyLineObject_HEADER
 #include <ossim/base/ossimGpt.h>
@@ -24,15 +24,26 @@ public:
                                      ossim_uint8 thickness=1);
    ossimGeoAnnotationPolyLineObject(const ossimGeoAnnotationPolyLineObject& rhs);
    virtual ~ossimGeoAnnotationPolyLineObject();
-   virtual ossimObject* dup()const
-      {
-         return new ossimGeoAnnotationPolyLineObject(*this);
-      }
-   
-   virtual void applyScale(double x,
-                           double y);
+   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 std::ostream& print(std::ostream& out)const;
    virtual void draw(ossimRgbImage& anImage)const;
    virtual ossimAnnotationObject* getNewClippedObject(const ossimDrect& rect)const;
@@ -59,7 +70,7 @@ public:
    virtual void setThickness(ossim_uint8 thickness);
 
 protected:
-   vector<ossimGpt>                thePolygon;
+   std::vector<ossimGpt>           thePolygon;
    ossimAnnotationMultiLineObject* theProjectedMultiLineObject;
 
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h
index 9092d77d3b6fd73205bbf1f592d1f935fcc5c561..53245fe0e083b9ca3dd7128406beb4665fa380e2 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimGeoAnnotationPolyObject.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyObject.h 9480 2006-09-01 13:52:19Z gpotts $
+// $Id: ossimGeoAnnotationPolyObject.h 13349 2008-07-30 15:34:34Z dburken $
 #ifndef ossimGeoAnnotationPolyObject_HEADER
 #define ossimGeoAnnotationPolyObject_HEADER
 
@@ -41,6 +41,20 @@ public:
    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 std::ostream& print(std::ostream& out)const;
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimHistogramRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimHistogramRemapper.h
index 8ea97ce33c27fb1fc27c5c7181a07b602352bf34..3f135a545541bdc974d4ba22d3f3fbfb99b710dc 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 12961 2008-06-03 13:20:35Z gpotts $
+// $Id: ossimHistogramRemapper.h 13912 2008-12-04 19:15:51Z gpotts $
 #ifndef ossimHistogramRemapper_HEADER
 #define ossimHistogramRemapper_HEADER
 
@@ -75,6 +75,9 @@ public:
     */
    void setStretchMode(StretchMode mode);
 
+   /**
+    * Stretch mode values can be linear_one_piece, linear_1std_from_mean, linear_2std_from_mean, linear_3std_from_mean, linear_auto_min_max
+    */
    void setStretchModeAsString(const ossimString& mode);
    
    /**
@@ -482,6 +485,10 @@ private:
     */
    void setupTable();
 
+   /**
+    * This set theBypassFlag.  This is an internally used flag to signal that
+    * there is nothing to do in this filter; hence, bypass.
+    */
    void verifyEnabled();
 
    /**
@@ -495,7 +502,6 @@ private:
    StretchMode                   theStretchMode;
    bool                          theDirtyFlag;
    ossimRefPtr<ossimMultiResLevelHistogram>  theHistogram;
-   ossim_uint32                  theTableSizeInBytes;
    vector<ossim_float64>         theNormalizedLowClipPoint;
    vector<ossim_float64>         theNormalizedHighClipPoint;
    vector<ossim_float64>         theMidPoint;
@@ -505,6 +511,8 @@ private:
    // Maps zero based band to histogram band.
    vector<ossim_uint32>          theBandList;
    
+   bool theByPassFlag;
+   
    TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageChain.h b/Utilities/otbossim/include/ossim/imaging/ossimImageChain.h
index ee2ce13973bdc16d4d09607608bdd6f7be808c34..b1922d5d00768e893472e8c2a2b49cc9eaaaa0ea 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageChain.h 13475 2008-08-22 14:21:54Z gpotts $
 #ifndef ossimImageChain_HEADER
 #define ossimImageChain_HEADER
 #include <vector>
@@ -54,18 +54,19 @@ public:
     */
    virtual ossimConnectableObject* getConnectableObject(ossim_uint32 index);
    
+   virtual ossim_int32 indexOf(ossimConnectableObject* obj)const;
    /**
     * Return the first source which is the one that first receives the
     * getTile request
     */
-   virtual ossimImageSourceInterface* getFirstSource();
+   virtual ossimImageSource* getFirstSource();
    virtual ossimObject* getFirstObject();
 
    /**
     * Return the last source which is the one that last receives the
     * getTile request.
     */
-   virtual ossimImageSourceInterface* getLastSource();
+   virtual ossimImageSource* getLastSource();
    virtual ossimObject* getLastObject();
 
 
@@ -120,8 +121,9 @@ public:
     */
    bool insertLeft(ossimConnectableObject* newObj,
                    ossimConnectableObject* leftOfThisObj);
-
    
+   bool replace(ossimConnectableObject* newObj,
+                ossimConnectableObject* oldObj);
    /**
     * Will return true or false if an image source was
     * added to the chain.  It will add and do a connection
@@ -212,7 +214,10 @@ public:
                                                object);
             }
          }
-         
+         else if(!theImageChainList.size())
+         {
+            return true;
+         }
          return false;
       }
       
@@ -335,7 +340,7 @@ protected:
    
    ossimRefPtr<ossimImageData>     theBlankTile;
    ossimImageChainChildListener*   theChildListener;
-   mutable bool                    thePropagateEventFlag;
+  // mutable bool                    thePropagateEventFlag;
    mutable bool                    theLoadStateFlag;
    /**
     * For dynamic loading to take place we must allocate all objects first and
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageDataFactory.h b/Utilities/otbossim/include/ossim/imaging/ossimImageDataFactory.h
index 5dfb2ad93e9329644ed8ea1979cbf9d8742ffc30..d04110c2510fd8118a564fe009e398cadcca40e3 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageDataFactory.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageDataFactory.h
@@ -10,15 +10,15 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimImageDataFactory.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageDataFactory.h 13474 2008-08-22 14:20:42Z gpotts $
 #ifndef ossimImageDataFactory_HEADER
 #define ossimImageDataFactory_HEADER
 
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/base/ossimRefPtr.h>
-
+#include <OpenThreads/Mutex>
 class ossimSource;
-class ossimImageSourceInterface;
+class ossimImageSource;
 
 
 /*!
@@ -44,12 +44,12 @@ public:
    virtual ossimRefPtr<ossimImageData> create(
       ossimSource* owner,
       ossim_uint32 bands,
-      ossimImageSourceInterface* inputSource)const;
+      ossimImageSource* inputSource)const;
    
    
    virtual ossimRefPtr<ossimImageData> create(
       ossimSource* owner,
-      ossimImageSourceInterface* inputSource)const;
+      ossimImageSource* inputSource)const;
    
 protected:
    ossimImageDataFactory(); // hide
@@ -57,6 +57,7 @@ protected:
    void operator = (ossimImageDataFactory&){}// hide
    
    static ossimImageDataFactory* theInstance;
+   static OpenThreads::Mutex theInstanceMutex;
 };
 
 #endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageDisplayWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageDisplayWriter.h
index 6f837cd8432199224f04f092926eb54af4e5f285..03b2a7446a2a3030dedf2c1e314bdc6d68d81ce6 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 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimImageDisplayWriter.h 13312 2008-07-27 01:26:52Z gpotts $
 #ifndef ossimImageDisplayWriter_HEADER
 #define ossimImageDisplayWriter_HEADER
 
@@ -32,7 +32,7 @@ public:
                             const ossimConnectableObject* object)const
       {
          
-         return (object&& PTR_CAST(ossimImageSourceInterface, object));
+         return (object&& PTR_CAST(ossimImageSource, object));
       }
    virtual void setOutputName(const ossimString& out)
       {
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerRegistry.h b/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerRegistry.h
index 49226b009611c9d2037d7750316835d966ed9428..098214cb5e77075e2b9f32258a5a3837f307fb9f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerRegistry.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageHandlerRegistry.h
@@ -8,7 +8,7 @@
 //               ImageHandlerRegistry.
 //
 //*******************************************************************
-//  $Id: ossimImageHandlerRegistry.h 10103 2006-12-14 16:12:19Z gpotts $
+//  $Id: ossimImageHandlerRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
 
 #ifndef ossimImageHandlerRegistry_HEADER
 #define ossimImageHandlerRegistry_HEADER
@@ -83,7 +83,7 @@ protected:
 private:
    void clear();
    std::vector<ossimImageHandlerFactoryBase*>   theFactoryList;
-   static ossimImageHandlerRegistry*            theInstance;
+   //static ossimImageHandlerRegistry*            theInstance;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h b/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h
index 89d6567c09bcf76f4c2c1424e95fecfbf284280f..1576d69b45046fe7db83df7fa5654e8f3f8fa80e 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageHistogramSource.h
@@ -5,18 +5,18 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageHistogramSource.h 12579 2008-03-26 18:52:51Z gpotts $
+// $Id: ossimImageHistogramSource.h 13312 2008-07-27 01:26:52Z gpotts $
 #ifndef ossimImageHistogramSource_HEADER
 #define ossimImageHistogramSource_HEADER
 #include <ossim/base/ossimHistogramSource.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/base/ossimProcessInterface.h>
 #include <ossim/base/ossimConnectableObjectListener.h>
 #include <ossim/base/ossimObjectEvents.h>
 #include <ossim/base/ossimIrect.h>
 
 /*!
- * This source expects as input an ossimImageSourceInterface.
+ * This source expects as input an ossimImageSource.
  * it will slice up the requested region into tiles and compute
  * the histogram of the passed in rectangle.
  */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h b/Utilities/otbossim/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h
index 5c304dfc2094496a261066335eb03d0ba78d8fa3..ea62f6515088222e2c918c0236ee40dc70c5c414 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h
@@ -3,7 +3,7 @@
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //----------------------------------------------------------------------------
-// $Id: ossimImageMetaDataWriterRegistry.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageMetaDataWriterRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
 
 #ifndef ossimImageMetaDataWriterRegistry_HEADER
 #define ossimImageMetaDataWriterRegistry_HEADER
@@ -86,7 +86,7 @@ protected:
    const ossimImageMetaDataWriterRegistry& operator=(
       const ossimImageMetaDataWriterRegistry &rhs);
 
-   static ossimImageMetaDataWriterRegistry* theInstance;
+  // static ossimImageMetaDataWriterRegistry* theInstance;
    std::vector<ossimImageMetaDataWriterFactoryBase*> theFactoryList;
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h b/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h
new file mode 100644
index 0000000000000000000000000000000000000000..ba82afbcd98b7981b0c12cd7a43b613f94dfbb91
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageModel.h
@@ -0,0 +1,189 @@
+//-----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Class declaration of ossimImageModel.
+//
+//-----------------------------------------------------------------------------
+// $Id$
+
+#ifndef ossimImageModel_HEADER
+#define ossimImageModel_HEADER 1
+
+#include <vector>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimObject.h>
+#include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimRtti.h>
+
+class ossimDrect;
+class ossimImageHandler;
+
+/**
+ * @brief Class to handle transforming image points, rectangles, and offsets
+ * from one reduced resolution data set (rrds) level to another.
+ *
+ * Derived from ossimObject only so users can pass via the
+ * ossimViewInterface::setView method.
+ */
+class OSSIM_DLL ossimImageModel : public ossimObject
+{
+public:
+   
+   /** @brief default constructor */
+   ossimImageModel();
+
+   /** @brief virtual destructor */
+   virtual ~ossimImageModel();
+
+   /**
+    * @brief Method to initialize class from an image handler.
+    *
+    * @param ih Image handler.
+    */
+   virtual void initialize(const ossimImageHandler& ih);
+
+   /**
+    * @brief Get r0 point from rn point.
+    * 
+    * @param rrds Source (rnPt) reduced resolution data set.
+    *
+    * @param rnPt The image point to tranform.
+    *
+    * @param r0Pt the Point to initialize.
+    *
+    * @note Throws ossimException on out of range rrds.
+    */
+   void rnToR0(ossim_uint32 rrds,
+               const ossimDpt& rnPt,
+               ossimDpt& r0Pt) const;
+
+   /**
+    * @brief Get r0 point from rn point.
+    *
+    * This requires calling setTargetRrds(ossim_uint32 rrds) to the level
+    * for rnPt.
+    * 
+    * @param rnPt The image point to tranform.
+    *
+    * @param r0Pt the Point to initialize.
+    *
+    * @note Throws ossimException on out of range rrds.
+    *
+    * @see setTargetRrds
+    */
+   void rnToR0(const ossimDpt& rnPt, ossimDpt& r0Pt) const;
+   
+   /**
+    * @brief Get rn point from r0 point.
+    * 
+    * @param rrds Target (rnPt) reduced resolution data set.
+    *
+    * @param r0Pt The image point to tranform.
+    *
+    * @param rnPt the Point to initialize.
+    *
+    * @note Throws ossimException on out of range rrds.
+    */
+   void r0ToRn(ossim_uint32 rrds,
+               const ossimDpt& r0Pt,
+               ossimDpt& rnPt) const;
+
+   /**
+    * @brief Get rn point from r0 point.
+    *
+    * This requires calling setTargetRrds(ossim_uint32 rrds) to the level
+    * for rnPt.
+    * 
+    * @param r0Pt The image point to tranform.
+    *
+    * @param rnPt the Point to initialize.
+    *
+    * @note Throws ossimException on out of range rrds.
+    *
+    * @see setTargetRrds
+    */
+   void r0ToRn(const ossimDpt& r0Pt,
+               ossimDpt& rnPt) const;
+
+   /**
+    * @brief Get the sub image offset for a given resolution level.
+    * 
+    * @param rrds The reduced resolution data set.
+    *
+    * @param offset the Point to initialize.
+    *
+    * @note Throws ossimException on out of range rrds.
+    */
+   void getSubImageOffset(ossim_uint32 rrds, ossimDpt& offset) const;
+
+   /**
+    * @brief Gets the zero-based image rectangle for a given reduced resolution
+    * data set.
+    *
+    * @param rrds The reduced resolution data set.
+    *
+    * @param rect Initialized with image rectangle for rrds.
+    *
+    * @note Throws ossimException on out of range rrds.
+    */
+   void getImageRectangle(ossim_uint32 rrds, ossimDrect& rect) const; 
+   
+   /**
+    * @brief Gets the model-based image rectangle for a given reduced
+    * resolution data set.
+    *
+    * If this image is a sub image the offset is applied.  So if the image
+    * has a sub image offset of (1024, 1024), and has 1024 lines and 1024
+    * samples the rectangle for r0 will be:  (1024, 1024) (2047, 2047)
+    *
+    * @param rrds The reduced resolution data set.
+    *
+    * @param rect Initialized with image rectangle for rrds.
+    *
+    * @note Throws ossimException on out of range rrds.
+    */
+   void getBoundingRectangle(ossim_uint32 rrds, ossimDrect& rect) const;
+
+   /**
+    * @return This returns the total number of decimation levels.
+    */
+   ossim_uint32 getNumberOfDecimationLevels()const;
+
+   /**
+    * @brief Set theTargetRrds data member.
+    *
+    * This is used by methods rnToR0 and r0ToRn that do not take a rrds
+    * argument.
+    *
+    * @param rrds Target reduced resolution data set.
+    */
+   void setTargetRrds(ossim_uint32 rrds);
+
+   /**
+    * @return The target reduced resolution data set.
+    */
+   ossim_uint32 getTargetRrds() const;
+   
+ 
+
+protected:
+
+   /** Offset from the full image. */
+   ossimDpt theSubImageOffset;
+
+   /** Decimation factors for each rrds level. */
+   std::vector<ossimDpt> theDecimationFactors;
+
+   ossim_uint32 theLines;
+   ossim_uint32 theSamples;
+   ossim_uint32 theTargetRrds;
+
+TYPE_DATA
+};
+
+#endif /* #ifndef ossimImageModel_HEADER */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h b/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h
index df62d9b276385be4a9dd8987229c5987f091860f..49bd19f514639d2795e5f41c78be0db897f43515 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageRenderer.h
@@ -8,11 +8,12 @@
 // Author: Garrett Potts
 //
 //*******************************************************************
-// $Id: ossimImageRenderer.h 12668 2008-04-14 14:12:31Z gpotts $
+// $Id: ossimImageRenderer.h 13330 2008-07-28 18:04:40Z dburken $
 
 #ifndef ossimImageRenderer_HEADER
 #define ossimImageRenderer_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimViewInterface.h>
 #include <ossim/base/ossimRationalNumber.h>
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageShapeFileIndex.h b/Utilities/otbossim/include/ossim/imaging/ossimImageShapeFileIndex.h
deleted file mode 100644
index 8973473fdd09518070579b9c267568ebb3a54ea9..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageShapeFileIndex.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef ossimImageShapeFileIndex_HEADER
-#define ossimImageShapeFileIndex_HEADER
-#include <ossim/base/ossimObject.h>
-#include <ossim/base/ossimReferenced.h>
-#include <ossim/base/ossimRefPtr.h>
-#include <ossim/base/ossimFilename.h>
-
-class OSSIM_DLL ossimImageShapeFileIndex : public ossimObject
-{
-public:
-   ossimImageShapeFileIndex(const ossimFilename& shapeFilename = "");
-   void setFilename(const ossimFilename& shapeFilename);
-   
-   void add(const ossimFilename& filename,
-            const ossim_int32 entry=-1, // default to all entries
-            const ossimString& groupName="RASTER");
-   /**
-    *
-    */ 
-   void build(ossim_uint32 maxDepth=1)const;
-   
-protected:
-   class ossimImageShapeFileIndexRecord : public ossimReferenced
-   {
-   public:
-      ossimImageShapeFileIndexRecord(const ossimFilename& filename="",
-                                     ossim_uint32 entry=0,
-                                     const ossimString& groupName="",
-                                     ossim_float64 minx=0.0,
-                                     ossim_float64 miny=0.0,
-                                     ossim_float64 maxx=0.0,
-                                     ossim_float64 maxy=0.0)
-         :theFilename(filename),
-         theEntry(entry),
-         theGroupName(groupName),
-         theMinx(minx),
-         theMiny(miny),
-         theMaxx(maxx),
-         theMaxy(maxy)
-      {
-      }
-
-      ossimFilename theFilename;
-      ossim_uint32  theEntry;
-      ossimString   theGroupName;
-      ossim_float64 theMinx;
-      ossim_float64 theMiny;
-      ossim_float64 theMaxx;
-      ossim_float64 theMaxy;
-   };
-
-   std::vector<ossimRefPtr<ossimImageShapeFileIndexRecord> > theRecords;
-
-   ossimFilename theFilename;
-   ossim_float64 theGlobalMinx;
-   ossim_float64 theGlobalMiny;
-   ossim_float64 theGlobalMaxx;
-   ossim_float64 theGlobalMaxy;
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h
index 3615a7387e2f3ef2f38e6a6e39f020e9b12b4785..b1728c1fcade73294755e53221d47e33ddfe06f0 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageSource.h
@@ -8,21 +8,18 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSource.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageSource.h 13329 2008-07-28 18:03:19Z dburken $
 #ifndef ossimImageSource_HEADER
 #define ossimImageSource_HEADER
 
-#include <ossim/base/ossimSource.h>
-#include <ossim/base/ossimErrorContext.h>
 #include <ossim/base/ossimConstants.h>
-#include <ossim/base/ossimDrect.h>
+#include <ossim/base/ossimSource.h>
+#include <ossim/base/ossimIrect.h>
 #include <ossim/imaging/ossimImageData.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
 
 class ossimDpt;
 
-class OSSIMDLLEXPORT ossimImageSource : public ossimSource,
-			                public ossimImageSourceInterface
+class OSSIMDLLEXPORT ossimImageSource : public ossimSource
 {
 public:
    ossimImageSource(ossimObject* owner = 0);
@@ -47,14 +44,14 @@ public:
                                                ossim_uint32 resLevel=0);
    
   /**
-   * For RTTI support. overrides ossimImageSourceInterface
+   * For RTTI support. overrides ossimImageSource
    * get object to return the correct casted base pointer
    * for RTTI casting
    */
    virtual ossimObject* getObject() { return this; }
    
    /**
-    * For RTTI support. overrides ossimImageSourceInterface
+    * For RTTI support. overrides ossimImageSource
     * get object to return the correct casted base pointer
     * for RTTI casting
     */
@@ -73,7 +70,7 @@ public:
    /**
     * Will return an array of all decimations for each resolution level.
     */
-   virtual void getDecimationFactors(vector<ossimDpt>& decimations) const;
+   virtual void getDecimationFactors(std::vector<ossimDpt>& decimations) const;
 
    /**
     * Will return the number of resolution levels.  Note: resolution
@@ -81,6 +78,11 @@ public:
     */
    virtual ossim_uint32 getNumberOfDecimationLevels() const;
    
+   /*!
+    * Returns the number of bands available from the input.
+    */
+   virtual ossim_uint32 getNumberOfInputBands() const = 0;
+   
    /**
     * Returns the number of bands in a tile returned from this TileSource.
     */
@@ -108,7 +110,7 @@ public:
    virtual ossim_uint32 getTileHeight() const;
 
    /**
-    * Each band has a null pixel associated with it.  The null pixel 
+         * Each band has a null pixel associated with it.  The null pixel 
     * represents an invalid value.
     */ 
    virtual double getNullPixelValue(ossim_uint32 band=0)const;
@@ -159,13 +161,13 @@ public:
     *
     * The default implementation is to return the bounding rect.
     */
-   virtual void getValidImageVertices(vector<ossimIpt>& validVertices,
+   virtual void getValidImageVertices(std::vector<ossimIpt>& validVertices,
                                       ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER,
                                       ossim_uint32 resLevel=0)const;
 
    /**
     * the default is to find the first input source that is of
-    * type ossimImageSourceInterface and return its input geometry.
+    * type ossimImageSource and return its input geometry.
     */
    virtual bool getImageGeometry(ossimKeywordlist& kwl,
                                  const char* prefix=0);
@@ -185,6 +187,9 @@ public:
     */
    virtual void saveImageGeometry(const ossimFilename& geometry_file) const;
    
+   virtual void initialize()=0;
+   
+   
    virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
    virtual void setProperty(ossimRefPtr<ossimProperty> property);
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceFilter.h
index 155610beefcfc668926d401296f14e374bc9d442..b34e3c3a0aef06ad93c5b9e1135a05114ce020ca 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageSourceFilter.h 13312 2008-07-27 01:26:52Z gpotts $
 #ifndef ossimImageSourceFilter_HEADER
 #define ossimImageSourceFilter_HEADER
 #include <ossim/imaging/ossimImageSource.h>
@@ -108,7 +108,7 @@ public:
    virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
    
 protected:
-   ossimImageSourceInterface* theInputConnection;
+   ossimImageSource* theInputConnection;
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceInterface.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceInterface.h
deleted file mode 100644
index ea924e442ab71207ac0b5afd9da4e59aa3041842..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceInterface.h
+++ /dev/null
@@ -1,109 +0,0 @@
-//*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
-//
-// License:  See top level LICENSE.txt file.
-//
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimImageSourceInterface.h 9094 2006-06-13 19:12:40Z dburken $
-#ifndef ossimImageSourceInterface_HEADER
-#define ossimImageSourceInterface_HEADER
-
-#include <vector>
-
-#include <ossim/base/ossimErrorContext.h>
-#include <ossim/base/ossimConstants.h>
-#include <ossim/base/ossimRefPtr.h>
-#include <ossim/base/ossimIrect.h>
-#include <ossim/base/ossimKeywordlist.h>
-#include <ossim/base/ossimFilename.h>
-
-class ossimImageData;
-class ossimObject;
-
-class OSSIMDLLEXPORT ossimImageSourceInterface
-{
-public:
-   virtual ~ossimImageSourceInterface();
-   
-   virtual ossimObject* getObject()=0;
-   virtual const ossimObject* getObject()const=0;
-   
-   virtual ossimRefPtr<ossimImageData> getTile(const ossimIpt& origin,
-                                               ossim_uint32 resLevel=0) = 0;
-   
-   virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
-                                               ossim_uint32 resLevel=0) = 0;
-   
-   virtual void getDecimationFactor(ossim_uint32 resLevel,
-                                    ossimDpt& result)const=0;
-   virtual void getDecimationFactors(std::vector<ossimDpt>& decimations)const=0;
-   virtual ossim_uint32 getNumberOfDecimationLevels()const=0;
-
-   /*!
-    * Returns the number of bands available from the input.
-    */
-   virtual ossim_uint32 getNumberOfInputBands() const = 0;
-
-   /*!
-    * Returns the number of bands in output.
-    */
-   virtual ossim_uint32 getNumberOfOutputBands() const = 0;
-
-   /*!
-    * Initializes bandList to the zero based order of output bands.
-    */
-   virtual void getOutputBandList(std::vector<ossim_uint32>& bandList) const=0;
-   
-   virtual ossimScalarType getOutputScalarType() const = 0;
-
-   virtual ossim_uint32 getTileWidth()  const = 0;
-   virtual ossim_uint32 getTileHeight() const = 0;
-
-   virtual double getNullPixelValue(ossim_uint32 band=0)const=0;
-   virtual double getMinPixelValue(ossim_uint32 band=0)const=0;
-   virtual double getMaxPixelValue(ossim_uint32 band=0)const=0;
-
-   virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0)const=0;
-   
-   virtual void getValidImageVertices(std::vector<ossimIpt>& validVertices,
-                                      ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER,
-                                      ossim_uint32 resLevel=0)const=0;
-   
-   virtual bool getImageGeometry(ossimKeywordlist& kwl,
-                                 const char* prefix=0)=0;
-
-   /**
-    * Sets the image geometry keyword list.
-    *
-    * @note Callers should note that this will override any existing
-    *       geometry.
-    *
-    * @note This does not write the geometry to disk, to do so call
-    *       one of the saveImageGeometry methods. 
-    */
-   virtual void setImageGeometry(const ossimKeywordlist& kwl)=0;
-
-   /**
-    * Saves the image geometry to a file that will be made based on the image
-    * file name.
-    */
-   virtual void saveImageGeometry()const=0;
-
-   /**
-    * Saves the image geomety to geom_file.
-    */
-   virtual void saveImageGeometry(const ossimFilename& geometry_file)const=0;
-
-   virtual void initialize()=0;
-   
-   virtual bool loadState(const ossimKeywordlist& kwl,
-                          const char* prefix=0)=0;
-   virtual bool saveState(ossimKeywordlist& kwl,
-                          const char* prefix=0)const=0;
-
-TYPE_DATA
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageSourceSequencer.h b/Utilities/otbossim/include/ossim/imaging/ossimImageSourceSequencer.h
index 4f67519c25ca8a594898e8044e788ac55ac45434..5b486fde1d80b47bc2f3c2ce932732057c2468c8 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageSourceSequencer.h 13312 2008-07-27 01:26:52Z gpotts $
 #ifndef ossimImageSourceSequencer_HEADER
 #define ossimImageSourceSequencer_HEADER
 #include <ossim/imaging/ossimImageSource.h>
@@ -135,7 +135,7 @@ public:
    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
    
 protected:
-   ossimImageSourceInterface*  theInputConnection;
+   ossimImageSource*  theInputConnection;
    ossimRefPtr<ossimImageData> theBlankTile;
    /*!
     * Is the area of interest.  The default will
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageToPlaneNormalFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimImageToPlaneNormalFilter.h
index 7e08d896db7301d8c112ae7743100a2d4fc6da4c..ed33f31a350a70ab956607cfcdf96960c64b9ef5 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageToPlaneNormalFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageToPlaneNormalFilter.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageToPlaneNormalFilter.h 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageToPlaneNormalFilter.h 13382 2008-08-04 18:53:26Z gpotts $
 #ifndef ossimImageToPlaneNormalFilter_HEADER
 #define ossimImageToPlaneNormalFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -45,6 +45,11 @@ public:
    bool saveState(ossimKeywordlist& kwl,
                   const char* prefix)const;
    virtual void initialize();
+   /* ------------------- PROPERTY INTERFACE -------------------- */
+   virtual void setProperty(ossimRefPtr<ossimProperty> property);
+   virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
+   virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
+   /* ------------------ PROPERTY INTERFACE END ------------------- */
    
 protected:
    ossimRefPtr<ossimImageData> theTile;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimImageWriterFactory.h b/Utilities/otbossim/include/ossim/imaging/ossimImageWriterFactory.h
index 4513fffe1b973375c80473aca830f385b392dbfd..4b0d034493069817774fb05f7370d5137beaa187 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimImageWriterFactory.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimImageWriterFactory.h
@@ -8,7 +8,7 @@
 // Author:  Frank Warmerdam (warmerda@home.com)
 //
 //*******************************************************************
-//  $Id: ossimImageWriterFactory.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageWriterFactory.h 13206 2008-07-22 19:48:02Z gpotts $
 
 #ifndef ossimImageWriterFactory_HEADER
 #define ossimImageWriterFactory_HEADER
@@ -52,7 +52,7 @@ protected:
 
    static ossimImageWriterFactory* theInstance;
 
-
+	ossimImageFileWriter* createFromMimeType(const ossimString& mimeType)const;
    bool isImageTypeName(const ossimString& name)const;
 };
 
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h
index c9485975ac1a19658e7ae390e51ddbd00494a811..811e32d57dda16b68ce391680b15b608cf9aa306 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimJpegTileSource.h
@@ -13,34 +13,11 @@
 // JpegTileSource is derived from ImageHandler which is derived from
 // TileSource.
 //*******************************************************************
-//  $Id: ossimJpegTileSource.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimJpegTileSource.h 13054 2008-06-23 13:55:13Z gpotts $
 
 #ifndef ossimJpegTileSource_HEADER
 #define ossimJpegTileSource_HEADER
 
-#include <cstdio>
-
-//---
-// Using windows .NET compiler there is a conflict in the libjpeg with INT32
-// in the file jmorecfg.h.  Defining XMD_H fixes this.
-//---
-#if defined(__BORLANDC__)
-#include <iostream>
-using std::size_t;
-#include <stdlib.h>
-#include <stdio.h>
-#endif
-extern "C"
-{
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__BORLANDC__)
-#  ifndef XMD_H
-#    define XMD_H
-#  endif
-#endif
-#include <jpeglib.h>
-#include <setjmp.h>
-}
-
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimAppFixedTileCache.h>
 
@@ -156,6 +133,18 @@ public:
     */
    bool open(const ossimFilename& jpeg_file);
 
+   /**
+    * @brief Gets a property for matching name.
+    * @param name The name of the property to get.
+    * @return Returns property matching "name".
+    */
+   virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
+   
+   /**
+    * @brief Gets a list of property names available.
+    * @param propertyNames The list to push back names to.
+    */
+   virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
 protected:
 	class PrivateData;
    /**
@@ -190,9 +179,6 @@ protected:
 
    PrivateData*                 thePrivateData;
 
-   struct jpeg_decompress_struct theCinfo;
-   struct jpeg_error_mgr         theJerr;
-
    ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId;
 
 TYPE_DATA
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h b/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h
index 4ab59451dc548b5bebd0f057273705bccb9f0faf..1980ab771e14e62d4d38c159793e302699902ee9 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimMemoryImageSource.h
@@ -18,6 +18,14 @@ public:
    ossimMemoryImageSource();
 
    void setImage(ossimRefPtr<ossimImageData> image);
+   void setImage(ossimScalarType scalarType,
+                 ossim_uint32 numberOfBands,
+                 ossim_uint32 width,
+                 ossim_uint32 height);
+   void setRect(ossim_uint32 ulx,
+                ossim_uint32 uly,
+                ossim_uint32 width,
+                ossim_uint32 height);
    virtual ossim_uint32 getNumberOfInputBands() const;
    virtual ossim_uint32 getNumberOfOutputBands() const;
    virtual ossimScalarType getOutputScalarType() const;
@@ -44,10 +52,9 @@ public:
       kwl.add(prefix, theImageGeometry);
       return (theImageGeometry.getSize() > 0);
    }
-	virtual ossim_uint32 getNumberOfDecimationLevels() const
-	{
-		return 1;
-	}
+	virtual ossim_uint32 getNumberOfDecimationLevels() const;
+   virtual void getDecimationFactor(ossim_uint32 resLevel,
+                                    ossimDpt& result) const;
   
 protected:
    ossimRefPtr<ossimImageData> theImage;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimMetadataFileWriter.h b/Utilities/otbossim/include/ossim/imaging/ossimMetadataFileWriter.h
index 45e17d952db07d4679823922ce20dec887edbc06..a53ef461f6b66f3892abb20af5fd9b220cb04d0a 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimMetadataFileWriter.h 13312 2008-07-27 01:26:52Z gpotts $
 
 #ifndef ossimMetadataFileWriter_H
 #define ossimMetadataFileWriter_H
@@ -22,7 +22,7 @@
 #include <ossim/base/ossimObjectEvents.h>
 #include <ossim/base/ossimProcessProgressEvent.h>
 
-class ossimImageSourceInterface;
+class ossimImageSource;
 
 /**
  * ossimMetadataFileWriter
@@ -165,7 +165,7 @@ protected:
     */
    virtual bool writeFile() = 0;
 
-   ossimImageSourceInterface* theInputConnection;
+   ossimImageSource* theInputConnection;
    ossimFilename              theFilename;
    ossimPixelType             thePixelType;
    ossimIrect                 theAreaOfInterest;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h b/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h
new file mode 100644
index 0000000000000000000000000000000000000000..61c098302bef3e0965350e7998ebe1950aaeef74
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNitf20Writer.h
@@ -0,0 +1,202 @@
+//*******************************************************************
+// Copyright (C) 2000 ImageLinks Inc.
+//
+// License:  See top level LICENSE.txt file.
+//
+// Author:  Garrett Potts
+//
+//*******************************************************************
+//  $Id: ossimNitfWriter.h 9256 2006-07-14 15:28:19Z dburken $
+#ifndef ossimNitf20Writer_HEADER
+#define ossimNitf20Writer_HEADER
+
+#include <iosfwd>
+#include <ossim/imaging/ossimImageFileWriter.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/projection/ossimMapProjectionInfo.h>
+#include <ossim/base/ossimRgbLutDataObject.h>
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/support_data/ossimNitfFileHeaderV2_0.h>
+#include <ossim/support_data/ossimNitfImageHeaderV2_0.h>
+
+class ossimProjection;
+
+class OSSIM_DLL ossimNitf20Writer : public ossimImageFileWriter
+{
+public:
+   ossimNitf20Writer(const ossimFilename& filename=ossimFilename(""),
+                   ossimImageSource* inputSource = (ossimImageSource*)NULL);
+   virtual ~ossimNitf20Writer();
+   virtual bool isOpen()const;
+   virtual bool open();
+   virtual void close();
+   
+   /**
+    * void getImageTypeList(std::vector<ossimString>& imageTypeList)const
+    *
+    * Appends this writer image types to list "imageTypeList".
+    *
+    * This writer has the following types:
+    * nitf_block_band_separate
+    * nitf_block_band_sequential
+    *
+    * @param imageTypeList stl::vector<ossimString> list to append to.
+    */   
+   virtual void getImageTypeList(std::vector<ossimString>& imageTypeList)const;
+   
+   virtual void setProperty(ossimRefPtr<ossimProperty> property);
+   virtual ossimRefPtr<ossimProperty> getProperty(
+      const ossimString& name)const;
+
+   /**
+    * @param propertyNames Array to populate with property names.
+    *
+    * @note The following names are handled:
+    *  file_header
+    *  image_header
+    *  enable_rpcb_tag
+    *  enable_blocka_tag
+    */
+   virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
+   
+   void addRegisteredTag(ossimRefPtr<ossimNitfRegisteredTag> registeredTag);
+
+   /**
+    * 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:
+   
+   /**
+    * @return true on success false on error.
+    */
+   virtual bool writeFile();
+   
+   /**
+    * write out block band separate
+    * 
+    * @return true on success and false on error
+    */
+   virtual bool writeBlockBandSeparate();
+   
+   /**
+    * Outputs in band sequential format.  Band 1 is followed by band
+    * 2, ... etc.
+    */
+   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;
+   ossimRefPtr<ossimNitfImageHeaderV2_0> 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;
+
+   /**
+    *
+    * If true this will enable searching the input connnection for another NITF handler and 
+    * bring the fields to this writers output fields and will maintin as many field values as possible
+    *
+    */
+   bool theCopyFieldsFlag;
+   
+TYPE_DATA   
+};
+
+#endif /* #ifndef ossimNitfWriter_HEADER */
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h
index c4aad5e28d233f227df7756950656e22cd0e2f1b..49b2404b7a443809d9cfc37f0974ebfa0e6d2e8f 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimNitfTileSource.h
@@ -9,7 +9,7 @@
 // Contains class declaration for NitfTileSource.
 //
 //*******************************************************************
-//  $Id: ossimNitfTileSource.h 12218 2007-12-26 14:14:02Z dburken $
+//  $Id: ossimNitfTileSource.h 13942 2009-01-01 18:58:36Z dburken $
 #ifndef ossimNitfTileSource_HEADER
 #define ossimNitfTileSource_HEADER
 
@@ -17,9 +17,10 @@
 
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimAppFixedTileCache.h>
+#include <ossim/support_data/ossimNitfFile.h>
+#include <ossim/support_data/ossimNitfFileHeader.h>
+#include <ossim/support_data/ossimNitfImageHeader.h>
 
-class ossimNitfFile;
-class ossimNitfImageHeader;
 struct jpeg_decompress_struct;
 
 class OSSIM_DLL ossimNitfTileSource : public ossimImageHandler
@@ -206,6 +207,7 @@ public:
    virtual double getMaxPixelValue(ossim_uint32 band=0)const;
    virtual double getNullPixelValue(ossim_uint32 band=0)const;
 
+   const ossimNitfFileHeader* getFileHeader()const;
    /**
     * @return The image header for the current entry.
     */
@@ -304,7 +306,7 @@ protected:
    /**
     * Initializes the data member "theScalarType" from the current entry.
     */
-   void initializeScalarType();
+   virtual void initializeScalarType();
 
    /**
     * Initializes the data member "theSwapBytesFlag" from the current entry.
@@ -379,6 +381,12 @@ protected:
     */
    virtual void initializeCompressedBuf();
 
+   /**
+    * Initializes the output tile size(width and height).
+    */
+   virtual void initializeOutputTile();
+   
+
    /**
     * Loads a block of data to theCacheTile.
     * 
@@ -476,8 +484,8 @@ protected:
    
    ossimRefPtr<ossimImageData>   theTile;
    ossimRefPtr<ossimImageData>   theCacheTile;
-   ossimNitfFile*                theNitfFile;
-   vector<ossimNitfImageHeader*> theNitfImageHeader;
+   ossimRefPtr<ossimNitfFile>    theNitfFile;
+   vector<ossimRefPtr<ossimNitfImageHeader> > theNitfImageHeader;
    ReadMode                      theReadMode;
    ossimScalarType               theScalarType;
    bool                          theSwapBytesFlag;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h b/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h
index 1b428064124a061a06835e91485b30c571dc8dad..ad5ca539d0aa229a12e2808e0cd08612b5252bcc 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimRLevelFilter.h
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRLevelFilter.h 9526 2006-09-06 16:18:51Z dburken $
+// $Id: ossimRLevelFilter.h 13180 2008-07-16 21:01:56Z dburken $
 #ifndef ossimRLevelFilter_HEADER
 #define ossimRLevelFilter_HEADER
 #include <ossim/imaging/ossimImageSourceFilter.h>
@@ -52,6 +52,19 @@ public:
    virtual bool getOverrideGeometryFlag() const;
    virtual void setOverrideGeometryFlag(bool override);
 
+   /**
+    * @brief Returns the bounding rectangle.
+    *
+    * @param resLevel This argument is only passed onto the input connection
+    * if this filter is disabled.  @see disableSource().
+    *
+    * To get the bounding rectangle of an rlevel when source is enabled do:
+    * myRLevelFilter->setCurrentRLevel(level);
+    * myRLevelFilter->getBoundingRect();
+    *
+    * @return Rectangle of the current rlevel if enabled; else, the rectangle
+    * of the input connection for resLevel.
+    */
    virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const;
 
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimSFIMFusion.h b/Utilities/otbossim/include/ossim/imaging/ossimSFIMFusion.h
index 841d396444938eea51562ecc9345aa85b3849c23..bb7a49442c05ce63ea6d6fae680d177a38eb1e72 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimSFIMFusion.h 13371 2008-08-02 13:42:42Z gpotts $
 #ifndef ossimSFIMFusion_HEADER
 #define ossimSFIMFusion_HEADER
 #include <ossim/imaging/ossimFusionCombiner.h>
@@ -23,6 +23,10 @@
  *  Pulished in INT. J. Remote Sensing, 2000, Vol. 21 NO. 18, 3461-3472
  *
  *  By J. G. LIU
+ *
+ *
+ * Auther: Garrett Potts
+ * LICENSE: LGPL
  */
 class OSSIM_DLL ossimSFIMFusion : public ossimFusionCombiner,
                                   public ossimAdjustableParameterInterface
@@ -44,6 +48,11 @@ public:
    }
    virtual void initAdjustableParameters();
    virtual void adjustableParametersChanged();
+   
+   virtual void setProperty(ossimRefPtr<ossimProperty> property);
+   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;
 
@@ -58,7 +67,7 @@ protected:
                           ossimRefPtr<ossimImageData> colorData,
                           ossim_uint32 colorBandIdx);
    
-   ossim_float64 theBlurrKernelWidth;
+   ossim_float64 theLowPassKernelWidth;
    ossim_uint32 theHighPassKernelWidth;
    // These are low and high pass filters for the single pan band
    //
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTableRemapper.h b/Utilities/otbossim/include/ossim/imaging/ossimTableRemapper.h
index f5e052589e7c17cff67634df81e540719e716a90..0fc25bee6905ec77121b682263152b6286826f74 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 11909 2007-10-28 18:17:05Z dburken $
+// $Id: ossimTableRemapper.h 13473 2008-08-22 14:19:49Z gpotts $
 #ifndef ossimTableRemapper_HEADER
 #define ossimTableRemapper_HEADER
 
@@ -101,23 +101,16 @@ protected:
     *   build the table and manage the memory yourself; in which case, you
     *   would set the own_table false; else it will be de
     */
-   virtual void setTable(ossim_uint8*    table,
+   virtual void setTable(const std::vector<ossim_uint8>&    table,
                          ossim_uint32    table_bin_count,
                          ossim_uint32    table_band_count,
                          RemapTableType  table_type,
-                         ossimScalarType output_scalar_type,
-                         bool            own_table = true);
+                         ossimScalarType output_scalar_type);
 
-   /**
-    * @param flag Should be true if this object is owner of theTable,
-    * false if derived class or user is responsible for allocation,
-    * deletion of "theTable".
-    */
-   virtual void setTableOwnership(bool flag);
    
    ossimRefPtr<ossimImageData> theTile;
    ossimRefPtr<ossimImageData> theTmpTile;
-   ossim_uint8*    theTable;
+   std::vector<ossim_uint8>    theTable;
    ossim_float64*  theNormBuf;
    ossim_uint32    theTableBinCount;
    ossim_uint32    theTableBandCount;
@@ -125,7 +118,6 @@ protected:
    ossimScalarType theInputScalarType;
    ossimScalarType theOutputScalarType;
    
-   bool theTableOwnerFlag; ///< True if "this" is responsible for memory.
    
    void allocate(const ossimIrect& rect);
    void destroy();
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h b/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h
index ba59205e429d7b93f8c8a5f83933d1c40b15b20c..77a2b12d2c5c6380fa82975e29f905ab53fc1226 100644
--- a/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTiffTileSource.h
@@ -16,10 +16,10 @@
 #ifndef ossimTiffTileSource_HEADER
 #define ossimTiffTileSource_HEADER
 
-#include <tiffio.h>
 
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/base/ossimIrect.h>
+#include <tiffio.h>
 
 class ossimImageData;
 class ossimTiffOverviewTileSource;
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTilePatch.h b/Utilities/otbossim/include/ossim/imaging/ossimTilePatch.h
index 7cf836f56d1b001daa940c83cb788014a59c6372..6874e9f1b0ac7cbcd9e10012eb99e2ddeedf949c 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimTilePatch.h 13312 2008-07-27 01:26:52Z gpotts $
 
 #ifndef ossimTilePatch_HEADER
 #define ossimTilePatch_HEADER
@@ -19,12 +19,12 @@
 #include <ossim/imaging/ossimDiscreteNearestNeighbor.h>
 #include <ossim/imaging/ossimImageData.h>
 
-class ossimImageSourceInterface;
+class ossimImageSource;
 
 class ossimTilePatch : public ossimObject
 {
 public:
-   ossimTilePatch(ossimImageSourceInterface* input);
+   ossimTilePatch(ossimImageSource* input);
    /*!
     * The rect is assumed up right and all we need
     * to do is compute the even tile boundary rect
@@ -86,7 +86,7 @@ public:
                          const ossimDpt   &length)const;
 
 
-   virtual void fillPatch(ossimImageSourceInterface *imageSource,
+   virtual void fillPatch(ossimImageSource *imageSource,
                           long resLevel = 0);
    
    
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTwoColorView.h b/Utilities/otbossim/include/ossim/imaging/ossimTwoColorView.h
new file mode 100644
index 0000000000000000000000000000000000000000..6210e533602202c337fb527fa3ddb99cf1a79308
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/imaging/ossimTwoColorView.h
@@ -0,0 +1,62 @@
+//-------------------------------------------------------------------
+// License:  LGPL.  See top level LICENSE.txt file.
+//
+// Author:  Garrett Potts
+//
+//-------------------------------------------------------------------
+//  $Id$
+#ifndef ossimTwoColorView_HEADER
+#define ossimTwoColorView_HEADER 1
+#include <ossim/base/ossimConstants.h>
+#include <ossim/imaging/ossimImageCombiner.h>
+
+/**
+ * This is a 2 color view of the input.  It basically allows for a change detection and by default will take the first input and map
+ * it to the blue channel and takes the second input and maps to the red channel.  The unused channel is mapped to a min pixel value.
+ */
+class OSSIM_DLL ossimTwoColorView : public ossimImageCombiner
+{
+public:
+   ossimTwoColorView();
+   virtual ossim_uint32 getNumberOfOutputBands() const;
+   /**
+    * @return the requested region of interest
+    */
+   virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& rect,
+                                               ossim_uint32 resLevel=0);
+   ossimScalarType getOutputScalarType() const;
+   
+   double getNullPixelValue(ossim_uint32 band)const;
+   double getMinPixelValue(ossim_uint32 band)const;
+   double getMaxPixelValue(ossim_uint32 band)const;
+   
+   /**
+    * Will allow you to change the mapping of the new input and old input to the output band.  
+    * Indexing from 0 based band numbering, by default the new channel (input 0) will be mapped to 
+    * the output tile's blue channel (band 2) and the input 1 will be mapped to the red channel (band 0) 
+    * and the green will have the value of min pix.  Use this method to change the new and old default output
+    * mappings.
+    */
+   void setIndexMapping(ossim_uint32 newIndex,
+                        ossim_uint32 oldIndex);
+   virtual void initialize();
+   
+protected:
+   void allocate();
+   void runAlgorithm(ossimImageData* newData, ossimImageData* oldData);
+   void runNative8(ossimImageData* newData,   ossimImageData* oldData);
+   void runNorm(ossimImageData* newData,   ossimImageData* oldData);
+   
+   bool theByPassFlag;
+   bool theNativeFlag;
+   ossimRefPtr<ossimImageData> theTwoColorTile;
+   ossimImageSource* theNewInput;
+   ossimImageSource* theOldInput;
+   ossim_uint32 theNewBufferDestinationIndex;
+   ossim_uint32 theOldBufferDestinationIndex;
+   ossim_uint32 theMinBufferDestinationIndex;
+
+TYPE_DATA
+};
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/imaging/ossimVertexExtractor.h b/Utilities/otbossim/include/ossim/imaging/ossimVertexExtractor.h
index 93ff0b2ca18cd193c40cbbdb8a89a82fe6cf5241..412d1e6f75483982f76286bf139f797cf8d19fa6 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 9968 2006-11-29 14:01:53Z gpotts $
+// $Id: ossimVertexExtractor.h 13312 2008-07-27 01:26:52Z gpotts $
 
 #ifndef ossimVertexExtractor_HEADER
 #define ossimVertexExtractor_HEADER
@@ -107,7 +107,7 @@ public:
                             const ossimConnectableObject* object)const
       {
          
-         return (object&& PTR_CAST(ossimImageSourceInterface, object));
+         return (object&& PTR_CAST(ossimImageSource, object));
       }
 
    vector<ossimIpt> getVertices() { return theVertice; }
diff --git a/Utilities/otbossim/include/ossim/kbool/_dl_itr.h b/Utilities/otbossim/include/ossim/kbool/_dl_itr.h
index cd8dd2f97d6f9e4c4e0744eb877d9b12f15974c3..058f2407bc41704a59252e6f374de9c37386aae9 100644
--- a/Utilities/otbossim/include/ossim/kbool/_dl_itr.h
+++ b/Utilities/otbossim/include/ossim/kbool/_dl_itr.h
@@ -5,7 +5,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: _dl_itr.h 9094 2006-06-13 19:12:40Z dburken $
+    RCS-ID: $Id: _dl_itr.h 13215 2008-07-23 18:51:54Z dburken $
 */
 
 //! author="Klaas Holwerda"
@@ -103,7 +103,7 @@ template <class Dtype> class DL_List
          ~DL_List();
 
 		   //!Report off List Errors
-   		void Error(char* function,Lerror a_error);
+   		void Error(const char* function,Lerror a_error);
 
 		   //!Number of items in the list
          int  count();
@@ -168,7 +168,7 @@ class DL_Iter
 		~DL_Iter();
 
 	   //!Report off Iterator Errors
-		void 	  Error(char* function,Lerror a_error);
+		void 	  Error(const char* function,Lerror a_error);
 
 //                bool isAttached()const;
 
diff --git a/Utilities/otbossim/include/ossim/kbool/_dl_itr.inc b/Utilities/otbossim/include/ossim/kbool/_dl_itr.inc
index 04d7c14d9a7856ae024f8d683abc9721c5ee0eb4..d53d9dbfcd39387e0f9539c64eaa11a6e33590e8 100644
--- a/Utilities/otbossim/include/ossim/kbool/_dl_itr.inc
+++ b/Utilities/otbossim/include/ossim/kbool/_dl_itr.inc
@@ -6,7 +6,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: _dl_itr.inc 11045 2007-05-25 17:29:17Z gpotts $
+    RCS-ID: $Id: _dl_itr.inc 13215 2008-07-23 18:51:54Z dburken $
 */
 
 #ifdef __GNUG__
@@ -124,7 +124,7 @@ Error("remove_all",ITER_GT_O);
 \param error code to generate a message for
 */
 template <class Dtype>
-void DL_List<Dtype>::Error(char* function,Lerror a_error)
+void DL_List<Dtype>::Error(const char* function,Lerror a_error)
 {
 	std::string buf = "DL_List<Dtype>::";
 	buf += ((function?function:""));
@@ -553,7 +553,7 @@ void DL_List<Dtype>::takeover(DL_List<Dtype>* otherlist)
  \param a_error:  error code to generate a message for
 */
 template <class Dtype>
-void DL_Iter<Dtype>::Error(char* function,Lerror a_error)
+void DL_Iter<Dtype>::Error(const char* function,Lerror a_error)
 {
 	std::string buf;
 	buf += "DL_Iter<Dtype>::";
diff --git a/Utilities/otbossim/include/ossim/kbool/bool_globals.h b/Utilities/otbossim/include/ossim/kbool/bool_globals.h
index 6bb8126e6a307b921692033508644b2d9d3e8091..b2ec9f0647a6125f03fe3fc8bbd9263e3cd62666 100644
--- a/Utilities/otbossim/include/ossim/kbool/bool_globals.h
+++ b/Utilities/otbossim/include/ossim/kbool/bool_globals.h
@@ -8,6 +8,7 @@
 #endif
 
 #include <limits> /* for numeric_limits::min/max */
+#include <string>
 #include <ossim/base/ossimConstants.h>
 
 #ifdef OSSIMMAKINGDLL
@@ -88,8 +89,8 @@ B_INT babs(B_INT);
 #define NULL 0
 #endif
 
-B_INT bmin(B_INT const value1, B_INT const value2);
-B_INT bmax(B_INT const value1, B_INT const value2);
+//B_INT bmin(B_INT const value1, B_INT const value2);
+//B_INT bmax(B_INT const value1, B_INT const value2);
 
 B_INT bmin(B_INT value1, B_INT value2);
 B_INT bmax(B_INT value1, B_INT value2);
@@ -130,19 +131,19 @@ enum BOOL_OP
 class A2DKBOOLDLLEXP Bool_Engine_Error
 {
 	public:
-		Bool_Engine_Error(char* message, char* header=0, int degree = 9, int fatal = 0);
+		Bool_Engine_Error(const char* message, const char* header=0, int degree = 9, int fatal = 0);
 		Bool_Engine_Error(const Bool_Engine_Error& a);
 		~Bool_Engine_Error();
-		char*	GetErrorMessage();
-		char* GetHeaderMessage();
+		const char* GetErrorMessage();
+		const char* GetHeaderMessage();
 		int	GetErrorDegree();
 		int	GetFatal();
 
 	protected:
-		char*	_message;
-		char*	_header;
-		int 	_degree;
-		int 	_fatal;
+                std::string _message;
+                std::string _header;
+		int _degree;
+		int _fatal;
 };
 
 // Re-enable the warning for other files
diff --git a/Utilities/otbossim/include/ossim/kbool/booleng.h b/Utilities/otbossim/include/ossim/kbool/booleng.h
index d2733a151dec25429bd4b52af1236b951f47f70c..8a99fbf2b2a50b77fa5a42a46a731def8c5f3b8f 100644
--- a/Utilities/otbossim/include/ossim/kbool/booleng.h
+++ b/Utilities/otbossim/include/ossim/kbool/booleng.h
@@ -5,7 +5,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: booleng.h 12954 2008-06-01 16:26:32Z dburken $
+    RCS-ID: $Id: booleng.h 13215 2008-07-23 18:51:54Z dburken $
 */
 
 #ifndef BOOLENG_H
@@ -50,13 +50,13 @@ class A2DKBOOLDLLEXP Bool_Engine {
    const char* GetVersion() { return KBOOL_VERSION; }
 
 	//! reports progress of algorithm.
-   virtual void SetState( char* = 0 );
+   virtual void SetState( const char* = 0 );
 
 	//! called at an internal error.
-	virtual void error(char *text, char *title);
+	virtual void error(const char *text, const char *title);
 
 	//! called at an internal generated possible error.
-   virtual void info(char *text, char *title);
+   virtual void info(const char *text, const char *title);
 
    bool Do_Operation(BOOL_OP operation);
 
@@ -235,13 +235,13 @@ class A2DKBOOLDLLEXP Bool_Engine {
    void SetLog( bool OnOff ); 
 
    //! used to write to log file
-   void Write_Log(char *);
+   void Write_Log(const char *);
    //! used to write to log file
-   void Write_Log(char *, char *);
+   void Write_Log(const char *, const char *);
    //! used to write to log file
-   void Write_Log(char *, double);
+   void Write_Log(const char *, double);
    //! used to write to log file
-   void Write_Log(char *, B_INT);
+   void Write_Log(const char *, B_INT);
 
    FILE* GetLogFile() { return m_logfile; }
 
diff --git a/Utilities/otbossim/include/ossim/matrix/include.h b/Utilities/otbossim/include/ossim/matrix/include.h
index 80f06d362036446b3d2dc9b65d192e25852cb38f..2da155dad3d8bca9c8811f85517b25d6637bcf3c 100644
--- a/Utilities/otbossim/include/ossim/matrix/include.h
+++ b/Utilities/otbossim/include/ossim/matrix/include.h
@@ -10,8 +10,8 @@
 // Activate just one of the following 3 statements
 
 //#define SimulateExceptions              // use simulated exceptions
-//#define UseExceptions                   // use C++ exceptions
-#define DisableExceptions               // do not use exceptions
+#define UseExceptions                   // use C++ exceptions
+//#define DisableExceptions               // do not use exceptions
 
 
 //#define TEMPS_DESTROYED_QUICKLY         // for compilers that delete
diff --git a/Utilities/otbossim/include/ossim/matrix/solution.h b/Utilities/otbossim/include/ossim/matrix/solution.h
index 96d87445240a3ad3efb5716ae056fd86b126c8f3..7eb63858d730103001a61b49ef70d9c32bdc4d61 100644
--- a/Utilities/otbossim/include/ossim/matrix/solution.h
+++ b/Utilities/otbossim/include/ossim/matrix/solution.h
@@ -1,6 +1,6 @@
 //$$ solution.h                      // solve routines
 
-#include <ossim/matrix/boolean.h>
+// #include <ossim/matrix/boolean.h>
 #include <ossim/matrix/myexcept.h>
 
 #ifdef use_namespace
diff --git a/Utilities/otbossim/include/ossim/ossimConfig.h.in b/Utilities/otbossim/include/ossim/ossimConfig.h.in
index 49cb88cf00d67c1b034892cc13b88e3e23340900..b8a09dcf11da32e340334cc26777ad9bdfbbf71d 100644
--- a/Utilities/otbossim/include/ossim/ossimConfig.h.in
+++ b/Utilities/otbossim/include/ossim/ossimConfig.h.in
@@ -1,70 +1,7 @@
-/*  $Id: ossimConfig.h.in,v 1.23 2005/11/09 19:30:09 gpotts Exp $ */
+/*  $Id: ossimConfig.h.in 13607 2008-09-25 19:39:45Z gpotts $ */
 #ifndef ossimConfig_HEADER
 #define ossimConfig_HEADER
 
-/* Define if you have dirent.h.  */
-#cmakedefine CMAKE_HAVE_DIRENT_H
-#ifdef CMAKE_HAVE_DIRENT_H
-#define HAVE_DIRENT_H 1
-#else
-#define HAVE_DIRENT_H 0
-#endif
-
-/* Define as 1 if you have unistd.h.  */
-#cmakedefine CMAKE_HAVE_UNISTD_H
-#ifdef CMAKE_HAVE_UNISTD_H 
-#define HAVE_UNISTD_H 1
-#else
-#define HAVE_UNISTD_H 0
-#endif
-
-/* Define as 1 if you have getopt.h.  */
-#cmakedefine CMAKE_HAVE_GETOPT_H
-#ifdef CMAKE_HAVE_GETOPT_H 
-#define HAVE_GETOPT_H 1
-#else
-#define HAVE_GETOPT_H 0
-#endif
-
-/* Define as 1 if you have fcntl.h.  */
-#cmakedefine CMAKE_HAVE_FCNTL_H
-#ifdef CMAKE_HAVE_FCNTL_H
-#define HAVE_FCNTL_H 1
-#else
-#define HAVE_FCNTL_H 0
-#endif
-
-/* Define as 1 if you have dbmalloc.h.  */
-#cmakedefine CMAKE_HAVE_DBMALLOC_H
-#ifdef CMAKE_HAVE_DBMALLOC_H
-#define HAVE_DBMALLOC_H 1
-#else
-#define  HAVE_DBMALLOC_H 0
-#endif
-
-/* Define as 1 if you have malloc.h.  */
-#cmakedefine CMAKE_HAVE_MALLOC_H
-#ifdef CMAKE_HAVE_MALLOC_H
-#define HAVE_MALLOC_H 1
-#else
-#define HAVE_MALLOC_H 0
-
-#endif
-
-/* Define as 1 if you have dlfcn.h. */
-#cmakedefine CMAKE_HAVE_DLFCN_H
-#ifdef CMAKE_HAVE_DLFCN_H
-#define HAVE_DLFCN_H 1
-#else 
-#define HAVE_DLFCN_H 0
-#endif
-
-#if 0
-/// Commented since ti seems not to be used
-/* Define if you have support for large (64 bit size) files */
-#define HAVE_LARGEFILE_SUPPORT 0
-#endif
-
 /* Define to "1" if you have libz installed, "0" if not. */
 #define OSSIM_HAS_LIBZ 0
 
@@ -83,49 +20,6 @@
 /* Enable cvs id strings for use with "ident" application. */
 #define OSSIM_ID_ENABLED 1
 
-/* Enable dynamic library support for plugins.
- * Usually set to 0 for static applications.
- */
-#define OSSIM_DYNAMIC_ENABLED 1
-
-/* Define to the correct byte sizes.  
- * If not available define to 0 so OSSIM uses the defaults
- */
-#define OSSIM_SIZEOF_FLOAT      @CMAKE_SIZEOF_FLOAT@
-#define OSSIM_SIZEOF_DOUBLE     @CMAKE_SIZEOF_DOUBLE@
-#define OSSIM_SIZEOF_LONG_LONG  @OTB_SIZEOF_LONG_LONG@
-#define OSSIM_SIZEOF_LONG_INT   @OTB_SIZEOF_LONG_INT@
-#define OSSIM_SIZEOF_INT        @CMAKE_SIZEOF_INT@
-#define OSSIM_SIZEOF_SHORT_INT  @OTB_SIZEOF_SHORT_INT@
-
-/* These are OS specific defines */
-#define __OSSIM_LINUX__ 0
-#define __OSSIM_DARWIN__ 0
-#define __OSSIM_ALPHA__ 0
-#define __OSSIM_SGI__ 0
-#define __OSSIM_SUN__ 0
-#define __OSSIM_SUNOS__ 0
-#define __OSSIM_SOLARIS__ 0
-#define __OSSIM_FREEBSD__ 0
-#define __OSSIM_BSD__ 0
-#define __OSSIM_OPENBSD__ 0
-#define __OSSIM_NETBSD__ 0
-#define __OSSIM_OSF__ 0
-#define __OSSIM_SYSV__ 0
-#define __OSSIM_AIX__ 0
-#define __OSSIM_DOS__ 0
-#define __OSSIM_POWERPC__ 0
-#define __OSSIM_BEOS__ 0
-#define __OSSIM_SVR4__ 0
-#define __OSSIM_EMX__ 0
-#define __OSSIM_CYGWIN__ 0
-
-#define OSSIM_MAJOR_VERSION_NUMBER @OSSIM_MAJOR_VERSION_NUMBER@
-#define OSSIM_MINOR_VERSION_NUMBER @OSSIM_MINOR_VERSION_NUMBER@
-#define OSSIM_PATCH_VERSION_NUMBER @OSSIM_PATCH_VERSION_NUMBER@
-#define OSSIM_RELEASE_NUMBER @OSSIM_RELEASE_NUMBER@
-#define OSSIM_VERSION "@OSSIM_VERSION@"
-
 // Added by otb developpers
 #if defined (_BASETSD_H) && !defined (_BASE_TSD_H_)
 #define _BASE_TSD_H_
@@ -136,4 +30,5 @@
 #define _BASE_TSD_H
 #endif
 
+
 #endif /* End of "#ifndef ossimConfig_HEADER" */
diff --git a/Utilities/otbossim/include/ossim/parallel/ossimMpi.h b/Utilities/otbossim/include/ossim/parallel/ossimMpi.h
index dbad1f02456aa480a94e17aaa6955abcb875b11a..3e4af6282c1b42bac634cf23470596f510eed697 100644
--- a/Utilities/otbossim/include/ossim/parallel/ossimMpi.h
+++ b/Utilities/otbossim/include/ossim/parallel/ossimMpi.h
@@ -6,17 +6,13 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimMpi.h 10167 2007-01-03 16:46:42Z dburken $
+// $Id: ossimMpi.h 13602 2008-09-25 14:23:32Z gpotts $
 #ifndef ossimMpi_HEADER
 #define ossimMpi_HEADER
 
 #include <ossim/ossimConfig.h>
 #include <ossim/base/ossimConstants.h>
 
-#if OSSIM_HAS_MPI
-#  include <mpi.h>
-#endif
-
 class OSSIM_DLL ossimMpi
 {
 public:
diff --git a/Utilities/otbossim/include/ossim/plugin/ossimDynamicLibrary.h b/Utilities/otbossim/include/ossim/plugin/ossimDynamicLibrary.h
index 55242e8489abfc89fd0819bd10d6e72d423d3085..92f40485350bd87fdd23b3c9c2acdbb8ffe9b664 100644
--- a/Utilities/otbossim/include/ossim/plugin/ossimDynamicLibrary.h
+++ b/Utilities/otbossim/include/ossim/plugin/ossimDynamicLibrary.h
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimDynamicLibrary.h 12319 2008-01-16 19:55:24Z gpotts $
+// $Id: ossimDynamicLibrary.h 13600 2008-09-24 15:11:44Z gpotts $
 #ifndef ossimDynamicLibrary_HEADER
 #define ossimDynamicLibrary_HEADER
 
@@ -20,11 +20,8 @@
 
 #if defined(_WIN32) || defined(__WIN32__)
 #include <windows.h>
-#elif HAVE_DLFCN_H
+#else 
 #include <dlfcn.h>
-#else
-#define OSSIM_DYNAMIC_DISABLED
-// #error "dynamic loading interface is unsupported on this platform"
 #endif
 
 class ossimDynamicLibrary : public ossimReferenced
diff --git a/Utilities/otbossim/include/ossim/plugin/ossimSharedPluginRegistry.h b/Utilities/otbossim/include/ossim/plugin/ossimSharedPluginRegistry.h
index d9301633ec6d5fbf82d874aff0535ebbe611cee7..59561fc9bf8a4af0ec9cb0c2db2f7e352de55c5e 100644
--- a/Utilities/otbossim/include/ossim/plugin/ossimSharedPluginRegistry.h
+++ b/Utilities/otbossim/include/ossim/plugin/ossimSharedPluginRegistry.h
@@ -1,5 +1,6 @@
 #ifndef ossimSharedPluginRegistry_HEADER
 #define ossimSharedPluginRegistry_HEADER
+#include <iostream>
 #include <vector>
 #include <ossim/plugin/ossimSharedObjectBridge.h>
 #include <ossim/base/ossimFilename.h>
@@ -15,7 +16,7 @@ public:
 
    bool registerPlugin(const ossimFilename& filename, bool insertFrontFlag=false);
    bool unregisterPlugin(int idx);
-  bool unregisterPlugin(ossimPluginLibrary* plugin);
+   bool unregisterPlugin(ossimPluginLibrary* plugin);
    const ossimPluginLibrary* getPlugin(const ossimFilename& filename)const;
    ossimPluginLibrary* getPlugin(const ossimFilename& filename);
 
@@ -23,7 +24,7 @@ public:
    ossimPluginLibrary* getPlugin(ossim_uint32 idx);
    const ossimPluginLibrary* getPlugin(ossim_uint32 idx)const;
    ossim_uint32 getNumberOfPlugins()const;
-   
+
    /**
     * Checks if filename is already loaded to avoid duplication.
     * 
@@ -32,13 +33,15 @@ public:
     * @return true if any of the plugins match file name, false if not.
     */
    bool isLoaded(const ossimFilename& filename) const;
-
+   
+   void printAllPluginInformation(std::ostream& out);
+   
 protected:
-   ossimSharedPluginRegistry(){}
+   ossimSharedPluginRegistry();
    ossimSharedPluginRegistry(const ossimSharedPluginRegistry&){}
    void operator = (const ossimSharedPluginRegistry&){}
 
-   static ossimSharedPluginRegistry* theInstance;   
+   //static ossimSharedPluginRegistry* theInstance;   
    std::vector<ossimRefPtr<ossimPluginLibrary> > theLibraryList;
 };
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimApplanixEcefModel.h b/Utilities/otbossim/include/ossim/projection/ossimApplanixEcefModel.h
index a49b529239e421b354c57c938c0c5d9129741b87..64220d16443997fa8c82277b304bd17013e5ded0 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimApplanixEcefModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimApplanixEcefModel.h
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimApplanixEcefModel.h 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimApplanixEcefModel.h 13562 2008-09-10 14:56:31Z gpotts $
 #ifndef ossimApplanixEcefModel_HEADER
 #define ossimApplanixEcefModel_HEADER
 #include <ossim/projection/ossimFcsiModel.h>
@@ -17,6 +17,14 @@ class OSSIM_DLL ossimApplanixEcefModel : public ossimSensorModel
 {
 public:
    ossimApplanixEcefModel();
+   ossimApplanixEcefModel(const ossimDrect& imageRect, // center in image space
+                          const ossimGpt& platformPosition,
+                          double roll,
+                          double pitch,
+                          double heading,
+                          const ossimDpt& principalPoint, // in millimeters
+                          double focalLength, // in millimeters
+                          const ossimDpt& pixelSize); // in millimeters
    ossimApplanixEcefModel(const ossimApplanixEcefModel& src);
    virtual ossimObject* dup()const;
    
@@ -62,6 +70,8 @@ public:
    virtual bool setupOptimizer(const ossimString& init_file); //!uses file path to init model
 
 protected:
+   void computeGsd();
+   
    NEWMAT::Matrix theCompositeMatrix;
    NEWMAT::Matrix theCompositeMatrixInverse;
    double         theRoll;
diff --git a/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h b/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h
new file mode 100644
index 0000000000000000000000000000000000000000..2e546fe364e26a6aefc1c94aa6762b9104b01666
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/projection/ossimImageProjectionModel.h
@@ -0,0 +1,61 @@
+//-----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Class declaration of ossimImageProjectionModel.
+//
+//-----------------------------------------------------------------------------
+// $Id$
+
+#ifndef ossimImageProjectionModel_HEADER
+#define ossimImageProjectionModel_HEADER 1
+
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimRtti.h>
+#include <ossim/imaging/ossimImageModel.h>
+
+class ossimProjection;
+
+/**
+ * @brief Class derived from ossimImageModel, this adds an image projection
+ * for lineSampleToWorld and worldToLineSample.
+ *
+ * Note that image points fed to projection methods should be full
+ * resolution with any sub image offset applied.
+ */
+class OSSIM_DLL ossimImageProjectionModel : public ossimImageModel
+{
+public:
+   
+   /** @brief default constructor */
+   ossimImageProjectionModel();
+
+   /** @brief virtual destructor */
+   virtual ~ossimImageProjectionModel();
+
+   /**
+    * @brief Method to initialize class from an image handler.
+    *
+    * @param ih Image handler.
+    */
+   virtual void initialize(const ossimImageHandler& ih);
+
+   /**
+    * @brief Method to get projection.
+    *
+    * @return Constant pointer to projection or 0 if not initialized.
+    */
+   const ossimProjection* getProjection() const;
+
+private:
+
+   ossimProjection* theProjection;
+
+TYPE_DATA
+};
+
+#endif /* #ifndef ossimImageProjectionModel_HEADER */
diff --git a/Utilities/otbossim/include/ossim/projection/ossimImageViewAffineTransform.h b/Utilities/otbossim/include/ossim/projection/ossimImageViewAffineTransform.h
index ae55e4b3c5cfb033f8e43b2af575dcfe8bfab1a4..b0e7aa9a397adf4e1c467a5ea87a103be38676d2 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageViewAffineTransform.h 13459 2008-08-20 12:48:50Z gpotts $
 #ifndef ossimImageViewAffineTransform_HEADER
 #define ossimImageViewAffineTransform_HEADER
 #include <ossim/projection/ossimImageViewTransform.h>
@@ -26,6 +26,20 @@ public:
                                  double translateOriginYValue = 0);
    virtual ~ossimImageViewAffineTransform();
    
+   ossimImageViewAffineTransform(const ossimImageViewAffineTransform& src)
+   :ossimImageViewTransform(src),
+   theTransform(src.theTransform),
+   theInverseTransform(src.theInverseTransform),
+   theRotation(src.theRotation),
+   theScale(src.theScale),
+   theTranslate(src.theTranslate),
+   theTranslateOrigin(src.theTranslateOrigin)
+   {
+   }
+   virtual ossimObject* dup()const
+   {
+      return new ossimImageViewAffineTransform(*this);
+   }
    virtual void imageToView(const ossimDpt& imagePoint,
                             ossimDpt&       viewPoint)const;
    virtual void viewToImage(const ossimDpt& viewPoint,
diff --git a/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h b/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h
index e7fa2675c82cdf8fe1c078e6dde2ff67f5cbba65..77c0f46c7fc54bd51b0fbc895f5574d8c9076a7e 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimImageViewProjectionTransform.h
@@ -12,16 +12,13 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimImageViewProjectionTransform.h 9968 2006-11-29 14:01:53Z gpotts $
+//  $Id: ossimImageViewProjectionTransform.h 13516 2008-08-29 14:54:12Z dburken $
 
 #ifndef ossimImageViewProjectionTransform_HEADER
 #define ossimImageViewProjectionTransform_HEADER
 
 #include <ossim/projection/ossimImageViewTransform.h>
 #include <ossim/projection/ossimProjection.h>
-#ifndef NULL
-#include <stddef.h>
-#endif
 
 class ossimProjection;
 class ossimMapProjection;
@@ -29,11 +26,18 @@ class ossimMapProjection;
 class OSSIMDLLEXPORT ossimImageViewProjectionTransform : public ossimImageViewTransform
 {
 public:
-   ossimImageViewProjectionTransform(ossimProjection* imageProjection=NULL,
-                                     ossimProjection* viewProjection=NULL,
+   ossimImageViewProjectionTransform(ossimProjection* imageProjection=0,
+                                     ossimProjection* viewProjection=0,
                                      bool ownsImageProjectionFlag=true,
                                      bool ownsViewProjectionFlag=true);
-   
+
+   /** copy constructor */
+   ossimImageViewProjectionTransform(const ossimImageViewProjectionTransform& src);
+
+   virtual ossimObject* dup()const
+   {
+      return new ossimImageViewProjectionTransform(*this);
+   }
    virtual ~ossimImageViewProjectionTransform();
 
    virtual bool isValid()const
diff --git a/Utilities/otbossim/include/ossim/projection/ossimMapProjection.h b/Utilities/otbossim/include/ossim/projection/ossimMapProjection.h
index 19c2cf1dabd8df957f8f65fd48aebfd5d817fe73..f6342f045de39d1566c0c5c360e95a342c52095d 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 12517 2008-02-28 15:21:44Z dburken $
+//  $Id: ossimMapProjection.h 13823 2008-10-31 17:21:22Z dburken $
 
 #ifndef ossimMapProjection_HEADER
 #define ossimMapProjection_HEADER
@@ -169,6 +169,8 @@ public:
    
    virtual void setMetersPerPixel(const ossimDpt& gsd);
    virtual void setDecimalDegreesPerPixel(const ossimDpt& gsd);
+   virtual void setUlTiePoints(const ossimGpt& gpt);
+   virtual void setUlTiePoints(const ossimDpt& eastingNorthing);
    virtual void setUlEastingNorthing(const  ossimDpt& ulEastingNorthing);
    virtual void setUlGpt(const  ossimGpt& ulGpt);
    virtual void assign( const  ossimProjection &aProjection);
@@ -259,6 +261,7 @@ public:
     * new tie point: -90.3246 42.0298
     */
    void snapTiePointTo(ossim_float64 multiple, ossimUnitType unitType);
+   void snapTiePointToOrigin();
                       
    void setElevationLookupFlag(bool flag);
    bool getElevationLookupFlag()const;
@@ -290,7 +293,7 @@ protected:
     *
     * @return true if match, false if not.
     */
-   bool verifyPcsCodeMatches();
+   bool verifyPcsCodeMatches() const;
    
    ossimEllipsoid   theEllipsoid;
    ossimGpt         theOrigin;
diff --git a/Utilities/otbossim/include/ossim/projection/ossimPcsCodeProjectionFactory.h b/Utilities/otbossim/include/ossim/projection/ossimPcsCodeProjectionFactory.h
index 31551cbd66bd809d73b1ee45f0743cfb59fda677..6bf166bc628531695a56a2498fa3efefb2e6a000 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimPcsCodeProjectionFactory.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimPcsCodeProjectionFactory.h
@@ -14,7 +14,7 @@
 // http://www.remotesensing.org/geotiff/spec/geotiff6.html#6.3.3.1
 // 
 //----------------------------------------------------------------------------
-//  $Id: ossimPcsCodeProjectionFactory.h 12081 2007-11-26 21:44:18Z dburken $
+//  $Id: ossimPcsCodeProjectionFactory.h 13819 2008-10-31 16:58:37Z dburken $
 
 #ifndef ossimPcsCodeProjectionFactory_HEADER
 #define ossimPcsCodeProjectionFactory_HEADER
@@ -68,12 +68,11 @@ public:
    virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
 
    /**
-    * Attempt to determine PCS code from projection.
+    * Attempts to determine PCS code from projection.
     *
     * @return a valid code or 0 if no match is found.
     */
-   
-   ossim_int16 getPcsCodeFromProjection(const ossimMapProjection* proj) const;
+   ossim_uint16 getPcsCodeFromProjection(const ossimMapProjection* proj) const;
 
 protected:
    ossimPcsCodeProjectionFactory();
diff --git a/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h b/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h
index 45741cc37d2e9f2c7042d5f082a87f67009ac0f0..3edb6adfd2cc240566813506a9965724a5c688f6 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimProjectionFactoryRegistry.h
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimProjectionFactoryRegistry.h 12081 2007-11-26 21:44:18Z dburken $
+// $Id: ossimProjectionFactoryRegistry.h 13508 2008-08-27 15:51:38Z gpotts $
 #ifndef ossimProjectionFactoryRegistry_HEADER
 #define ossimProjectionFactoryRegistry_HEADER
 #include <ossim/base/ossimString.h>
@@ -69,7 +69,6 @@ protected:
    ossimProjectionFactoryRegistry(const ossimProjectionFactoryRegistry& rhs);
    void operator = (const ossimProjectionFactoryRegistry&);
 
-   static ossimProjectionFactoryRegistry*   theInstance;
    std::vector<ossimProjectionFactoryBase*> theFactoryList;
 
    void initializeDefaults();
diff --git a/Utilities/otbossim/include/ossim/projection/ossimSensorModel.h b/Utilities/otbossim/include/ossim/projection/ossimSensorModel.h
index 82fdd87f69a5d8c920fb25177abff1444f8cd50c..01d735e96d5690ccec1b578ee7a487f6b8f8eb7a 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 12123 2007-12-06 15:21:16Z gpotts $
+//  $Id: ossimSensorModel.h 13673 2008-10-03 15:10:52Z gpotts $
 
 #ifndef ossimSensorModel_HEADER
 #define ossimSensorModel_HEADER
@@ -189,7 +189,9 @@ public:
 /*                  (p.u<=(double)(theImageSize.u-(1-FLT_EPSILON))) && */
 /*                  (p.v>=(0.0-FLT_EPSILON)) && */
 /*                  (p.v<=(double)(theImageSize.v-(1-FLT_EPSILON))) ); */
-         return theImageClipRect.pointWithin(p);
+         // if it's close to the edge we will consider it inside the image
+         //
+         return theImageClipRect.pointWithin(p, 2.0);
       }
 
    /*!
@@ -319,6 +321,10 @@ protected:
     * bounds.
     */ 
    ossimRefPtr<ossimProjection> theSeedFunction;
+   
+   mutable bool theExtrapolateImageFlag;
+   mutable bool theExtrapolateGroundFlag;
+   
 TYPE_DATA
 };
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h b/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h
index e05ef2523b9f178401166b4a7262e0448346ab8d..beb919ca2e58cccb56484569c7b8c58be4753756 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimSpot5Model.h
@@ -1,16 +1,16 @@
 //*******************************************************************
 //
 // License:  See top level LICENSE.txt file.
-// 
+//
 // Author:  Oscar Kramer <okramer@imagelinks.com>
 //          ossim port by David Burken <dburken@imagelinks.com>
 //
-// Description:  
+// Description:
 //
 // Contains declaration of class ossimSpot5Model.
-// 
+//
 //*****************************************************************************
-// $Id: ossimSpot5Model.h 12138 2007-12-07 14:30:22Z gpotts $
+// $Id: ossimSpot5Model.h 13976 2009-01-20 16:00:16Z gpotts $
 #ifndef ossimSpot5Model_HEADER
 #define ossimSpot5Model_HEADER
 
@@ -52,7 +52,7 @@ public:
       YAW_RATE,
       FOCAL_LEN_OFFSET,
       NUM_ADJUSTABLE_PARAMS // not an index
-   };   
+   };
 
    /*!
     * Returns pointer to a new instance, copy of this.
@@ -71,7 +71,7 @@ public:
     */
    virtual bool saveState(ossimKeywordlist& kwl,
                           const char* prefix=NULL) const;
-   
+
    virtual bool loadState(const ossimKeywordlist& kwl,
                           const char* prefix=NULL);
 
@@ -87,7 +87,7 @@ public:
    virtual void lineSampleHeightToWorld(const ossimDpt& image_point,
                                         const ossim_float64& heightEllipsoid,
                                         ossimGpt& worldPoint) const;
-   
+
    /*!
     * Given an image point, returns a ray originating at some arbitrarily high
     * point (ideally at the sensor position) and pointing towards the target.
@@ -115,10 +115,11 @@ protected:
     * Sets adjustables to default values.
     */
    void initAdjustableParameters();
-   
+
    void loadGeometry(FILE*);
    void loadSupportData();
-   NEWMAT::Matrix computeSatToOrbRotation(ossim_float64 t)const;
+    //void computeSatToOrbRotation(ossim_float64 t)const;
+   void computeSatToOrbRotation(NEWMAT::Matrix& result, ossim_float64 t)const;
 
 /*    virtual ossimDpt extrapolate (const ossimGpt& gp) const; */
 /*    virtual ossimGpt extrapolate (const ossimDpt& ip, */
@@ -130,14 +131,14 @@ protected:
    // Image constant parameters:
    //---
    ossimFilename  theMetaDataFile;
-   ossim_float64  theIllumAzimuth;  
+   ossim_float64  theIllumAzimuth;
    ossim_float64  theIllumElevation;
    ossim_float64  thePositionError;
    ossim_float64  theRefImagingTime;
 
    /** relative to full image */
    ossim_float64  theRefImagingTimeLine;
-   
+
    ossim_float64  theLineSamplingPeriod;
    ossimDpt       theSpotSubImageOffset;
 
diff --git a/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionInfo.h b/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionInfo.h
index 86a63584af4880e58705f447bb9ee4c495e8b6f0..2191ac90b5967a0d6e215e44cf359b1108c6476c 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionInfo.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimStatePlaneProjectionInfo.h
@@ -4,7 +4,7 @@
 //
 // Author: Garrett Potts
 //*******************************************************************
-//  $Id: ossimStatePlaneProjectionInfo.h 12442 2008-02-07 22:33:52Z dburken $
+//  $Id: ossimStatePlaneProjectionInfo.h 13399 2008-08-07 18:06:05Z dburken $
 #ifndef ossimStatePlaneProjectionInfo_HEADER
 #define ossimStatePlaneProjectionInfo_HEADER
 
@@ -99,7 +99,7 @@ private:
    
    double               theScaleFactor;
    
-   ossimUnitType        theUnits;        // "us_survey_ft" or "meters"
+   ossimUnitType        theUnits;        // "us_survey_ft" "feet" or "meters"
 };
 
 #endif /* #ifndef ossimStatePlaneProjectionInfo_HEADER */
diff --git a/Utilities/otbossim/include/ossim/projection/ossimUtmProjection.h b/Utilities/otbossim/include/ossim/projection/ossimUtmProjection.h
index 45051cded2512690311d7827c6ca6760f23a5f0a..49d1a57649621d6d77e0de007e285d1fc5b5976f 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimUtmProjection.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimUtmProjection.h
@@ -8,7 +8,7 @@
 //
 // Calls Geotrans Utm projection code.  
 //*******************************************************************
-//  $Id: ossimUtmProjection.h 11436 2007-07-27 19:41:42Z dburken $
+//  $Id: ossimUtmProjection.h 13825 2008-10-31 17:29:51Z dburken $
 #ifndef ossimUtmProjection_HEADER
 #define ossimUtmProjection_HEADER
 #include <ossim/projection/ossimMapProjection.h>
@@ -31,8 +31,18 @@ public:
    virtual ossimGpt inverse(const ossimDpt &eastingNorthing)const;
    virtual ossimDpt forward(const ossimGpt &latLon)const;
    virtual void update();
+
+   /**
+    * This will set the utm zone and utm origin base on origin passed in.
+    *
+    * @note If the origin latitude is not 0.0 it will also set the
+    * hemisphere.  If 0.0 hemisphere is unchanged from previous stored value.
+    */
+   virtual void setOrigin(const ossimGpt& origin);
+   
    void setZone(const ossimGpt& ground);
    void setZone(ossim_int32 zone);
+   void setHemisphere(const ossimGpt& ground);
    void setHemisphere(char hemisphere);
    static ossim_int32 computeZone(const ossimGpt& gpt);
 
@@ -44,7 +54,6 @@ public:
    ossim_int32 getZone()const;
 
    char getHemisphere()const;
-   
    virtual bool operator==(const ossimProjection& projection) const;
 
    /**
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimDtedAcc.h b/Utilities/otbossim/include/ossim/support_data/ossimDtedAcc.h
index 9ef5b9f66367cf4416232d51328db440fc012e3a..54237f430f36dcd69287ec89731e72ae5dc87a1c 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimDtedAcc.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimDtedAcc.h
@@ -8,7 +8,7 @@
 //               (ACC) of a DTED Level 1 file.
 //
 //********************************************************************
-// $Id: ossimDtedAcc.h 10262 2007-01-14 18:58:38Z dburken $
+// $Id: ossimDtedAcc.h 13571 2008-09-12 14:59:59Z gpotts $
 
 #ifndef ossimDtedAcc_H
 #define ossimDtedAcc_H
@@ -70,6 +70,7 @@ public:
                                               const ossimDtedAcc& acc);
    void parse(std::istream& in);
 
+   void clearFields();
 private:
    // Do not allow...
    ossimDtedAcc(const ossimDtedAcc& source);
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimERS.h b/Utilities/otbossim/include/ossim/support_data/ossimERS.h
index 0c79c43668b178332adee68e5bdcd97c24f98e75..c167fbb8660576a7af5fe5f1f2f15173f725a1b9 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimERS.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimERS.h
@@ -9,7 +9,7 @@
 // This class parses a ER Mapper raster file format header.
 //
 //********************************************************************
-// $Id: ossimERS.h 10315 2007-01-19 18:05:28Z dburken $
+// $Id: ossimERS.h 13216 2008-07-23 18:56:53Z dburken $
 
 #ifndef ossimERS_HEADER
 #define ossimERS_HEADER
@@ -80,7 +80,7 @@ public:
    
 private:
 
-   void parseError(char *msg);
+   void parseError(const char *msg);
    std::vector<ossimString> parseLine(std::istream& in);
    void parseHeader(std::istream& fptr);
    void parseRasterInfo(std::istream& fptr);
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h
new file mode 100644
index 0000000000000000000000000000000000000000..6153c9acff8403b089563c9e440b386170d2d074
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSizRecord.h
@@ -0,0 +1,126 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Container class for J2K Image and tile size (SIZ) record.
+//
+// See document BPJ2K01.00 Table 7-6 Image and tile size (15444-1 Annex A5.1)
+// 
+//----------------------------------------------------------------------------
+// $Id: ossimJ2kSizRecord.h,v 1.5 2005/10/13 21:24:47 dburken Exp $
+#ifndef ossimJ2kSizRecord_HEADER
+#define ossimJ2kSizRecord_HEADER
+
+#include <iosfwd>
+
+#include <ossim/base/ossimConstants.h>
+
+class OSSIM_DLL ossimJ2kSizRecord
+{
+public:
+   
+   /** default constructor */
+   ossimJ2kSizRecord();
+
+   /** destructor */
+   ~ossimJ2kSizRecord();
+
+   /**
+    * Parse method.  Performs byte swapping as needed.
+    *
+    * @param in Stream to parse.
+    *
+    * @note Marker is not read.
+    */
+   void parseStream(std::istream& in);
+
+   /** @return scalar type based on bit depth and signed bit from theSsiz. */
+   ossimScalarType getScalarType() const;
+
+   /**
+    * Print method.
+    *
+    * @param out Stream to print to.
+    * 
+    * @return std::ostream&
+    */
+   std::ostream& print(std::ostream& out) const;
+
+   /** operator<< */
+   friend OSSIM_DLL std::ostream& operator<<(
+      std::ostream& out, const ossimJ2kSizRecord& obj);
+
+   /** segmet marker 0xff51 (big endian) */
+   ossim_uint16 theSizMarker;
+
+   /** length of segment minus marker */
+   ossim_uint16 theLsiz;
+
+   /** profile */
+   ossim_uint16 theRsiz;
+
+   /** width of reference grid */
+   ossim_uint32 theXsiz;
+
+   /** height of reference grid */
+   ossim_uint32 theYziz;
+
+   /**
+    * Horizontal offset from the orgin of reference grid to the left side
+    * of image.
+    */
+   ossim_uint32 theXOsiz;
+
+   /**
+    * Vertical offset from the orgin of reference grid to the top
+    * of image.
+    */
+   ossim_uint32 theYOsiz;
+
+   /** width of one reference tile */
+   ossim_uint32 theXTsiz;
+   
+   /** height of one reference tile */   
+   ossim_uint32 theYTsiz;
+
+   /**
+    * Horizontal offset from the orgin of reference grid to the left edge
+    * of first tile.
+    */
+   ossim_uint32 theXTOsiz;
+
+   /**
+    * Vertical offset from the orgin of reference grid to the top
+    * edge of first tile.
+    */
+   ossim_uint32 theYTOsiz;
+
+   /** number of component in the image */
+   ossim_uint16 theCsiz;
+
+   /**
+    * sign bit and bit depth of data
+    * unsigned = 0xxx xxxx (msb == 0)
+    * signed   = 1xxx xxxx (msb == 1)
+    * bit depth = x000 0000 + 1 (first seven bits plus one)
+    */
+   ossim_uint8  theSsiz;
+
+   /**
+    * Horizontal separation of a sample of the component with respect to the
+    * reference grid.
+    */
+   ossim_uint8  theXRsiz;
+
+   /**
+    * Vertical separation of a sample of the component with respect to the
+    * reference grid.
+    */
+   ossim_uint8  theYRsiz;
+};
+
+#endif /* End of "#ifndef ossimJ2kSizRecord_HEADER" */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h
new file mode 100644
index 0000000000000000000000000000000000000000..8738afb46b6f7be00ae3b64703b5dd790ba39cdb
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/support_data/ossimJ2kSotRecord.h
@@ -0,0 +1,80 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Container class for J2K "Start Of Tile" (SOT) record.
+//
+// See document BPJ2K01.00 Table 7-3 Image and tile size (15444-1 Annex A.4.2)
+// 
+//----------------------------------------------------------------------------
+// $Id: ossimJ2kSotRecord.h,v 1.5 2005/10/13 21:24:47 dburken Exp $
+#ifndef ossimJ2kSotRecord_HEADER
+#define ossimJ2kSotRecord_HEADER
+
+#include <iosfwd>
+
+#include <ossim/base/ossimConstants.h>
+
+class OSSIM_DLL ossimJ2kSotRecord
+{
+public:
+   
+   /** default constructor */
+   ossimJ2kSotRecord();
+
+   /** destructor */
+   ~ossimJ2kSotRecord();
+
+   /**
+    * Parse method.  Performs byte swapping as needed.
+    *
+    * @param in Stream to parse.
+    *
+    * @note Marker is not read.
+    */
+   void parseStream(std::istream& in);
+
+   /**
+    * Print method.
+    *
+    * @param out Stream to print to.
+    * 
+    * @return std::ostream&
+    */
+   std::ostream& print(std::ostream& out) const;
+
+   /**
+    * operator<<.
+    */
+   friend OSSIM_DLL std::ostream& operator<<(
+      std::ostream& out, const ossimJ2kSotRecord& obj);
+
+   /** Start of tile-part marker code. 0xff90 */
+   ossim_uint16 theSotMarker;
+   
+   /** Length in bytes of the marker segment. */
+   ossim_uint16 theLsot;
+
+   /** Tile index. Tiles are in raster order starting at 0. */
+   ossim_uint16 theIsot;
+
+   /** The length in bytes of this record including the SOT marker. */
+   ossim_uint32 thePsot;
+
+   /** Tile-Part index. */
+   ossim_uint8  theTpsot;
+
+   /**
+    * 0 = Number of tile-parts of this tile in the codestream is not defined
+    * in this header.
+    *
+    * 1-255 number of tile-parts of this tile in the codestream.
+    */
+   ossim_uint8  theTnsot;
+};
+
+#endif /* End of "#ifndef ossimJ2kSotRecord_HEADER" */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h
index 11efe634c2d39bf83581d0fbd88d9da3095b1942..6dff7b8077f7fe4841c7b704d652bf2f751a810b 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfCommon.h
@@ -7,7 +7,7 @@
 // Description: Utility class for global nitf methods.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfCommon.h 13025 2008-06-13 17:06:30Z sbortman $
+// $Id: ossimNitfCommon.h 13619 2008-09-29 19:10:31Z gpotts $
 #ifndef ossimNitfCommon_HEADER
 #define ossimNitfCommon_HEADER
 
@@ -122,7 +122,26 @@ public:
                         std::streamsize width,
                         std::ios_base::fmtflags ioflags = std::ios::left,
                         char fill = ' ');
-
+   /**
+    * This will encode a 60 character IGEOLO field.
+    */
+   static ossimString encodeUtm(
+                                ossim_uint32 zone,
+                                const ossimDpt& ul,
+                                const ossimDpt& ur,
+                                const ossimDpt& lr,
+                                const ossimDpt& ll);
+   static ossimString encodeGeographicDms(
+                                          const ossimDpt& ul,
+                                          const ossimDpt& ur,
+                                          const ossimDpt& lr,
+                                          const ossimDpt& ll);
+   static ossimString encodeGeographicDecimalDegrees(
+                                                     const ossimDpt& ul,
+                                                     const ossimDpt& ur,
+                                                     const ossimDpt& lr,
+                                                     const ossimDpt& ll);
+   
 }; // End of class ossimNitfCommon.
    
 #endif /* #ifndef ossimNitfCommon_HEADER */
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeader.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeader.h
index 0e2c86f0fd234defdf0e473a238274054d3b302a..0997021a9dbf7b68a79ba43bc23b78aeb9f0b879 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 10552 2007-02-28 20:35:07Z gpotts $
+// $Id: ossimNitfFileHeader.h 13629 2008-09-30 17:39:20Z gpotts $
 #ifndef ossimNitfFileHeader_HEADER
 #define ossimNitfFileHeader_HEADER
 
@@ -128,6 +128,8 @@ public:
    virtual ossim_int32 getNumberOfDataExtSegments()const=0;
    virtual ossim_int32 getHeaderSize()const=0;
    
+   void addTag(const ossimNitfTagInformation& tag);
+   virtual void removeTag(const ossimString& tagName);
    virtual bool  getTagInformation(ossimNitfTagInformation& tag,
                                    int idx)const;
 
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h
index 6807dd4e3c67e351c82cb57d4d710e3b2f7dafc6..4fa6c7707da6b8551c753249ae728d20beeede5a 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_0.h
@@ -7,7 +7,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_0.h 12959 2008-06-02 17:16:09Z gpotts $
+// $Id: ossimNitfFileHeaderV2_0.h 13619 2008-09-29 19:10:31Z gpotts $
 #ifndef ossimNitfFileHeaderV2_0_HEADER
 #define ossimNitfFileHeaderV2_0_HEADER
 
@@ -27,7 +27,9 @@ public:
    ossim_int32 getHeaderLength()const;
    ossim_int32 getImageLength()const;
    ossim_int32 getTotalLength()const;
-   
+   void setSubheaderLength(ossim_uint32 length);
+   void setImageLength(ossim_uint32 length);
+
    /*!
     * Is a 6 byte numeric 0-999999
     */
@@ -169,6 +171,9 @@ public:
    virtual const char* getVersion()const;
 
    virtual ossimDrect getImageRect()const;
+  
+   virtual void addImageInfoRecord(const ossimNitfImageInfoRecordV2_0& recordInfo);
+   virtual void replaceImageInfoRecord(ossim_uint32 i, const ossimNitfImageInfoRecordV2_0& recordInfo);
 
    virtual ossimNitfImageHeader*  getNewImageHeader(ossim_int32 imageNumber,
                                                     std::istream& in)const;
@@ -210,6 +215,8 @@ public:
    void setSecurityDowngrade(const ossimString& securityDowngrade);
    void setDowngradingEvent(const ossimString& downgradeEvent);
 
+   virtual void setFileLength(ossim_uint64 fileLength);
+   virtual void setHeaderLength(ossim_uint64 headerLength);
    /**
     * Properties of a NITF 2.0 Header file. See MIL-STD-2500A for details.
     *
@@ -263,8 +270,17 @@ private:
    };
 
    void clearFields();
+   /**
+    * Sets the number of image records in the NITF 2.0 File Header.
+    *
+    * @param num
+    *        The number of image records for the entire NITF 2.0 file.
+    *
+    * @throw std::out_of_range
+    */
+   void setNumberOfImageInfoRecords(ossim_uint64 num);
    
-   /*!
+  /*!
     * This method will be used to setup information about the file.
     * Example: NITF files have display levels where the lowest number is the
     * back most image and the highes number is the front most image.  We
@@ -443,7 +459,7 @@ private:
     * indicates that the file length was not
     * available.
     */
-   char theNitfFileLength[13];
+   char theFileLength[13];
 
    /**
     * HL:
@@ -455,7 +471,7 @@ private:
     * 999999 indicates that the length of the
     * header was not available upon creation.
     */
-   char theNitfHeaderLength[7];
+   char theHeaderLength[7];
 
    /**
     * NUMI:
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h
index 99f69c9dc48f8b6850bb6590b37c0ce2ebc6d7a8..75b726c8c826289f4dc5e456eae919416e3496fb 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfFileHeaderV2_X.h
@@ -8,7 +8,8 @@ class ossimNitfFileHeaderV2_X : public ossimNitfFileHeader
 public:
    ossimNitfFileHeaderV2_X();
 
-   static ossimString formatDate(const ossimLocalTm& d);
+   static ossimString formatDate(const ossimString& version,
+                                 const ossimLocalTm& d);
 
    virtual void setCodeWords(const ossimString& codeWords) = 0;
    virtual void setControlAndHandling(const ossimString& controlAndHandling) = 0;
@@ -114,6 +115,8 @@ protected:
    /**
     * Field: FDT
     * 
+    * for NITF 2.1 format we have
+    *
     * Has the form CCYYMMDDhhmmss and is a required field
     *
     * where CC is the first two digits of the year 00-99
@@ -123,6 +126,17 @@ protected:
     *       hh is the hour 00-23
     *       mm is the minutes 00-59
     *       ss is the seconds 00-59
+    *
+    * For NITF 2.0 format we have
+    *
+    * DDHHMMSSZMONYY
+    *
+    * where  DD is the day
+    *        HH is the hour
+    *        MM is the minutes
+    *        SS is the seconds
+    *        MON is the first 3 characters of the month
+    *        YY is the 2 digit year
     */
    char  theDateTime[15];  // 14 bytes
 
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h
index 85ad684c2043a012845a1c492ce0a3a3464468d1..e781366d8915b572644bf759e9176deb78a5eddb 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeader.h
@@ -7,7 +7,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeader.h 13101 2008-07-01 18:44:31Z dburken $
+// $Id: ossimNitfImageHeader.h 13630 2008-09-30 17:41:15Z gpotts $
 #ifndef ossimNitfImageHeader_HEADER
 #define ossimNitfImageHeader_HEADER
 
@@ -44,7 +44,7 @@ public:
    
    virtual ossim_uint32 getNumberOfTags()const;
 
-   virtual void addTag(ossimNitfTagInformation tag);
+   virtual void addTag(const ossimNitfTagInformation& tag);
    virtual void removeTag(const ossimString& tagName);
    
    virtual void parseStream(std::istream &in)= 0;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h
index e451b14b37c87726c8da18f2a7402ebe631cd6cc..81332bc27026b608796beb914a195d669d9c2bab 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_0.h
@@ -8,7 +8,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_0.h 13101 2008-07-01 18:44:31Z dburken $
+// $Id: ossimNitfImageHeaderV2_0.h 13619 2008-09-29 19:10:31Z gpotts $
 #ifndef ossimNitfImageHeaderV2_0_HEADER
 #define ossimNitfImageHeaderV2_0_HEADER
 #include <ossim/support_data/ossimNitfImageHeaderV2_X.h>
@@ -71,6 +71,31 @@ public:
    virtual const ossimRefPtr<ossimNitfCompressionHeader> getCompressionHeader()const;
    virtual const ossimRefPtr<ossimNitfImageBand> getBandInformation(ossim_uint32 idx)const;
 
+   virtual void setNumberOfBands(ossim_uint32 nbands);
+   virtual void setBandInfo(ossim_uint32 idx,
+                            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;
    static const ossimString ISREL_KW;
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_1.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_1.h
index 7bdcc5e2ced8939f57dae68218e0c0e47757d87b..c2fa013dfaa592cb85a61ce246f7350daaf65b85 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 13101 2008-07-01 18:44:31Z dburken $
+// $Id: ossimNitfImageHeaderV2_1.h 13618 2008-09-29 19:08:10Z gpotts $
 
 #ifndef ossimNitfImageHeaderV2_1_HEADER
 #define ossimNitfImageHeaderV2_1_HEADER
@@ -140,15 +140,6 @@ public:
 private:
    void clearFields();
 
-   /**
-   * WIll throw out_of_range exception;
-   */
-   ossimString encodeUtm(ossim_uint32 zone,
-                         const ossimDpt& ul,
-                         const ossimDpt& ur,
-                         const ossimDpt& lr,
-                         const ossimDpt& ll)const;
-
    /**
     * FIELD: ISCLSY
     * 
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h
index 385d08337853aa68f90c7def460b4a1e20aae999..352808f89b67259d1dd94828d149c9c83aeeef40 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimNitfImageHeaderV2_X.h
@@ -76,6 +76,7 @@ public:
    static const ossimString IDATIM_KW;
    static const ossimString TGTID_KW;
    static const ossimString IID2_KW;
+   static const ossimString ITITLE_KW; // also IID2 in 2.1 spec and ITITLE in 2.0 spec
    static const ossimString ISCLAS_KW;
    static const ossimString ENCRYP_KW;
    static const ossimString ISORCE_KW;
diff --git a/Utilities/otbossim/include/ossim/vec/ossimShapeDatabase.h b/Utilities/otbossim/include/ossim/vec/ossimShapeDatabase.h
deleted file mode 100644
index 95465b7a9d4b8efd9309e1cbc1e13f19fa67ebbc..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/vec/ossimShapeDatabase.h
+++ /dev/null
@@ -1,136 +0,0 @@
-#ifndef ossimShapeDatabase_HEADER
-#define ossimShapeDatabase_HEADER
-#include <iostream>
-#include <ossim/vec/shapefil.h>
-#include <ossim/base/ossimFilename.h>
-#include <ossim/base/ossimString.h>
-
-
-class OSSIM_DLL ossimShapeDatabaseField
-{
-public:
-   ossimString fieldTypeAsString()const;
-   
-   ossimString  theName;
-   int         theWidth;
-   int         theDecimals;
-   ossim_DBFFieldType theFieldType;
-   ossimString  theValue;
-};
-
-class OSSIM_DLL ossimShapeDatabaseRecord
-{
-   
-public:
-   bool getField(ossimShapeDatabaseField& result,
-                 ossim_uint32 i)
-      {
-         if(i < theFieldArray.size())
-         {
-            result = theFieldArray[i];
-            return true;
-         }
-         return false;
-      }
-   bool setField(const ossimShapeDatabaseField& field,
-                 ossim_uint32 i)
-      {
-         if(i < theFieldArray.size())
-         {
-            theFieldArray[i] = field;
-            return true;
-         }
-         return false;
-      }
-   int getNumberOfFields()const
-      {
-         return theFieldArray.size();
-      }
-   void setNumberOfFields(int n)
-      {
-         if(n)
-         {
-            theFieldArray.resize(n);
-         }
-         else
-         {
-            theFieldArray.clear();
-         }
-      }
-   ossim_int32 getFieldIdx(const ossimString& name,
-                           bool caseInsensitive=true)const;
-protected:
-	std::vector<ossimShapeDatabaseField> theFieldArray;
-};
-
-class OSSIM_DLL ossimShapeDatabase
-{
-public:
-   friend std::ostream& operator <<(std::ostream& out, const ossimShapeDatabase& rhs)
-      {
-         rhs.print(out);
-         
-         return out;
-      }
-   
-   ossimShapeDatabase();
-   virtual ~ossimShapeDatabase();
-   
-   virtual bool open(const ossimFilename& file,
-                     const ossimString& flags=ossimString("rb"));
-   
-   virtual void close();
-   
-   bool getRecord(ossimShapeDatabaseRecord& result);
-   
-   bool getRecord(ossimShapeDatabaseRecord& result,
-                  int recordNumber)
-      {
-         if(isOpen())
-         {
-            if(recordNumber < getNumberOfRecords())
-            {
-               theRecordNumber = recordNumber;
-               return getRecord(result);
-            }
-         }
-
-         return false;
-      }
-   
-   bool getNextRecord(ossimShapeDatabaseRecord& result)
-      {
-         if(isOpen() && ((theRecordNumber+1) < getNumberOfRecords()))
-         {
-            ++theRecordNumber;
-            return getRecord(result);
-         }
-
-         return false;
-      }
-
-   int getNumberOfRecords()const;
-   bool isOpen()const
-      {
-         return (theHandle!=NULL);
-      }
-   virtual ossim_DBFHandle getHandle()
-      {
-         return theHandle;
-      }
-
-   virtual const ossim_DBFHandle getHandle()const
-      {
-         return theHandle;
-      }
-   
-   virtual void print(std::ostream& out)const;
-
-protected:
-   ossim_DBFHandle theHandle;
-   ossimFilename theFilename;
-
-   int theRecordNumber;
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/vec/ossimShapeFile.h b/Utilities/otbossim/include/ossim/vec/ossimShapeFile.h
deleted file mode 100644
index 02c45848c64efc08dd441ed87d5e6199572a1bb2..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/vec/ossimShapeFile.h
+++ /dev/null
@@ -1,312 +0,0 @@
-//*******************************************************************
-//
-// License:  See top level LICENSE.txt file.
-// 
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimShapeFile.h 11424 2007-07-27 17:01:23Z dburken $
-
-#ifndef ossimShapeFile_HEADER
-#define ossimShapeFile_HEADER
-#include <iostream>
-#include <ossim/base/ossimConstants.h>
-#include <ossim/base/ossimFilename.h>
-#include <ossim/base/ossimString.h>
-#include <ossim/base/ossimDrect.h>
-
-#include <ossim/vec/shapefil.h>
-
-class ossimShapeFile;
-class ossimAnnotationObject;
-
-class OSSIMDLLEXPORT ossimShapeObject
-{
-public:
-   friend std::ostream& operator<<(std::ostream& out,
-                              const ossimShapeObject& rhs);
-   
-   ossimShapeObject()
-      :theShape((ossim_SHPObject*)NULL),
-       theIndex(-1)
-      {
-      }
-
-   ~ossimShapeObject()
-      {
-         if(theShape)
-         {
-            ossim_SHPDestroyObject(theShape);
-            theShape = NULL;
-         }
-      }
-   void setShape(ossim_SHPObject* obj);
-   bool isLoaded()const
-      {
-         return (theShape!=NULL);
-      }
-   long getIndex()const
-      {
-         return theIndex;
-      }
-   long getId()const
-      {
-         if(theShape)
-         {
-            return theShape->nShapeId;
-         }
-         
-         return -1;
-      }
-   
-   bool loadShape(const ossimShapeFile& shapeFile,
-                  long shapeRecord);
-   
-   ossim_uint32 getNumberOfParts()const
-      {
-         if(theShape)
-         {
-            return theShape->nParts;
-         }
-
-         return 0;
-      }
-   ossim_uint32 getNumberOfVertices()const
-      {
-         if(theShape)
-         {
-            return theShape->nVertices;
-         }
-         
-         return 0;
-      }
-
-   void getBounds(double& minX, double& minY, double& minZ, double& minM,
-                  double& maxX, double& maxY, double& maxZ, double& maxM)const
-      {
-         if(theShape)
-         {
-            minX = theShape->dfXMin;
-            minY = theShape->dfYMin;
-            minZ = theShape->dfZMin;
-            minM = theShape->dfMMin;
-            maxX = theShape->dfXMax;
-            maxY = theShape->dfYMax;
-            maxZ = theShape->dfZMax;
-            maxM = theShape->dfMMax;
-         }
-         else
-         {
-            minX = minY = minZ = minM =
-            maxX = maxY = maxZ = maxM = ossim::nan();
-         }
-      }
-
-   void getBounds(double& minX, double& minY,
-                  double& maxX, double& maxY)const
-      {
-         if(theShape)
-         {
-            minX = theShape->dfXMin;
-            minY = theShape->dfYMin;
-            maxX = theShape->dfXMax;
-            maxY = theShape->dfYMax;
-         }
-         else
-         {
-            minX = minY = 
-            maxX = maxY = ossim::nan();
-         }
-      }
-
-   void getBoundingRect(ossimDrect& result,
-                        ossimCoordSysOrientMode orient = OSSIM_RIGHT_HANDED)const;
-
-   ossimDrect getBoundingRect(ossimCoordSysOrientMode orient = OSSIM_RIGHT_HANDED)const
-      {
-         ossimDrect result;
-         
-         getBoundingRect(result, orient);
-
-         return result;
-      }
-
-   int getType()const
-      {
-         if(theShape)
-         {
-            return theShape->nSHPType;
-         }
-         return ossim_SHPT_NULL;
-      }
-   ossimString getTypeByName()const
-      {
-         if(theShape)
-         {
-            return ossimString(ossim_SHPTypeName(theShape->nSHPType));
-         }
-         return "unknown";
-      }
-   int getPartType(ossim_uint32 partIndex)const
-      {
-         if((partIndex > getNumberOfParts())||
-            (!theShape))
-         {
-            return -1;
-         }
-
-         return theShape->panPartType[partIndex];
-      }
-   ossimString getPartByName(ossim_uint32 partIndex)const
-      {
-         if((partIndex > getNumberOfParts())||
-            (!theShape))
-         {
-         }
-         switch(theShape->panPartType[partIndex])
-         {
-         case ossim_SHPP_TRISTRIP:
-         {
-            ossimString("tristrip");
-            break;
-         }
-         case ossim_SHPP_TRIFAN:
-         {
-            ossimString("trifan");
-            break;
-         }
-         case ossim_SHPP_OUTERRING:
-         {
-            ossimString("outerring");
-            break;
-         }
-         case ossim_SHPP_INNERRING:
-         {
-            ossimString("innerring");
-            break;
-         }
-         case ossim_SHPP_RING:
-         {
-            ossimString("ring");
-            break;
-         }
-         }
-         return ossimString("unknown");
-      }
-   ossim_SHPObject* getShapeObject()
-      {
-         return theShape;
-      }
-   const ossim_SHPObject* getShapeObject()const
-      {
-         return theShape;
-      }
-
-   
-protected:
-   ossim_SHPObject* theShape;
-   long       theIndex;
-};
-
-class OSSIMDLLEXPORT ossimShapeFile
-{
-public:
-   friend std::ostream& operator <<(std::ostream& out, const ossimShapeFile& rhs)
-      {
-         rhs.print(out);
-         
-         return out;
-      }
-   
-   ossimShapeFile();
-   virtual ~ossimShapeFile();
-   
-   virtual bool open(const ossimFilename& file,
-                     const ossimString& flags=ossimString("rb"));
-   
-   virtual void close();
-   bool isOpen()const
-      {
-         return (theHandle!=NULL);
-      }
-   virtual ossim_SHPHandle getHandle()
-      {
-         return theHandle;
-      }
-
-   virtual const ossim_SHPHandle getHandle()const
-      {
-         return theHandle;
-      }
-   
-   virtual void print(std::ostream& out)const;
-   virtual ossimString getShapeTypeString()const;
-
-   
-   virtual long getNumberOfShapes()const
-      {
-         if(theHandle)
-         {
-            return theHandle->nRecords;
-         }
-         return 0;
-      }
-   void getBounds(double& minX, double& minY, double& minZ, double& minM,
-                  double& maxX, double& maxY, double& maxZ, double& maxM)const
-      {
-         if(theHandle)
-         {
-            minX = theHandle->adBoundsMin[0];
-            minY = theHandle->adBoundsMin[1];
-            minZ = theHandle->adBoundsMin[2];
-            minM = theHandle->adBoundsMin[3];
-            maxX = theHandle->adBoundsMax[0];
-            maxY = theHandle->adBoundsMax[1];
-            maxZ = theHandle->adBoundsMax[2];
-            maxM = theHandle->adBoundsMax[3];
-         }
-         else
-         {
-            minX = minY = minZ = minM =
-            maxX = maxY = maxZ = maxM = ossim::nan();
-         }
-      }
-   
-   void getBounds(double& minX, double& minY,
-                  double& maxX, double& maxY)const
-      {
-         if(theHandle)
-         {
-            minX = theHandle->adBoundsMin[0];
-            minY = theHandle->adBoundsMin[1];
-            maxX = theHandle->adBoundsMax[0];
-            maxY = theHandle->adBoundsMax[1];
-         }
-         else
-         {
-            minX = minY = maxX = maxY = ossim::nan();
-         }
-      }
-
-   void getBoundingRect(ossimDrect& result,
-                        ossimCoordSysOrientMode orient = OSSIM_RIGHT_HANDED)const;
-   
-   ossimDrect getBoundingRect(ossimCoordSysOrientMode orient = OSSIM_RIGHT_HANDED)const
-      {
-         ossimDrect result;
-         
-         getBoundingRect(result, orient);
-         
-         return result;
-      }
-   const ossimFilename& getFilename()const
-      {
-         return theFilename;
-      }
-protected:
-   ossim_SHPHandle	 theHandle;
-   ossimFilename theFilename;
-
-};
-
-#endif
diff --git a/Utilities/otbossim/include/ossim/vec/shapefil.h b/Utilities/otbossim/include/ossim/vec/shapefil.h
deleted file mode 100644
index 7dfa62d68860dc92416541f6b3fb7d3a3da07cac..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/include/ossim/vec/shapefil.h
+++ /dev/null
@@ -1,540 +0,0 @@
-#ifndef _SHAPEFILE_H_INCLUDED
-#define _SHAPEFILE_H_INCLUDED
-
-/******************************************************************************
- * $Id: shapefil.h 11039 2007-05-24 15:42:43Z gpotts $
- *
- * Project:  Shapelib
- * Purpose:  Primary include file for Shapelib.
- * Author:   Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log$
- * Revision 1.5  2005/10/08 12:57:26  gpotts
- * Added adiitional patches
- *
- * Revision 1.14  2005/03/14 15:21:29  fwarmerdam
- * updated
- *
- * Revision 1.30  2005/01/03 22:30:13  fwarmerdam
- * added support for saved quadtrees
- *
- * Revision 1.29  2004/09/26 20:09:35  fwarmerdam
- * avoid rcsid warnings
- *
- * Revision 1.28  2003/12/29 06:02:18  fwarmerdam
- * added cpl_error.h option
- *
- * Revision 1.27  2003/04/21 18:30:37  warmerda
- * added header write/update public methods
- *
- * Revision 1.26  2002/09/29 00:00:08  warmerda
- * added FTLogical and logical attribute read/write calls
- *
- * Revision 1.25  2002/05/07 13:46:30  warmerda
- * added ossim_DBFWriteAttributeDirectly().
- *
- * Revision 1.24  2002/04/10 16:59:54  warmerda
- * added ossim_SHPRewindObject
- *
- * Revision 1.23  2002/01/15 14:36:07  warmerda
- * updated email address
- *
- * Revision 1.22  2002/01/15 14:32:00  warmerda
- * try to improve ossim_SHPAPI_CALL docs
- *
- * Revision 1.21  2001/11/01 16:29:55  warmerda
- * move pabyRec into ossim_SHPInfo for thread safety
- *
- * Revision 1.20  2001/07/20 13:06:02  warmerda
- * fixed ossim_SHPAPI attribute for ossim_SHPTreeFindLikelyShapes
- *
- * Revision 1.19  2001/05/31 19:20:13  warmerda
- * added ossim_DBFGetFieldIndex()
- *
- * Revision 1.18  2001/05/31 18:15:40  warmerda
- * Added support for NULL fields in ossim_DBF files
- *
- * Revision 1.17  2001/05/23 13:36:52  warmerda
- * added use of ossim_SHPAPI_CALL
- *
- * Revision 1.16  2000/09/25 14:15:59  warmerda
- * added ossim_DBFGetNativeFieldType()
- *
- * Revision 1.15  2000/02/16 16:03:51  warmerda
- * added null shape support
- *
- * Revision 1.14  1999/11/05 14:12:05  warmerda
- * updated license terms
- *
- * Revision 1.13  1999/06/02 18:24:21  warmerda
- * added trimming code
- *
- * Revision 1.12  1999/06/02 17:56:12  warmerda
- * added quad'' subnode support for trees
- *
- * Revision 1.11  1999/05/18 19:11:11  warmerda
- * Added example searching capability
- *
- * Revision 1.10  1999/05/18 17:49:38  warmerda
- * added initial quadtree support
- *
- * Revision 1.9  1999/05/11 03:19:28  warmerda
- * added new Tuple api, and improved extension handling - add from candrsn
- *
- * Revision 1.8  1999/03/23 17:22:27  warmerda
- * Added extern "C" protection for C++ users of shapefil.h.
- *
- * Revision 1.7  1998/12/31 15:31:07  warmerda
- * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
- *
- * Revision 1.6  1998/12/03 15:48:15  warmerda
- * Added ossim_SHPCalculateExtents().
- *
- * Revision 1.5  1998/11/09 20:57:16  warmerda
- * Altered ossim_SHPGetInfo() call.
- *
- * Revision 1.4  1998/11/09 20:19:33  warmerda
- * Added 3D support, and use of ossim_SHPObject.
- *
- * Revision 1.3  1995/08/23 02:24:05  warmerda
- * Added support for reading bounds.
- *
- * Revision 1.2  1995/08/04  03:17:39  warmerda
- * Added header.
- *
- */
-
-#include <stdio.h>
-
-#ifdef USE_DBMALLOC
-#include <dbmalloc.h>
-#endif
-
-#ifdef USE_CPL
-#include "cpl_error.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/************************************************************************/
-/*                        Configuration options.                        */
-/************************************************************************/
-
-/* -------------------------------------------------------------------- */
-/*      Should the ossim_DBFReadStringAttribute() strip leading and           */
-/*      trailing white space?                                           */
-/* -------------------------------------------------------------------- */
-#define TRIM_DBF_WHITESPACE
-
-/* -------------------------------------------------------------------- */
-/*      Should we write measure values to the Multipatch object?        */
-/*      Reportedly ArcView crashes if we do write it, so for now it     */
-/*      is disabled.                                                    */
-/* -------------------------------------------------------------------- */
-#define DISABLE_MULTIPATCH_MEASURE
-
-/* -------------------------------------------------------------------- */
-/*      ossim_SHPAPI_CALL                                                     */
-/*                                                                      */
-/*      The following two macros are present to allow forcing           */
-/*      various calling conventions on the Shapelib API.                */
-/*                                                                      */
-/*      To force __stdcall conventions (needed to call Shapelib         */
-/*      from Visual Basic and/or Dephi I believe) the makefile could    */
-/*      be modified to define:                                          */
-/*                                                                      */
-/*        /DSHPAPI_CALL=__stdcall                                       */
-/*                                                                      */
-/*      If it is desired to force export of the Shapelib API without    */
-/*      using the shapelib.def file, use the following definition.      */
-/*                                                                      */
-/*        /DSHAPELIB_DLLEXPORT                                          */
-/*                                                                      */
-/*      To get both at once it will be necessary to hack this           */
-/*      include file to define:                                         */
-/*                                                                      */
-/*        #define ossim_SHPAPI_CALL __declspec(dllexport) __stdcall           */
-/*        #define ossim_SHPAPI_CALL1 __declspec(dllexport) * __stdcall        */
-/*                                                                      */
-/*      The complexity of the situtation is partly caused by the        */
-/*      peculiar requirement of Visual C++ that __stdcall appear        */
-/*      after any "*"'s in the return value of a function while the     */
-/*      __declspec(dllexport) must appear before them.                  */
-/* -------------------------------------------------------------------- */
-#include <ossim/base/ossimConstants.h>
-
-#ifdef OSSIMMAKINGDLL
-#  define ossim_SHPAPI_CALL OSSIM_DLL
-#  define ossim_SHPAPI_CALL1(x)  OSSIM_DLL_DATA(x)
-#endif
-#ifndef ossim_SHPAPI_CALL
-#  define ossim_SHPAPI_CALL
-#endif
-#ifndef ossim_SHPAPI_CALL1
-#  define ossim_SHPAPI_CALL1(x)      x ossim_SHPAPI_CALL
-#endif
-
-#if 0
-#ifdef SHAPELIB_DLLEXPORT
-#  define ossim_SHPAPI_CALL __declspec(dllexport)
-#  define ossim_SHPAPI_CALL1(x)  __declspec(dllexport) x
-#endif
-#ifndef ossim_SHPAPI_CALL
-#  define ossim_SHPAPI_CALL
-#endif
-#ifndef ossim_SHPAPI_CALL1
-#  define ossim_SHPAPI_CALL1(x)      x ossim_SHPAPI_CALL
-#endif
-#endif
-
-/* -------------------------------------------------------------------- */
-/*      Macros for controlling CVSID and ensuring they don't appear     */
-/*      as unreferenced variables resulting in lots of warnings.        */
-/* -------------------------------------------------------------------- */
-#ifndef DISABLE_CVSID
-#  define ossim_SHP_CVSID(string)     static char cpl_cvsid[] = string; \
-static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
-#else
-#  define ossim_SHP_CVSID(string)
-#endif
-
-/************************************************************************/
-/*                             ossim_SHP Support.                             */
-/************************************************************************/
-typedef	struct
-{
-    FILE        *fpSHP;
-    FILE	*fpSHX;
-
-    int		nShapeType;				/* ossim_SHPT_* */
-
-    int		nFileSize;				/* ossim_SHP file */
-
-    int         nRecords;
-    int		nMaxRecords;
-    int		*panRecOffset;
-    int		*panRecSize;
-
-    double	adBoundsMin[4];
-    double	adBoundsMax[4];
-
-    int		bUpdated;
-
-    unsigned char *pabyRec;
-    int         nBufSize;
-} ossim_SHPInfo;
-
-typedef ossim_SHPInfo * ossim_SHPHandle;
-
-/* -------------------------------------------------------------------- */
-/*      Shape types (nSHPType)                                          */
-/* -------------------------------------------------------------------- */
-#define ossim_SHPT_NULL	0
-#define ossim_SHPT_POINT	1
-#define ossim_SHPT_ARC	3
-#define ossim_SHPT_POLYGON	5
-#define ossim_SHPT_MULTIPOINT	8
-#define ossim_SHPT_POINTZ	11
-#define ossim_SHPT_ARCZ	13
-#define ossim_SHPT_POLYGONZ	15
-#define ossim_SHPT_MULTIPOINTZ 18
-#define ossim_SHPT_POINTM	21
-#define ossim_SHPT_ARCM	23
-#define ossim_SHPT_POLYGONM	25
-#define ossim_SHPT_MULTIPOINTM 28
-#define ossim_SHPT_MULTIPATCH 31
-
-
-/* -------------------------------------------------------------------- */
-/*      Part types - everything but ossim_SHPT_MULTIPATCH just uses           */
-/*      ossim_SHPP_RING.                                                      */
-/* -------------------------------------------------------------------- */
-
-#define ossim_SHPP_TRISTRIP	0
-#define ossim_SHPP_TRIFAN	1
-#define ossim_SHPP_OUTERRING	2
-#define ossim_SHPP_INNERRING	3
-#define ossim_SHPP_FIRSTRING	4
-#define ossim_SHPP_RING	5
-
-/* -------------------------------------------------------------------- */
-/*      ossim_SHPObject - represents on shape (without attributes) read       */
-/*      from the .shp file.                                             */
-/* -------------------------------------------------------------------- */
-typedef struct
-{
-    int		nSHPType;
-
-    int		nShapeId; /* -1 is unknown/unassigned */
-
-    int		nParts;
-    int		*panPartStart;
-    int		*panPartType;
-
-    int		nVertices;
-    double	*padfX;
-    double	*padfY;
-    double	*padfZ;
-    double	*padfM;
-
-    double	dfXMin;
-    double	dfYMin;
-    double	dfZMin;
-    double	dfMMin;
-
-    double	dfXMax;
-    double	dfYMax;
-    double	dfZMax;
-    double	dfMMax;
-} ossim_SHPObject;
-
-/* -------------------------------------------------------------------- */
-/*      ossim_SHP API Prototypes                                              */
-/* -------------------------------------------------------------------- */
-ossim_SHPHandle ossim_SHPAPI_CALL
-      ossim_SHPOpen( const char * pszShapeFile, const char * pszAccess );
-ossim_SHPHandle ossim_SHPAPI_CALL
-      ossim_SHPCreate( const char * pszShapeFile, int nShapeType );
-void ossim_SHPAPI_CALL
-      ossim_SHPGetInfo( ossim_SHPHandle hSHP, int * pnEntities, int * pnShapeType,
-                  double * padfMinBound, double * padfMaxBound );
-
-ossim_SHPObject ossim_SHPAPI_CALL1(*)
-      ossim_SHPReadObject( ossim_SHPHandle hSHP, int iShape );
-int ossim_SHPAPI_CALL
-      ossim_SHPWriteObject( ossim_SHPHandle hSHP, int iShape, ossim_SHPObject * psObject );
-
-void ossim_SHPAPI_CALL
-      ossim_SHPDestroyObject( ossim_SHPObject * psObject );
-void ossim_SHPAPI_CALL
-      ossim_SHPComputeExtents( ossim_SHPObject * psObject );
-ossim_SHPObject ossim_SHPAPI_CALL1(*)
-      ossim_SHPCreateObject( int nSHPType, int nShapeId, int nParts,
-                       const int * panPartStart, const int * panPartType,
-                       int nVertices,
-                       const double * padfX, const double * padfY,
-                       const double * padfZ, const double * padfM );
-ossim_SHPObject ossim_SHPAPI_CALL1(*)
-      ossim_SHPCreateSimpleObject( int nSHPType, int nVertices,
-                             const double * padfX,
-                             const double * padfY,
-                             const double * padfZ );
-
-int ossim_SHPAPI_CALL
-      ossim_SHPRewindObject( ossim_SHPHandle hSHP, ossim_SHPObject * psObject );
-
-void ossim_SHPAPI_CALL ossim_SHPClose( ossim_SHPHandle hSHP );
-void ossim_SHPAPI_CALL ossim_SHPWriteHeader( ossim_SHPHandle hSHP );
-
-const char ossim_SHPAPI_CALL1(*)
-      ossim_SHPTypeName( int nSHPType );
-const char ossim_SHPAPI_CALL1(*)
-      ossim_SHPPartTypeName( int nPartType );
-
-/* -------------------------------------------------------------------- */
-/*      Shape quadtree indexing API.                                    */
-/* -------------------------------------------------------------------- */
-
-/* this can be two or four for binary or quad tree */
-#define MAX_SUBNODE	4
-
-typedef struct shape_tree_node
-{
-    /* region covered by this node */
-    double	adfBoundsMin[4];
-    double	adfBoundsMax[4];
-
-    /* list of shapes stored at this node.  The papsShapeObj pointers
-       or the whole list can be NULL */
-    int		nShapeCount;
-    int		*panShapeIds;
-    ossim_SHPObject   **papsShapeObj;
-
-    int		nSubNodes;
-    struct shape_tree_node *apsSubNode[MAX_SUBNODE];
-
-} ossim_SHPTreeNode;
-
-typedef struct
-{
-    ossim_SHPHandle   hSHP;
-
-    int		nMaxDepth;
-    int		nDimension;
-    int         nTotalCount;
-
-    ossim_SHPTreeNode	*psRoot;
-} ossim_SHPTree;
-
-ossim_SHPTree ossim_SHPAPI_CALL1(*)
-      ossim_SHPCreateTree( ossim_SHPHandle hSHP, int nDimension, int nMaxDepth,
-                     double *padfBoundsMin, double *padfBoundsMax );
-void    ossim_SHPAPI_CALL
-      ossim_SHPDestroyTree( ossim_SHPTree * hTree );
-
-int	ossim_SHPAPI_CALL
-      ossim_SHPWriteTree( ossim_SHPTree *hTree, const char * pszFilename );
-ossim_SHPTree ossim_SHPAPI_CALL
-      ossim_SHPReadTree( const char * pszFilename );
-
-int	ossim_SHPAPI_CALL
-      ossim_SHPTreeAddObject( ossim_SHPTree * hTree, ossim_SHPObject * psObject );
-int	ossim_SHPAPI_CALL
-      ossim_SHPTreeAddShapeId( ossim_SHPTree * hTree, ossim_SHPObject * psObject );
-int	ossim_SHPAPI_CALL
-      ossim_SHPTreeRemoveShapeId( ossim_SHPTree * hTree, int nShapeId );
-
-void 	ossim_SHPAPI_CALL
-      ossim_SHPTreeTrimExtraNodes( ossim_SHPTree * hTree );
-
-int    ossim_SHPAPI_CALL1(*)
-      ossim_SHPTreeFindLikelyShapes( ossim_SHPTree * hTree,
-                               double * padfBoundsMin,
-                               double * padfBoundsMax,
-                               int * );
-int     ossim_SHPAPI_CALL
-      ossim_SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
-
-int ossim_SHPAPI_CALL1(*)
-    ossim_SHPSearchDiskTree( FILE *fp,
-                   double *padfBoundsMin, double *padfBoundsMax,
-                   int *pnShapeCount );
-
-/************************************************************************/
-/*                             ossim_DBF Support.                             */
-/************************************************************************/
-typedef	struct
-{
-    FILE	*fp;
-
-    int         nRecords;
-
-    int		nRecordLength;
-    int		nHeaderLength;
-    int		nFields;
-    int		*panFieldOffset;
-    int		*panFieldSize;
-    int		*panFieldDecimals;
-    char	*pachFieldType;
-
-    char	*pszHeader;
-
-    int		nCurrentRecord;
-    int		bCurrentRecordModified;
-    char	*pszCurrentRecord;
-
-    int		bNoHeader;
-    int		bUpdated;
-} ossim_DBFInfo;
-
-typedef ossim_DBFInfo * ossim_DBFHandle;
-
-typedef enum {
-  FTString,
-  FTInteger,
-  FTDouble,
-  FTLogical,
-  FTInvalid
-} ossim_DBFFieldType;
-
-#define XBASE_FLDHDR_SZ       32
-
-ossim_DBFHandle ossim_SHPAPI_CALL
-      ossim_DBFOpen( const char * pszDBFFile, const char * pszAccess );
-ossim_DBFHandle ossim_SHPAPI_CALL
-      ossim_DBFCreate( const char * pszDBFFile );
-
-int	ossim_SHPAPI_CALL
-      ossim_DBFGetFieldCount( ossim_DBFHandle psDBF );
-int	ossim_SHPAPI_CALL
-      ossim_DBFGetRecordCount( ossim_DBFHandle psDBF );
-int	ossim_SHPAPI_CALL
-      ossim_DBFAddField( ossim_DBFHandle hDBF, const char * pszFieldName,
-                   ossim_DBFFieldType eType, int nWidth, int nDecimals );
-
-ossim_DBFFieldType ossim_SHPAPI_CALL
-      ossim_DBFGetFieldInfo( ossim_DBFHandle psDBF, int iField,
-                       char * pszFieldName, int * pnWidth, int * pnDecimals );
-
-int ossim_SHPAPI_CALL
-      ossim_DBFGetFieldIndex(ossim_DBFHandle psDBF, const char *pszFieldName);
-
-int 	ossim_SHPAPI_CALL
-      ossim_DBFReadIntegerAttribute( ossim_DBFHandle hDBF, int iShape, int iField );
-double 	ossim_SHPAPI_CALL
-      ossim_DBFReadDoubleAttribute( ossim_DBFHandle hDBF, int iShape, int iField );
-const char ossim_SHPAPI_CALL1(*)
-      ossim_DBFReadStringAttribute( ossim_DBFHandle hDBF, int iShape, int iField );
-const char ossim_SHPAPI_CALL1(*)
-      ossim_DBFReadLogicalAttribute( ossim_DBFHandle hDBF, int iShape, int iField );
-int     ossim_SHPAPI_CALL
-      ossim_DBFIsAttributeNULL( ossim_DBFHandle hDBF, int iShape, int iField );
-
-int ossim_SHPAPI_CALL
-      ossim_DBFWriteIntegerAttribute( ossim_DBFHandle hDBF, int iShape, int iField,
-                                int nFieldValue );
-int ossim_SHPAPI_CALL
-      ossim_DBFWriteDoubleAttribute( ossim_DBFHandle hDBF, int iShape, int iField,
-                               double dFieldValue );
-int ossim_SHPAPI_CALL
-      ossim_DBFWriteStringAttribute( ossim_DBFHandle hDBF, int iShape, int iField,
-                               const char * pszFieldValue );
-int ossim_SHPAPI_CALL
-     ossim_DBFWriteNULLAttribute( ossim_DBFHandle hDBF, int iShape, int iField );
-
-int ossim_SHPAPI_CALL
-     ossim_DBFWriteLogicalAttribute( ossim_DBFHandle hDBF, int iShape, int iField,
-			       const char lFieldValue);
-int ossim_SHPAPI_CALL
-     ossim_DBFWriteAttributeDirectly(ossim_DBFHandle psDBF, int hEntity, int iField,
-                               void * pValue );
-const char ossim_SHPAPI_CALL1(*)
-      ossim_DBFReadTuple(ossim_DBFHandle psDBF, int hEntity );
-int ossim_SHPAPI_CALL
-      ossim_DBFWriteTuple(ossim_DBFHandle psDBF, int hEntity, void * pRawTuple );
-
-ossim_DBFHandle ossim_SHPAPI_CALL
-      ossim_DBFCloneEmpty(ossim_DBFHandle psDBF, const char * pszFilename );
-
-void	ossim_SHPAPI_CALL
-      ossim_DBFClose( ossim_DBFHandle hDBF );
-void    ossim_SHPAPI_CALL
-      ossim_DBFUpdateHeader( ossim_DBFHandle hDBF );
-char    ossim_SHPAPI_CALL
-      ossim_DBFGetNativeFieldType( ossim_DBFHandle hDBF, int iField );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ndef _SHAPEFILE_H_INCLUDED */
diff --git a/Utilities/otbossim/include/ossim/vec/vpf.h b/Utilities/otbossim/include/ossim/vec/vpf.h
index 1f5399158b828efb91363dcc616f555b1b203ab7..aaf85e3074adb4f2541ab2e4172948800cdafc2e 100644
--- a/Utilities/otbossim/include/ossim/vec/vpf.h
+++ b/Utilities/otbossim/include/ossim/vec/vpf.h
@@ -11,7 +11,7 @@
 //              vpf file.
 //
 //********************************************************************
-// $Id: vpf.h 9097 2006-06-13 20:57:27Z dburken $
+// $Id: vpf.h 13586 2008-09-17 01:35:25Z gpotts $
 #ifndef VPF_HEADER
 #define VPF_HEADER
 
@@ -23,6 +23,7 @@
 
 extern "C"
 {
+#include <ossim/vpfutil/vpfapi.h>
 #include <ossim/vpfutil/vpfview.h>
 #include <ossim/vpfutil/vpfselec.h>
 #include <ossim/vpfutil/vpftable.h>
diff --git a/Utilities/otbossim/include/ossim/vpfutil/vpfapi.h b/Utilities/otbossim/include/ossim/vpfutil/vpfapi.h
new file mode 100644
index 0000000000000000000000000000000000000000..a6c22f7e594b4e149a9cc0172292182edf65ab76
--- /dev/null
+++ b/Utilities/otbossim/include/ossim/vpfutil/vpfapi.h
@@ -0,0 +1,13 @@
+#ifndef VPFAPI_HEADER
+#define VPFAPI_HEADER
+#ifdef __cplusplus
+extern "C" {
+#endif
+   float distance(double lat1, double lon1, double lat2, double lon2,
+                  int units );
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/Utilities/otbossim/include/ossim/vpfutil/vpftable.h b/Utilities/otbossim/include/ossim/vpfutil/vpftable.h
index 5baa09e09aeb3aeb0b9b5c97e72fd7fa09547585..9573fbe68d698c1f57f4fcd93d2e4fe5a0462b45 100644
--- a/Utilities/otbossim/include/ossim/vpfutil/vpftable.h
+++ b/Utilities/otbossim/include/ossim/vpfutil/vpftable.h
@@ -245,9 +245,9 @@ row_type  read_next_row( vpf_table_type table );
 row_type  read_row( long int row_number,
 		    vpf_table_type table );
 
-vpf_table_type vpf_open_table( char *tablename,
+vpf_table_type vpf_open_table( const char *tablename,
 			       storage_type storage,
-			       char *mode,
+			       const char *mode,
 			       char *defstr );   /* rdf added */
 
 row_type get_row( long int row_number,
@@ -255,8 +255,8 @@ row_type get_row( long int row_number,
 
 void free_row( row_type row, vpf_table_type table );
 
-long int table_pos( char *field_name,
-	       vpf_table_type table );
+long int table_pos( const char *field_name,
+                    vpf_table_type table );
 
 void *get_table_element( long int field_number,
 			 row_type row,
@@ -280,7 +280,7 @@ void vpf_close_table( vpf_table_type *table );
 
 void vpf_dump_table( char *tablename, char *outname );
 
-long int is_vpf_table( char *fname );
+long int is_vpf_table( const char *fname );
 
 /* Write functions */
 
@@ -294,6 +294,8 @@ void nullify_table_element( long int field, row_type row,
 long int put_table_element( long int field, row_type row,
 			    vpf_table_type table,
 			    void *value, long int count );
+void vpf_dump_table( char *tablename, char *outname );
+void vpf_dump_doc_table( char *tablename, char *outname );
 
 void swap_two(char*, char*);
 void swap_four(char*, char*);
diff --git a/Utilities/otbossim/include/ossim/vpfutil/xmemory.h b/Utilities/otbossim/include/ossim/vpfutil/xmemory.h
index fd10e22470d9012c7fc95f65e6f5a190e85985bd..875f48f4fca0b6d0dbbfad2f046029f48fe3d029 100644
--- a/Utilities/otbossim/include/ossim/vpfutil/xmemory.h
+++ b/Utilities/otbossim/include/ossim/vpfutil/xmemory.h
@@ -9,18 +9,6 @@
 extern "C" {
 #endif
 
-#include <ossim/ossimConfig.h>
-
-#if __OSSIM_DOS__
-#include <alloc.h>
-#else
-#if __OSSIM_CARBON__
-#include <sys/types.h>
-#include <sys/malloc.h>
-#else
-/*  #include <malloc.h> */
-#endif
-#endif
 
 
 #define Xmark()
diff --git a/Utilities/otbossim/src/ossim/CMakeLists.txt b/Utilities/otbossim/src/ossim/CMakeLists.txt
index 2d4ec0c48c44c6197ed7502a3bfdf9f25b01b0ec..237aff4ed49d118951738019a7e9b40e261ec0e9 100644
--- a/Utilities/otbossim/src/ossim/CMakeLists.txt
+++ b/Utilities/otbossim/src/ossim/CMakeLists.txt
@@ -56,7 +56,7 @@ ADD_CUSTOM_COMMAND(
   OUTPUT ${OTB_BINARY_DIR}/Utilities/otbossim/include/ossim/ossimVersion.h
   DEPENDS version-config
   COMMAND version-config
-  ARGS "${OTB_BINARY_DIR}/Utilities/otbossim/include/ossim/ossimVersion.h"
+  ARGS "${OTB_BINARY_DIR}/Utilities/otbossim/include/ossim/ossimVersion.h" "${OSSIM_VERSION}"
   COMMENT "Generating ossimVersion.h"
   )
 SET_SOURCE_FILES_PROPERTIES(
diff --git a/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransform.cpp b/Utilities/otbossim/src/ossim/base/ossim2dTo2dTransform.cpp
index c45848adc5f73d808364b3e8eb002e50323c9bf3..bcbb6d56d18e309dc6ef5bbf274eadc0e752f18e 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 12953 2008-06-01 16:24:05Z dburken $
+// $Id: ossim2dTo2dTransform.cpp 13664 2008-10-02 19:57:24Z gpotts $
 
 #include <cstdlib>
 #include <sstream>
@@ -194,8 +194,15 @@ bool ossim2dTo2dTransform::loadState(const ossimKeywordlist& kwl,
    const char* dxdy = kwl.find(prefix, "dxdy");
    if(dxdy)
    {
-      std::istringstream in(dxdy);
-      in>>theDxDy.x >> theDxDy.y;
+      ossimString tempString(dxdy);
+      std::vector<ossimString> splitArray;
+      tempString = tempString.trim();
+      tempString.split(splitArray, " ");
+      if(splitArray.size()==2)
+      {
+         theDxDy.x = splitArray[0].toDouble();
+         theDxDy.y = splitArray[1].toDouble();
+      }
    }
    if(result)
    {
diff --git a/Utilities/otbossim/src/ossim/base/ossimColorProperty.cpp b/Utilities/otbossim/src/ossim/base/ossimColorProperty.cpp
index bfa4fa0f7b31ca14ccc730b870b6b0ff74c8d2f5..c43d8ad74c86a63188448962e4703eb480364e0d 100644
--- a/Utilities/otbossim/src/ossim/base/ossimColorProperty.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimColorProperty.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks.com)
 //
 //*************************************************************************
-// $Id: ossimColorProperty.cpp 9966 2006-11-29 02:01:07Z gpotts $
+// $Id: ossimColorProperty.cpp 13667 2008-10-02 19:59:55Z gpotts $
 #include <sstream>
 #include <ossim/base/ossimColorProperty.h>
 
@@ -53,15 +53,22 @@ const ossimProperty& ossimColorProperty::assign(const ossimProperty& rhs)
 
 bool ossimColorProperty::setValue(const ossimString& value)
 {
-   istringstream in(value);
-
-   int r,g,b;
-
-   in >> r >> g >> b;
-
-   theValue = ossimRgbVector(r,g,b);
+   bool result = false;
+   std::vector<ossimString> splitArray;
+   
+   value.split(splitArray, " ");
+   if(splitArray.size() == 3)
+   {
+      int r,g,b;
+      r = splitArray[0].toInt32();
+      g = splitArray[1].toInt32();
+      b = splitArray[2].toInt32();
+      result = true;
+      
+      theValue = ossimRgbVector(r,g,b);
+   }
    
-   return in.good();
+   return result;
 }
 
 void ossimColorProperty::valueToString(ossimString& valueResult)const
diff --git a/Utilities/otbossim/src/ossim/base/ossimCommon.cpp b/Utilities/otbossim/src/ossim/base/ossimCommon.cpp
index a695fdff3d764ac583e2631c6bee7c99dae90a08..de44f728e783cb242cfc6bacf75e82ef3b430f97 100644
--- a/Utilities/otbossim/src/ossim/base/ossimCommon.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimCommon.cpp
@@ -7,7 +7,7 @@
 // Description: Common file for global functions.
 //
 //*************************************************************************
-// $Id: ossimCommon.cpp 12334 2008-01-18 18:01:10Z dburken $
+// $Id: ossimCommon.cpp 13666 2008-10-02 19:59:15Z gpotts $
 
 #include <sstream>
 
@@ -287,10 +287,24 @@ void ossim::defaultTileSize(ossimIpt& tileSize)
 
    if(tileSizeKw)
    {
-      std::istringstream in(tileSizeKw);
+      std::vector<ossimString> splitArray;
+      ossimString tempString(tileSizeKw);
+      tempString.split(splitArray, " ");
       bool hasX = true;
-      in >> tileSize.x >> tileSize.y;
-      
+    if(splitArray.size() == 2)
+      {
+         tileSize.x = splitArray[0].toInt32();
+         tileSize.y = splitArray[1].toInt32();
+      }
+      else if(splitArray.size() == 1)
+      {
+         tileSize.x = splitArray[0].toInt32();
+         tileSize.y = splitArray[0].toInt32();
+      }
+      else
+      {
+         tileSize = ossimIpt(0,0);
+      }
       if(tileSize.x < 1)
       {
          tileSize.x = OSSIM_DEFAULT_TILE_WIDTH;
diff --git a/Utilities/otbossim/src/ossim/base/ossimConnectableObject.cpp b/Utilities/otbossim/src/ossim/base/ossimConnectableObject.cpp
index eb0a2ac3ada1667499eb7eeb9b0ea6a1d89334bf..8092c05b9a8f5ea83a2b147c0dfc0b8cceb71ebe 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 12645 2008-04-09 21:02:33Z dburken $
+// $Id: ossimConnectableObject.cpp 13362 2008-08-01 14:02:32Z gpotts $
 #include <ossim/base/ossimConnectableObject.h>
 #include <ossim/base/ossimIdManager.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -1647,6 +1647,7 @@ void ossimConnectableObject::propagateEventToOutputs(ossimEvent& event)
       ossimConnectableObject* obj = getOutput(i);
       if(obj)
       {
+         event.setPropagationType(ossimEvent::PROPAGATION_OUTPUT);
          obj->fireEvent(event);
          obj->propagateEventToOutputs(event);
       }
diff --git a/Utilities/otbossim/src/ossim/base/ossimDate.cpp b/Utilities/otbossim/src/ossim/base/ossimDate.cpp
index a51131a0af18a7913629d8698c507a74b81bf4e3..76d88f4d4de98985f3bef972ae1019a1c00b7417 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDate.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDate.cpp
@@ -1,6 +1,7 @@
 #include <ossim/base/ossimDate.h>
 #include <iomanip>
 #include <sstream>
+#include <iostream>
 
 std::ostream& operator<< (std::ostream& out, const ossimDate& src)
 {
@@ -45,7 +46,7 @@ int operator>=  (ossimLocalTm const & t1, ossimLocalTm const & t2)
 char ossimLocalTm::timech = ':';
 char ossimLocalTm::datech = '/';
 
-int ossimLocalTm::datefmt = ossimLocalTm::ossimLocalTmFormatIntlShort;
+int ossimLocalTm::datefmt = ossimLocalTm::ossimLocalTmFormatFull;
 int ossimLocalTm::timefmt = ossimLocalTm::ossimTimeFormatInternational;
 
 
@@ -506,6 +507,12 @@ ossimLocalTm& ossimLocalTm::setSec(int s)
    return *this;
 }
 
+ossimLocalTm& ossimLocalTm::setFloatSec(double s)
+{
+   tm_sec = (int)s;
+   return setFractionalSecond(s-tm_sec);
+}
+
 ossimLocalTm& ossimLocalTm::setFractionalSecond(double fractionalSecond)
 {
    theFractionalSecond = fractionalSecond;
@@ -576,6 +583,282 @@ void ossimLocalTm::setTimeGivenEpoc(time_t ticks)
    *this = *localtime(&ticks);
 }
 
+
+static bool readIntegerFromString(ossim_int32& result,
+                                 const std::string& input,
+                                 std::string::size_type& currentPos,
+                                 int digits)
+{
+   ossimString number;
+   while((digits>0)&&
+         (currentPos < input.size()))
+   {
+      if(isdigit(input[currentPos]))
+      {
+         number += input[currentPos];
+         ++currentPos;
+         --digits;
+      }
+      else
+      {
+         return false;
+      }
+   }
+   result = number.toInt32();
+   return (digits <= 0);
+}
+
+static bool readTimeZoneOffset(ossim_int32& result,
+                               const std::string& input,
+                               std::string::size_type& currentPos)
+{
+   bool returnValue = false;
+   result = 0;
+   if(input[currentPos] == '+'||
+      input[currentPos] == '-')
+   {
+      returnValue = true;
+      ossim_int32 signMult = ((input[0] == '+')?1:-1);
+      ossim_int32 zoneMin = 0;
+      ossim_int32 zoneHour = 0;
+      ++currentPos;
+      if(readIntegerFromString(zoneHour,
+                               input,
+                               currentPos,
+                               2))
+      {
+         if(!isdigit(input[currentPos]))
+         {
+            ++currentPos; // skip :
+         }
+         if(readIntegerFromString(zoneMin,
+                                  input,
+                                  currentPos,
+                                  2))
+         {
+            result = signMult*(zoneMin*60 + zoneHour*3600);
+         }
+      }
+   }
+   
+   return returnValue;
+}
+
+bool ossimLocalTm::setIso8601(const std::string& timeString, bool shiftToGmtOffsetZero)
+{
+   ossimDate now;
+   std::string::size_type pos = 0;
+   ossim_int32 year  = 0;
+   ossim_int32 month = 0;
+   ossim_int32 day   = 0;
+   ossim_int32 timeZoneOffset = 0;
+   
+   if(timeString[0] != 'T') // make sure it's not time only
+   {
+      // look for year
+      //
+      if(readIntegerFromString(year,
+                               timeString,
+                               pos,
+                               4))
+      {
+         // retrieved the year portion
+         // now check for separator not digit
+         //
+         
+         // we at least have a year
+         // now check for others
+         setYear(year);
+         if(!isdigit(timeString[pos]))
+         {
+            // skip separator
+            ++pos;
+         }
+         if(readIntegerFromString(month,
+                                  timeString,
+                                  pos,
+                                  2))
+         
+         {
+            setMonth(month);
+            if(!isdigit(timeString[pos]))
+            {
+               // skip separator
+               ++pos;
+            }
+            if(readIntegerFromString(day,
+                                     timeString,
+                                     pos,
+                                     2))
+            {
+               setDay(day);
+            }
+         }
+      }
+      else
+      {
+         return false;
+      }
+   }
+   else // set year month day to current
+   {
+      setYear(now.getYear());
+      setMonth(now.getMonth());
+      setDay(now.getDay());
+   }
+   // check to see if we need to read time portion
+   if(timeString[pos] == 'T')
+   {
+      ++pos; // skip T character
+      ossim_int32 hours=0, minutes=0;
+      
+      if(readIntegerFromString(hours,
+                               timeString,
+                               pos,
+                               2))
+      {
+         setHour(hours);
+         
+         // now check for separator
+         if(!isdigit(timeString[pos]))
+         {
+            ++pos; // skip separator if present
+         }
+         if(readIntegerFromString(minutes,
+                                  timeString,
+                                  pos,
+                                  2))
+         {
+            setMin(minutes);
+            // now check for time zone if only a hour minute time
+            //
+            if(timeString[pos] == 'Z')
+            {
+               // no adjustment needed
+            }
+            else if(!readTimeZoneOffset(timeZoneOffset,
+                                       timeString,
+                                       pos))
+            {
+               double fractionalSeconds = 0.0;
+               if(!isdigit(timeString[pos]))
+               {
+                  ++pos;
+               }
+               std::string::size_type endPos = timeString.find_first_not_of("0123456789.", pos);
+               if(endPos == std::string::npos)
+               {
+                  fractionalSeconds = ossimString(timeString.begin()+pos,
+                                                  timeString.end()).toDouble();
+               }
+               else
+               {
+                  fractionalSeconds = ossimString(timeString.begin()+pos,
+                                                  timeString.begin()+endPos).toDouble();
+               }
+               setFloatSec(fractionalSeconds);
+               pos = endPos;
+               if(pos == std::string::npos)
+               {
+                  // we will not be too strict so if at the end then just return we got enough
+                  return true;
+               }
+               if(timeString[pos] == 'Z')
+               {
+                  // no adjustment needed
+               }
+               else
+               {
+                  readTimeZoneOffset(timeZoneOffset,
+                                          timeString,
+                                     pos);
+               }
+            }
+         }
+      }
+      else
+      {
+         // need at least hours 
+         return false;
+      }
+   }
+   else if(isdigit(timeString[pos]))
+   {
+      ossim_int32 hours=0, minutes=0;
+      
+      if(readIntegerFromString(hours,
+                               timeString,
+                               pos,
+                               2))
+      {
+         setHour(hours);
+         
+         // now check for separator
+         if(!isdigit(timeString[pos]))
+         {
+            ++pos; // skip separator if present
+         }
+         if(readIntegerFromString(minutes,
+                                  timeString,
+                                  pos,
+                                  2))
+         {
+            setMin(minutes);
+            
+            if(!readTimeZoneOffset(timeZoneOffset,
+                                  timeString,
+                                  pos))
+            {
+               double fractionalSeconds = 0.0;
+               if(!isdigit(timeString[pos]))
+               {
+                  ++pos;
+               }
+               std::string::size_type endPos = timeString.find_first_not_of("0123456789.", pos);
+               if(endPos == std::string::npos)
+               {
+                  fractionalSeconds = ossimString(timeString.begin()+pos,
+                                                  timeString.end()).toDouble();
+               }
+               else
+               {
+                  fractionalSeconds = ossimString(timeString.begin()+pos,
+                                                  timeString.begin()+endPos).toDouble();
+               }
+               setFloatSec(fractionalSeconds);
+               pos = endPos;
+               if(pos == std::string::npos)
+               {
+                  // we will not be too strict so if at the end then just return we got enough
+                  return true;
+               }
+               if(timeString[pos] == 'Z')
+               {
+                  // no adjustment needed
+               }
+               else
+               {
+                  readTimeZoneOffset(timeZoneOffset,
+                                     timeString,
+                                     pos);
+               }
+            }
+         }
+      }  
+   }
+   else
+   {
+      // need at least hours 
+      return false;
+   }
+   
+   if(shiftToGmtOffsetZero && (timeZoneOffset!=0))
+   {
+      addSeconds(-timeZoneOffset);
+   }
+   return true;
+}
+
 ossimRefPtr<ossimXmlNode> ossimLocalTm::saveXml()const
 {
    ossimRefPtr<ossimXmlNode> result = new ossimXmlNode;
diff --git a/Utilities/otbossim/src/ossim/base/ossimDatumFactory.cpp b/Utilities/otbossim/src/ossim/base/ossimDatumFactory.cpp
index 2fc217880b7892ced1e96abe9706a734d7c9c1d9..9145d4ff5799de773a063ecd5f1bfed96b79f7cc 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDatumFactory.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDatumFactory.cpp
@@ -9,7 +9,7 @@
 //
 // This holds the class definition of DatumFactory.
 //*******************************************************************
-//  $Id: ossimDatumFactory.cpp 13018 2008-06-10 16:11:57Z dburken $
+//  $Id: ossimDatumFactory.cpp 13302 2008-07-25 19:10:39Z gpotts $
 
 #include <utility> /* for std::make_pair */
 
@@ -29,6 +29,9 @@
 ossimDatumFactory* ossimDatumFactory::theInstance = 0;
 std::map<ossimString, ossimDatum*> ossimDatumFactory::theDatumTable;
 
+static const char WGE[] = "WGE";
+static const char WGD[] = "WGD";
+
 ossimDatumFactory::~ossimDatumFactory()
 {
    deleteAll();
@@ -46,8 +49,8 @@ ossimDatumFactory* ossimDatumFactory::instance()
       // so make sure an instance exists
       ossimEllipsoidFactory::instance();
       theInstance->initializeDefaults();
-      theInstance->theWgs84Datum = theInstance->create("WGE");
-      theInstance->theWgs72Datum = theInstance->create("WGD");
+      theInstance->theWgs84Datum = theInstance->create(WGE);
+      theInstance->theWgs72Datum = theInstance->create(WGD);
    }  
    return theInstance; 
 } 
@@ -234,10 +237,10 @@ const ossimDatum* ossimDatumFactory::create(const ossimDatum* aDatum)const
       return 0;
 }
 
-std::list<ossimString> ossimDatumFactory::getList()const
+std::vector<ossimString> ossimDatumFactory::getList()const
 {
    std::map<ossimString, ossimDatum*>::const_iterator datum = theDatumTable.begin();
-   std::list<ossimString> result;
+   std::vector<ossimString> result;
    
    while(datum != theDatumTable.end())
    {
@@ -247,7 +250,7 @@ std::list<ossimString> ossimDatumFactory::getList()const
    return result;
 }
 
-void ossimDatumFactory::getList(std::list<ossimString>& list) const
+void ossimDatumFactory::getList(std::vector<ossimString>& list) const
 {
    std::map<ossimString, ossimDatum*>::const_iterator datum =
       theDatumTable.begin();
@@ -278,17 +281,17 @@ void ossimDatumFactory::deleteAll()
 void ossimDatumFactory::initializeDefaults()
 {
    //make the standards
-   theDatumTable.insert(make_pair(ossimString("WGE"),
+   theDatumTable.insert(make_pair(ossimString(WGE),
                                   (ossimDatum*)new ossimWgs84Datum));
-   theDatumTable.insert(make_pair(ossimString("WGD"),
+   theDatumTable.insert(make_pair(ossimString(WGD),
                                   (ossimDatum*)new ossimWgs72Datum));
 
    ossim_uint32 idx = 0;     
 
    for(idx = 0; idx < NUMBER_OF_THREE_PARAM_DATUMS; ++idx)
    {
-      if((threeParamDatum[idx].theCode != "WGE")&&
-         (threeParamDatum[idx].theCode != "WGD"))
+      if( (threeParamDatum[idx].theCode != WGE) &&
+          (threeParamDatum[idx].theCode != WGD) )
       {
          theDatumTable.insert(std::make_pair(threeParamDatum[idx].theCode,
                                              (ossimDatum*)new ossimThreeParamDatum(threeParamDatum[idx].theCode, threeParamDatum[idx].theName,
@@ -301,8 +304,8 @@ void ossimDatumFactory::initializeDefaults()
    }
    for(idx = 0; idx < NUMBER_OF_SEVEN_PARAM_DATUMS; ++idx)
    {
-      if((threeParamDatum[idx].theCode != "WGE")&&
-         (threeParamDatum[idx].theCode != "WGD"))
+      if((threeParamDatum[idx].theCode != WGE)&&
+         (threeParamDatum[idx].theCode != WGD))
       {
          theDatumTable.insert(std::make_pair(sevenParamDatum[idx].theCode,
                                              (ossimDatum*)new ossimSevenParamDatum(sevenParamDatum[idx].theCode, sevenParamDatum[idx].theName,
diff --git a/Utilities/otbossim/src/ossim/base/ossimDatumFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/base/ossimDatumFactoryRegistry.cpp
index 5a4042f44502ea25d6a79ff3157771c818517312..e447f60e1db3b1cc7defe4da1dac3afbf7aa01d8 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDatumFactoryRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDatumFactoryRegistry.cpp
@@ -14,7 +14,7 @@
 #include <ossim/base/ossimDatum.h>
 #include <ossim/base/ossimString.h>
 
-ossimDatumFactoryRegistry* ossimDatumFactoryRegistry::theInstance = 0;
+//ossimDatumFactoryRegistry* ossimDatumFactoryRegistry::theInstance = 0;
 
 ossimDatumFactoryRegistry::~ossimDatumFactoryRegistry()
 {
@@ -22,11 +22,9 @@ ossimDatumFactoryRegistry::~ossimDatumFactoryRegistry()
 
 ossimDatumFactoryRegistry* ossimDatumFactoryRegistry::instance()
 {
-   if (!theInstance)
-   {
-      theInstance = new ossimDatumFactoryRegistry();
-   }
-   return theInstance;
+   static ossimDatumFactoryRegistry sharedInstance;
+
+   return &sharedInstance;
 }
 
 void ossimDatumFactoryRegistry::registerFactory(
@@ -58,7 +56,7 @@ const ossimDatum* ossimDatumFactoryRegistry::create(
    return result;
 }
 
-void ossimDatumFactoryRegistry::getList(std::list<ossimString>& list) const
+void ossimDatumFactoryRegistry::getList(std::vector<ossimString>& list) const
 {
    std::vector<ossimDatumFactoryInterface*>::const_iterator i =
       theFactoryList.begin();
diff --git a/Utilities/otbossim/src/ossim/base/ossimDoubleGridProperty.cpp b/Utilities/otbossim/src/ossim/base/ossimDoubleGridProperty.cpp
index c879b4f8efec8bd1fb1a3e5500c074a8680b49aa..9fb1ed0dfcd0213de79f77da1fd59dc60a75b9a4 100644
--- a/Utilities/otbossim/src/ossim/base/ossimDoubleGridProperty.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimDoubleGridProperty.cpp
@@ -60,26 +60,28 @@ const ossimProperty& ossimDoubleGridProperty::assign(const ossimProperty& rhs)
   
 bool ossimDoubleGridProperty::setValue(const ossimString& value)
 {
-  std::istringstream in(value.c_str());
-
-  int numberOfRows;
-  int numberOfCols;
-  int rowIdx = 0;
-  int colIdx = 0;
-  in >> numberOfRows >> numberOfCols;
-  
-  theValues.resize(numberOfRows);
-
-  for(rowIdx = 0; rowIdx < numberOfRows; ++rowIdx)
-    {
+   std::istringstream in(value.c_str());
+   ossimString nRows, nCols, v;
+   int numberOfRows=0;
+   int numberOfCols=0;
+   int rowIdx = 0;
+   int colIdx = 0;
+   in >> nRows >> nCols;
+   numberOfRows = nRows.toInt32();
+   numberOfCols = nCols.toInt32();
+   theValues.resize(numberOfRows);
+   
+   for(rowIdx = 0; rowIdx < numberOfRows; ++rowIdx)
+   {
       theValues[rowIdx].resize(numberOfCols);
       for(colIdx = 0; colIdx < numberOfCols; ++ colIdx)
-	{
-	  in >> theValues[rowIdx][colIdx];
-	}
-    }
-
-  return true;
+      {
+         in >> v;
+         theValues[rowIdx][colIdx] = v.toDouble();
+      }
+   }
+   
+   return true;
 }
 
 void ossimDoubleGridProperty::valueToString(ossimString& valueResult)const
diff --git a/Utilities/otbossim/src/ossim/base/ossimEllipsoid.cpp b/Utilities/otbossim/src/ossim/base/ossimEllipsoid.cpp
index 21db3b2b3ac11b20863fbb7ca4abe2c58ba9b4f2..e81a6eaff23e596b8b63acd9d64bfc990833d9bd 100644
--- a/Utilities/otbossim/src/ossim/base/ossimEllipsoid.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimEllipsoid.cpp
@@ -13,7 +13,7 @@
 //              Initial coding.
 //<
 //*****************************************************************************
-//  $Id: ossimEllipsoid.cpp 12755 2008-04-29 13:33:56Z dburken $
+//  $Id: ossimEllipsoid.cpp 13864 2008-11-14 13:24:37Z gpotts $
 
 #include <ossim/base/ossimEllipsoid.h>
 
@@ -460,11 +460,14 @@ void ossimEllipsoid::jacobianWrtGeo(const ossimEcefPoint& location,
 //*****************************************************************************
 double ossimEllipsoid::geodeticRadius(const double& lat) const
 {
+   double cos_lat = ossim::cosd(lat);
    double sin_lat = ossim::sind(lat);
+   double cos2_lat = cos_lat*cos_lat;
    double sin2_lat = sin_lat*sin_lat;
+   double a2_cos = theA_squared*cos_lat;
+   double b2_sin = theB_squared*sin_lat;
    
-   return (theA_squared/
-           sqrt(theA_squared - theA_squared*sin2_lat + theB_squared*sin2_lat));
+   return sqrt( ( (a2_cos*a2_cos) + (b2_sin*b2_sin) )/ (theA_squared*cos2_lat + theB_squared*sin2_lat));
 }
 
 void ossimEllipsoid::latLonHeightToXYZ(double lat, double lon, double height,
diff --git a/Utilities/otbossim/src/ossim/base/ossimEvent.cpp b/Utilities/otbossim/src/ossim/base/ossimEvent.cpp
index 16b17c7f1302e5ae3f69bcd6eee4a1dcf385f60e..542ac10f2f95ddc8f0c64620468b964b96c4dd85 100644
--- a/Utilities/otbossim/src/ossim/base/ossimEvent.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimEvent.cpp
@@ -7,27 +7,32 @@
 //
 //
 //*************************************************************************
-// $Id: ossimEvent.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimEvent.cpp 13362 2008-08-01 14:02:32Z gpotts $
 #include <ossim/base/ossimEvent.h>
 
 RTTI_DEF1(ossimEvent, "ossimEvent", ossimObject);
 
 
 ossimEvent::ossimEvent(ossimObject* object, long id)
-   :
-      ossimObject(),
-      theObject(object),
-      theId(id),
-      theIsConsumedFlag(false)
+:
+ossimObject(),
+theObject(object),
+theCurrentObject(object),
+theId(id),
+theIsConsumedFlag(false),
+thePropagationType(PROPAGATION_NONE)
 {
 }
 
 ossimEvent::ossimEvent(const ossimEvent& rhs)
-   :
-      ossimObject(),
-      theObject(rhs.theObject),
-      theId(rhs.theId),
-      theIsConsumedFlag(rhs.theIsConsumedFlag)
+:
+ossimObject(),
+theObject(rhs.theObject),
+theCurrentObject(rhs.theCurrentObject),
+theId(rhs.theId),
+theIsConsumedFlag(rhs.theIsConsumedFlag),
+thePropagationType(PROPAGATION_NONE)
+
 {
 }
 
@@ -66,7 +71,38 @@ ossimObject* ossimEvent::getObject()
    return theObject;
 }
 
+const ossimObject* ossimEvent::getCurrentObject() const
+{
+   return theCurrentObject;
+}
+
+ossimObject* ossimEvent::getCurrentObject()
+{
+   return theCurrentObject;
+}
+
 void ossimEvent::setObject(ossimObject* object)
 {
    theObject = object;
 }
+
+void ossimEvent::setCurrentObject(ossimObject* object)
+{
+   theCurrentObject = object;
+}
+
+void ossimEvent::setPropagationType(PropagationType type)
+{
+   thePropagationType = type;
+}
+
+bool ossimEvent::isPropagatingToOutputs()const
+{
+   return thePropagationType&PROPAGATION_OUTPUT;
+}
+
+bool ossimEvent::isPropagatingToInputs()const
+{
+   return thePropagationType&PROPAGATION_INPUT;
+}
+
diff --git a/Utilities/otbossim/src/ossim/base/ossimFilename.cpp b/Utilities/otbossim/src/ossim/base/ossimFilename.cpp
index d4285694abc6bf8a43c9aa59b3ef99e6293c7b63..2c2d25a418a1880f1a301d41f31af511522940f2 100644
--- a/Utilities/otbossim/src/ossim/base/ossimFilename.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimFilename.cpp
@@ -5,7 +5,7 @@
 // Description: This class provides manipulation of filenames.
 //
 //*************************************************************************
-// $Id: ossimFilename.cpp 13049 2008-06-19 18:06:45Z gpotts $
+// $Id: ossimFilename.cpp 13604 2008-09-25 14:41:28Z gpotts $
 
 #include <ossim/ossimConfig.h>  /* to pick up platform defines */
 
@@ -29,15 +29,9 @@ using namespace std;
 #include <sys/types.h>
 #include <utime.h>
 #include <sys/stat.h>
-#   if HAVE_UNISTD_H
-#      include <unistd.h>
-#   endif
-#   if HAVE_DIRENT_H
-#      include <dirent.h>
-#   endif
-#   if HAVE_FCNTL_H
-#      include <fcntl.h>
-#   endif
+#include <unistd.h>
+#include <dirent.h>
+#include <fcntl.h>
 #endif
 
 #include <sys/stat.h>
@@ -1014,7 +1008,7 @@ bool ossimFilename::remove(const ossimFilename& pathname)
    {
       result = false;
    }
-#elif HAVE_UNISTD_H
+#else
    if(pathname.isDir())
    {
       result = (rmdir(pathname) >=0);
@@ -1023,14 +1017,6 @@ bool ossimFilename::remove(const ossimFilename& pathname)
    {
       result = false;
    }
-#else
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_WARN)
-         << "WARNING: "
-         << "ossimFilename::remove,  Not supported by platform!"
-         << endl;
-   }
 #endif /* HAVE_UNISTD_H */
 
    return result;
@@ -1074,20 +1060,11 @@ bool ossimFilename::wildcardRemove(const ossimFilename& pathname)
       {
          result = false;
       }
-#elif HAVE_UNISTD_H
+#else
       if (unlink(fileListToRemove[idx]) == -1)
       {
          result = false;
       }
-#else
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN)
-            << "WARNING: "
-            << "ossimFilename::remove,  Not supported by platform!"
-            << endl;
-      }
-      result = false;
 #endif /* HAVE_UNISTD_H */
    }
    return result;
diff --git a/Utilities/otbossim/src/ossim/base/ossimGeoPolygon.cpp b/Utilities/otbossim/src/ossim/base/ossimGeoPolygon.cpp
index a65d26acec23da8bc1893970d82bc6e102a223b7..cb3a4e1b6ade1e78029eb9c43f173936b93d4c5f 100644
--- a/Utilities/otbossim/src/ossim/base/ossimGeoPolygon.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimGeoPolygon.cpp
@@ -6,7 +6,7 @@
 // AUTHOR: Garrett Potts
 //
 //*****************************************************************************
-//  $Id: ossimGeoPolygon.cpp 12976 2008-06-03 23:58:10Z dburken $
+//  $Id: ossimGeoPolygon.cpp 13686 2008-10-07 02:13:52Z gpotts $
 
 #include <ostream>
 #include <sstream>
@@ -319,24 +319,15 @@ bool ossimGeoPolygon::loadState(const ossimKeywordlist& kwl,
    theVertexList.clear();
    int i = 0;
    int vertexCount = ossimString(number_vertices).toLong();
-   double lat = 0.0, lon =0.0;
-   ossimString height;
+   ossimString lat, lon, height;
    for(i = 0; i < vertexCount; ++i)
    {
       ossimString v = kwl.find(prefix, (ossimString("v")+ossimString::toString(i)).c_str());
+      ossimString latString, lonString, heightString;
       v = v.trim();
-
-      std::istringstream vStream(v);
-      vStream >> lat >> lon >> height;
-      height = height.trim();
-      if(height == "nan")
-      {
-         theVertexList.push_back(ossimGpt(lat, lon, ossim::nan(), datum));
-      }
-      else
-      {
-         theVertexList.push_back(ossimGpt(lat, lon, height.toDouble(), datum));
-      }
+      std::istringstream in(v);
+      in>>lat>>lon>>height;
+      theVertexList.push_back(ossimGpt(lat.toDouble(), lon.toDouble(), height.toDouble(), datum));
    }
 
    return true;
diff --git a/Utilities/otbossim/src/ossim/base/ossimGzStream.cpp b/Utilities/otbossim/src/ossim/base/ossimGzStream.cpp
index f9f1d92560346f9b547fc10b6d5d946f742a2f6c..5dae54b7a8a047dfe0a4e031581346e2cb4a6266 100644
--- a/Utilities/otbossim/src/ossim/base/ossimGzStream.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimGzStream.cpp
@@ -18,8 +18,8 @@
 // ============================================================================
 //
 // File          : gzstream.C
-// Revision      : $Revision: 13050 $
-// Revision_date : $Date: 2008-06-19 20:07:35 +0200 (Thu, 19 Jun 2008) $
+// Revision      : $Revision: 13213 $
+// Revision_date : $Date: 2008-07-24 01:36:39 +0800 (Thu, 24 Jul 2008) $
 // Author(s)     : Deepak Bandyopadhyay, Lutz Kettner
 // 
 // Standard streambuf implementation following Nicolai Josuttis, "The 
@@ -49,8 +49,9 @@ struct ossimGzStreamBuf::PrivateData
 // Internal classes to implement gzstream. See header file for user classes.
 // ----------------------------------------------------------------------------
 ossimGzStreamBuf::ossimGzStreamBuf()
-   : opened(false),
-   prvtData(new PrivateData())
+   : prvtData(new PrivateData()),
+     opened(false),
+     mode(0) // ??? (drb)
 {
 
    setp( buffer, buffer + (bufferSize-1));
diff --git a/Utilities/otbossim/src/ossim/base/ossimHistogram.cpp b/Utilities/otbossim/src/ossim/base/ossimHistogram.cpp
index e78864751be147eb0f3190e966eed4448e0dde89..8ee74f267ce15806bb371585f08cf0b4e5f6ff2c 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 12953 2008-06-01 16:24:05Z dburken $
+// $Id: ossimHistogram.cpp 13709 2008-10-14 14:55:11Z gpotts $
 //
 
 #include <stdio.h>
@@ -1387,13 +1387,13 @@ bool ossimHistogram::loadState(const ossimRefPtr<ossimXmlNode> xmlNode)
       float maxValue = 0.0;
       std::vector<float> floatValues;
       std::istringstream in(binValues->getText());
-      float v;
+      ossimString vString;
       while(!in.fail())
       {
-         in>>v;
+         in>>vString;
          if(!in.fail())
          {
-            floatValues.push_back(v);
+            floatValues.push_back(vString.toFloat32());
          }
       }
       count = floatValues.size();
diff --git a/Utilities/otbossim/src/ossim/base/ossimListenerManager.cpp b/Utilities/otbossim/src/ossim/base/ossimListenerManager.cpp
index 1b89aa991f64703a0b37adc931f6a4306509ea2a..2291ce37cec4584d93533f2791a41fb42fd6008e 100644
--- a/Utilities/otbossim/src/ossim/base/ossimListenerManager.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimListenerManager.cpp
@@ -8,7 +8,7 @@
 // Description: A brief description of the contents of the file.
 //
 //*************************************************************************
-// $Id: ossimListenerManager.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimListenerManager.cpp 13362 2008-08-01 14:02:32Z gpotts $
 
 #include <algorithm>
 #include <ossim/base/ossimListenerManager.h>
@@ -35,6 +35,7 @@ ossimListenerManager::~ossimListenerManager()
 void ossimListenerManager::fireEvent(ossimEvent& event)
 {
    // only process the event if it has not been consumed.
+   event.setCurrentObject(PTR_CAST(ossimObject, this));
    if(event.isConsumed())
    {
       return;
diff --git a/Utilities/otbossim/src/ossim/base/ossimMatrixProperty.cpp b/Utilities/otbossim/src/ossim/base/ossimMatrixProperty.cpp
index 76f161cef492670fe54a6e23fcebb8205fe28491..26d9dc23944d779233104eadd6ee14e0af869f94 100644
--- a/Utilities/otbossim/src/ossim/base/ossimMatrixProperty.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimMatrixProperty.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts (gpotts@imagelinks.com)
 //
 //*************************************************************************
-// $Id: ossimMatrixProperty.cpp 12911 2008-05-28 13:36:06Z gpotts $
+// $Id: ossimMatrixProperty.cpp 13710 2008-10-14 16:27:57Z gpotts $
 #include <sstream>
 #include <ossim/base/ossimMatrixProperty.h>
 #include <ossim/base/ossimCommon.h>
@@ -82,15 +82,15 @@ bool ossimMatrixProperty::setValue(const ossimString& value)
 {
    std::istringstream in(value);
    
-   int numberOfRows;
-   int numberOfCols;
-   double tempValue;
+   ossimString numberOfRows;
+   ossimString numberOfCols;
+   ossimString tempValue;
    
    in>>numberOfRows >> numberOfCols;
 
    if(!in.bad())
    {
-      resize(numberOfRows, numberOfCols);
+      resize(numberOfRows.toInt32(), numberOfCols.toInt32());
 
       int rowIdx = 0;
       int colIdx = 0;
@@ -100,7 +100,7 @@ bool ossimMatrixProperty::setValue(const ossimString& value)
          {
             in >> tempValue;
             
-            theValueArray[rowIdx][colIdx] = tempValue;
+            theValueArray[rowIdx][colIdx] = tempValue.toDouble();
          }
       }
    }
diff --git a/Utilities/otbossim/src/ossim/base/ossimNBandLutDataObject.cpp b/Utilities/otbossim/src/ossim/base/ossimNBandLutDataObject.cpp
index dd57888c2db3b9d370fd2272213e5adc7948a129..2e9ade00ec2feb4fd54017cda10b1c8fcd018273 100644
--- a/Utilities/otbossim/src/ossim/base/ossimNBandLutDataObject.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimNBandLutDataObject.cpp
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimNBandLutDataObject.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimNBandLutDataObject.cpp 13710 2008-10-14 16:27:57Z gpotts $
 
 #include <iostream>
 #include <sstream>
@@ -327,12 +327,13 @@ bool ossimNBandLutDataObject::loadState(const ossimKeywordlist& kwl, const char*
          if(v != "")
          {
             std::istringstream istr(v);
-            
+            ossimString lutValue;
             for(bandIdx = 0; bandIdx < theNumberOfBands; ++bandIdx)
             {
                if(!istr.fail())
                {
-                  istr >> lutPtr[bandIdx];
+                  istr >> lutValue;
+                  lutPtr[bandIdx] = lutValue.toInt32();
                }
             }
          }
diff --git a/Utilities/otbossim/src/ossim/base/ossimObjectFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/base/ossimObjectFactoryRegistry.cpp
index 8a537d84d05af76a83e485326f003c2e90b542ec..08683e2d5bdd4debc83a1f5fe1b83cd158b1736a 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimObjectFactoryRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
 
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 
@@ -17,21 +17,20 @@ RTTI_DEF1(ossimObjectFactoryRegistry, "ossimObjectFactoryRegistry", ossimObject)
 #include <ossim/base/ossimString.h>
 using namespace std;
 
-ossimObjectFactoryRegistry* ossimObjectFactoryRegistry::theInstance=NULL;
+
+ossimObjectFactoryRegistry::ossimObjectFactoryRegistry()
+{
+}
 
 ossimObjectFactoryRegistry::~ossimObjectFactoryRegistry()
 {
-   theInstance = NULL;
 }
 
 ossimObjectFactoryRegistry* ossimObjectFactoryRegistry::instance()
 {
-   if(!theInstance)
-   {
-      theInstance = new ossimObjectFactoryRegistry;
-   }
+   static ossimObjectFactoryRegistry sharedInstance;
    
-   return theInstance;
+   return &sharedInstance;
 }
 
 bool ossimObjectFactoryRegistry::addFactory(ossimObjectFactory* factory)
diff --git a/Utilities/otbossim/src/ossim/base/ossimPolyArea2d.cpp b/Utilities/otbossim/src/ossim/base/ossimPolyArea2d.cpp
index 7c6d19439aa7badc9725b6a3ee56f8bad4f22139..05ec1c0c00aa11240cbf1d8d65699e782102b6c5 100644
--- a/Utilities/otbossim/src/ossim/base/ossimPolyArea2d.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimPolyArea2d.cpp
@@ -1,7 +1,7 @@
 //---
 // License:  See top level LICENSE.txt file.
 //
-// $Id: ossimPolyArea2d.cpp 12966 2008-06-03 14:17:40Z gpotts $
+// $Id: ossimPolyArea2d.cpp 13710 2008-10-14 16:27:57Z gpotts $
 //---
 #include <ossim/base/ossimPolyArea2d.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -678,7 +678,7 @@ bool ossimPolyArea2d::loadState(const ossimKeywordlist& kwl,
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimPolyArea2d.cpp 12966 2008-06-03 14:17:40Z gpotts $
+// $Id: ossimPolyArea2d.cpp 13710 2008-10-14 16:27:57Z gpotts $
 #include <list>
 #include <sstream>
 using namespace std;
@@ -1539,6 +1539,7 @@ bool ossimPolyArea2d::loadState(const ossimKeywordlist& kwl,
          ossim_uint32 currentPoint = 0;
          while(numberOfMatches < numberOfPoints)
          {
+            ossimString x,y;
             ossimString pointString = "point";
             pointString += ossimString::toString(currentPoint);
             const char* pointLookup = kwl.find((*currentContour).c_str(),
@@ -1547,9 +1548,10 @@ bool ossimPolyArea2d::loadState(const ossimKeywordlist& kwl,
             {
                istringstream s(pointLookup);
 
-               s >> v[0] >> v[1];
+               s >> x >> y;
+               v[0] = x.toDouble();
+               v[1] = y.toDouble();
                v[2] = 0;
-
                // initialize the poly if we are on the
                // first match point else we just add it.
                if(!numberOfMatches)
diff --git a/Utilities/otbossim/src/ossim/base/ossimPolyLine.cpp b/Utilities/otbossim/src/ossim/base/ossimPolyLine.cpp
index e0472fb0a91ff7d313d4eed2cb2818f813181137..7d87943e280df124426298dac1888d4963f57aa8 100644
--- a/Utilities/otbossim/src/ossim/base/ossimPolyLine.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimPolyLine.cpp
@@ -5,7 +5,7 @@
 // AUTHOR: Garrett Potts (gpotts@imagelinks.com)
 //
 //*****************************************************************************
-//  $Id: ossimPolyLine.cpp 13020 2008-06-10 16:15:21Z dburken $
+//  $Id: ossimPolyLine.cpp 13709 2008-10-14 14:55:11Z gpotts $
 //
 #include <ossim/base/ossimPolyLine.h>
 #include <ossim/base/ossimCommon.h>
@@ -549,7 +549,7 @@ bool ossimPolyLine::loadState(const ossimKeywordlist& kwl,
 
    theVertexList.clear();
    int vertexCount = ossimString(number_vertices).toLong();
-   double x = 0.0, y =0.0;
+   ossimString x = 0.0, y =0.0;
    for(i = 0; i < vertexCount; ++i)
    {
       ossimString v = kwl.find(prefix, (ossimString("v")+ossimString::toString(i)).c_str());
@@ -557,7 +557,7 @@ bool ossimPolyLine::loadState(const ossimKeywordlist& kwl,
 
       istringstream vStream(v);
       vStream >> x >> y;
-      theVertexList.push_back(ossimDpt(x,y));
+      theVertexList.push_back(ossimDpt(x.toDouble(),y.toDouble()));
    }
 
    return true;
diff --git a/Utilities/otbossim/src/ossim/base/ossimPolygon.cpp b/Utilities/otbossim/src/ossim/base/ossimPolygon.cpp
index 1fa0463018e9544d1b948d44696b3ed114bc4124..ef92633a01b46d9b3478040725104cd8b2d3703c 100644
--- a/Utilities/otbossim/src/ossim/base/ossimPolygon.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimPolygon.cpp
@@ -12,7 +12,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimPolygon.cpp 13019 2008-06-10 16:14:07Z dburken $
+//  $Id: ossimPolygon.cpp 13686 2008-10-07 02:13:52Z gpotts $
 
 #include <algorithm>
 #include <iterator>
@@ -743,7 +743,7 @@ bool ossimPolygon::loadState(const ossimKeywordlist& kwl,
 {
    ossimString order = kwl.find(prefix, VERTEX_ORDER_KW);
    const char* number_vertices = kwl.find(prefix, NUMBER_VERTICES_KW);
-
+   ossimString x,y;
    if(order=="unknown")
    {
       theOrderingType = OSSIM_VERTEX_ORDER_UNKNOWN;
@@ -759,7 +759,6 @@ bool ossimPolygon::loadState(const ossimKeywordlist& kwl,
 
    theVertexList.clear();
    int vertexCount = ossimString(number_vertices).toLong();
-   double x = 0.0, y =0.0;
    int i = 0;
    for(i = 0; i < vertexCount; ++i)
    {
@@ -768,7 +767,7 @@ bool ossimPolygon::loadState(const ossimKeywordlist& kwl,
 
       istringstream vStream(v);
       vStream >> x >> y;
-      theVertexList.push_back(ossimDpt(x,y));
+      theVertexList.push_back(ossimDpt(x.toDouble(),y.toDouble()));
    }
 
    return true;
diff --git a/Utilities/otbossim/src/ossim/base/ossimReferenced.cpp b/Utilities/otbossim/src/ossim/base/ossimReferenced.cpp
index 03851cc27dcdd6fe7b88741dc4d21627621e00bb..ad6488f96f3150e57cae77d488dba008a827084d 100644
--- a/Utilities/otbossim/src/ossim/base/ossimReferenced.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimReferenced.cpp
@@ -5,6 +5,11 @@
 
 ossimReferenced::~ossimReferenced()
 {
+   if(theRefMutex)
+   {
+      delete theRefMutex;
+      theRefMutex = 0;
+   }
    if (theRefCount>0)
    {
       ossimNotify(ossimNotifyLevel_WARN)<<"Warning: deleting still referenced object "<<this<<std::endl;
diff --git a/Utilities/otbossim/src/ossim/base/ossimRgbLutDataObject.cpp b/Utilities/otbossim/src/ossim/base/ossimRgbLutDataObject.cpp
index fc0a53447f0f4312dc51424c0bb51159bd620fd9..82df6553b03cee4743592728bcca2f3ff74784dc 100644
--- a/Utilities/otbossim/src/ossim/base/ossimRgbLutDataObject.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimRgbLutDataObject.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimRgbLutDataObject.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimRgbLutDataObject.cpp 13710 2008-10-14 16:27:57Z gpotts $
 #include <ossim/base/ossimRgbLutDataObject.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimFilename.h>
@@ -243,11 +243,11 @@ bool ossimRgbLutDataObject::loadState(const ossimKeywordlist& kwl, const char* p
          ossimString v = tempKwl->find(tempPrefix, newPrefix.c_str());
          istringstream istr(v);
 
-         int r, g, b;
+         ossimString r, g, b;
          istr >> r >> g >> b;
-         theLut[index].setR((unsigned char)r);
-         theLut[index].setG((unsigned char)g);
-         theLut[index].setB((unsigned char)b);
+         theLut[index].setR((unsigned char)r.toInt32());
+         theLut[index].setG((unsigned char)g.toInt32());
+         theLut[index].setB((unsigned char)b.toInt32());
       }
    }
    else
diff --git a/Utilities/otbossim/src/ossim/base/ossimString.cpp b/Utilities/otbossim/src/ossim/base/ossimString.cpp
index d8182141eb393fb1099a387e81b825a87b435152..90adb312898e53e15fd3d9dac132c34e969ed1ae 100644
--- a/Utilities/otbossim/src/ossim/base/ossimString.cpp
+++ b/Utilities/otbossim/src/ossim/base/ossimString.cpp
@@ -6,11 +6,12 @@
 // Description: This class extends the stl's string class.
 // 
 //********************************************************************
-// $Id: ossimString.cpp 13141 2008-07-06 20:19:03Z dburken $
+// $Id: ossimString.cpp 13761 2008-10-22 19:28:35Z gpotts $
 
 #include <iostream>
 #include <iomanip>
 #include <sstream>
+#include <stdlib.h>
 #include <algorithm>
 #include <ossim/base/ossimCommon.h>
 #include <ossim/base/ossimString.h>
@@ -21,7 +22,7 @@
 static ossimTrace traceDebug("ossimString:debug");
 
 #ifdef OSSIM_ID_ENABLED
-static char OSSIM_ID[] = "$Id: ossimString.cpp 13141 2008-07-06 20:19:03Z dburken $";
+static char OSSIM_ID[] = "$Id: ossimString.cpp 13761 2008-10-22 19:28:35Z gpotts $";
 #endif
 
 ossimString ossimString::upcase(const ossimString& aString)
@@ -82,7 +83,7 @@ char* ossimString::stringDup()const
 
    if(length() == 0)
    {
-      result = new char;
+      result = new char[1];
       result[0] = '\0';
    }
    else
@@ -443,169 +444,141 @@ bool ossimString::toBool(const ossimString& aString)
 int ossimString::toInt()const
 {
    int i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 int ossimString::toInt(const ossimString& aString)
 {
-   int i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;
+   return aString.toInt();
 }
 
 ossim_int32 ossimString::toInt32()const
 {
    ossim_int32 i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 ossim_int32 ossimString::toInt32(const ossimString& aString)
 {
-   ossim_int32 i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;
+   return aString.toInt32();
 }
 
 ossim_uint32 ossimString::toUInt32()const
 {
    ossim_uint32 i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 ossim_uint32 ossimString::toUInt32(const ossimString& aString)
 {
-   ossim_uint32 i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;   
+   return aString.toUInt32();
 }
 
 ossim_int64 ossimString::toInt64()const
 {
    ossim_int64 i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 ossim_int64 ossimString::toInt64(const ossimString& aString)
 {
-   ossim_int64 i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;
+   return aString.toInt64();
 }
 
 ossim_uint64 ossimString::toUInt64()const
 {
    ossim_uint64 i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 ossim_uint64 ossimString::toUInt64(const ossimString& aString)
 {
-   ossim_int64 i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;
+   return aString.toUInt64();
 }
 
 long ossimString::toLong()const
 {
-   long i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+  long i = 0;
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 long ossimString::toLong(const ossimString& aString)
 {
-   long i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;
+   return aString.toLong();
 }
 
 unsigned long  ossimString::toULong()const
 {
    unsigned long i = 0;
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> i;
+      if(is.fail())
+      {
+         i = 0;
+      }
    }
    return i;
 }
 
 unsigned long ossimString::toULong(const ossimString& aString)
 {
-   unsigned long i = 0;
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> i;
-   }
-   return i;
+   return aString.toULong();
 }
 
 ossim_float32 ossimString::toFloat32()const
@@ -619,47 +592,26 @@ ossim_float32 ossimString::toFloat32()const
    // There is a possibility that this isn't a thread safe implementation
    // in mingw stl.  Let's resort back to atof for now
 
+#if 1
+   d = (ossim_float32)atof(c_str());
+#endif
 #if 0
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> d;
+      if(is.fail())
+      {
+         d = 0.0;
+      }
    }
 #endif
-   if(!this->empty())
-   {
-      d = (ossim_float32)atof(this->c_str());
-   }
-
    return d;
 }
 
 ossim_float32 ossimString::toFloat32(const ossimString& aString)
 {
-   if(aString.contains("nan"))
-   {
-      return ossim::nan();
-   }
-   ossim_float32 d = 0.0;
-   // this part is core dumping under mingw in ossimPlanet.
-   // There is a possibility that this isn't a thread safe implementation
-   // in mingw stl.  Let's resort back to atof for now
-
-#if 0
-   ossimString os =aString.c_str();
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> d;
-   }
-#endif
-   if(!aString.empty())
-   {
-      d = (ossim_float32)atof(aString.c_str());
-   }
-
-   return d;
+   return aString.toFloat32();
 }
 
 ossim_float64 ossimString::toFloat64()const
@@ -673,46 +625,26 @@ ossim_float64 ossimString::toFloat64()const
    // There is a possibility that this isn't a thread safe implementation
    // in mingw stl.  Let's resort back to atof for now
 
+#if 1
+   d = (ossim_float64)atof(c_str());
+#endif
 #if 0
-   ossimString os = ths->c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+      std::istringstream is(*this);
       is >> d;
+      if(is.fail())
+      {
+         d = 0.0;
+      }
    }
 #endif
-   if(!this->empty())
-   {
-      d = (ossim_float64)atof(this->c_str());
-   }
-   
    return d;
 }
 
 ossim_float64 ossimString::toFloat64(const ossimString& aString)
 {
-   if(aString.contains("nan"))
-   {
-      return ossim::nan();
-   }
-   ossim_float64 d = 0.0;
-   // this part is core dumping under mingw in ossimPlanet.
-   // There is a possibility that this isn't a thread safe implementation
-   // in mingw stl.  Let's resort back to atof for now
-
-#if 0
-   ossimString os = aString;
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> d;
-   }
-#endif
-   if(!aString.empty())
-   {
-      d = (ossim_float64)atof(aString.c_str());
-   }
-   return d;
+   return aString.toFloat64();
 }
 
 double ossimString::toDouble()const
@@ -727,48 +659,26 @@ double ossimString::toDouble()const
    // There is a possibility that this isn't a thread safe implementation
    // in mingw stl.  Let's resort back to atof for now
 
-#if 0
-   ossimString os = c_str();
-   if (!os.empty())
+   if (!empty())
    {
-      std::istringstream is(os);
+#if 1
+      d = atof(c_str());
+#endif
+#if 0
+      std::istringstream is(*this);
       is >> d;
-   }
+      if(is.fail())
+      {
+         d = 0.0;
+      }
 #endif
-
-   if(!this->empty())
-   {
-      d = atof(this->c_str());
    }
-   
    return d;
 }
 
 double ossimString::toDouble(const ossimString& aString)
 {
-   if(aString.contains("nan"))
-   {
-      return ossim::nan();
-   }
-   double d = 0.0;
-   // this part is core dumping under mingw in ossimPlanet.
-   // There is a possibility that this isn't a thread safe implementation
-   // in mingw stl.  Let's resort back to atof for now
-
-#if 0
-   ossimString os = c_str();
-   if (!os.empty())
-   {
-      std::istringstream is(os);
-      is >> d;
-   }
-#endif
-   if(!aString.empty())
-   {
-      d = atof(aString.c_str());
-   }
-
-   return d;
+   return aString.toDouble();
 }
 
 ossimString ossimString::toString(bool aValue)
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimElevSource.cpp b/Utilities/otbossim/src/ossim/elevation/ossimElevSource.cpp
index 3dff2a708bdb9961d131d21c6423842e6fff0f2a..2fcb922b6a7c252d17132ba4fffc618c985f6617 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimElevSource.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimElevSource.cpp
@@ -15,7 +15,7 @@
 //              Initial coding.
 //<
 //*****************************************************************************
-// $Id: ossimElevSource.cpp 11506 2007-08-06 09:41:03Z dburken $
+// $Id: ossimElevSource.cpp 13457 2008-08-18 18:49:25Z gpotts $
 
 #include <ossim/elevation/ossimElevSource.h>
 #include <ossim/base/ossimPreferences.h>
@@ -149,7 +149,11 @@ bool ossimElevSource::intersectRay(const ossimEcefRay& ray, ossimGpt& gpt)
    bool            done = false;
    int             iteration_count = 0;
 
-   if(ray.hasNans()) return false;
+   if(ray.hasNans()) 
+   {
+      gpt.makeNan();
+      return false;
+   }
    //***
    // Set the initial guess for horizontal intersect position as the ray's
    // origin, and establish the datum and ellipsoid:
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimElevationShapeIdx.cpp b/Utilities/otbossim/src/ossim/elevation/ossimElevationShapeIdx.cpp
deleted file mode 100644
index da29ea1366bd9c9908d2eb3831a2bead17ace890..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/elevation/ossimElevationShapeIdx.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-#include <ossim/elevation/ossimElevationShapeIdx.h>
-#include <ossim/vec/shapefil.h>
-
-ossimString ossimElevationShapeIdx::theDefaultName = "elevation_idx.shp";
-
-class ossimElevationShapeIdxPrivate : public ossimReferenced
-{
-public:
-   ossimElevationShapeIdxPrivate()
-      :theShapefileHandle(0),
-       theDbfHandle(0)
-      {
-      }
-   virtual ~ossimElevationShapeIdxPrivate()
-      {
-         shpClose();
-      }
-   ossim_SHPHandle shpOpen(const ossimFilename& file, bool overWriteFlag)
-      {
-         shpClose();
-         theShapeFilename = file;
-         if(overWriteFlag)
-         {
-            theShapefileHandle = ossim_SHPCreate(file.c_str(),
-                                           ossim_SHPT_POLYGON);
-         }
-         else
-         {
-            theShapefileHandle = ossim_SHPOpen(file.c_str(),
-                                         "r+b");
-            if(!theShapefileHandle)
-            {
-               theShapefileHandle = ossim_SHPCreate(file.c_str(),
-                                              ossim_SHPT_POLYGON);
-            }
-         }
-         dbfOpen(overWriteFlag);
-         
-         return theShapefileHandle;
-      }
-   void shpClose()
-      {
-         if(theShapefileHandle)
-         {
-            ossim_SHPClose(theShapefileHandle);
-            theShapefileHandle = 0;  
-         }
-      }
-   ossim_SHPHandle shpHandle()
-      {
-         return theShapefileHandle;
-      }
-
-   ossim_DBFHandle dbfHandle()
-      {
-         return theDbfHandle;
-      }
-   
-protected:
-   void dbfOpen(bool overWriteFlag)
-      {
-         dbfClose();
-
-         if(overWriteFlag)
-         {
-            theDbfHandle = ossim_DBFCreate(theShapeFilename.c_str());
-            if(theDbfHandle)
-            {
-               ossim_DBFAddField(theDbfHandle, "FILENAME", FTString, 256, 0);
-               ossim_DBFAddField(theDbfHandle, "MINZ", FTDouble, 32, 17);
-               ossim_DBFAddField(theDbfHandle, "MAXZ", FTDouble, 32, 17);
-            }
-         }
-         else
-         {
-            theDbfHandle = ossim_DBFOpen(theShapeFilename.c_str(), "r+b");
-            if(!theDbfHandle)
-            {
-               theDbfHandle = ossim_DBFCreate(theShapeFilename.c_str());
-               if(theDbfHandle)
-               {
-                  ossim_DBFAddField(theDbfHandle, "FILENAME", FTString, 256, 0);
-                  ossim_DBFAddField(theDbfHandle, "MINZ", FTDouble, 32, 17);
-                  ossim_DBFAddField(theDbfHandle, "MAXZ", FTDouble, 32, 17);
-               }
-            }
-         }
-      }
-   void dbfClose()
-      {
-         if(theDbfHandle)
-         {
-            ossim_DBFClose(theDbfHandle);
-            theDbfHandle = 0;
-         }
-      }
-   ossimFilename theShapeFilename;
-   ossim_SHPHandle   theShapefileHandle;
-   ossim_DBFHandle   theDbfHandle;
-};
-
-ossimElevationShapeIdx::ossimElevationShapeIdx(const ossimFilename& shapeFilename,
-                                               bool overWriteFlag)
-   :thePrivateData(0)
-{
-   setFilename(shapeFilename, overWriteFlag);
-}
-
-ossimElevationShapeIdx::~ossimElevationShapeIdx()
-{
-   if(thePrivateData)
-   {
-      delete thePrivateData;
-      thePrivateData = 0;
-   }
-}
-
-const ossimString& ossimElevationShapeIdx::defaultName()
-{
-   return theDefaultName;
-}
-
-void ossimElevationShapeIdx::setFilename(const ossimFilename& shapeFilename, bool overWriteFlag)
-{
-   if(thePrivateData)
-   {
-      delete thePrivateData;
-      thePrivateData = 0;
-   }
-   if(shapeFilename == "") return;
-   if(shapeFilename.isDir())
-   {
-      theShapeFilename = shapeFilename.dirCat(theDefaultName);
-   }
-   else if(shapeFilename.isFile())
-   {
-      theShapeFilename = shapeFilename;
-      theShapeFilename.setExtension("shp");
-   }
-   else
-   {
-      theShapeFilename = shapeFilename.path();
-      
-      theShapeFilename = theShapeFilename.dirCat(theDefaultName);
-      theShapeFilename.setExtension("shp");
-   }
-   thePrivateData = new ossimElevationShapeIdxPrivate();
-   
-   if(!thePrivateData->shpOpen(theShapeFilename, overWriteFlag))
-   {
-      thePrivateData = 0;
-      throw(("ossimElevationShapeIdx::setFilename: Unable to setup index file " + theShapeFilename).c_str());
-   }
-   double minBounds[4];
-   double maxBounds[4];
-   int nEntities = 0;
-   int shapeType = ossim_SHPT_NULL;
-   ossim_SHPGetInfo(thePrivateData->shpHandle(),
-              &nEntities,
-              &shapeType,
-              minBounds,
-              maxBounds);
-   if(nEntities < 0)
-   {
-      // set it up for the adds
-      //
-      theGlobalMinx = 180.0;
-      theGlobalMiny = 90.0;
-      theGlobalMaxx = -180.0;
-      theGlobalMaxy = -90.0;
-   }
-   else
-   {
-      theGlobalMinx = minBounds[0];
-      theGlobalMiny = minBounds[1];
-      theGlobalMaxx = maxBounds[0];
-      theGlobalMaxy = maxBounds[1];
-   }
-}
-
-void ossimElevationShapeIdx::add(const ossimFilename& filename,
-                                 ossim_float64 minx, // decimal degrees
-                                 ossim_float64 miny, // decimal degrees
-                                 ossim_float64 minz, // meters
-                                 ossim_float64 maxx, // decimal degrees
-                                 ossim_float64 maxy, // decimal degrees
-                                 ossim_float64 maxz )// meters
-{
-   if(!thePrivateData) return;
-   int iRecord = ossim_DBFGetRecordCount(thePrivateData->dbfHandle());
-   double* x = new double[8];
-   double* y = new double[8];
-   int nVertices = 4;
-   x[0] = minx;
-   x[1] = maxx;
-   x[2] = maxx;
-   x[3] = minx;
-   
-   y[0] = maxy;
-   y[1] = maxy;
-   y[2] = miny;
-   y[3] = miny;
-   
-
-   if(minx < theGlobalMinx)
-   {
-      theGlobalMinx = minx;
-   }
-   if(miny < theGlobalMiny)
-   {
-      theGlobalMiny = miny;
-   }
-   if(maxx > theGlobalMaxx)
-   {
-      theGlobalMaxx = maxx;
-   }
-   if(maxy > theGlobalMaxy)
-   {
-      theGlobalMaxy = maxy;
-   }
-   ossim_SHPObject* obj = ossim_SHPCreateSimpleObject(ossim_SHPT_POLYGON,
-                                          nVertices,
-                                          x,
-                                          y,
-                                          0);
-
-   ossim_SHPWriteObject( thePrivateData->shpHandle(),
-                   -1,
-                   obj );
-   ossim_DBFWriteStringAttribute(thePrivateData->dbfHandle(),
-                           iRecord,
-                           0,
-                           filename.c_str());
-   ossim_DBFWriteDoubleAttribute(thePrivateData->dbfHandle(),
-                           iRecord,
-                           0,
-                           (double)minz);
-   ossim_DBFWriteDoubleAttribute(thePrivateData->dbfHandle(),
-                           iRecord,
-                           0,
-                           (double)maxz);
-}
-
-void ossimElevationShapeIdx::buildQuadTree(int maxDepth)
-{
-   if(!thePrivateData) return;
-   
-   ossimFilename qTree = theShapeFilename;
-
-   qTree.setExtension("qtree");
-
-   if(thePrivateData->shpHandle())
-   {
-      double minBounds[4] = {0.0,0.0,0.0,0.0};
-      double maxBounds[4] = {0.0,0.0,0.0,0.0};
-
-      minBounds[0] = theGlobalMinx;
-      minBounds[1] = theGlobalMiny;
-      maxBounds[0] = theGlobalMaxx;
-      maxBounds[1] = theGlobalMaxy;
-      
-      ossim_SHPTree* tree = ossim_SHPCreateTree(thePrivateData->shpHandle(),
-                                    2,
-                                    maxDepth,
-                                    minBounds,
-                                    maxBounds);
-      if(tree)
-      {
-         ossim_SHPWriteTree(tree,
-                      qTree.c_str());
-         
-         ossim_SHPDestroyTree(tree);
-      }
-   }
-}
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevFactory.cpp b/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevFactory.cpp
index 216080562478ef1d7e93872b00b858240bbcea68..e933a17fe2f24a14e459b05f438edc15bb77eed1 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevFactory.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevFactory.cpp
@@ -64,7 +64,7 @@ ossimElevSource* ossimGeneralRasterElevFactory::getNewElevSource(const ossimGpt&
    std::vector<ossimGeneralRasterElevHandler::GeneralRasterInfo>::const_iterator i = theGeneralRasterInfoList.begin();
    while (i != theGeneralRasterInfoList.end())
    {
-      if ((*i).theBounds.pointWithin(pt))
+      if ((*i).theWgs84GroundRect.pointWithin(pt))
       {
          return new ossimGeneralRasterElevHandler((*i));
          
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevHandler.cpp b/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevHandler.cpp
index 05bb0511e0d8aed51d88a5d69eecfb9ac429a5e7..a19bbdc01845e0ef9b83f0cc8c040773baa9a2d6 100644
--- a/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevHandler.cpp
+++ b/Utilities/otbossim/src/ossim/elevation/ossimGeneralRasterElevHandler.cpp
@@ -4,13 +4,22 @@
 #include <ossim/base/ossimDirectory.h>
 #include <ossim/base/ossimEndian.h>
 #include <ossim/base/ossimUnitTypeLut.h>
-#include <OpenThreads/ScopedLock>
+#include <ossim/imaging/ossimImageHandlerRegistry.h>
+#include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/imaging/ossimImageSource.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/projection/ossimMapProjection.h>
+#include <ossim/projection/ossimImageViewTransform.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimDpt.h>
+#include <ossim/base/ossimGpt.h>
 
 RTTI_DEF1(ossimGeneralRasterElevHandler, "ossimGeneralRasterElevHandler", ossimElevCellHandler);
 
 ossimGeneralRasterElevHandler::ossimGeneralRasterElevHandler(const ossimFilename& file)
    :ossimElevCellHandler(file.c_str())
 {
+
    if(file != "")
    {
       if(!setFilename(file))
@@ -29,6 +38,7 @@ ossimGeneralRasterElevHandler::ossimGeneralRasterElevHandler(const ossimGeneralR
 
 ossimGeneralRasterElevHandler::ossimGeneralRasterElevHandler(const ossimGeneralRasterElevHandler::GeneralRasterInfo& generalRasterInfo)
 {
+
    close();
    theGeneralRasterInfo = generalRasterInfo;
    if(!open())
@@ -55,7 +65,6 @@ ossimGeneralRasterElevHandler::~ossimGeneralRasterElevHandler()
 
 double ossimGeneralRasterElevHandler::getHeightAboveMSL(const ossimGpt& gpt)
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if(!theInputStream.valid())
    {
       return ossim::nan();
@@ -132,7 +141,7 @@ double ossimGeneralRasterElevHandler::getHeightAboveMSL(const ossimGpt& gpt)
 
 ossimIpt ossimGeneralRasterElevHandler::getSizeOfElevCell() const
 {
-   return ossimIpt(theGeneralRasterInfo.theNumberOfSamples, theGeneralRasterInfo.theNumberOfLines);
+   return ossimIpt(theGeneralRasterInfo.theWidth, theGeneralRasterInfo.theHeight);
 }
    
 double ossimGeneralRasterElevHandler::getPostValue(const ossimIpt& gridPt) const
@@ -164,7 +173,6 @@ void ossimGeneralRasterElevHandler::close()
 
 bool ossimGeneralRasterElevHandler::setFilename(const ossimFilename& file)
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if(file.trim() == "")
    {
       return false;
@@ -172,11 +180,8 @@ bool ossimGeneralRasterElevHandler::setFilename(const ossimFilename& file)
    ossimFilename hdrFile  = file;
    ossimFilename geomFile = file;
    theGeneralRasterInfo.theFilename = file;
-   theGeneralRasterInfo.thePostSpacing.makeNan();
-   theGeneralRasterInfo.theUlGpt.makeNan();
-   theGeneralRasterInfo.theLrGpt.makeNan();
-   theGeneralRasterInfo.theNumberOfSamples = 0;
-   theGeneralRasterInfo.theNumberOfLines = 0;
+   theGeneralRasterInfo.theWidth = 0;
+   theGeneralRasterInfo.theHeight = 0;
    theNullHeightValue = ossim::nan();
    hdrFile = hdrFile.setExtension("omd");
    geomFile = geomFile.setExtension("geom");
@@ -210,101 +215,42 @@ bool ossimGeneralRasterElevHandler::setFilename(const ossimFilename& file)
    kwl.clear();
    if(kwl.addFile(geomFile))
    {
-      theGeneralRasterInfo.theDatum = 0;
-      const char* datumCode = kwl.find(ossimKeywordNames::DATUM_KW);
-      const char* dlat      = kwl.find(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT);
-      const char* dlon      = kwl.find(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON);
-      const char* tieLat    = kwl.find(ossimKeywordNames::TIE_POINT_LAT_KW);
-      const char* tieLon    = kwl.find(ossimKeywordNames::TIE_POINT_LON_KW);
-
-      if(datumCode)
-      {
-         theGeneralRasterInfo.theDatum = ossimDatumFactory::instance()->create(datumCode);
-      }
-      if(!theGeneralRasterInfo.theDatum)
-      {
-         theGeneralRasterInfo.theDatum = ossimDatumFactory::instance()->wgs84();
-      }
-      if(!dlat||!dlon)
-      {
-         const char* scale     = kwl.find(ossimKeywordNames::PIXEL_SCALE_XY_KW);
-         const char* scaleUnit = kwl.find(ossimKeywordNames::PIXEL_SCALE_UNITS_KW);
-         if(scale&&scaleUnit)
-         {
-            if(ossimString(scaleUnit).trim() == ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES))
-            {
-               theGeneralRasterInfo.thePostSpacing.toPoint(scale);
-            }
-            else
-            {
-               ossimNotify(ossimNotifyLevel_WARN) << "ossimGeneralRasterElevHandler::initializeInfo WARNING: Decimal degrees per pixel for lat and lon are not specified" << std::endl;
-               return false;
-            }
-         }
-         else
-         {
-            ossimNotify(ossimNotifyLevel_WARN) << "ossimGeneralRasterElevHandler::initializeInfo WARNING: Decimal degrees per pixel for lat and lon are not specified" << std::endl;
-            return false;
-         }
-
-      }
-      else
-      {
-         theGeneralRasterInfo.thePostSpacing.x   = ossimString(dlon).toDouble();
-         theGeneralRasterInfo.thePostSpacing.y   = ossimString(dlat).toDouble();
-      }
-      if(!tieLat||!tieLon)
-      {
-         const char* tie_point_xy = kwl.find(ossimKeywordNames::TIE_POINT_XY_KW);
-         const char* tie_point_units = kwl.find(ossimKeywordNames::TIE_POINT_UNITS_KW);
-         if(tie_point_xy&&(ossimString(tie_point_units).downcase() == "degrees"))
-         {
-            ossimDpt tie;
-            tie.toPoint(tie_point_xy);
-           
-            theGeneralRasterInfo.theUlGpt = ossimGpt(tie.lat+(theGeneralRasterInfo.thePostSpacing.y*.5),
-                                                     tie.lon-(theGeneralRasterInfo.thePostSpacing.x*.5),
-                                                     0.0,
-                                                     theGeneralRasterInfo.theDatum);
+      theGeneralRasterInfo.theNullHeightValue = generalInfo.getNullPixelValue(0);
+      theGeneralRasterInfo.theImageRect       = generalInfo.imageRect();
+      theGeneralRasterInfo.theUl              = theGeneralRasterInfo.theImageRect.ul();
+      theGeneralRasterInfo.theLr              = theGeneralRasterInfo.theImageRect.lr();
+      theGeneralRasterInfo.theWidth           = theGeneralRasterInfo.theImageRect.width();
+      theGeneralRasterInfo.theHeight          = theGeneralRasterInfo.theImageRect.height();
+      theGeneralRasterInfo.theImageRect       = generalInfo.imageRect();
+      theGeneralRasterInfo.theByteOrder       = generalInfo.getImageDataByteOrder();
+      theGeneralRasterInfo.theScalarType      = generalInfo.getScalarType();
+      theGeneralRasterInfo.theBytesPerRawLine = generalInfo.bytesPerRawLine();
 
-         }
-         else
-         {
-            return false;
-         }
-      }
-      else
-      {
-         theGeneralRasterInfo.theUlGpt = ossimGpt(ossimString(tieLat).toDouble(),
-                                                  ossimString(tieLon).toDouble(),
-                                                  0.0,
-                                                  theGeneralRasterInfo.theDatum);
-      }
-      theGeneralRasterInfo.theLrGpt = theGeneralRasterInfo.theUlGpt;
-      theGeneralRasterInfo.theNumberOfSamples = generalInfo.rawSamples();
-      theGeneralRasterInfo.theNumberOfLines   = generalInfo.rawLines();
-      if(theGeneralRasterInfo.theNumberOfLines && theGeneralRasterInfo.theNumberOfSamples)
+	  //add  by simbla
+      theGeneralRasterInfo.theProjection = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+      
+      if(!theGeneralRasterInfo.theProjection.valid())
       {
-         theGeneralRasterInfo.theLrGpt.latd(theGeneralRasterInfo.theUlGpt.latd() - ((theGeneralRasterInfo.theNumberOfLines)*
-                                                                                    theGeneralRasterInfo.thePostSpacing.y));
-         theGeneralRasterInfo.theLrGpt.lond(theGeneralRasterInfo.theUlGpt.lond() + ((theGeneralRasterInfo.theNumberOfSamples)*
-                                                                                    theGeneralRasterInfo.thePostSpacing.x));
+         return false;
       }
-      theGeneralRasterInfo.theNullHeightValue = generalInfo.getNullPixelValue(0);
-      theGeneralRasterInfo.theBounds = ossimDrect(theGeneralRasterInfo.theUlGpt,
-                                                  theGeneralRasterInfo.theUlGpt,
-                                                  theGeneralRasterInfo.theLrGpt,
-                                                  theGeneralRasterInfo.theLrGpt,
-                                                  OSSIM_RIGHT_HANDED);
-      theGeneralRasterInfo.theByteOrder = generalInfo.getImageDataByteOrder();
-      theGeneralRasterInfo.theScalarType = generalInfo.getScalarType();
-      theGeneralRasterInfo.theBytesPerRawLine = generalInfo.bytesPerRawLine();
-      theMeanSpacing = (theGeneralRasterInfo.thePostSpacing.lat +
-                        theGeneralRasterInfo.thePostSpacing.lon)*ossimGpt().metersPerDegree().x / 2.0;
-      theGroundRect = ossimGrect(theGeneralRasterInfo.theBounds.ul().lat,
-                                 theGeneralRasterInfo.theBounds.ul().lon,
-                                 theGeneralRasterInfo.theBounds.lr().lat,
-                                 theGeneralRasterInfo.theBounds.lr().lon);
+      ossimGpt defaultDatum;
+      ossimGpt ulGpt;
+      ossimGpt urGpt;
+      ossimGpt lrGpt;
+      ossimGpt llGpt;
+      theGeneralRasterInfo.theDatum = defaultDatum.datum();
+      theGeneralRasterInfo.theProjection->lineSampleToWorld(theGeneralRasterInfo.theImageRect.ul(), ulGpt);
+      theGeneralRasterInfo.theProjection->lineSampleToWorld(theGeneralRasterInfo.theImageRect.ur(), urGpt);
+      theGeneralRasterInfo.theProjection->lineSampleToWorld(theGeneralRasterInfo.theImageRect.lr(), lrGpt);
+      theGeneralRasterInfo.theProjection->lineSampleToWorld(theGeneralRasterInfo.theImageRect.ll(), llGpt);
+      
+      ulGpt.changeDatum(theGeneralRasterInfo.theDatum);
+      urGpt.changeDatum(theGeneralRasterInfo.theDatum);
+      lrGpt.changeDatum(theGeneralRasterInfo.theDatum);
+      llGpt.changeDatum(theGeneralRasterInfo.theDatum);
+      theMeanSpacing = theGeneralRasterInfo.theProjection->getMetersPerPixel().y;
+      theGroundRect = ossimGrect(ulGpt, urGpt, lrGpt, llGpt);
+      theGeneralRasterInfo.theWgs84GroundRect = ossimDrect(ulGpt, urGpt, lrGpt, llGpt, OSSIM_RIGHT_HANDED);
       theNullHeightValue = theGeneralRasterInfo.theNullHeightValue;
    }
    else
@@ -313,7 +259,6 @@ bool ossimGeneralRasterElevHandler::setFilename(const ossimFilename& file)
    }
    
    return true;
-   
 }
 
 #if 0
@@ -411,16 +356,26 @@ double ossimGeneralRasterElevHandler::getHeightAboveMSLTemplate(
    ossimEndian endian;
    
    ossimGpt shiftedPoint = gpt;
-   shiftedPoint.changeDatum(info.theUlGpt.datum());
-   if(!info.theBounds.pointWithin(shiftedPoint))
+   shiftedPoint.changeDatum(info.theDatum);
+   if(!info.theWgs84GroundRect.pointWithin(shiftedPoint))
    {
       return ossim::nan();
    }
    
-   double xi = (shiftedPoint.lond() - info.theUlGpt.lond())/info.thePostSpacing.x;
-   double yi = (info.theUlGpt.latd() -
-                shiftedPoint.latd())/info.thePostSpacing.y;
-
+   ossimDpt pt;
+   info.theProjection->worldToLineSample(shiftedPoint,pt);
+   double xi = pt.x;
+   double yi = pt.y;
+   
+   xi -= info.theUl.x;
+   yi -= info.theUl.y;
+   
+  //modifed by simbla  2008 7.17
+   //double xi = (shiftedPoint.lond() - info.theUlGpt.lond())/info.thePostSpacing.x;
+   //double yi = (info.theUlGpt.latd() -
+   //             shiftedPoint.latd())/info.thePostSpacing.y;
+   
+   
    ossim_sint64 x0 = static_cast<ossim_sint64>(xi);
    ossim_sint64 y0 = static_cast<ossim_sint64>(yi);
 
@@ -434,18 +389,19 @@ double ossimGeneralRasterElevHandler::getHeightAboveMSLTemplate(
    double w10 = xt1*yt0;
    double w11 = xt0*yt0;
    
-   if ( xi < 0.0 || yi < 0.0 ||
-        x0 > (info.theNumberOfSamples  - 1.0) ||
-        y0 > (info.theNumberOfLines    - 1.0) )
+   
+   if ( xi < 0 || yi < 0 ||
+        x0 > (info.theWidth  - 1.0) ||
+        y0 > (info.theHeight  - 1.0) )
    {
       return ossim::nan();
    }
 
-   if(x0 == (info.theNumberOfSamples  - 1.0))
+   if(x0 == (info.theWidth  - 1.0))
    {
       --x0;
    }
-   if(y0 == (info.theNumberOfLines  - 1.0))
+   if(y0 == (info.theHeight  - 1.0))
    {
       --y0;
    }
@@ -552,14 +508,14 @@ void ossimGeneralRasterElevHandler::addInfo(const ossimGeneralRasterElevHandler:
 #endif
 ossimDrect ossimGeneralRasterElevHandler::getBoundingRect()const
 {
-   return theGeneralRasterInfo.theBounds;
+   return theGeneralRasterInfo.theWgs84GroundRect;
 }
 
 bool ossimGeneralRasterElevHandler::pointHasCoverage(const ossimGpt& gpt) const
 {
    ossimDpt pt = gpt;
 
-   return theGeneralRasterInfo.theBounds.pointWithin(pt);
+   return theGeneralRasterInfo.theWgs84GroundRect.pointWithin(pt);
 //    BoundingRectListType::const_iterator i = theBoundingRectInfoList.begin();
 //    while (i != theBoundingRectInfoList.end())
 //    {
diff --git a/Utilities/otbossim/src/ossim/elevation/ossimSrtmFactory.cpp b/Utilities/otbossim/src/ossim/elevation/ossimSrtmFactory.cpp
index 62506f0532203642a21b217ef48eb9250e39c692..673fb23c200b916ef4c35a1fb9b6b183a1a5b274 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 12982 2008-06-04 01:12:46Z dburken $
+// $Id: ossimSrtmFactory.cpp 13282 2008-07-25 15:06:00Z dburken $
 
 #include <cstdlib> /* abs() */
 #include <iostream>
@@ -26,7 +26,6 @@
 #include <ossim/base/ossimDirectory.h>
 #include <ossim/support_data/ossimSrtmFilename.h>
 #include <ossim/support_data/ossimSrtmSupportData.h>
-#include <ossim/elevation/ossimElevationShapeIdx.h>
 
 static ossimTrace traceDebug ("ossimSrtmFactory:debug");
 
@@ -168,61 +167,3 @@ ossimElevSource* ossimSrtmFactory::getNewElevSource(const ossimGpt& gpt) const
    }
    return srtmPtr;
 }
-
-void ossimSrtmFactory::createIndex()
-{
-   ossimDirectory dir;
-
-   if(dir.open(theDirectory))
-   {
-      ossimFilename f;
-      if(dir.getFirst(f, ossimDirectory::OSSIM_DIR_FILES))
-      {
-         ossimRefPtr<ossimElevationShapeIdx> shpIdx = 0;
-         try
-         {
-            shpIdx = new ossimElevationShapeIdx(theDirectory, true);
-         }
-         catch(...)
-         {
-            shpIdx = 0;
-            return;
-         }
-         
-         do
-         {
-            if(f.contains(".hgt"))
-            {
-               // check and remove the gz extension if present
-               //
-               ossimFilename file = f.file();
-               if(f.ext() == "gz")
-               {
-                  f = f.setExtension("");
-               }
-               ossimSrtmFilename srtmFile;
-               if(srtmFile.setFilename(f.file()))
-               {
-                  ossimSrtmSupportData srtmSupport;
-
-                  if(srtmSupport.setFilename(f, true))
-                  {
-                     shpIdx->add(f,
-                                 srtmFile.ul().lond(),
-                                 srtmFile.ll().latd(),
-                                 srtmSupport.getMinPixelValue(),
-                                 srtmFile.ur().lond(),
-                                 srtmFile.ur().latd(),
-                                 srtmSupport.getMaxPixelValue());
-                  }
-               }
-            }
-         }while(dir.getNext(f));
-         shpIdx->buildQuadTree();
-      }
-   }
-   else
-   {
-      ossimNotify(ossimNotifyLevel_WARN) << "ossimSrtmFactory::createIndex(): Directory can't be opened for indexing." << std::endl;
-   }
-}
diff --git a/Utilities/otbossim/src/ossim/font/ossimFontFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/font/ossimFontFactoryRegistry.cpp
index 6fee44b9702af6e69e282823a4ffd8659a82759e..7a66ef922993ea6da550eb875dcc8700f5414b65 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 9099 2006-06-13 21:21:10Z dburken $
+// $Id: ossimFontFactoryRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
 #include <algorithm>
 #include <ossim/font/ossimFontFactoryRegistry.h>
 #include <ossim/font/ossimGdBitmapFont.h>
@@ -17,25 +17,23 @@
 
 #include <ossim/font/ossimGdSansBold.inc>
 
-ossimFontFactoryRegistry* ossimFontFactoryRegistry::theInstance = 0;
+//ossimFontFactoryRegistry* ossimFontFactoryRegistry::theInstance = 0;
 
 ossimFontFactoryRegistry::ossimFontFactoryRegistry()
    :theDefaultFont(NULL)
 {
-   theInstance = this;
+  // theInstance = this;
+#if OSSIM_HAS_FREETYPE
+   registerFactory(ossimFreeTypeFontFactory::instance());
+#endif
 }
 
 ossimFontFactoryRegistry* ossimFontFactoryRegistry::instance()
 {
-   if(!theInstance)
-   {
-      theInstance = new ossimFontFactoryRegistry;
-#if OSSIM_HAS_FREETYPE
-      theInstance->registerFactory(ossimFreeTypeFontFactory::instance());
-#endif
-   }
+   static ossimFontFactoryRegistry sharedInstance;
+      //theInstance = new ossimFontFactoryRegistry;
 
-   return theInstance;
+   return &sharedInstance;
 }
 
 bool ossimFontFactoryRegistry::registerFactory(ossimFontFactoryBase* factory)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAdrgHeader.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAdrgHeader.cpp
index d2cc9c1fe9a65a538f82cb436262c8b4c988d5b4..e9156867144dc975783e29e325c045e0695f6155 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAdrgHeader.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAdrgHeader.cpp
@@ -7,7 +7,7 @@
 //              support data for a ADRG image file(s).
 //
 //********************************************************************
-// $Id: ossimAdrgHeader.cpp 12956 2008-06-02 01:38:50Z dburken $
+// $Id: ossimAdrgHeader.cpp 13766 2008-10-22 19:31:32Z gpotts $
 
 #include <cstring>
 #include <iostream>
@@ -68,7 +68,10 @@ ossimAdrgHeader::ossimAdrgHeader(const ossimFilename& img_file)
 ossimAdrgHeader::~ossimAdrgHeader()
 {
    if(theTim)
+   {
       delete [] theTim;
+      theTim = 0;
+   }
 }
 
 //**************************************************************************
@@ -254,6 +257,11 @@ void ossimAdrgHeader::parse()
 
    theValidImageRect = ossimIrect(0, 0, theSamples - 1, theLines - 1);
 
+   if(theTim)
+   {
+      delete [] theTim;
+      theTim = 0;
+   }
    // Initialize the TIM (tile index map).
    theTim = new ossim_uint32[theLinesInTiles * theSamplesInTiles];
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationEllipseObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationEllipseObject.cpp
index bc768c7e9295e11c7d0340f73ae42350f19fd552..1ab9a252f1ca37fb1999c9412f68297f3be9bd5c 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationEllipseObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationEllipseObject.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationEllipseObject.cpp 11955 2007-10-31 16:10:22Z gpotts $
+// $Id: ossimAnnotationEllipseObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
 #include <ossim/imaging/ossimAnnotationEllipseObject.h>
 #include <ossim/imaging/ossimRgbImage.h>
 #include <ossim/base/ossimCommon.h>
@@ -36,7 +36,7 @@ ossimAnnotationEllipseObject::ossimAnnotationEllipseObject(
 
 ossimAnnotationEllipseObject::ossimAnnotationEllipseObject(
    const ossimAnnotationEllipseObject& rhs)
-   :
+   :ossimAnnotationObject(rhs),
    theCenter(rhs.theCenter),
    theWidthHeight(rhs.theWidthHeight),
    theAzimuthInDegrees(rhs.theAzimuthInDegrees),
@@ -61,7 +61,7 @@ void ossimAnnotationEllipseObject::applyScale(double x, double y)
    theCenter.y      *= y;
    theWidthHeight.x *= x;
    theWidthHeight.y *= y;
-   theBoundingRect  *= ossimDpt(x,y);
+   computeBoundingRect();
 }
 
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationFontObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationFontObject.cpp
index 8c43d9e84facb29a490d27373bb653787adedf3e..d1148c0fa73e1890a78f05a4f684bf9f012fd0b5 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 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimAnnotationFontObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
 
 #include <ossim/imaging/ossimAnnotationFontObject.h>
 #include <ossim/font/ossimFontFactoryRegistry.h>
@@ -17,7 +17,7 @@ ossimAnnotationFontObject::ossimAnnotationFontObject()
    :ossimAnnotationObject(),
     theFont(ossimFontFactoryRegistry::instance()->getDefaultFont()),
     theOwnsFontFlag(false),
-    theCenterPosition(0,0),
+    thePosition(0,0),
     theString(""),
     theRotation(0.0),
     theHorizontalScale(0.0),
@@ -50,17 +50,21 @@ ossimAnnotationFontObject::ossimAnnotationFontObject(const ossimIpt& upperLeft,
     theVerticalShear(shear.y)
 {
    setFontInfo();
+   thePosition = upperLeft;
+   computeBoundingRect();
+#if 0
    if (theFont)
    {
       theFont->getBoundingBox(theBoundingRect);
    }
    theBoundingRect += upperLeft;
-   theCenterPosition = theBoundingRect.midPoint();
+   thePosition = theBoundingRect.ul();
+#endif
 }
 
 ossimAnnotationFontObject::ossimAnnotationFontObject(const ossimAnnotationFontObject& rhs)
    :ossimAnnotationObject(rhs),
-    theCenterPosition(rhs.theCenterPosition),
+    thePosition(rhs.thePosition),
     theString(rhs.theString),
     thePixelSize(rhs.thePixelSize),
     theRotation(rhs.theRotation),
@@ -70,9 +74,11 @@ ossimAnnotationFontObject::ossimAnnotationFontObject(const ossimAnnotationFontOb
     theVerticalShear(rhs.theVerticalShear),
     theBoundingRect(rhs.theBoundingRect)
 {
+   theOwnsFontFlag = false;
    if(rhs.theOwnsFontFlag&&theFont)
    {
       theFont = (ossimFont*)rhs.theFont->dup();
+      theOwnsFontFlag = true;
    }
    else
    {
@@ -143,7 +149,6 @@ void ossimAnnotationFontObject::draw(ossimRgbImage& anImage)const
          }
          
          theFont->getBufferRect(fontBufferRect);
-
          ossimIrect clipRect = boundingRect.clipToRect(fontBufferRect);
          
          long clipHeight = clipRect.height();
@@ -207,7 +212,7 @@ std::ostream& ossimAnnotationFontObject::print(std::ostream& out)const
           << "Style:           " << theFont->getStyleName()  << endl;
    }
    out << "String:             " << theString << endl
-       << "Center Position:    " << theCenterPosition << endl
+       << "Upper Left Position:    " << thePosition << endl
        << "Rotation:           " << theRotation << endl
        << "Horizontal shear:   " << theHorizontalShear << endl
        << "Vertical shear:     " << theVerticalShear << endl
@@ -231,8 +236,8 @@ void ossimAnnotationFontObject::computeBoundingRect()
       theFont->getBoundingBox(textRect);
       ossim_int32 w = textRect.width();
       ossim_int32 h = textRect.height();
-      ossim_int32 ulx = theCenterPosition.x - w/2;
-      ossim_int32 uly = theCenterPosition.y - h/2;
+      ossim_int32 ulx = thePosition.x;
+      ossim_int32 uly = thePosition.y;
       theBoundingRect = ossimIrect(ulx,
                                    uly,
                                    ulx + w - 1,
@@ -263,10 +268,20 @@ void ossimAnnotationFontObject::setFont(ossimFont* font,
    }
 }
 
-void ossimAnnotationFontObject::setPositionCenter(const ossimIpt& position)
+void ossimAnnotationFontObject::setCenterPosition(const ossimIpt& position)
 {
-   theCenterPosition = position;
-   computeBoundingRect();
+   ossimDpt pt = theBoundingRect.midPoint();
+   ossimIpt delta = position-pt;
+   theBoundingRect += delta;
+   thePosition = theBoundingRect.ul();
+}
+
+void ossimAnnotationFontObject::setUpperLeftPosition(const ossimIpt& position)
+{
+   ossimDpt pt = theBoundingRect.ul();
+   ossimIpt delta = position-pt;
+   theBoundingRect += delta;
+   thePosition = theBoundingRect.ul();
 }
 
 void ossimAnnotationFontObject::setFontInfo()const
@@ -315,8 +330,8 @@ void ossimAnnotationFontObject::setPointSize(const ossimIpt& size)
    {
       theFont->getBoundingBox(theBoundingRect);
    }
-   theBoundingRect += (theCenterPosition - theBoundingRect.midPoint());
-   theCenterPosition = theBoundingRect.midPoint();
+   theBoundingRect += (thePosition - theBoundingRect.ul());
+   thePosition = theBoundingRect.ul();         
 }
 
 void ossimAnnotationFontObject::setRotation(double rotation)
@@ -327,8 +342,8 @@ void ossimAnnotationFontObject::setRotation(double rotation)
    {
       theFont->getBoundingBox(theBoundingRect);
    }
-   theBoundingRect += (theCenterPosition - theBoundingRect.midPoint());
-   theCenterPosition = theBoundingRect.midPoint();         
+   theBoundingRect += (thePosition - theBoundingRect.ul());
+   thePosition = theBoundingRect.ul();         
 }
 
 void ossimAnnotationFontObject::setScale(const ossimDpt& scale)
@@ -340,8 +355,8 @@ void ossimAnnotationFontObject::setScale(const ossimDpt& scale)
    {
       theFont->getBoundingBox(theBoundingRect);
    }
-   theBoundingRect += (theCenterPosition - theBoundingRect.midPoint());
-   theCenterPosition = theBoundingRect.midPoint();         
+   theBoundingRect += (thePosition - theBoundingRect.ul());
+   thePosition = theBoundingRect.ul();         
 }
 
 void ossimAnnotationFontObject::setShear(const ossimDpt& shear)
@@ -353,8 +368,8 @@ void ossimAnnotationFontObject::setShear(const ossimDpt& shear)
    {
       theFont->getBoundingBox(theBoundingRect);
    }
-   theBoundingRect += (theCenterPosition - theBoundingRect.midPoint());
-   theCenterPosition = theBoundingRect.midPoint();                  
+   theBoundingRect += (thePosition - theBoundingRect.ul());
+   thePosition = theBoundingRect.ul();         
 }
 
 void ossimAnnotationFontObject::setGeometryInformation(const ossimFontInformation& info)
@@ -371,24 +386,18 @@ void ossimAnnotationFontObject::setGeometryInformation(const ossimFontInformatio
    {
       theFont->getBoundingBox(theBoundingRect);
    }
-   theBoundingRect += (theCenterPosition - theBoundingRect.midPoint());
-   theCenterPosition = theBoundingRect.midPoint();
+   theBoundingRect += (thePosition - theBoundingRect.ul());
+   thePosition = theBoundingRect.ul();         
 }
 
 void ossimAnnotationFontObject::applyScale(double x, double y)
 {
-   theCenterPosition.x = ossim::round<int>(theCenterPosition.x *x);
-   theCenterPosition.y = ossim::round<int>(theCenterPosition.x *y);
-   theHorizontalScale *= x;
-   theVerticalScale   *= y;
+   thePosition.x = ossim::round<int>(thePosition.x *x);
+   thePosition.y = ossim::round<int>(thePosition.y *y);
    
    setFontInfo();
-   if (theFont)
-   {
-      theFont->getBoundingBox(theBoundingRect);
-   }
-   theBoundingRect += (theCenterPosition - theBoundingRect.midPoint());
-   theCenterPosition = theBoundingRect.midPoint();
+   computeBoundingRect();
+
 }
 
 ossimObject* ossimAnnotationFontObject::dup()const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationLineObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationLineObject.cpp
index 843577a188261682062c111ff221f633bae01125..466fabc6dc774778b488f14de2a354db1e6e99ef 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationLineObject.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationLineObject.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimAnnotationLineObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
 
 #include <ossim/imaging/ossimAnnotationLineObject.h>
 #include <ossim/imaging/ossimRgbImage.h>
@@ -72,6 +72,7 @@ void ossimAnnotationLineObject::applyScale(double x, double y)
    theStart.y = ossim::round<int>(theStart.y*y);
    theEnd.x   = ossim::round<int>(theEnd.x*x);
    theEnd.y   = ossim::round<int>(theEnd.y*y);
+   computeBoundingRect();
 }
 
 ossimAnnotationObject* ossimAnnotationLineObject::getNewClippedObject(const ossimDrect& rect)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationMultiPolyLineObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationMultiPolyLineObject.cpp
index e835d3554f84fea95359250511c77bb6a703dae6..fcbafe3e953f3e2ff9c06393a67b48cba0a0332f 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationMultiPolyLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationMultiPolyLineObject.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationMultiPolyLineObject.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimAnnotationMultiPolyLineObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
 #include <ossim/imaging/ossimAnnotationMultiPolyLineObject.h>
 #include <ossim/imaging/ossimAnnotationMultiLineObject.h>
 #include <ossim/imaging/ossimRgbImage.h>
@@ -43,8 +43,8 @@ void ossimAnnotationMultiPolyLineObject::applyScale(double x,
    {
       theMultiPolyLine[i] *= ossimDpt(x, y);
    }
-   
-   theBoundingRect *= ossimDpt(x,y);
+   computeBoundingRect();
+   // theBoundingRect *= ossimDpt(x,y);
 }
 
 bool ossimAnnotationMultiPolyLineObject::intersects(const ossimDrect& rect)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationPolyObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationPolyObject.cpp
index 0d57ddf043db2896bb2054729f0fb2a2dcb62bbe..3573f1fe871b50939bf405bd159bee805b13c673 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAnnotationPolyObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAnnotationPolyObject.cpp
@@ -6,7 +6,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimAnnotationPolyObject.cpp 10867 2007-05-09 19:58:25Z gpotts $
+// $Id: ossimAnnotationPolyObject.cpp 13964 2009-01-14 16:30:07Z gpotts $
 #include <ossim/imaging/ossimAnnotationPolyObject.h>
 #include <ossim/imaging/ossimAnnotationMultiPolyObject.h>
 #include <ossim/imaging/ossimAnnotationMultiLineObject.h>
@@ -64,7 +64,7 @@ ossimAnnotationPolyObject::~ossimAnnotationPolyObject()
 void ossimAnnotationPolyObject::applyScale(double x, double y)
 {
    thePolygon      *= ossimDpt(x, y);
-   theBoundingRect *= ossimDpt(x,y);
+   computeBoundingRect();
 }
 
 bool ossimAnnotationPolyObject::intersects(const ossimDrect& rect)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp
index c600405c532e75f153557388387eeb5abbd89ca0..1b2f51fc8ff568f16d585e69525d58f0f7a75854 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAppFixedTileCache.cpp
@@ -7,7 +7,7 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimAppFixedTileCache.cpp 12653 2008-04-10 15:32:46Z gpotts $
+// $Id: ossimAppFixedTileCache.cpp 13676 2008-10-03 17:35:02Z gpotts $
 #include <algorithm>
 #include <sstream>
 #include <ossim/imaging/ossimAppFixedTileCache.h>
@@ -60,11 +60,21 @@ ossimAppFixedTileCache::ossimAppFixedTileCache()
    const char* tileSize = ossimPreferences::instance()->findPreference("tile_size");
    if(tileSize)
    {
-      std::stringstream in(tileSize);
-      in >> theTileSize.x >> theTileSize.y;
-      if(theTileSize.x < 1) theTileSize.x = 64;
-      if(theTileSize.y < 1) theTileSize.y = 64;
-   }
+      ossimString tempString(tileSize);
+      std::vector<ossimString> splitString;
+      tempString = tempString.trim();
+      tempString.split(splitString, " ");
+      if(splitString.size() > 1)
+      {
+         theTileSize.x = splitString[0].toInt32();
+         theTileSize.y = splitString[1].toInt32();
+      }
+      else 
+      {
+         theTileSize = ossimIpt(64,64);
+      }
+         
+    }
    if(cacheSize)
    {
       setMaxCacheSize(cacheSize);
@@ -107,7 +117,7 @@ ossimAppFixedTileCache *ossimAppFixedTileCache::instance(ossim_uint32  maxSize)
 
 void ossimAppFixedTileCache::setMaxCacheSize(ossim_uint32 cacheSize)
 {
-OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    theMaxGlobalCacheSize = cacheSize;
    theMaxCacheSize = cacheSize;
    //   theMaxCacheSize      = (ossim_uint32)(theMaxGlobalCacheSize*.2);
@@ -223,11 +233,11 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::getTile(
    ossimAppFixedCacheId cacheId,
    const ossimIpt& origin)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = 0;
    ossimFixedTileCache* cache = getCache(cacheId);
    if(cache)
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
       result = cache->getTile(origin);
    }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp b/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp
index b61a7b4747b78dd362d6323e90670dc6ad30196a..e7325c6a5323295529d0b0005c6973ee35da68d7 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimAppTileCache.cpp
@@ -10,14 +10,15 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimAppTileCache.cpp 9251 2006-07-13 20:04:49Z gpotts $
+// $Id: ossimAppTileCache.cpp 13214 2008-07-23 17:43:51Z dburken $
 
 #include <ossim/imaging/ossimAppTileCache.h>
 #include <ossim/imaging/ossimTileCache.h>
 #include <ossim/base/ossimDataObject.h>
+#include <ossim/base/ossimNotify.h>
 #include <ossim/base/ossimPreferences.h>
 
-ossimAppTileCache* ossimAppTileCache::theInstance = NULL;
+ossimAppTileCache* ossimAppTileCache::theInstance = 0;
 
 // we will need to grab this from the preferences
 const ossim_uint32 ossimAppTileCache::DEFAULT_SIZE          = 80*1024*1024;
@@ -39,7 +40,8 @@ ossimAppTileCache *ossimAppTileCache::instance(ossim_uint32  maxSize)
          {
             maxSize = DEFAULT_SIZE;
          }
-         cout << "Setting SIZE----------------------- " << maxSize << std::endl;
+         ossimNotify(ossimNotifyLevel_NOTICE)
+            << "Setting SIZE----------------------- " << maxSize << std::endl;
       }
       theInstance = new ossimAppTileCache(maxSize);
    }
@@ -54,7 +56,7 @@ ossimAppTileCache::~ossimAppTileCache()
 
 ossimAppTileCache::ossimAppCacheId ossimAppTileCache::newTileCache(ossim_uint32 bucketSize)
 {
-   ossimTileCache *aCache = NULL;
+   ossimTileCache *aCache = 0;
    ossimAppCacheId result = 0;
 
    aCache = new ossimTileCache(bucketSize);
@@ -76,7 +78,7 @@ ossimDataObject *ossimAppTileCache::get(ossimAppCacheId id,
                                         const ossimDpt3d &origin,
                                         ossim_uint32 resLevel)
 {
-   ossimDataObject* result = NULL;
+   ossimDataObject* result = 0;
    if(id>0)
    {
       ossimTileCache *aCache = this->get(id);
@@ -98,7 +100,7 @@ ossimDataObject* ossimAppTileCache::removeTile(ossimAppCacheId id,
                                               const ossimDpt3d &origin,
                                               unsigned long resLevel)
 {
-   ossimDataObject *result = NULL;
+   ossimDataObject *result = 0;
    if(id>0)
    {
       ossimTileCache *aCache = this->get(id);
@@ -124,8 +126,8 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
                                           const ossimDataObject* data,
                                           ossim_uint32 resLevel)
 {
-   static char *MODULE = "ossimAppTileCache::insert";
-   ossimDataObject *result = NULL;
+   static const char MODULE[] = "ossimAppTileCache::insert";
+   ossimDataObject *result = 0;
 
    // find the cache and if it's not there then return NULL
    ossimTileCache *aCache = this->get(appId);
@@ -134,12 +136,12 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
       return result;
    }
    
-   ossimDataObject *tileToInsert = NULL;
+   ossimDataObject *tileToInsert = 0;
    long dataSize = data->getDataSizeInBytes();
    
    if( (theCurrentCacheSize+dataSize) > theMaxCacheSize)
    {
-      ossimDataObject *tempTile     = NULL;
+      ossimDataObject *tempTile     = 0;
       do
       {
          tempTile = removeTile();
@@ -147,7 +149,7 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
          if(tempTile)
          {
             delete tempTile;
-            tempTile = NULL;
+            tempTile = 0;
          }
       }while((theCurrentCacheSize+dataSize) > theMaxCacheSize);
    }
@@ -161,10 +163,12 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
                               resLevel);
       if(!result)
       {
-         cout << MODULE << " ERROR: can't insert and should not happen"
-              << endl;
+         ossimNotify(ossimNotifyLevel_WARN)
+            << MODULE << " ERROR: can't insert and should not happen"
+            << endl;
 
          delete tileToInsert;
+         tileToInsert = 0;
       }
       else
       {
@@ -181,7 +185,7 @@ ossimDataObject* ossimAppTileCache::insert(ossimAppCacheId appId,
 
 ossimTileCache* ossimAppTileCache::get(ossimAppCacheId id)
 {
-   ossimTileCache *result=NULL;
+   ossimTileCache *result=0;
    
    AppIdIterator anIterator = theAppCache.find(id);
    
@@ -267,7 +271,7 @@ void ossimAppTileCache::deleteAppCacheFromQueue(ossimAppCacheId appId)
 
 ossimDataObject* ossimAppTileCache::removeTile()
 {
-   ossimDataObject *result = NULL;
+   ossimDataObject *result = 0;
    if(!theUsedQueue.empty())
    {
       ossimAppCacheTileInfo &info = *(theUsedQueue.begin());
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimBandMergeSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimBandMergeSource.cpp
index 58aff7784562eba6e4af5d4a5568bba74df03fe4..44172c3c445f1c2967a3da4df55e44e370544573 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 11411 2007-07-27 13:53:51Z dburken $
+// $Id: ossimBandMergeSource.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimBandMergeSource.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
@@ -84,7 +84,7 @@ ossimRefPtr<ossimImageData> ossimBandMergeSource::getTile(const ossimIrect& tile
    ossim_uint32 inputIdx = 0;
    for(inputIdx = 0; inputIdx < getNumberOfInputs(); ++inputIdx)
    {
-      ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                   getInput(inputIdx));
       ossimRefPtr<ossimImageData> currentTile = 0;
 
@@ -147,7 +147,7 @@ double ossimBandMergeSource::getNullPixelValue(ossim_uint32 band)const
    while((currentBandCount < maxBands)&&
 	 (idx < getNumberOfInputs()))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(idx));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(idx));
       if(temp)
       {
 	ossim_uint32 previousCount = currentBandCount;
@@ -175,7 +175,7 @@ double ossimBandMergeSource::getMinPixelValue(ossim_uint32 band)const
    while((currentBandCount < maxBands)&&
 	 (idx < getNumberOfInputs()))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(idx));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(idx));
       if(temp)
       {
 	ossim_uint32 previousCount = currentBandCount;
@@ -203,7 +203,7 @@ double ossimBandMergeSource::getMaxPixelValue(ossim_uint32 band)const
    while((currentBandCount < maxBands)&&
 	 (idx < getNumberOfInputs()))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(idx));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(idx));
       if(temp)
       {
 	ossim_uint32 previousCount = currentBandCount;
@@ -248,7 +248,7 @@ ossim_uint32 ossimBandMergeSource::computeNumberOfInputBands()const
    ossim_uint32 size   = getNumberOfInputs();
    for(ossim_uint32 index = 0; index < size; ++index)
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(index));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(index));
       if(temp)
       {
          if(temp->getNumberOfOutputBands() == 0)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimBandSelector.cpp b/Utilities/otbossim/src/ossim/imaging/ossimBandSelector.cpp
index 69c96eeda8fc289bafc05989c25ec5bf049bfcab..127ba0fc9771000e4e121f8e593381e2c62b2ba5 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimBandSelector.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimBandSelector.cpp
@@ -10,7 +10,7 @@
 // Contains class declaration for ossimBandSelector.
 // 
 //*******************************************************************
-//  $Id: ossimBandSelector.cpp 13022 2008-06-10 16:25:36Z dburken $
+//  $Id: ossimBandSelector.cpp 13493 2008-08-23 17:10:23Z dburken $
 
 #include <iostream>
 #include <algorithm>
@@ -28,7 +28,8 @@ ossimBandSelector::ossimBandSelector()
    :
       ossimImageSourceFilter(),
       theTile(0),
-      theWithinRangeFlag(ossimBandSelectorWithinRangeFlagState_NOT_SET)
+      theWithinRangeFlag(ossimBandSelectorWithinRangeFlagState_NOT_SET),
+      theOrderedCorrectlyFlag(false)
 
 {
 //   theEnableFlag = false; // Start off disabled.
@@ -58,7 +59,7 @@ ossimRefPtr<ossimImageData> ossimBandSelector::getTile(
       return t;  // This tile source bypassed, return the input tile source.
    }
 
-   if (isOrderedCorrectly())
+   if (theOrderedCorrectlyFlag)
    {
       return t; // Input band order same as output band order.
    }
@@ -117,6 +118,7 @@ void ossimBandSelector::setOutputBandList(
       theTile = 0;       // Force an allocate call next getTile.
 
       theWithinRangeFlag = ossimBandSelectorWithinRangeFlagState_NOT_SET;
+      theOrderedCorrectlyFlag = isOrderedCorrectly();
    }
 }
 
@@ -147,6 +149,8 @@ void ossimBandSelector::initialize()
 
       if ( theEnableFlag )
       {
+         theOrderedCorrectlyFlag = isOrderedCorrectly();
+
          if ( theTile.valid() )
          {
             //---
@@ -155,7 +159,7 @@ void ossimBandSelector::initialize()
             // - band change
             // - scalar change
             //---
-            if( isOrderedCorrectly() ||
+            if( theOrderedCorrectlyFlag ||
                 ( theTile->getNumberOfBands() != theOutputBandList.size() ) ||
                 ( theTile->getScalarType() !=
                   theInputConnection->getOutputScalarType() ) )
@@ -177,8 +181,8 @@ void ossimBandSelector::initialize()
 
 void ossimBandSelector::allocate()
 {
-   initialize(); // Update the connection.
-
+   //initialize(); // Update the connection.
+   //theOrderedCorrectlyFlag = isOrderedCorrectly();
    theTile = ossimImageDataFactory::instance()->create(this, this);
    theTile->initialize();
 }
@@ -317,20 +321,32 @@ bool ossimBandSelector::loadState(const ossimKeywordlist& kwl,
 
 bool ossimBandSelector::isOrderedCorrectly() const
 {
+   bool result = false;
+
    if(theInputConnection)
    {
       std::vector<ossim_uint32> inputList;
       theInputConnection->getOutputBandList(inputList);
-      
-      ossim_uint32 output_bands = (ossim_uint32)theOutputBandList.size();
 
-      if(inputList.size() != output_bands) return false;
-      
-      for (ossim_uint32 i=0; i<output_bands; ++i)
+      if ( inputList.size() == theOutputBandList.size() )
       {
-         if (inputList[i] != theOutputBandList[i]) return false;
+         const std::vector<ossim_uint32>::size_type SIZE =
+            theOutputBandList.size();
+      
+         std::vector<ossim_uint32>::size_type i = 0;
+         while (i < SIZE)
+         {
+            if ( inputList[i] != theOutputBandList[i] )
+            {
+               break;
+            }
+            ++i;
+         }
+         if (i == SIZE)
+         {
+            result = true;
+         }
       }
-      return true;
    }
    else
    {
@@ -339,7 +355,7 @@ bool ossimBandSelector::isOrderedCorrectly() const
          << "Method called prior to initialization!\n";
    }
 
-   return false;
+   return result;
 }
 
 bool ossimBandSelector::outputBandsWithinInputRange() const
@@ -402,17 +418,20 @@ void ossimBandSelector::setProperty(ossimRefPtr<ossimProperty> property)
 {
    if(!property) return;
 
-   if(property->getName() == "Selected bands")
+   if(property->getName() == "bandSelection")
    {
      ossimString str = property->valueToString();
      std::vector<ossimString> str_vec;
      std::vector<ossim_uint32> int_vec;
      
-     str.split( str_vec, "," );
+     str.split( str_vec, " " );
      
      for ( ossim_uint32 i = 0; i < str_vec.size(); ++i )
      {
-        int_vec.push_back( str_vec[i].toUInt32() );
+        if(!str_vec[i].empty())
+        {
+           int_vec.push_back( str_vec[i].toUInt32() );
+        }
      }
      setOutputBandList( int_vec );
    }
@@ -424,7 +443,7 @@ void ossimBandSelector::setProperty(ossimRefPtr<ossimProperty> property)
 
 ossimRefPtr<ossimProperty> ossimBandSelector::getProperty(const ossimString& name)const
 {
-   if(name == "Selected bands")
+   if(name == "bandSelection")
    {
       std::vector<ossim_uint32> bands;
 	  
@@ -439,9 +458,9 @@ ossimRefPtr<ossimProperty> ossimBandSelector::getProperty(const ossimString& nam
 	  
 	  ossimString str;
 	  
-	  str.join( bandNames, "," );
+	  str.join( bandNames, " " );
 	  
-      ossimStringProperty* stringProp = new ossimStringProperty("Selected bands", str);
+      ossimStringProperty* stringProp = new ossimStringProperty(name, str);
 									
       stringProp->clearChangeType();
       stringProp->setReadOnlyFlag(false);
@@ -456,6 +475,6 @@ ossimRefPtr<ossimProperty> ossimBandSelector::getProperty(const ossimString& nam
 void ossimBandSelector::getPropertyNames(std::vector<ossimString>& propertyNames)const
 {
    ossimImageSourceFilter::getPropertyNames(propertyNames);
-   propertyNames.push_back("Selected bands");
+   propertyNames.push_back("bandSelection");
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimBumpShadeTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimBumpShadeTileSource.cpp
index c348e62254f1929560528b9b39eef07300ec33c4..7e25504d5e80b0fd5c12023c7adad1ffe6b61e90 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimBumpShadeTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimBumpShadeTileSource.cpp
@@ -8,13 +8,14 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimBumpShadeTileSource.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimBumpShadeTileSource.cpp 13382 2008-08-04 18:53:26Z gpotts $
 
 #include <ossim/imaging/ossimBumpShadeTileSource.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimTilePatch.h>
 #include <ossim/imaging/ossimImageData.h>
+#include <ossim/base/ossimNumericProperty.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimKeyword.h>
@@ -49,37 +50,23 @@ ossimRefPtr<ossimImageData> ossimBumpShadeTileSource::getTile(
 
    if(!theTile.get())
    {
-      initialize();
+      allocate();
    }
-   
-   ossimImageSourceInterface* normalSource =
-      PTR_CAST(ossimImageSourceInterface, getInput(0));
-   ossimImageSourceInterface* colorSource =
-      PTR_CAST(ossimImageSourceInterface, getInput(1));
+   if(!theTile.valid())
+   {
+      return theTile;
+   }
+   ossimImageSource* normalSource =
+      PTR_CAST(ossimImageSource, getInput(0));
+   ossimImageSource* colorSource =
+      PTR_CAST(ossimImageSource, getInput(1));
    
    if(!theTile.get())
    {
       return ossimRefPtr<ossimImageData>();
    }
 
-   long w = tileRect.width();
-   long h = tileRect.height();
-   ossimIpt origin = tileRect.ul();
-   
-   theTile->setOrigin(origin);
-
-   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();
-      }
-   }
+   theTile->setImageRectangle(tileRect);
  
    ossimRefPtr<ossimImageData> inputTile = NULL;
 
@@ -282,7 +269,7 @@ void ossimBumpShadeTileSource::computeColor(ossim_uint8& r,
 
 ossimIrect ossimBumpShadeTileSource::getBoundingRect(ossim_uint32 resLevel)const
 {
-   ossimImageSourceInterface* source = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* source = PTR_CAST(ossimImageSource, getInput(0));
    if(source)
    {
       return source->getBoundingRect(resLevel);
@@ -296,7 +283,7 @@ ossimIrect ossimBumpShadeTileSource::getBoundingRect(ossim_uint32 resLevel)const
 void ossimBumpShadeTileSource::getDecimationFactor(ossim_uint32 resLevel,
                                                    ossimDpt& result) const
 {
-   ossimImageSourceInterface* source = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* source = PTR_CAST(ossimImageSource, getInput(0));
    if(source)
    {
       return source->getDecimationFactor(resLevel, result);
@@ -307,7 +294,7 @@ void ossimBumpShadeTileSource::getDecimationFactor(ossim_uint32 resLevel,
 
 void ossimBumpShadeTileSource::getDecimationFactors(vector<ossimDpt>& decimations) const
 {
-   ossimImageSourceInterface* source = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* source = PTR_CAST(ossimImageSource, getInput(0));
    
    if(source)
    {
@@ -317,7 +304,7 @@ void ossimBumpShadeTileSource::getDecimationFactors(vector<ossimDpt>& decimation
 
 ossim_uint32 ossimBumpShadeTileSource::getNumberOfDecimationLevels()const
 {
-   ossimImageSourceInterface* source = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* source = PTR_CAST(ossimImageSource, getInput(0));
    
    if(source)
    {
@@ -329,7 +316,7 @@ ossim_uint32 ossimBumpShadeTileSource::getNumberOfDecimationLevels()const
 
 ossim_uint32 ossimBumpShadeTileSource::getTileWidth()const
 {
-   ossimImageSourceInterface* source = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* source = PTR_CAST(ossimImageSource, getInput(0));
    if(source)
    {
       return source->getTileWidth();
@@ -340,7 +327,7 @@ ossim_uint32 ossimBumpShadeTileSource::getTileWidth()const
 
 ossim_uint32 ossimBumpShadeTileSource::getTileHeight()const
 {
-   ossimImageSourceInterface* source = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* source = PTR_CAST(ossimImageSource, getInput(0));
    if(source)
    {
       return source->getTileHeight();
@@ -352,13 +339,18 @@ ossim_uint32 ossimBumpShadeTileSource::getTileHeight()const
 void ossimBumpShadeTileSource::initialize()
 {
   ossimImageCombiner::initialize();
-  
-  theTile = ossimImageDataFactory::instance()->create(this, this);
-  theTile->initialize();
+   theTile = 0;
+   
   computeLightDirection();
   
 }
 
+void ossimBumpShadeTileSource::allocate()
+{
+   theTile = ossimImageDataFactory::instance()->create(this, this);
+   theTile->initialize();
+}
+
 void ossimBumpShadeTileSource::computeLightDirection()
 {
    NEWMAT::Matrix m = ossimMatrix3x3::createRotationMatrix(theLightSourceElevationAngle,
@@ -482,7 +474,7 @@ bool ossimBumpShadeTileSource::canConnectMyInputTo(ossim_int32 inputIndex,
 {
    return (object&&
            ( (inputIndex>=0) && inputIndex < 2)&&
-           PTR_CAST(ossimImageSourceInterface, object));
+           PTR_CAST(ossimImageSource, object));
    
 }
 
@@ -505,3 +497,46 @@ void ossimBumpShadeTileSource::refreshEvent(ossimRefreshEvent& event)
 {
    initialize();
 }
+
+void ossimBumpShadeTileSource::setProperty(ossimRefPtr<ossimProperty> property)
+{
+   ossimString name = property->getName();
+   if(name == "lightSourceElevationAngle")
+   {
+      theLightSourceElevationAngle = property->valueToString().toDouble();
+   }
+   else if(name == "lightSourceAzimuthAngle")
+   {
+      theLightSourceAzimuthAngle = property->valueToString().toDouble();
+   }
+   else
+   {
+      ossimImageCombiner::setProperty(property);
+   }
+}
+
+ossimRefPtr<ossimProperty> ossimBumpShadeTileSource::getProperty(const ossimString& name)const
+{
+   if(name == "lightSourceElevationAngle")
+   {
+      ossimProperty* prop = new ossimNumericProperty(name, theLightSourceElevationAngle, 0.0, 90.0);
+      prop->setCacheRefreshBit();
+      return prop;
+   }
+   else if(name == "lightSourceAzimuthAngle")
+   {
+      ossimProperty* prop = new ossimNumericProperty(name, theLightSourceAzimuthAngle, 0.0, 90.0);
+      prop->setCacheRefreshBit();
+      return prop;
+   }
+   
+   return ossimImageCombiner::getProperty(name);
+}
+
+void ossimBumpShadeTileSource::getPropertyNames(std::vector<ossimString>& propertyNames)const
+{
+   ossimImageCombiner::getPropertyNames(propertyNames);
+   propertyNames.push_back("lightSourceElevationAngle");
+   propertyNames.push_back("lightSourceAzimuthAngle");
+}
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimCacheTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimCacheTileSource.cpp
index 71b2cd6a82cd3650e292ef2e97ba9b91f1fec446..4742d714bfafac6845a34be1e45e0fad08f6c810 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimCacheTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimCacheTileSource.cpp
@@ -7,12 +7,13 @@
 // Description:  ossimCacheTileSource
 // 
 //*******************************************************************
-//  $Id: ossimCacheTileSource.cpp 12623 2008-04-07 14:10:08Z gpotts $
+//  $Id: ossimCacheTileSource.cpp 13822 2008-10-31 17:15:43Z dburken $
 
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimNotify.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimStringProperty.h>
+#include <ossim/base/ossimBooleanProperty.h>
 #include <ossim/imaging/ossimCacheTileSource.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
@@ -39,18 +40,6 @@ ossimCacheTileSource::ossimCacheTileSource()
    theFixedTileSize = ossimAppFixedTileCache::instance()->getTileSize(theCacheId);
 }
 
-// ossimCacheTileSource::ossimCacheTileSource(ossimImageSource* inputSource)
-//    : ossimImageSourceFilter(inputSource),
-//      theCacheId(ossimAppFixedTileCache::instance()->newTileCache()),
-//      theTile(0),
-//      theCachingEnabled(true),
-//      theEventProgressFlag(false)
-// {
-//    theBoundingRect.makeNan();
-//    theFixedTileSize = ossimAppFixedTileCache::instance()->getTileSize(theCacheId);
-//    theCacheRLevel = 0;
-// }
-
 ossimCacheTileSource::~ossimCacheTileSource()
 {
    ossimAppFixedTileCache::instance()->deleteCache(theCacheId);
@@ -82,74 +71,61 @@ void ossimCacheTileSource::allocate()
    }
 }
 
-ossimRefPtr<ossimImageData> ossimCacheTileSource::getTile(const ossimIrect& tileRect,
-                                              ossim_uint32 resLevel)
+ossimRefPtr<ossimImageData> ossimCacheTileSource::getTile(
+   const ossimIrect& tileRect, ossim_uint32 resLevel)
 {
-   if(traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimCacheTileSource::getTile DEBUG: Entered ..." << std::endl;
-   }
-   if(!theInputConnection)
-   {
-      if(traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimCacheTileSource::getTile DEBUG: Leaving with theInputConnection NULL ..." << std::endl;
-      }
-      return 0;
-   }
+   ossimRefPtr<ossimImageData> result = 0;
    
-   if(!isSourceEnabled())
-   {
-      if(traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimCacheTileSource::getTile DEBUG: Source not enabled so leaving ..." << std::endl;
-      }
-      return theInputConnection->getTile(tileRect, resLevel);
-   }
-   
-   if(!theTile.get())
-   {
-      allocate();
-   }
-
-   if(!theTile.get())
+   if ( theInputConnection )
    {
-      if(traceDebug())
+      if ( isSourceEnabled() )
       {
-         ossimNotify(ossimNotifyLevel_DEBUG) << "ossimCacheTileSource::getTile DEBUG: Unable to allocate tile so leaving ..." << std::endl;
-      }
-      return 0;
-   }
-
-   if(resLevel != theCacheRLevel)
-   {
-      flush();
-      theCacheRLevel = 9999999;
-      allocate();  // Do we need this??? (drb)
-      theBoundingRect = getBoundingRect(resLevel);
-      if(theBoundingRect.hasNans())
-      {
-         if(traceDebug())
+         if( (resLevel != theCacheRLevel) ||  theBoundingRect.hasNans() )
+         {
+            flush();
+            // allocate();
+            
+            // theCacheRLevel = 9999999;
+            theCacheRLevel = resLevel;
+            theBoundingRect = getBoundingRect(resLevel);
+            if( !theBoundingRect.hasNans() )
+            {
+               theFixedTileSize = ossimAppFixedTileCache::instance()->getTileSize(theCacheId);
+               theBoundingRect.stretchToTileBoundary(theFixedTileSize);
+               ossimAppFixedTileCache::instance()->setRect(theCacheId,
+                                                           theBoundingRect);
+               // theCacheRLevel = resLevel;
+            }
+         }
+         
+         if(!theTile.valid())
          {
-            ossimNotify(ossimNotifyLevel_DEBUG) << "ossimCacheTileSource::getTile DEBUG: bounding rect has nans so leaving ..." << std::endl;
+            allocate();
+         }
+         
+         if (theTile.valid())
+         {
+            theTile->setImageRectangle(tileRect);
+            theTile->makeBlank();
+            
+            if( !theBoundingRect.hasNans() )
+            {
+               result = fillTile(resLevel);
+            }
+            else
+            {
+               result = theTile;
+            }
          }
-         return 0;
       }
-      theFixedTileSize = ossimAppFixedTileCache::instance()->getTileSize(theCacheId);
-      theBoundingRect.stretchToTileBoundary(theFixedTileSize);
-      ossimAppFixedTileCache::instance()->setRect(theCacheId,
-                                                  theBoundingRect);
-      theCacheRLevel = resLevel;
-   }
+      else // Not enabled...
+      {
+         result = theInputConnection->getTile(tileRect, resLevel);
+      }
 
-   theTile->setImageRectangle(tileRect);
-   theTile->makeBlank();
+   } // End:  if ( theInputConnection )
 
-   if(traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimCacheTileSource::getTile DEBUG: filling tile and leaving ..." << std::endl;
-   }
-   return fillTile(resLevel);
+   return result;
 }
 
 ossimRefPtr<ossimImageData> ossimCacheTileSource::fillTile(
@@ -162,112 +138,119 @@ ossimRefPtr<ossimImageData> ossimCacheTileSource::fillTile(
    
    ossimIrect allignedRect = tileRect.clipToRect(boundingRect);
    
-   if (allignedRect.hasNans())
-   {
-      theTile->makeBlank();
-      return theTile;
-   }
-   
-   allignedRect.stretchToTileBoundary(theFixedTileSize);
-   ossimAppFixedTileCache::ossimAppFixedCacheId cacheId = theCacheId;
-   
-   // check to see if we need to loop
-   if((allignedRect == tileRect)&&
-      (static_cast<ossim_int32>(tileRect.width())  == theFixedTileSize.x)&&
-      (static_cast<ossim_int32>(tileRect.height()) == theFixedTileSize.y))
+   if ( !allignedRect.hasNans() )
    {
-      ossimIpt origin = tileRect.ul();
-      if(theCachingEnabled)
-      {
-         tempTile = ossimAppFixedTileCache::instance()->getTile(cacheId, origin);
-      }
-      if(!tempTile.valid())
+      allignedRect.stretchToTileBoundary(theFixedTileSize);
+      ossimAppFixedTileCache::ossimAppFixedCacheId cacheId = theCacheId;
+      
+      // check to see if we need to loop
+      if((allignedRect == tileRect)&&
+         (static_cast<ossim_int32>(tileRect.width())  == theFixedTileSize.x)&&
+         (static_cast<ossim_int32>(tileRect.height()) == theFixedTileSize.y))
       {
-         tempTile = theInputConnection->getTile(tileRect, resLevel);
-         
-         if(tempTile.valid())
+         ossimIpt origin = tileRect.ul();
+         if(theCachingEnabled)
          {
-            if((tempTile->getBuf())&&
-               (tempTile->getDataObjectStatus()!=OSSIM_EMPTY)&&
-               theCachingEnabled)
+            tempTile = ossimAppFixedTileCache::instance()->getTile(cacheId,
+                                                                   origin);
+         }
+         if(!tempTile.valid())
+         {
+            tempTile = theInputConnection->getTile(tileRect, resLevel);
+            
+            if(tempTile.valid())
             {
-               ossimAppFixedTileCache::instance()->addTile(cacheId, tempTile);
+               if((tempTile->getBuf())&&
+                  (tempTile->getDataObjectStatus()!=OSSIM_EMPTY)&&
+                  theCachingEnabled)
+               {
+                  ossimAppFixedTileCache::instance()->addTile(cacheId,
+                                                              tempTile);
+               }
             }
          }
-      }
-      
-      if(tempTile.valid())
-      {
-         if((tempTile->getDataObjectStatus() != OSSIM_NULL)&&
-            (tempTile->getDataObjectStatus() != OSSIM_EMPTY))
+         
+         if(tempTile.valid())
          {
-            
-            theTile->setDataObjectStatus(tempTile->getDataObjectStatus());
-            theTile->loadTile(tempTile.get());
+            if((tempTile->getDataObjectStatus() != OSSIM_NULL)&&
+               (tempTile->getDataObjectStatus() != OSSIM_EMPTY))
+            {
+               
+               // theTile->setDataObjectStatus(tempTile->getDataObjectStatus());
+               theTile->loadTile(tempTile.get());
+            }
          }
+         fireProgressEvent(100.0);
       }
-      fireProgressEvent(100.0);
-   }
-   else
-   {
-      long boundaryHeight = allignedRect.height();
-      long boundaryWidth  = allignedRect.width();
-      ossimIpt origin(allignedRect.ul());
-      long totalTiles  = (boundaryHeight/theFixedTileSize.y)*
-         (boundaryWidth/theFixedTileSize.x);
-      long currentTile = 0;
-      for(long row = 0; row < boundaryHeight; row+=theFixedTileSize.y)
+      else
       {
-         origin.x  =  allignedRect.ul().x;
-         for(long col = 0; col < boundaryWidth; col+=theFixedTileSize.x)
+         ossim_int32 boundaryHeight = allignedRect.height();
+         ossim_int32 boundaryWidth  = allignedRect.width();
+         ossimIpt origin(allignedRect.ul());
+         ossim_int32 totalTiles  = (boundaryHeight/theFixedTileSize.y)*
+            (boundaryWidth/theFixedTileSize.x);
+         ossim_int32 currentTile = 0;
+         for(ossim_int32 row = 0;
+             row < boundaryHeight;
+             row+=theFixedTileSize.y)
          {
-            ++currentTile;
-            if(theCachingEnabled)
+            origin.x  =  allignedRect.ul().x;
+            for(ossim_int32 col = 0;
+                col < boundaryWidth;
+                col+=theFixedTileSize.x)
             {
-               tempTile = ossimAppFixedTileCache::instance()->getTile(cacheId,
-                                                                      origin);
-            }
-            else
-            {
-               tempTile = 0;
-            }
-            if(!tempTile.valid())
-            {
-               ossimIrect rect(origin.x,
-                               origin.y,
-                               origin.x + theFixedTileSize.x-1,
-                               origin.y + theFixedTileSize.y-1);
-
-               tempTile = theInputConnection->getTile(rect, resLevel);
-               
-               if(tempTile.valid())
+               ++currentTile;
+               if(theCachingEnabled)
                {
-                  if(theTile->getBuf()&&
-                     (tempTile->getDataObjectStatus()!=OSSIM_EMPTY)&&
-                     theCachingEnabled)
+                  tempTile =
+                     ossimAppFixedTileCache::instance()->getTile(cacheId,
+                                                                 origin);
+               }
+               else
+               {
+                  tempTile = 0;
+               }
+               if(!tempTile.valid())
+               {
+                  ossimIrect rect(origin.x,
+                                  origin.y,
+                                  origin.x + theFixedTileSize.x-1,
+                                  origin.y + theFixedTileSize.y-1);
+                  
+                  tempTile = theInputConnection->getTile(rect, resLevel);
+                  
+                  if(tempTile.valid())
                   {
-                     ossimAppFixedTileCache::instance()->addTile(cacheId, tempTile);
+                     // drb if(theTile->getBuf()&&
+                     if(tempTile->getBuf()&&                        
+                        (tempTile->getDataObjectStatus()!=OSSIM_EMPTY)&&
+                        theCachingEnabled)
+                     {
+                        ossimAppFixedTileCache::instance()->
+                           addTile(cacheId, tempTile);
+                     }
                   }
                }
-            }
-            if(tempTile.valid())
-            {
-               if(tempTile->getBuf()&&
-                  (tempTile->getDataObjectStatus()!=OSSIM_EMPTY))
+               if(tempTile.valid())
                {
-                  theTile->loadTile(tempTile.get());
+                  if(tempTile->getBuf()&&
+                     (tempTile->getDataObjectStatus()!=OSSIM_EMPTY))
+                  {
+                     theTile->loadTile(tempTile.get());
+                  }
                }
+               double percent = 100.0*((double)currentTile/(double)totalTiles);
+               fireProgressEvent(percent);
+               origin.x   += theFixedTileSize.x;
             }
-            double percent = 100.0*((double)currentTile/(double)totalTiles);
-            fireProgressEvent(percent);
-            origin.x   += theFixedTileSize.x;
+            origin.y += theFixedTileSize.y;
          }
-         origin.y += theFixedTileSize.y;
+         fireProgressEvent(100);
       }
-      fireProgressEvent(100);
-   }
-   
-   theTile->validate();
+
+      theTile->validate();
+      
+   } // End of:  if ( !allignedRect.hasNans() )
    
    return theTile;
 }
@@ -340,7 +323,13 @@ ossimRefPtr<ossimProperty> ossimCacheTileSource::getProperty(
       result->setCacheRefreshBit();
       return result;
    }
-
+   else if(name == ossimKeywordNames::ENABLE_CACHE_KW)
+   {
+      ossimRefPtr<ossimProperty> result = new ossimBooleanProperty(name,
+                                                                   theCachingEnabled);
+      result->setCacheRefreshBit();
+      return result;
+   }
    return ossimImageSourceFilter::getProperty(name);
 }
 
@@ -368,14 +357,21 @@ void ossimCacheTileSource::setProperty(ossimRefPtr<ossimProperty> property)
             << std::endl;
       }
    }
-
-   ossimImageSourceFilter::setProperty(property);
+   else if(name == ossimKeywordNames::ENABLE_CACHE_KW)
+   {
+      setCachingEnabledFlag(property->valueToString().toBool());
+   }
+   else
+   {
+      ossimImageSourceFilter::setProperty(property);
+   }
 }
 
 void ossimCacheTileSource::getPropertyNames(
    std::vector<ossimString>& propertyNames)const
 {
    propertyNames.push_back(TILE_SIZE_XY_KW);
+   propertyNames.push_back(ossimKeywordNames::ENABLE_CACHE_KW);
    
    ossimImageSourceFilter::getPropertyNames(propertyNames);
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimCcfHead.cpp b/Utilities/otbossim/src/ossim/imaging/ossimCcfHead.cpp
index 1b9d0dd98940143e7aaef14b83b69e25e2762cbc..d9e97270ddfe1cf5b7830eb3518b79fd25028805 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimCcfHead.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimCcfHead.cpp
@@ -9,7 +9,7 @@
 // Contains class definition for CcfHead.
 // 
 //*******************************************************************
-//  $Id: ossimCcfHead.cpp 10268 2007-01-15 10:53:26Z dburken $
+//  $Id: ossimCcfHead.cpp 13842 2008-11-04 19:40:10Z gpotts $
 
 #include <sstream>
 #include <iostream>
@@ -197,7 +197,7 @@ bool ossimCcfHead::parseCcfHeader(const char* ccf_file)
       }
       is->close();
       delete is;
-      status = false;
+       return false;
 
       break;
    }
@@ -428,17 +428,17 @@ bool ossimCcfHead::parseV6CcfHeader(std::istream& is)
 
    for (i=0; i<theNumberOfValidImageVertices; i++)
    {
-      ossim_float64 tmp_dbl;  // Can be doubles in header.
+      ossimString tmp_dbl;  // Can be doubles in header.
       
       is >> tmp      // skip "Vertex"
          >> tmp      // skip Vertex number
          >> tmp_dbl; // line
 
-      theValidImageVertices[i].y = static_cast<int>(tmp_dbl);
-
+      theValidImageVertices[i].y = static_cast<int>(tmp_dbl.toDouble());
+      tmp_dbl = "";
       is >> tmp_dbl; // sample
 
-      theValidImageVertices[i].x = static_cast<int>(tmp_dbl);
+      theValidImageVertices[i].x = static_cast<int>(tmp_dbl.toDouble());
    }
 
    is.read(tmp, 1);                   // eat the '\n'
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp
index e5abd3adf8f6356f46681061697be0c75b00ba82..26031f1bf7ce8e0c27916ed59c0f308c83163783 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimDtedTileSource.cpp
@@ -12,7 +12,7 @@
 // Contains class declaration for ossimDtedTileSource.
 //
 //********************************************************************
-// $Id: ossimDtedTileSource.cpp 12979 2008-06-04 00:25:14Z dburken $
+// $Id: ossimDtedTileSource.cpp 13484 2008-08-22 17:05:42Z gpotts $
 
 #include <cstdlib>
 #include <iostream>
@@ -363,7 +363,10 @@ void ossimDtedTileSource::allocate()
    // from the statistics.
    //---
    theTile = ossimImageDataFactory::instance()->create(this, this);
-   theTile->initialize();
+   if(theTile.valid())
+   {
+      theTile->initialize();
+   }
 
    if (traceDebug())
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp
index 43531a09e08f8f4635347be53393ffaa65fa81d1..b85a7379aee37939a6d3deb011135761479a680d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimERSFileWriter.cpp
@@ -10,13 +10,13 @@
 // writing an ERS header file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimERSFileWriter.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimERSFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimERSFileWriter.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimIrect.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimMapProjection.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEastingNorthingCutter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEastingNorthingCutter.cpp
index 4fca1174e4c7cac2949c982b502c4aeef01e2b9f..e77a610a03f33db9c10c4af6bdff82e3da853085 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimEastingNorthingCutter.cpp 13711 2008-10-14 16:49:38Z gpotts $
 //----------------------------------------------------------------------------
 
 #include <sstream>
@@ -108,15 +108,26 @@ bool ossimEastingNorthingCutter::loadState(const ossimKeywordlist& kwl,
    if(ul)
    {
       istringstream in(ul);
-
-      in >> theUlEastingNorthing.x >> theUlEastingNorthing.y;
+      ossimString x;
+      ossimString y;
+      
+      in >> x >> y;
+      
+      theUlEastingNorthing.x = x.toDouble();
+      theUlEastingNorthing.y = y.toDouble();
+      
    }
    
    if(lr)
    {
       istringstream in(lr);
-
-      in >> theLrEastingNorthing.x >> theLrEastingNorthing.y;
+      ossimString x;
+      ossimString y;
+      
+      in >> x >> y;
+      
+      theLrEastingNorthing.x = x.toDouble();
+      theLrEastingNorthing.y = y.toDouble();
    }
 
    if (traceDebug())
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp
index 9a4324ee252740ce2bbfcafe2017c357553bac21..483d0b5f7604e96a6083f22fb64cc525e5612be1 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimEnviHeaderFileWriter.cpp
@@ -13,12 +13,12 @@
 // writing an ENVI (The Environment for Visualizing Images) header file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimEnviHeaderFileWriter.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimEnviHeaderFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimEnviHeaderFileWriter.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimIrect.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimMapProjection.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEquationCombiner.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEquationCombiner.cpp
index 8f4bc4597b7632e2df2764e74f6630e0663a7ca3..466c8141c014ec319f20fe2ec8d8fdff0c785692 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 12979 2008-06-04 00:25:14Z dburken $
+// $Id: ossimEquationCombiner.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <cstdlib>
 #include <sstream>
@@ -420,7 +420,7 @@ double ossimEquationCombiner::getNullPixelValue(ossim_uint32 band)const
    {
       if(getInput())
       {
-         ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface, getInput());
+         ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput());
          if(inter)
          {
             return inter->getNullPixelValue(band);
@@ -436,7 +436,7 @@ double ossimEquationCombiner::getMinPixelValue(ossim_uint32 band)const
    {
       if(getInput())
       {
-         ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface, getInput());
+         ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput());
          if(inter)
          {
             return inter->getMinPixelValue(band);
@@ -452,7 +452,7 @@ double ossimEquationCombiner::getMaxPixelValue(ossim_uint32 band)const
    {
       if(getInput())
       {
-         ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface, getInput());
+         ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput());
          if(inter)
          {
             return inter->getMaxPixelValue(band);
@@ -469,7 +469,7 @@ ossimScalarType ossimEquationCombiner::getOutputScalarType() const
    {
       if(getInput())
       {
-         ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface, getInput());
+         ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput());
          if(inter)
          {
             return inter->getOutputScalarType();
@@ -521,8 +521,8 @@ ossimRefPtr<ossimImageData> ossimEquationCombiner::getTile(
    {
       if(getInput())
       {
-         ossimImageSourceInterface* inter =
-            PTR_CAST(ossimImageSourceInterface, getInput());
+         ossimImageSource* inter =
+            PTR_CAST(ossimImageSource, getInput());
          if(inter)
          {
             return inter->getTile(tileRect, resLevel);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEsriShapeFileCutter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEsriShapeFileCutter.cpp
deleted file mode 100644
index 08bb370054d5a94c8dfa4099b200826898a8e228..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/imaging/ossimEsriShapeFileCutter.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-//*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
-//
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
-//
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimEsriShapeFileCutter.cpp 9094 2006-06-13 19:12:40Z dburken $
-#include <ossim/imaging/ossimEsriShapeFileCutter.h>
-
-RTTI_DEF2(ossimEsriShapeFileCutter,
-          "ossimEsriShapeFileCutter",
-          ossimImageSourceFilter,
-          ossimViewInterface);
-
-ossimEsriShapeFileCutter::ossimEsriShapeFileCutter()
-   :ossimImageSourceFilter(),
-    ossimViewInterface(),
-    theEsriShapeFile(NULL),
-    theMaskFilter(NULL)
-{
-   theObject = this;
-   theEsriShapeFile = new ossimEsriShapeFileFilter;
-   theEsriShapeFile->setFillFlag(true);
-
-   theMaskFilter    = new ossimMaskFilter;
-
-   theMaskFilter->connectMyInputTo(1,
-                                   theEsriShapeFile);
-}
-
-ossimEsriShapeFileCutter::~ossimEsriShapeFileCutter()
-{
-   if(theEsriShapeFile)
-   {
-      delete theEsriShapeFile;
-      theEsriShapeFile = NULL;
-   }
-
-   if(theMaskFilter)
-   {
-      delete theMaskFilter;
-      theMaskFilter = NULL;
-   }
-}
-
-ossimRefPtr<ossimImageData> ossimEsriShapeFileCutter::getTile(
-   const ossimIrect& rect,
-   ossim_uint32 resLevel)
-{
-   if(isSourceEnabled())
-   {
-      if(theMaskFilter)
-      {
-         return theMaskFilter->getTile(rect, resLevel);
-      }
-   }
-   else
-   {
-      if(getInput())
-      {
-         ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                                     getInput());
-         
-         if(input)
-         {
-            return input->getTile(rect, resLevel);
-         }
-      }
-   }
-   
-   return NULL;
-}
-
-void ossimEsriShapeFileCutter::initialize()
-{
-   if(theEsriShapeFile)
-   {
-      theEsriShapeFile->initialize();
-   }
-
-   
-   if(theMaskFilter)
-   {
-      theMaskFilter->disconnectMyInput((ossim_int32)0);
-      theMaskFilter->disconnectMyInput((ossim_int32)1);
-      theMaskFilter->connectMyInputTo((int)0,
-                                      getInput(0));
-      theMaskFilter->connectMyInputTo(1,
-                                      theEsriShapeFile);
-   }
-}
-
-bool ossimEsriShapeFileCutter::loadState(const ossimKeywordlist& kwl,
-                                         const char* prefix)
-{
-   ossimString shapeFilePrefix = ossimString(prefix) + "shape_file_filter.";
-   ossimString maskPrefix      = ossimString(prefix) + "mask.";
-                                 
-   theEsriShapeFile->loadState(kwl, shapeFilePrefix.c_str());
-   theMaskFilter->loadState(kwl, maskPrefix.c_str());
-
-   return ossimImageSourceFilter::loadState(kwl, prefix);
-}
-
-bool ossimEsriShapeFileCutter::saveState(ossimKeywordlist& kwl,
-                                         const char* prefix)const
-{
-   ossimString shapeFilePrefix = ossimString(prefix) + "shape_file_filter.";
-   ossimString maskPrefix      = ossimString(prefix) + "mask.";
-                                 
-   theEsriShapeFile->saveState(kwl, shapeFilePrefix.c_str());
-   theMaskFilter->saveState(kwl, maskPrefix.c_str());
-   
-   return ossimImageSourceFilter::saveState(kwl, prefix);
-}
-
-void ossimEsriShapeFileCutter::getDecimationFactor(ossim_uint32 resLevel,
-                                                   ossimDpt& result)const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(0));
-   if(input)
-   {
-      input->getDecimationFactor(resLevel, result);
-   }
-}
-
-ossimIrect ossimEsriShapeFileCutter::getBoundingRect(ossim_uint32 resLevel)const
-{
-   ossimIrect result;
-   result.makeNan();
-   
-   if(theMaskFilter)
-   {
-      result = theMaskFilter->getBoundingRect(resLevel);
-   }
-   
-   return result;
-}
-
-void ossimEsriShapeFileCutter::getDecimationFactors(
-   vector<ossimDpt>& decimations)const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      input->getDecimationFactors(decimations);
-   }     
-}
-
-ossim_uint32 ossimEsriShapeFileCutter::getNumberOfDecimationLevels()const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getNumberOfDecimationLevels();
-   } 
-   return 0;
-}
-
-ossim_uint32 ossimEsriShapeFileCutter::getNumberOfOutputBands() const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getNumberOfOutputBands();
-   }
-   return 0;
-}
-
-ossimScalarType ossimEsriShapeFileCutter::getOutputScalarType() const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getOutputScalarType();
-   }
-   
-   return OSSIM_SCALAR_UNKNOWN;
-}
-
-void ossimEsriShapeFileCutter::getValidImageVertices(
-   vector<ossimIpt>& validVertices,
-   ossimVertexOrdering ordering,
-   ossim_uint32 resLevel) const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      input->getValidImageVertices(validVertices, ordering, resLevel);
-   }
-}
-
-ossim_uint32 ossimEsriShapeFileCutter::getTileWidth() const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getTileWidth();
-   }
-   
-   return 0;
-}
-
-ossim_uint32 ossimEsriShapeFileCutter::getTileHeight() const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getTileHeight();
-   }
-   return 0;
-}
-
-double ossimEsriShapeFileCutter::getNullPixelValue(ossim_uint32 band)const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getNullPixelValue(band);
-   }
-   return 0;
-}
-   
-double ossimEsriShapeFileCutter::getMinPixelValue(ossim_uint32 band)const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
-   if(input)
-   {
-      return input->getMinPixelValue(band);
-   }
-   return 0;
-}
-   
-double ossimEsriShapeFileCutter::getMaxPixelValue(ossim_uint32 band)const
-{
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(0));
-   if(input)
-   {
-      return input->getMaxPixelValue(band);
-   }
-   return 0;
-}
-
-void ossimEsriShapeFileCutter::loadFile(const ossimFilename& filename)
-{
-   if(theEsriShapeFile)
-   {
-      theEsriShapeFile->loadShapeFile(filename);
-   }
-}
-
-bool ossimEsriShapeFileCutter::setView(ossimObject* baseObject,
-                                       bool ownsTheView)
-{
-   if(theEsriShapeFile)
-   {
-      return theEsriShapeFile->setView(baseObject, ownsTheView);
-   }
-   
-   return false;
-}
-
-ossimObject* ossimEsriShapeFileCutter::getView()
-{
-   if(theEsriShapeFile)
-   {
-      return theEsriShapeFile->getView();
-   }
-   
-   return NULL;;
-}
-
-const ossimObject* ossimEsriShapeFileCutter::getView()const
-{
-   if(theEsriShapeFile)
-   {
-      return theEsriShapeFile->getView();
-   }
-   
-   return NULL;;
-}
-
-ossimFilename ossimEsriShapeFileCutter::getFilename()const
-{
-   if(theEsriShapeFile)
-   {
-      return theEsriShapeFile->getFilename();
-   }
-   
-   return ossimFilename();
-}
-
-void ossimEsriShapeFileCutter::setMaskType(
-   ossimMaskFilter::ossimFileSelectionMaskType type)
-{
-   if(theMaskFilter)
-   {
-      theMaskFilter->setMaskType(type);
-   }
-}
-
-ossimMaskFilter::ossimFileSelectionMaskType ossimEsriShapeFileCutter::getMaskType()const
-{
-   if(theMaskFilter)
-   {
-      return theMaskFilter->getMaskType();
-   }
-   
-   return ossimMaskFilter::OSSIM_MASK_TYPE_SELECT;
-}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimEsriShapeFileFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimEsriShapeFileFilter.cpp
deleted file mode 100644
index d47c07b7e014898e1e8384170f02d4fe2762ff9c..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/imaging/ossimEsriShapeFileFilter.cpp
+++ /dev/null
@@ -1,813 +0,0 @@
-//*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
-//
-// License: See LICENSE.txt file in the top level directory.
-//
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimEsriShapeFileFilter.cpp 11411 2007-07-27 13:53:51Z dburken $
-
-#include <cstdio>
-#include <cstdlib>
-#include <sstream>
-using namespace std;
-
-#include <ossim/imaging/ossimEsriShapeFileFilter.h>
-#include <ossim/vec/ossimShapeFile.h>
-#include <ossim/imaging/ossimAnnotationPolyObject.h>
-#include <ossim/imaging/ossimGeoAnnotationPolyLineObject.h>
-#include <ossim/imaging/ossimAnnotationObject.h>
-#include <ossim/imaging/ossimGeoAnnotationPolyObject.h>
-#include <ossim/imaging/ossimGeoAnnotationEllipseObject.h>
-#include <ossim/base/ossimTrace.h>
-#include <ossim/base/ossimCommon.h>
-#include <ossim/base/ossimConstants.h>
-#include <ossim/base/ossimKeywordNames.h>
-#include <ossim/base/ossimTrace.h>
-#include <ossim/base/ossimNotifyContext.h>
-#include <ossim/base/ossimFilename.h>
-#include <ossim/base/ossimGeoPolygon.h>
-#include <ossim/base/ossimUnitConversionTool.h>
-#include <ossim/projection/ossimProjection.h>
-#include <ossim/projection/ossimProjectionFactoryRegistry.h>
-#include <ossim/projection/ossimMapProjection.h>
-
-
-RTTI_DEF2(ossimEsriShapeFileFilter,
-          "ossimEsriShapeFileFilter",
-          ossimAnnotationSource,
-          ossimViewInterface);
-
-static const ossimTrace traceDebug("ossimEsriShapeFileFilter:debug");
-
-ossimEsriShapeFileFilter::ossimEsriShapeFileFilter(ossimImageSource* inputSource)
-   :ossimAnnotationSource(inputSource),
-    ossimViewInterface(),
-    theViewProjection(NULL),
-    theShapeFileProjection(NULL),
-    theOwnsViewProjectionFlag(true),
-    theCoordinateSystem(OSSIM_GEOGRAPHIC_SPACE),
-    theUnitType(OSSIM_METERS),
-    theTree((ossim_SHPTree*)NULL),
-    theMaxQuadTreeLevels(10),
-    thePenColor(255,255,255),
-    theBrushColor(255,255,255),
-    theFillFlag(false),
-    theThickness(1),
-    thePointWidthHeight(1, 1),
-    theBorderSize(0.0),
-    theBorderSizeUnits(OSSIM_DEGREES)
-{
-   ossimViewInterface::theObject = this;
-   ossimAnnotationSource::setNumberOfBands(3);
-   theBoundingRect.makeNan();
-   theMinArray[0] = theMinArray[1] = theMinArray[2] = theMinArray[3] = ossim::nan();
-   theMaxArray[0] = theMaxArray[1] = theMaxArray[2] = theMaxArray[3] = ossim::nan();
-}
-
-ossimEsriShapeFileFilter::~ossimEsriShapeFileFilter()
-{
-   removeViewProjection();
-   
-   if(theTree)
-   {
-      ossim_SHPDestroyTree(theTree);
-   }
-
-   deleteCache();
-}
-
-bool ossimEsriShapeFileFilter::setView(ossimObject* baseObject,
-                                       bool ownsTheView)
-{
-   ossimProjection* proj = PTR_CAST(ossimProjection, baseObject);
-   if(proj)
-   {
-      setProjection(proj, ownsTheView);
-      
-      return true;
-   }
-   else if(!baseObject)
-   {
-      setProjection((ossimProjection*)NULL, true);
-   }
-
-   return false;
-}
-
-ossimObject* ossimEsriShapeFileFilter::getView()
-{
-   return theViewProjection;
-}
-
-const ossimObject* ossimEsriShapeFileFilter::getView()const
-{
-   return theViewProjection;
-}
-
-bool ossimEsriShapeFileFilter::addObject(ossimAnnotationObject* anObject)
-{
-   ossimNotify(ossimNotifyLevel_WARN)
-      << "ossimEsriShapeFileFilter::addObject\n"
-      << "Can't add objects to layer, must go through Esri loadShapeFile"
-      <<endl;
-   
-   return false;
-}
-
-void ossimEsriShapeFileFilter::computeBoundingRect()
-{
-//   ossimAnnotationSource::computeBoundingRect();
-   
-   std::multimap<int, ossimAnnotationObject*>::iterator iter = theShapeCache.begin();
-   
-   theBoundingRect.makeNan();
-   while(iter != theShapeCache.end())
-   {
-       ossimDrect rect = (*iter).second->getBoundingRect();
-      if(theBoundingRect.hasNans())
-      {
-         theBoundingRect = rect;
-      }
-      else
-      {
-         if(!rect.hasNans())
-         {
-            theBoundingRect = theBoundingRect.combine(rect);
-         }
-      }
-      
-      ++iter;
-   }
-}
-
-ossimIrect ossimEsriShapeFileFilter::getBoundingRect(ossim_uint32 resLevel)const
-{
-   if(!isSourceEnabled()||
-      getInput())
-   {
-      if(getInput())
-      {
-         ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
-                                                     getInput());
-         if(input)
-         {
-            return input->getBoundingRect(resLevel);
-         }
-      }
-   }
-   return theBoundingRect;
-}
-
-void ossimEsriShapeFileFilter::drawAnnotations(ossimRefPtr<ossimImageData> tile)
-{
-   ossimAnnotationSource::drawAnnotations(tile);
-   
-   if (!theTree||!theShapeFile.isOpen()) return;
-   if(theViewProjection)
-   {
-      ossimIrect rect = tile->getImageRectangle();
-
-      rect = ossimIrect(rect.ul().x,
-                        rect.ul().y,
-                        rect.lr().x,
-                        rect.lr().y);
-      double boundsMin[2];
-      double boundsMax[2];
-      
-      ossimGpt gp1;
-      ossimGpt gp2;
-      ossimGpt gp3;
-      ossimGpt gp4;
-
-      theViewProjection->lineSampleToWorld(rect.ul(),
-                                           gp1);
-      theViewProjection->lineSampleToWorld(rect.ur(),
-                                           gp2);
-      theViewProjection->lineSampleToWorld(rect.lr(),
-                                           gp3);
-      theViewProjection->lineSampleToWorld(rect.ll(),
-                                           gp4);
-
-      ossimDrect boundsRect( ossimDpt(gp1.lond(),
-                                      gp1.latd()),
-                             ossimDpt(gp2.lond(),
-                                      gp2.latd()),
-                             ossimDpt(gp3.lond(),
-                                      gp3.latd()),
-                             ossimDpt(gp4.lond(),
-                                      gp4.latd()),
-                             OSSIM_RIGHT_HANDED);
-
-      boundsMin[0] = boundsRect.ul().x;
-      boundsMin[1] = boundsRect.lr().y;
-
-      boundsMax[0] = boundsRect.lr().x;
-      boundsMax[1] = boundsRect.ul().y;
-
-      int n;
-      int *array=(int*)NULL;
-      
-      array = ossim_SHPTreeFindLikelyShapes(theTree,
-                                      boundsMin,
-                                      boundsMax,
-                                      &n);
-      
-      theImage->setCurrentImageData(tile);
-      if(n&&array)
-      {
-         for(int i = 0; i < n; ++i)
-         {
-            std::multimap<int, ossimAnnotationObject*>::iterator iter = theShapeCache.find(array[i]);
-            while( ((*iter).first == array[i]) && (iter != theShapeCache.end()) )
-            {
-               (*iter).second->draw(*theImage);
-               ++iter;
-            }
-         }
-         
-         free(array);
-      }
-   }
-}
-
-void ossimEsriShapeFileFilter::transformObjects(ossimProjection* projection)
-{
-   std::multimap<int, ossimAnnotationObject*>::iterator iter = theShapeCache.begin();
-
-
-   ossimProjection* proj = theViewProjection;
-   if(projection)
-   {
-      proj = projection;
-   }
-
-   if(!proj) return;
-   
-   while(iter != theShapeCache.end())
-   {
-      ossimGeoAnnotationObject* obj = PTR_CAST(ossimGeoAnnotationObject,
-                                               (*iter).second);
-      if(obj)
-      {
-         obj->transform(proj);
-      }
-      ++iter;
-   }
-
-   computeBoundingRect();
-}
-
-void ossimEsriShapeFileFilter::setProjection(ossimProjection* projection,
-                                             bool ownsProjectionFlag)
-{
-   removeViewProjection();
-
-   theViewProjection         = projection;
-   theOwnsViewProjectionFlag = ownsProjectionFlag;
-
-   transformObjects();
-}
-
-bool ossimEsriShapeFileFilter::getImageGeometry(ossimKeywordlist& kwl,
-                                                const char* prefix)
-{
-   if(theViewProjection)
-   {
-      return theViewProjection->saveState(kwl, prefix);
-   }
-   else
-   {
-      ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(0));
-      if(input)
-      {
-         return input->getImageGeometry(kwl, prefix);
-      }
-      else
-      {
-         kwl.add(prefix,
-                 ossimKeywordNames::TYPE_KW,
-                 "ossimEquDistCylProjection",
-                 true);
-         kwl.add(prefix,
-                 ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT,
-                 .1,
-                 true);
-         kwl.add(prefix,
-                 ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON,
-                 .1,
-                 true);
-         kwl.add(prefix,
-                 ossimKeywordNames::CENTRAL_MERIDIAN_KW,
-                 0.0,
-                 true);
-         kwl.add(prefix,
-                 ossimKeywordNames::ORIGIN_LATITUDE_KW,
-                 0.0,
-                 true);
-         kwl.add(prefix,
-                 ossimKeywordNames::DATUM_KW,
-                 "WGE",
-                 true);
-         return true;
-      }
-   }
-   
-   return false;
-}
-
-void ossimEsriShapeFileFilter::removeViewProjection()
-{
-   if(theViewProjection&&theOwnsViewProjectionFlag)
-   {
-      delete theViewProjection;
-   }
-
-   theViewProjection = NULL;
-}
-
-void ossimEsriShapeFileFilter::deleteCache()
-{
-   std::multimap<int, ossimAnnotationObject*>::iterator iter = theShapeCache.begin();
-
-
-   while(iter != theShapeCache.end())
-   {
-      if((*iter).second)
-      {
-         delete (*iter).second;
-      }
-      ++iter;
-   }
-
-   theShapeCache.clear();
-}
-
-void ossimEsriShapeFileFilter::checkAndSetDefaultView()
-{
-   if(!theViewProjection)
-   {
-      ossimKeywordlist tempKwl;
-      getImageGeometry(tempKwl);
-      
-      theViewProjection = ossimProjectionFactoryRegistry::instance()->createProjection(tempKwl);
-      
-      if(theViewProjection)
-      {
-         transformObjects();
-      }
-   }
-}
-
-bool ossimEsriShapeFileFilter::loadShapeFile(const ossimFilename& shapeFile)
-{
-   if(theTree)
-   {
-      ossim_SHPDestroyTree(theTree);
-      theTree = (ossim_SHPTree*)NULL;
-   }
-   theShapeFile.open(shapeFile);
-   deleteCache();
-   deleteAll();
-   
-   if(theShapeFile.isOpen())
-   {
-      theShapeFile.getBounds(theMinArray[0],theMinArray[1],theMinArray[2],theMinArray[3],
-                             theMaxArray[0],theMaxArray[1],theMaxArray[2],theMaxArray[3]);
-
-      theTree = ossim_SHPCreateTree(theShapeFile.getHandle(),
-                              2,
-                              theMaxQuadTreeLevels,
-                              theMinArray,
-                              theMaxArray);  
-      
-      ossimShapeObject obj;
-      for(int index = 0 ; index < theShapeFile.getNumberOfShapes(); ++index)
-      {
-         obj.loadShape(theShapeFile,
-                       index);
-         
-         if(obj.isLoaded())
-         {
-            switch(obj.getType())
-            {
-               case ossim_SHPT_POLYGON:
-               case ossim_SHPT_POLYGONZ:
-               {
-                  loadPolygon(obj);
-                  break;
-               }
-               case ossim_SHPT_POINT:
-               case ossim_SHPT_POINTZ:
-               {
-                  loadPoint(obj);
-                  break;
-               }
-               case ossim_SHPT_ARC:
-               case ossim_SHPT_ARCZ:
-               {
-                  loadArc(obj);
-                  break;
-               }
-               case ossim_SHPT_NULL:
-               {
-                  break;
-               }
-               default:
-               {
-                  ossimNotify(ossimNotifyLevel_WARN)
-                     << "ossimEsriShapeFileFilter::loadShapeFile\n"
-                     << "SHAPE " << obj.getTypeByName()
-                     << " Not supported" <<  endl;
-                  break;
-               }
-            }
-         }
-      }
-      
-      theCurrentObject = theShapeCache .begin();
-      if(theViewProjection)
-      {
-         transformObjects();
-      }
-      else
-      {
-         checkAndSetDefaultView();
-      }
-   }
-   
-   return true;
-}
-
-void ossimEsriShapeFileFilter::loadPolygon(ossimShapeObject& obj)
-{
-   int starti = 0;
-   int endi   = 0;
-   if(obj.getNumberOfParts() > 1)
-   {
-      starti = obj.getShapeObject()->panPartStart[0];
-      endi   = obj.getShapeObject()->panPartStart[1];
-   }
-   else
-   {
-      starti = 0;
-      endi   = obj.getShapeObject()->nVertices;
-   }
-   
-   vector<ossimGpt> groundPolygon;
-   for(ossim_uint32 part = 0; part < obj.getNumberOfParts(); ++part)
-   {
-      if(obj.getPartType(part) != ossim_SHPP_RING)
-      {
-         ossimNotify(ossimNotifyLevel_WARN)
-            << "ossimEsriShapeFileFilter::loadPolygon\n"
-            << "Part = " << obj.getPartByName(part)
-            << " not supported for shape = "
-            << obj.getTypeByName() << endl;
-         break;
-      }
-      groundPolygon.clear();
-      for(ossim_int32 vertexNumber = starti; vertexNumber < endi; ++vertexNumber)
-      {
-         groundPolygon.push_back(ossimGpt(obj.getShapeObject()->padfY[vertexNumber],
-                                          obj.getShapeObject()->padfX[vertexNumber]));
-         
-      }
-      starti = endi;   
-      if((part + 2) < obj.getNumberOfParts())
-      {  
-         endi = obj.getShapeObject()->panPartStart[part+2];
-      }
-      else
-      {
-         endi = obj.getShapeObject()->nVertices;
-      }
-      
-      ossimRgbVector color;
-      
-      if(theFillFlag)
-      {
-         color = theBrushColor;
-      }
-      else
-      {
-         color = thePenColor;
-      }
-
-      if(theBorderSize != 0.0)
-      {
-         ossimGeoPolygon tempPoly(groundPolygon);
-         ossimGeoPolygon tempPoly2;
-         
-         tempPoly.stretchOut(tempPoly2,
-                             theBorderSize);
-         groundPolygon = tempPoly2.getVertexList();
-
-      }
-      
-      ossimGeoAnnotationObject *newGeoObj = new ossimGeoAnnotationPolyObject(groundPolygon,
-                                                                             theFillFlag,
-                                                                             color.getR(),
-                                                                             color.getG(),
-                                                                             color.getB(),
-                                                                             theThickness);
-      newGeoObj->setName(theFeatureName);
-      theShapeCache.insert(make_pair(obj.getId(),
-                                     newGeoObj));
-   }
-}
-
-void ossimEsriShapeFileFilter::loadPoint(ossimShapeObject& obj)
-{
-   int n   = obj.getNumberOfVertices();
-
-   if(n)
-   {
-      ossimGpt gpt(obj.getShapeObject()->padfY[0],
-                   obj.getShapeObject()->padfX[0]);
-      
-      ossimRgbVector color;
-      
-      if(theFillFlag)
-      {
-         color = theBrushColor;
-      }
-      else
-      {
-         color = thePenColor;
-      }
-      ossimGeoAnnotationEllipseObject *newGeoObj =
-         new ossimGeoAnnotationEllipseObject(gpt,
-                                             thePointWidthHeight,
-                                             theFillFlag,
-                                             color.getR(),
-                                             color.getG(),
-                                             color.getB(),
-                                             theThickness);
-      newGeoObj->setEllipseWidthHeightUnitType(OSSIM_PIXEL);
-      newGeoObj->setName(theFeatureName);
-      theShapeCache.insert(make_pair(obj.getId(),
-                                     newGeoObj));
-
-   }
-}
-
-void ossimEsriShapeFileFilter::loadArc(ossimShapeObject& obj)
-{
-   int starti = 0;
-   int endi   = 0;
-   if(obj.getNumberOfParts() > 1)
-   {
-      starti = obj.getShapeObject()->panPartStart[0];
-      endi   = obj.getShapeObject()->panPartStart[1];
-   }
-   else
-   {
-      starti = 0;
-      endi   = obj.getShapeObject()->nVertices;
-   }
-   
-   vector<ossimGpt> groundPolygon;
-   for(ossim_uint32 part = 0; part < obj.getNumberOfParts(); ++part)
-   {
-      if(obj.getPartType(part) != ossim_SHPP_RING)
-      {
-         ossimNotify(ossimNotifyLevel_WARN)
-            << "ossimEsriShapeFileFilter::loadArc\n"
-            << "Part = " << obj.getPartByName(part)
-            << " not supported for shape = "
-            << obj.getTypeByName() << endl;
-         break;
-      }
-      groundPolygon.clear();
-      for(ossim_int32 vertexNumber = starti; vertexNumber < endi; ++vertexNumber)
-      {
-         groundPolygon.push_back(ossimGpt(obj.getShapeObject()->padfY[vertexNumber],
-                                          obj.getShapeObject()->padfX[vertexNumber]));
-         
-      }
-      starti = endi;   
-      if((part + 2) < obj.getNumberOfParts())
-      {  
-         endi = obj.getShapeObject()->panPartStart[part+2];
-      }
-      else
-      {
-         endi = obj.getShapeObject()->nVertices;
-      }
-      
-      ossimRgbVector color;
-      
-      if(theFillFlag)
-      {
-         color = theBrushColor;
-      }
-      else
-      {
-         color = thePenColor;
-      }
-      
-      ossimGeoAnnotationObject *newGeoObj = new ossimGeoAnnotationPolyLineObject(groundPolygon,
-                                                                                 color.getR(),
-                                                                                 color.getG(),
-                                                                                 color.getB(),
-                                                                                 theThickness);
-      newGeoObj->setName(theFeatureName);
-      theShapeCache.insert(make_pair(obj.getId(),
-                                     newGeoObj));
-   }
-}
-
-bool ossimEsriShapeFileFilter::saveState(ossimKeywordlist& kwl,
-                                         const char* prefix)const
-{
-   ossimString s;
-   
-   kwl.add(prefix,
-           ossimKeywordNames::FILENAME_KW,
-           theShapeFile.getFilename(),
-           true);
-
-   kwl.add(prefix,
-           ossimKeywordNames::MAX_QUADTREE_LEVELS_KW,
-           theMaxQuadTreeLevels,
-           true);
-
-   s = ossimString::toString((int)thePenColor.getR()) + " " +
-       ossimString::toString((int)thePenColor.getG()) + " " +
-       ossimString::toString((int)thePenColor.getB());
-   
-   kwl.add(prefix,
-           ossimKeywordNames::PEN_COLOR_KW,
-           s.c_str(),
-           true);
-
-   s = ossimString::toString((int)theBrushColor.getR()) + " " +
-       ossimString::toString((int)theBrushColor.getG()) + " " +
-       ossimString::toString((int)theBrushColor.getB());
-   
-   kwl.add(prefix,
-           ossimKeywordNames::BRUSH_COLOR_KW,
-           s.c_str(),
-           true);
-
-   kwl.add(prefix,
-           ossimKeywordNames::FILL_FLAG_KW,
-           (int)theFillFlag,
-           true);
-
-   kwl.add(prefix,
-           ossimKeywordNames::FEATURE_NAME_KW,
-           theFeatureName.c_str(),
-           true);
-
-   kwl.add(prefix,
-           ossimKeywordNames::THICKNESS_KW,
-           theThickness,
-           true);
-
-   ossimString border;
-   border = ossimString::toString(theBorderSize);
-   border += " degrees";
-   kwl.add(prefix,
-           ossimKeywordNames::BORDER_SIZE_KW,
-           border,
-           true);
-   
-   s = ossimString::toString((int)thePointWidthHeight.x) + " " +
-       ossimString::toString((int)thePointWidthHeight.y) + " ";
-   
-   kwl.add(prefix,
-           ossimKeywordNames::POINT_WIDTH_HEIGHT_KW,
-           s.c_str(),
-           true);
-   
-   if(theViewProjection)
-   {
-      ossimString newPrefix = prefix;
-      newPrefix += "view_proj.";
-      theViewProjection->saveState(kwl,
-                                   newPrefix.c_str());
-   }
-   
-   return ossimAnnotationSource::saveState(kwl, prefix);
-}
-
-bool ossimEsriShapeFileFilter::loadState(const ossimKeywordlist& kwl,
-                                         const char* prefix)
-{
-   
-   const char* quadLevels  = kwl.find(prefix, ossimKeywordNames::MAX_QUADTREE_LEVELS_KW);
-   const char* filename    = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
-   const char* penColor    = kwl.find(prefix, ossimKeywordNames::PEN_COLOR_KW);
-   const char* brushColor  = kwl.find(prefix, ossimKeywordNames::BRUSH_COLOR_KW);
-   const char* featureName = kwl.find(prefix, ossimKeywordNames::FEATURE_NAME_KW);
-   const char* fillFlag    = kwl.find(prefix, ossimKeywordNames::FILL_FLAG_KW);
-   const char* thickness   = kwl.find(prefix, ossimKeywordNames::THICKNESS_KW);
-   const char* pointWh     = kwl.find(prefix, ossimKeywordNames::POINT_WIDTH_HEIGHT_KW);
-   const char* border_size = kwl.find(prefix, ossimKeywordNames::BORDER_SIZE_KW);
-   
-   deleteCache();
-
-   if(thickness)
-   {
-      theThickness = ossimString(thickness).toLong();
-   }
-   if(quadLevels)
-   {
-      theMaxQuadTreeLevels = ossimString(quadLevels).toLong();
-   }
-   
-   if(penColor)
-   {
-      int r, g, b;
-      istringstream s(penColor);
-      s>>r>>g>>b;
-      thePenColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
-   }
-
-   if(brushColor)
-   {
-      int r, g, b;
-      istringstream s(brushColor);
-      s>>r>>g>>b;
-      theBrushColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
-   }
-   if(pointWh)
-   {
-      double w, h;
-      istringstream s(pointWh);
-      s>>w>>h;
-      thePointWidthHeight = ossimDpt(w, h);
-   }
-   
-   if(fillFlag)
-   {
-      theFillFlag = ossimString(fillFlag).toBool();
-   }
-
-   if(border_size)
-   {
-      istringstream input(border_size);
-
-      ossimString s;
-      input >> s;
-
-      theBorderSize = s.toDouble();
-      
-      ossimString s2;
-      
-      input >> s2;
-
-      s2 = s2.upcase();
-      
-      if(s2 == "US")
-      {
-         theBorderSizeUnits = OSSIM_US_SURVEY_FEET;
-      }
-      else if(s2 == "METERS")
-      {
-         theBorderSizeUnits = OSSIM_METERS;
-      }
-      else if(s2 == "FEET")
-      {
-         theBorderSizeUnits = OSSIM_FEET;
-      }
-      else
-      {
-         theBorderSizeUnits = OSSIM_DEGREES;
-      }
-      ossimUnitConversionTool unitConvert(theBorderSize,
-                                          theBorderSizeUnits);
-      
-      theBorderSize      = unitConvert.getValue(OSSIM_DEGREES);
-      theBorderSizeUnits = OSSIM_DEGREES;
-   }
-   else
-   {
-      theBorderSize      = 0.0;
-      theBorderSizeUnits = OSSIM_DEGREES;
-   }
-   
-   theFeatureName = featureName;
-   
-   removeViewProjection();
-   
-   ossimString newPrefix = prefix;
-   newPrefix += "view_proj.";
-   
-   theViewProjection = ossimProjectionFactoryRegistry::instance()->createProjection(kwl,
-                                                                                    newPrefix.c_str());
-   theOwnsViewProjectionFlag = true;
-   
-   if(filename)
-   {
-      loadShapeFile(ossimFilename(filename));
-   }
-   
-   checkAndSetDefaultView();
-
-   
-   return ossimAnnotationSource::loadState(kwl, prefix);
-}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFeatherMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFeatherMosaic.cpp
index f7a130bf25e279af28a265c5d4dd7a301885fd4d..86582b4914f19d7043ab556323c61064167c306c 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 12912 2008-05-28 15:05:54Z gpotts $
+// $Id: ossimFeatherMosaic.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimFeatherMosaic.h>
 #include <ossim/base/ossimDpt.h>
@@ -376,7 +376,7 @@ void ossimFeatherMosaic::initialize()
    for(long index = 0; index < theFeatherInfoSize; ++ index)
    {
       validVertices.clear();
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(index));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(index));
       if(temp)
       {
          temp->getValidImageVertices(validVertices, OSSIM_CLOCKWISE_ORDER);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFgdcFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFgdcFileWriter.cpp
index 8053721421e51d1ae49ead24525eae9e49f6c40a..3e9c1e3cb65f09de11436fa5e4d0685348b478ac 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimFgdcFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <fstream>
 using namespace std;
@@ -21,7 +21,7 @@ using namespace std;
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimXmlNode.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/projection/ossimMapProjection.h>
 #include <ossim/projection/ossimMapProjectionInfo.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -832,8 +832,11 @@ bool ossimFgdcFileWriter::writeTemplate(const ossimFilename& file) const
 
    os.close();
 
-   ossimNotify(ossimNotifyLevel_NOTICE)
+	if(traceDebug())
+	{
+		ossimNotify(ossimNotifyLevel_NOTICE)
       << "Wrote file:  " << file.c_str() << endl;
+	}
    
    return true;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFixedTileCache.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFixedTileCache.cpp
index 09787c54173dc41e9bfa10598f9920879a66633f..804ac4eb32cb51f6d619ae61b9c3b23264f41012 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimFixedTileCache.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimFixedTileCache.cpp
@@ -7,7 +7,7 @@
 // Description: This file contains the Application cache algorithm
 //
 //***********************************
-// $Id: ossimFixedTileCache.cpp 11694 2007-09-09 21:55:16Z dburken $
+// $Id: ossimFixedTileCache.cpp 13485 2008-08-22 17:06:20Z gpotts $
 #include <ossim/imaging/ossimFixedTileCache.h>
 #include <algorithm>
 
@@ -42,6 +42,7 @@ ossimFixedTileCache::~ossimFixedTileCache()
 
 void ossimFixedTileCache::setRect(const ossimIrect& rect)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    ossim::defaultTileSize(theTileSize);
    theTileBoundaryRect      = rect;
    theTileBoundaryRect.stretchToTileBoundary(theTileSize);
@@ -55,6 +56,7 @@ void ossimFixedTileCache::setRect(const ossimIrect& rect)
 void ossimFixedTileCache::setRect(const ossimIrect& rect,
                                   const ossimIpt& tileSize)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    theTileBoundaryRect      = rect;
    theTileSize              = tileSize;
    theTileBoundaryRect.stretchToTileBoundary(theTileSize);
@@ -68,6 +70,7 @@ void ossimFixedTileCache::setRect(const ossimIrect& rect,
 
 void ossimFixedTileCache::keepTilesWithinRect(const ossimIrect& rect)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter = theTileMap.begin();
 
    while(tileIter != theTileMap.end())
@@ -87,6 +90,7 @@ void ossimFixedTileCache::keepTilesWithinRect(const ossimIrect& rect)
 ossimRefPtr<ossimImageData> ossimFixedTileCache::addTile(ossimRefPtr<ossimImageData> imageData,
                                                          bool duplicateData)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = NULL;
    if(!imageData.valid())
    {
@@ -131,6 +135,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::addTile(ossimRefPtr<ossimImageD
 
 ossimRefPtr<ossimImageData> ossimFixedTileCache::getTile(ossim_int32 id)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = NULL;
 
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
@@ -146,6 +151,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::getTile(ossim_int32 id)
 
 ossimIpt ossimFixedTileCache::getTileOrigin(ossim_int32 tileId)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    ossimIpt result;
    result.makeNan();
 
@@ -202,6 +208,7 @@ void ossimFixedTileCache::deleteTile(ossim_int32 tileId)
 
 ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile(ossim_int32 tileId)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = NULL;
    
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
@@ -223,6 +230,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile(ossim_int32 tileId)
 
 void ossimFixedTileCache::flush()
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
       theTileMap.begin();
 
@@ -241,6 +249,7 @@ void ossimFixedTileCache::flush()
 
 void ossimFixedTileCache::deleteTile()
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if(theUseLruFlag)
    {
       if(theLruQueue.begin() != theLruQueue.end())
@@ -252,6 +261,7 @@ void ossimFixedTileCache::deleteTile()
 
 ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile()
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if(theUseLruFlag)
    {
       if(theLruQueue.begin() != theLruQueue.end())
@@ -265,6 +275,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile()
 
 void ossimFixedTileCache::adjustLru(ossim_int32 id)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if(theUseLruFlag)
    {
       std::list<ossim_int32>::iterator iter = std::find(theLruQueue.begin(), theLruQueue.end(), id);
@@ -280,6 +291,7 @@ void ossimFixedTileCache::adjustLru(ossim_int32 id)
 
 void ossimFixedTileCache::eraseFromLru(ossim_int32 id)
 {
+   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
    if(theUseLruFlag)
    {
       
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimFusionCombiner.cpp b/Utilities/otbossim/src/ossim/imaging/ossimFusionCombiner.cpp
index 6b6fac10a1218084540547946dbaa8ce20006ae2..eb1e2abb5110ab5d7a5db415d1715f3c3f8e50e7 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimFusionCombiner.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimFusionCombiner.cpp
@@ -8,7 +8,7 @@
 // Description: implementation for base fusion
 //
 //*************************************************************************
-// $Id: ossimFusionCombiner.cpp 9282 2006-07-17 14:50:54Z gpotts $
+// $Id: ossimFusionCombiner.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimFusionCombiner.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
@@ -69,7 +69,7 @@ bool ossimFusionCombiner::canConnectMyInputTo(ossim_int32 inputIndex,
 					      const ossimConnectableObject* object)const
 {
   return ((inputIndex<2)&&
-	  (PTR_CAST(ossimImageSourceInterface, object)||!object));
+	  (PTR_CAST(ossimImageSource, object)||!object));
 }
 
 ossimScalarType ossimFusionCombiner::getOutputScalarType() const
@@ -169,14 +169,14 @@ void ossimFusionCombiner::initialize()
 {
    ossimImageCombiner::initialize();
    
-   theInputConnection     = PTR_CAST(ossimImageSourceInterface, getInput(0));
-   theIntensityConnection = PTR_CAST(ossimImageSourceInterface, getInput(1));
+   theInputConnection     = PTR_CAST(ossimImageSource, getInput(0));
+   theIntensityConnection = PTR_CAST(ossimImageSource, getInput(1));
 
    if(getInput(0)&&getInput(1))
    {
-      ossimImageSourceInterface* temp  = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* temp  = PTR_CAST(ossimImageSource,
                                                   getInput(0));
-      ossimImageSourceInterface* temp2 = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* temp2 = PTR_CAST(ossimImageSource,
                                                   getInput(1));
 
       if(temp&&temp2)
@@ -184,9 +184,9 @@ void ossimFusionCombiner::initialize()
          if((temp->getNumberOfOutputBands()==1)&&
             (temp2->getNumberOfOutputBands()!=1))
          {
-            theIntensityConnection = PTR_CAST(ossimImageSourceInterface,
+            theIntensityConnection = PTR_CAST(ossimImageSource,
                                               getInput(0));
-            theInputConnection     = PTR_CAST(ossimImageSourceInterface,
+            theInputConnection     = PTR_CAST(ossimImageSource,
                                               getInput(1));
          }
       }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp
index 6912d8d160ae1297112245ae77f8d91e57fb5bf4..99d9da2e66fdea24239e0e6344b80048564b9a85 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterTileSource.cpp
@@ -8,7 +8,7 @@
 //
 // Contains class definition for ossimGeneralRasterTileSource.
 //*******************************************************************
-//  $Id: ossimGeneralRasterTileSource.cpp 11347 2007-07-23 13:01:59Z gpotts $
+//  $Id: ossimGeneralRasterTileSource.cpp 13768 2008-10-22 19:32:18Z gpotts $
 
 #include <ossim/imaging/ossimGeneralRasterTileSource.h>
 #include <ossim/base/ossimConstants.h>
@@ -997,6 +997,11 @@ bool ossimGeneralRasterTileSource::initializeHandler()
    // Get the buffer size.  This is bytes, not pixels.
    ossim_int32 buffer_size = theBufferSizeInPixels * theImageData.bytesPerPixel();
 
+   if(theBuffer)
+   {
+      delete [] theBuffer;
+      theBuffer = 0;
+   }
    theBuffer = new ossim_uint8[buffer_size];
 
    // Set the buffer interleave type.
@@ -1093,7 +1098,7 @@ void ossimGeneralRasterTileSource::close()
    if (theBuffer)
    {
       delete [] theBuffer;
-      theBuffer = NULL;
+      theBuffer = 0;
    }
 
    // Delete the list of input streams and clear the list.
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeneralRasterWriter.cpp
index 2ba66e08e5936bb315ffa80bc27fdd5a0988bece..cca21c5c8ebb5b27046eeedad6eb282316ef2fab 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 12980 2008-06-04 00:50:33Z dburken $
+//  $Id: ossimGeneralRasterWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <cstdlib>
 #include <fstream>
@@ -196,7 +196,7 @@ bool ossimGeneralRasterWriter::writeToBip()
    
    //---
    // Get an arbitrary tile just to get the size in bytes!
-   // This should be changed later... An ossimImageSourceInterface should know
+   // This should be changed later... An ossimImageSource should know
    // this.
    //---
    ossimRefPtr<ossimImageData> id;
@@ -342,7 +342,7 @@ bool ossimGeneralRasterWriter::writeToBil()
 
    //***
    // Get an arbitrary tile just to get the size in bytes!
-   // This should be changed later... An ossimImageSourceInterface should know
+   // This should be changed later... An ossimImageSource should know
    // this.
    //***
    ossimRefPtr<ossimImageData> id;
@@ -477,7 +477,7 @@ bool ossimGeneralRasterWriter::writeToBsq()
 
    //***
    // Get an arbitrary tile just to get the size in bytes!
-   // This should be changed later... An ossimImageSourceInterface should know
+   // This should be changed later... An ossimImageSource should know
    // this.
    //***
    ossimRefPtr<ossimImageData> id;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp
index 758cdaf8ba7d116cc6885cd9589b64cd0fdb014d..1a95f094abeaeec56794a685245d86f5eddbb2aa 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationBitmap.cpp
@@ -8,10 +8,12 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationBitmap.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationBitmap.cpp 13348 2008-07-30 15:33:53Z dburken $
 
 #include <ossim/imaging/ossimGeoAnnotationBitmap.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
 #include <ossim/base/ossimIrect.h>
 
 RTTI_DEF1(ossimGeoAnnotationBitmap,
@@ -56,7 +58,42 @@ ossimGeoAnnotationBitmap::ossimGeoAnnotationBitmap(
 ossimGeoAnnotationBitmap::~ossimGeoAnnotationBitmap()
 {
 }
+
+ossimObject* ossimGeoAnnotationBitmap::dup()const
+{
+   return new ossimGeoAnnotationBitmap(*this);
+}
+
+bool ossimGeoAnnotationBitmap::intersects(const ossimDrect& rect) const
+{
+   if(theImageData.valid())
+   {
+      return theImageData->getImageRectangle().intersects(rect);
+   }
+   
+   return false;
+}
+
+ossimGeoAnnotationBitmap* ossimGeoAnnotationBitmap::getNewClippedObject(
+   const ossimDrect& rect)const
+{
+   ossimGeoAnnotationBitmap* result = (ossimGeoAnnotationBitmap*)dup();
+   
+   ossimNotify(ossimNotifyLevel_WARN)
+      << "ossimGeoAnnotationBitmap::getNewClippedObject WRNING: "
+      << "not implemented" << std::endl;
    
+   return result;
+}
+
+void ossimGeoAnnotationBitmap::applyScale(double x, double y)
+{
+     ossimNotify(ossimNotifyLevel_WARN)
+      << "ossimGeoAnnotationBitmap::applyScale WRNING: not implemented"
+      << std::endl; 
+}
+
+
 std::ostream& ossimGeoAnnotationBitmap::print(std::ostream& out)const
 {
    out << "center:    " << theCenterPoint << endl;
@@ -142,8 +179,7 @@ void ossimGeoAnnotationBitmap::transform(ossimProjection* projection)
 {
    if(projection)
    {
-      projection->worldToLineSample(theCenterPoint,
-                                    theProjectedPoint);
+      projection->worldToLineSample(theCenterPoint, theProjectedPoint);
       theProjectedPoint = ossimIpt(theProjectedPoint);
       if(theImageData.valid())
       {
@@ -155,6 +191,43 @@ 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 e09445e411afa3af09ff4afcc4fa9084de942754..79ddc572bf0d8b0867e366fd9363a4aaebb43f6a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationEllipseObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationEllipseObject.cpp
@@ -5,13 +5,15 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationEllipseObject.cpp 11570 2007-08-10 19:59:59Z dburken $
+// $Id: ossimGeoAnnotationEllipseObject.cpp 13348 2008-07-30 15:33:53Z dburken $
 
 #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>
 #include <ossim/base/ossimUnitTypeLut.h>
 #include <ossim/base/ossimUnitConversionTool.h>
 
@@ -156,6 +158,44 @@ 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
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp
index a74722e5304fbeb181cb31a9c9299c6a33aa56d5..32f0711f311ac56c39b0234b83bd0a6c042ea53a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationFontObject.cpp
@@ -4,15 +4,17 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-//$Id: ossimGeoAnnotationFontObject.cpp 11411 2007-07-27 13:53:51Z dburken $
+//$Id: ossimGeoAnnotationFontObject.cpp 13965 2009-01-14 16:30:52Z gpotts $
 
 #include <sstream>
 
 #include <ossim/imaging/ossimGeoAnnotationFontObject.h>
 #include <ossim/imaging/ossimAnnotationFontObject.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
 #include <ossim/font/ossimFont.h>
 #include <ossim/font/ossimFontFactoryRegistry.h>
+#include <ossim/base/ossimException.h>
 #include <ossim/base/ossimNotifyContext.h>
 
 RTTI_DEF1(ossimGeoAnnotationFontObject,
@@ -186,7 +188,36 @@ void ossimGeoAnnotationFontObject::transform(ossimProjection* projection)
       ossimDpt ipt;
 
       projection->worldToLineSample(theCenterGround, ipt);
-      theAnnotationFontObject->setPositionCenter(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();
    }
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp
index ceb89fe31dfab26699097a2c383895d634b1ad7a..ff948885edcdccc64588d6b43518121d672763a2 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationGdBitmapFont.cpp
@@ -6,12 +6,16 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationGdBitmapFont.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimGeoAnnotationGdBitmapFont.cpp 13348 2008-07-30 15:33:53Z dburken $
 #include <ossim/imaging/ossimGeoAnnotationGdBitmapFont.h>
 #include <ossim/imaging/ossimAnnotationGdBitmapFont.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
 
-RTTI_DEF1(ossimGeoAnnotationGdBitmapFont, "ossimGeoAnnotationGdBitmapFont", ossimGeoAnnotationObject)
+RTTI_DEF1(ossimGeoAnnotationGdBitmapFont,
+          "ossimGeoAnnotationGdBitmapFont",
+          ossimGeoAnnotationObject)
 
 ossimGeoAnnotationGdBitmapFont::ossimGeoAnnotationGdBitmapFont(const ossimGpt& position,
                                                                const ossimString &text,
@@ -34,21 +38,25 @@ ossimGeoAnnotationGdBitmapFont::ossimGeoAnnotationGdBitmapFont(const ossimGpt& p
 
 ossimGeoAnnotationGdBitmapFont::ossimGeoAnnotationGdBitmapFont(const ossimGeoAnnotationGdBitmapFont& rhs)
    :ossimGeoAnnotationObject(rhs),
-    theProjectedFont(rhs.theProjectedFont?(ossimAnnotationGdBitmapFont*)theProjectedFont->dup():(ossimAnnotationGdBitmapFont*)NULL),
+    theProjectedFont(rhs.theProjectedFont?(ossimAnnotationGdBitmapFont*)theProjectedFont->dup():(ossimAnnotationGdBitmapFont*)0),
     thePosition(rhs.thePosition)
 {
 }
 
-
 ossimGeoAnnotationGdBitmapFont::~ossimGeoAnnotationGdBitmapFont()
 {
    if(theProjectedFont)
    {
       delete theProjectedFont;
-      theProjectedFont=NULL;
+      theProjectedFont=0;
    }
 }
 
+ossimObject* ossimGeoAnnotationGdBitmapFont::dup()const
+{
+   return new ossimGeoAnnotationGdBitmapFont(*this);
+}
+
 void ossimGeoAnnotationGdBitmapFont::applyScale(double x, double y)
 {
    thePosition.lond(thePosition.lond()*x);
@@ -97,7 +105,7 @@ ossimAnnotationObject* ossimGeoAnnotationGdBitmapFont::getNewClippedObject(const
       }
    }
    
-   return (ossimAnnotationObject*)NULL;
+   return (ossimAnnotationObject*)0;
 }
 
 void ossimGeoAnnotationGdBitmapFont::computeBoundingRect()
@@ -108,12 +116,37 @@ void ossimGeoAnnotationGdBitmapFont::computeBoundingRect()
 void ossimGeoAnnotationGdBitmapFont::transform(ossimProjection* projection)
 {
    ossimDpt position;
-
    projection->worldToLineSample(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 87d6ce54d1ecebd539566b53fa9c63c0bdd1b84c..b5e3ba0db652d55227c8a17772bcddd58ce9e59b 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationLineObject.cpp
@@ -6,12 +6,17 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationLineObject.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimGeoAnnotationLineObject.cpp 13348 2008-07-30 15:33:53Z dburken $
 #include <ossim/imaging/ossimGeoAnnotationLineObject.h>
 #include <ossim/imaging/ossimAnnotationLineObject.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
 
-RTTI_DEF1(ossimGeoAnnotationLineObject, "ossimGeoAnnotationLineObject", ossimGeoAnnotationObject)
+
+RTTI_DEF1(ossimGeoAnnotationLineObject,
+          "ossimGeoAnnotationLineObject",
+          ossimGeoAnnotationObject)
    
 ossimGeoAnnotationLineObject::ossimGeoAnnotationLineObject(const ossimGpt& start,
                                                            const ossimGpt& end,
@@ -20,7 +25,7 @@ ossimGeoAnnotationLineObject::ossimGeoAnnotationLineObject(const ossimGpt& start
                                                            unsigned char b,
                                                            long thickness)
    :ossimGeoAnnotationObject(r, g, b, thickness),
-    theProjectedLineObject(NULL),
+    theProjectedLineObject(0),
     theStart(start),
     theEnd(end)
 {
@@ -34,7 +39,7 @@ ossimGeoAnnotationLineObject::ossimGeoAnnotationLineObject(const ossimGpt& start
 
 ossimGeoAnnotationLineObject::ossimGeoAnnotationLineObject(const ossimGeoAnnotationLineObject& rhs)
    :ossimGeoAnnotationObject(rhs),
-    theProjectedLineObject(rhs.theProjectedLineObject?(ossimAnnotationLineObject*)rhs.theProjectedLineObject->dup():(ossimAnnotationLineObject*)NULL),
+    theProjectedLineObject(rhs.theProjectedLineObject?(ossimAnnotationLineObject*)rhs.theProjectedLineObject->dup():(ossimAnnotationLineObject*)0),
     theStart(rhs.theStart),
     theEnd(rhs.theEnd)
 {
@@ -47,10 +52,15 @@ ossimGeoAnnotationLineObject::~ossimGeoAnnotationLineObject()
    if(theProjectedLineObject)
    {
       delete theProjectedLineObject;
-      theProjectedLineObject = NULL;
+      theProjectedLineObject = 0;
    }
 }
 
+ossimObject* ossimGeoAnnotationLineObject::dup()const
+{
+   return new ossimGeoAnnotationLineObject(*this);
+}
+
 void ossimGeoAnnotationLineObject::applyScale(double x, double y)
 {
    theStart.lond(theStart.lond()*x);
@@ -71,13 +81,43 @@ void ossimGeoAnnotationLineObject::transform(ossimProjection* projection)
       ossimDpt projectedStart;
       ossimDpt projectedEnd;
       
-      projection->worldToLineSample(theStart,
-                                    projectedStart);
-      projection->worldToLineSample(theEnd,
-                                    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;
+         }
+      }
 
-      theProjectedLineObject->setLine(projectedStart,
-                                      projectedEnd);
+      theProjectedLineObject->setLine(projectedStart, projectedEnd);
    }
 }
 
@@ -113,7 +153,7 @@ ossimAnnotationObject* ossimGeoAnnotationLineObject::getNewClippedObject(const o
       }
    }
    
-   return (ossimAnnotationObject*)NULL;
+   return (ossimAnnotationObject*)0;
 }
 
 void ossimGeoAnnotationLineObject::getBoundingRect(ossimDrect& rect)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp
index 576e3455125dddf9145024f9bf5bbcaf08cfc03c..a559812f73c72ae0a43239fcc09d5a178fbf6a47 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiEllipseObject.cpp
@@ -5,11 +5,13 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiEllipseObject.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimGeoAnnotationMultiEllipseObject.cpp 13348 2008-07-30 15:33:53Z dburken $
 
 #include <ossim/imaging/ossimGeoAnnotationMultiEllipseObject.h>
 #include <ossim/imaging/ossimAnnotationMultiEllipseObject.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
 
 ossimGeoAnnotationMultiEllipseObject::ossimGeoAnnotationMultiEllipseObject()
    :ossimGeoAnnotationObject(),
@@ -58,13 +60,12 @@ ossimGeoAnnotationMultiEllipseObject::ossimGeoAnnotationMultiEllipseObject(const
 {
 }
    
-void ossimGeoAnnotationMultiEllipseObject::transform(ossimProjection* projection)
+void ossimGeoAnnotationMultiEllipseObject::transform(
+   ossimProjection* projection)
 {
-   theProjectedObject->resize(thePointList.size());
-   int i = 0;
-   int bounds = (int)thePointList.size();
-
-   for(i = 0; i < bounds; ++i)
+   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]);
       
@@ -72,6 +73,43 @@ void ossimGeoAnnotationMultiEllipseObject::transform(ossimProjection* projection
    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 8b6dcd8a682eaf0a7641b84f93574d3eba5b655b..c042e7988edd227a54e2b12525eab3c18caa66ae 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.cpp
@@ -5,13 +5,16 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiPolyLineObject.cpp 11411 2007-07-27 13:53:51Z dburken $
+// $Id: ossimGeoAnnotationMultiPolyLineObject.cpp 13711 2008-10-14 16:49:38Z gpotts $
 
 #include <sstream>
 
 #include <ossim/imaging/ossimGeoAnnotationMultiPolyLineObject.h>
 #include <ossim/imaging/ossimAnnotationMultiPolyLineObject.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
+
 
 RTTI_DEF1(ossimGeoAnnotationMultiPolyLineObject,
           "ossimGeoAnnotationMultiPolyLineObject",
@@ -101,7 +104,9 @@ void ossimGeoAnnotationMultiPolyLineObject::transform(ossimProjection* projectio
       theProjectedPolyLineObject->getMultiPolyLine();
    ossimGpt tempPoint(0,0, ossim::nan(), theDatum);
    
-   for(ossim_uint32 polyI = 0; polyI < theMultiPolyLine.size(); ++polyI)
+   for(std::vector<ossimPolyLine>::size_type polyI = 0;
+       polyI < theMultiPolyLine.size();
+       ++polyI)
    {
       ossimPolyLine polyLine;
       
@@ -122,6 +127,74 @@ 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)
@@ -301,10 +374,10 @@ bool ossimGeoAnnotationMultiPolyLineObject::loadState(
       {
          ++numberOfMatches;
          ossimDpt dpt;
-
+         ossimString x,y;
          std::istringstream is(lookup);
-         is >> dpt.x >> dpt.y;
-         pl.addPoint(dpt);
+         is >> x >> y;
+         pl.addPoint(ossimDpt(x.toDouble(), y.toDouble()));
       }
 
       if (pl.size() == 2)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp
index dfdf4d87282b0cf2523f5a79c9679b5476211871..15c8158fcf878bbf223d643b34ac84ff1f352a7c 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationMultiPolyObject.cpp
@@ -5,11 +5,13 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationMultiPolyObject.cpp 10849 2007-05-04 17:42:14Z dburken $
+// $Id: ossimGeoAnnotationMultiPolyObject.cpp 13348 2008-07-30 15:33:53Z dburken $
 
 #include <ossim/imaging/ossimGeoAnnotationMultiPolyObject.h>
 #include <ossim/imaging/ossimAnnotationMultiPolyObject.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
 #include <ossim/base/ossimPolyArea2d.h>
 
 RTTI_DEF1(ossimGeoAnnotationMultiPolyObject, "ossimGeoAnnotationMultiPolyObject", ossimGeoAnnotationObject);
@@ -53,6 +55,11 @@ ossimGeoAnnotationMultiPolyObject::ossimGeoAnnotationMultiPolyObject(const ossim
 {
 }
 
+ossimObject* ossimGeoAnnotationMultiPolyObject::dup()const
+{
+   return new ossimGeoAnnotationMultiPolyObject(*this);
+}
+
 ossimGeoAnnotationMultiPolyObject::~ossimGeoAnnotationMultiPolyObject()
 {
    if(theProjectedPolyObject)
@@ -116,6 +123,75 @@ 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)
@@ -153,7 +229,54 @@ void ossimGeoAnnotationMultiPolyObject::getBoundingRect(ossimDrect& rect)const
 {
    rect = theBoundingRect;
 }
- 
+
+void ossimGeoAnnotationMultiPolyObject::addPoint(ossim_uint32 polygonIndex,
+                                                 const ossimGpt& pt)
+{
+   if(polygonIndex < theMultiPolygon.size())
+   {
+      theMultiPolygon[polygonIndex].addPoint(pt);
+      
+      // we will have to reset the projected polygon
+      if(theProjectedPolyObject)
+      {
+         delete theProjectedPolyObject;
+         theProjectedPolyObject = 0;
+      }
+   }
+}
+
+void ossimGeoAnnotationMultiPolyObject::setMultiPolygon(
+   const vector<ossimGeoPolygon>& multiPoly)
+{
+   theMultiPolygon = multiPoly;
+   if(theProjectedPolyObject)
+   {
+      delete theProjectedPolyObject;
+      theProjectedPolyObject = 0;
+   }
+}
+
+void ossimGeoAnnotationMultiPolyObject::setColor(unsigned char r,
+                                                 unsigned char g,
+                                                 unsigned char b)
+{
+   ossimAnnotationObject::setColor(r, g, b);
+   if(theProjectedPolyObject)
+   {
+      theProjectedPolyObject->setColor(r, g, b);
+   }
+}
+
+void ossimGeoAnnotationMultiPolyObject::setThickness(ossim_uint8 thickness)
+{
+   ossimAnnotationObject::setThickness(thickness);
+   if(theProjectedPolyObject)
+   {
+      theProjectedPolyObject->setThickness(thickness);
+   }
+}
+
 void ossimGeoAnnotationMultiPolyObject::computeBoundingRect()
 {
    theBoundingRect.makeNan();
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp
index 7015d3304f2996a26dccaebbab3acccfa3b6926c..54d97b8aedd5ec97bee834b27c00d3ddc1b0e059 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyLineObject.cpp
@@ -6,10 +6,13 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyLineObject.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimGeoAnnotationPolyLineObject.cpp 13348 2008-07-30 15:33:53Z dburken $
 #include <ossim/imaging/ossimGeoAnnotationPolyLineObject.h>
 #include <ossim/imaging/ossimAnnotationMultiLineObject.h>
 #include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/base/ossimException.h>
+
 
 RTTI_DEF1(ossimGeoAnnotationPolyLineObject,
           "ossimGeoAnnotationPolyLineObject",
@@ -22,7 +25,7 @@ ossimGeoAnnotationPolyLineObject::ossimGeoAnnotationPolyLineObject(
    ossim_uint8 b,
    ossim_uint8 thickness)
    :ossimGeoAnnotationObject(r, g, b, thickness),
-    theProjectedMultiLineObject(NULL)
+    theProjectedMultiLineObject(0)
 {
 
    thePolygon = groundPts;
@@ -52,10 +55,15 @@ ossimGeoAnnotationPolyLineObject::~ossimGeoAnnotationPolyLineObject()
    if(theProjectedMultiLineObject)
    {
       delete theProjectedMultiLineObject;
-      theProjectedMultiLineObject = NULL;
+      theProjectedMultiLineObject = 0;
    }
 }
 
+ ossimObject* ossimGeoAnnotationPolyLineObject::dup()const
+{
+   return new ossimGeoAnnotationPolyLineObject(*this);
+}
+
 void ossimGeoAnnotationPolyLineObject::applyScale(double x,
                                                    double y)
 {
@@ -78,25 +86,74 @@ void ossimGeoAnnotationPolyLineObject::transform(ossimProjection* projection)
    {
       return;
    }
-   vector<ossimPolyLine>& polyList =theProjectedMultiLineObject->getPolyLineList();
+   vector<ossimPolyLine>& polyList =
+      theProjectedMultiLineObject->getPolyLineList();
 
    if(polyList.size())
    {
       vector<ossimDpt>& poly = polyList[0].getVertexList();
       
-      long upperBound = thePolygon.size();
+      const std::vector<ossimGpt>::size_type BOUNDS = thePolygon.size();
       
-      for(long index=0; index < upperBound; ++index)
+      for(std::vector<ossimGpt>::size_type index=0; index < BOUNDS; ++index)
       {
          projection->worldToLineSample(thePolygon[index], poly[index]);
       }
       
       // update the bounding rect
-      //
       theProjectedMultiLineObject->computeBoundingRect();
    }
 }
 
+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 52f7c9b6286c57a35f1a2fc3b6874ef34956b235..0a6937e5839c3fe74a7a8d5e72b90e97244c1e04 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyObject.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimGeoAnnotationPolyObject.cpp
@@ -6,13 +6,15 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimGeoAnnotationPolyObject.cpp 9479 2006-08-31 20:46:39Z gpotts $
+// $Id: ossimGeoAnnotationPolyObject.cpp 13387 2008-08-04 21:30:04Z dburken $
 
 #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>
 #include <ossim/base/ossimTrace.h>
 
 static const ossimTrace
@@ -111,9 +113,9 @@ void ossimGeoAnnotationPolyObject::transform(ossimProjection* projection)
       return;
    }
    ossimPolygon& poly = theProjectedPolyObject->getPolygon();
-   long upperBound = thePolygon.size();
-
-   for(long index=0; index < upperBound; ++index)
+   const std::vector<ossimGpt>::size_type BOUNDS = thePolygon.size();
+   
+   for(std::vector<ossimGpt>::size_type index=0; index < BOUNDS; ++index)
    {
       projection->worldToLineSample(thePolygon[index], poly[index]);
    }
@@ -123,6 +125,46 @@ 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;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimHistogramRemapper.cpp b/Utilities/otbossim/src/ossim/imaging/ossimHistogramRemapper.cpp
index 1d511d5500b6645a3767067b60a09265418c700c..6e33a4b856551d08fa4fc05eb493d592ee5e7585 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 12980 2008-06-04 00:50:33Z dburken $
+// $Id: ossimHistogramRemapper.cpp 13829 2008-10-31 19:11:59Z dburken $
 
 #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 12980 2008-06-04 00:50:33Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimHistogramRemapper.cpp 13829 2008-10-31 19:11:59Z dburken $";
 #endif
 
 ossimHistogramRemapper::ossimHistogramRemapper()
@@ -51,13 +51,13 @@ ossimHistogramRemapper::ossimHistogramRemapper()
    theStretchMode(ossimHistogramRemapper::LINEAR_ONE_PIECE),
    theDirtyFlag(false),
    theHistogram(0),
-   theTableSizeInBytes(0),
    theNormalizedLowClipPoint(),
    theNormalizedHighClipPoint(),
    theMidPoint(),
    theMinOutputValue(),
    theMaxOutputValue(),
-   theBandList()
+   theBandList(),
+   theByPassFlag(true)
 {
    if (traceDebug())
    {
@@ -68,23 +68,10 @@ ossimHistogramRemapper::ossimHistogramRemapper()
          << "OSSIM_ID:  " << OSSIM_ID << "\n";
 #endif      
    }
-	
-   disableSource();
-	
-   //---
-   // We will control the allocation and deletion of "theTable" so set the
-   // base class ownership flag to false (ossimTableRemapper does not own).
-   //---
-   setTableOwnership(false);
 }
 
 ossimHistogramRemapper::~ossimHistogramRemapper()
 {
-   if (theTable)
-   {
-      delete [] theTable;
-      theTable = 0;
-   }
 }
 
 void ossimHistogramRemapper::initialize()
@@ -113,12 +100,8 @@ void ossimHistogramRemapper::initialize()
          // Somethings changed.  Set everthing back.
          initializeClips();
          setNullCount();
-         if (theTable)
-         {
-            delete [] theTable;
-            theTable = 0;
-            recomputeAutoFlag = true;
-         }
+         theTable.clear();
+         recomputeAutoFlag = true;
       }
       else
       {
@@ -183,11 +166,7 @@ ossimHistogramRemapper::setHistogram(ossimRefPtr<ossimMultiResLevelHistogram> hi
    // Note: initializeClips before setNullCount since it relies on clips.
    initializeClips();
 	
-   if (theTable)
-   {
-      delete [] theTable;
-      theTable = 0;
-   }
+   theTable.clear();
 }
 
 bool ossimHistogramRemapper::openHistogram(const ossimFilename& histogram_file)
@@ -195,7 +174,7 @@ bool ossimHistogramRemapper::openHistogram(const ossimFilename& histogram_file)
    ossimRefPtr<ossimMultiResLevelHistogram> h = new ossimMultiResLevelHistogram();
    if (h->importHistogram(histogram_file))
    {
-      setHistogram(h); // True for, "I own it!"
+      setHistogram(h);
       return true;
    }
 	
@@ -207,19 +186,23 @@ ossimRefPtr<ossimImageData> ossimHistogramRemapper::getTile(
    const ossimIrect& tile_rect,
    ossim_uint32 resLevel)
 {
-   if((theStretchMode == STRETCH_UNKNOWN)||(!theEnableFlag))
+   ossimRefPtr<ossimImageData> result = 0;
+   if((theStretchMode == STRETCH_UNKNOWN)||(!theEnableFlag)||(theByPassFlag))
    {
       if(theInputConnection)
       {
-         return theInputConnection->getTile(tile_rect, resLevel);
+         result = theInputConnection->getTile(tile_rect, resLevel);
       }
-      return ossimRefPtr<ossimImageData>();
    }
-   if (theDirtyFlag || !theTable)
+   else // need remap
    {
-      buildTable();
+      if (theDirtyFlag || theTable.empty())
+      {
+         buildTable();
+      }
+      result = ossimTableRemapper::getTile(tile_rect, resLevel);
    }
-   return ossimTableRemapper::getTile(tile_rect, resLevel);
+   return result;
 }
 
 void ossimHistogramRemapper::setLowNormalizedClipPoint(const ossim_float64& clip)
@@ -762,7 +745,6 @@ bool ossimHistogramRemapper::loadState(const ossimKeywordlist& kwl,
                                        const char* prefix)
 {
    static const char MODULE[] = "ossimHistogramRemapper::loadState";
-	
    if (traceDebug())
    {
       CLOG << " Entered..."
@@ -905,7 +887,7 @@ bool ossimHistogramRemapper::loadState(const ossimKeywordlist& kwl,
          theStretchMode = ossimHistogramRemapper::STRETCH_UNKNOWN;
       }
    }
-	
+
    // Load the base class states...
    bool status = ossimTableRemapper::loadState(kwl, prefix);
 	
@@ -1006,6 +988,8 @@ bool ossimHistogramRemapper::saveState(ossimKeywordlist& kwl,
               theMaxOutputValue[band],
               true);
    }
+
+   return ossimConnectableObject::saveState(kwl, prefix);
    
    return ossimTableRemapper::saveState(kwl, prefix);
 }
@@ -1079,6 +1063,8 @@ void ossimHistogramRemapper::buildTable()
          }
          break;
    }
+
+   verifyEnabled();
 	
    if (traceDebug())
    {
@@ -1193,18 +1179,22 @@ template <class T> void ossimHistogramRemapper::buildLinearTable(T /* dummy */)
    theTableType = ossimTableRemapper::NATIVE;
    
    const ossim_uint32 BANDS = getNumberOfInputBands();
-	
+   theByPassFlag = false;
+   
    // Sanity check.
    if (theNormalizedLowClipPoint.size() != BANDS || !theHistogram)
    {
-      theEnableFlag = false;
-      ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimHistogramRemapper::buildTable ERROR!"
-         << " Line:  " << __LINE__ << endl;
+      theByPassFlag = true;
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimHistogramRemapper::buildTable ERROR!"
+            << " Line:  " << __LINE__ << endl;
+      }
       return;
    }
    
-   T* table = reinterpret_cast<T*>(theTable);
+   T* table = reinterpret_cast<T*>(&theTable.front());
    ossim_uint32 index = 0;
    
    // Finally, build the table...
@@ -1224,10 +1214,13 @@ template <class T> void ossimHistogramRemapper::buildLinearTable(T /* dummy */)
 		
       if (!h)
       {
-         theEnableFlag = false;
-         ossimNotify(ossimNotifyLevel_WARN)
+         theByPassFlag = true;
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "ossimHistogramRemapper::buildTable ERROR!"
             << " Line:  " << __LINE__ << endl;
+         }
          return; 
       }
 		
@@ -1278,15 +1271,19 @@ template <class T> void ossimHistogramRemapper::buildLinearTable(T /* dummy */)
 template <class T> void ossimHistogramRemapper::buildAutoLinearMinMaxTableTemplate(T /* dummy */)
 {
    const ossim_uint32 BANDS = getNumberOfInputBands();
+	theByPassFlag = false;
 	
    // Sanity check.
    if (theNormalizedLowClipPoint.size() != BANDS || !theHistogram)
    {
-      theEnableFlag = false;
-      ossimNotify(ossimNotifyLevel_WARN)
+      theByPassFlag = true;
+		if(traceDebug())
+		{
+			ossimNotify(ossimNotifyLevel_WARN)
          << "ossimHistogramRemapper::buildTable ERROR!"
          << " Line:  " << __LINE__ << endl;
-      return;
+		}
+		return;
    }
    for (ossim_uint32 band = 0; band < BANDS; ++band)
    {
@@ -1356,16 +1353,21 @@ void ossimHistogramRemapper::buildLinearTableStdFromMean()
 {
    const ossim_uint32 BANDS = getNumberOfInputBands();
 	
+   theByPassFlag = false;
+   
    // Sanity check.
    if (theNormalizedLowClipPoint.size() != BANDS || !theHistogram)
    {
-      theEnableFlag = false;
-      ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimHistogramRemapper::buildTable ERROR!"
-         << " Line:  " << __LINE__ << endl;
+      theByPassFlag = true;
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossimHistogramRemapper::buildTable ERROR!"
+            << " Line:  " << __LINE__ << endl;
+      }
       return;
    }
-	
+   
    ossim_float64 multiplier = 1.0;
    if (theStretchMode == LINEAR_2STD_FROM_MEAN)
    {
@@ -1422,14 +1424,15 @@ void ossimHistogramRemapper::initializeClips()
 
 void ossimHistogramRemapper::initializeClips(ossim_uint32 bands)
 {
-   theEnableFlag = false;
    theDirtyFlag  = false;
 	
    if (bands == 0)
    {
       return;
    }
-	
+   
+   theByPassFlag = false;
+   
    theNormalizedLowClipPoint.resize(bands);
    theNormalizedHighClipPoint.resize(bands);
    theMidPoint.resize(bands);
@@ -1506,8 +1509,10 @@ ostream& ossimHistogramRemapper::print(ostream& os) const
       << "\nossimHistogramRemapper::print:"
       << "\ntheStretchMode:         " << getStretchModeString().c_str()
       << "\ntheDirtyFlag:           " << (theDirtyFlag?"true":"false")
+      << "\ntheByPassFlag:          " << (theByPassFlag?"true":"false")
+      
       << "\ntheHistogram:           " << (theHistogram.valid()?"initialized":"null")
-      << "\ntheTableSizeInBytes:    " << theTableSizeInBytes
+      << "\ntheTableSizeInBytes:    " << theTable.size()
       << endl;
 	
    const ossim_uint32 BANDS = (ossim_uint32)theNormalizedLowClipPoint.size();
@@ -1603,20 +1608,13 @@ void ossimHistogramRemapper::setupTable()
    
    theTableBinCount  = values_per_band;
    theTableBandCount = BANDS;
-	
    // Check the size of the table prior to deletion and making a new one.
    ossim_uint32 size_in_bytes = values_per_band * BANDS * bytes_per_pixel;
-	
-   if (!theTable || (theTableSizeInBytes != size_in_bytes))
+   if(theTable.empty() || (theTable.size() != size_in_bytes))
    {
-      if (theTable)
-      {
-         delete [] theTable;
-      }
-      theTable = new ossim_uint8[size_in_bytes];
-      theTableSizeInBytes = size_in_bytes;
+      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
@@ -1640,33 +1638,39 @@ void ossimHistogramRemapper::setupTable()
 
 void ossimHistogramRemapper::verifyEnabled()
 {
-   theEnableFlag = false;
-	
-   if (!theInputConnection)
-   {
-      //---
-      // Since this filter can be constructed with no input connection do not
-      // output and error, simply return.
-      //---
-      return;
-   }
-	
-   const ossim_uint32 BANDS = (ossim_uint32)theNormalizedLowClipPoint.size();
-   for (ossim_uint32 band = 0; band < BANDS; ++band)
+   theByPassFlag = true;
+
+   //---
+   // Since this filter can be constructed with no input connection do not
+   // output and error, simply return.
+   //---	
+   if (theInputConnection)
    {
-      const double MIN = getMinPixelValue(band);
-      const double MAX = getMaxPixelValue(band);
       
-      if ( theNormalizedLowClipPoint[band]  != 0.0   ||
-           theNormalizedHighClipPoint[band] != 1.0   ||
-           // theMidPoint != 0.0 || ????
-           theMinOutputValue[band] != MIN ||
-           theMaxOutputValue[band] != MAX )
+      const ossim_uint32 BANDS =
+         (ossim_uint32)theNormalizedLowClipPoint.size();
+      for (ossim_uint32 band = 0; band < BANDS; ++band)
       {
-         theEnableFlag = true;
-         break;
+         const double MIN = getMinPixelValue(band);
+         const double MAX = getMaxPixelValue(band);
+         
+         if ( theNormalizedLowClipPoint[band]  != 0.0   ||
+              theNormalizedHighClipPoint[band] != 1.0   ||
+              // theMidPoint != 0.0 || ????
+              theMinOutputValue[band] != MIN ||
+              theMaxOutputValue[band] != MAX )
+         {
+            theByPassFlag = false;
+            break;
+         }
       }
    }
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "ossimHistogramRemapper::verifyEnabled theBypassFlag: "
+         << (theByPassFlag ? "true" : "false") << endl;
+   }
 }
 
 ossimRefPtr<ossimHistogram>
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimHistogramWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimHistogramWriter.cpp
index 0ff20405bfaf2b1d0c475e5089d9a4e65e621aa8..aca0ef466ff6853fb25770f19af672a38aa17549 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimHistogramWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimHistogramWriter.cpp
@@ -7,7 +7,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimHistogramWriter.cpp 12580 2008-03-26 18:54:03Z gpotts $
+// $Id: ossimHistogramWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/base/ossimProcessListener.h>
 #include <ossim/imaging/ossimHistogramWriter.h>
 #include <ossim/imaging/ossimImageSource.h>
@@ -137,7 +137,7 @@ bool ossimHistogramWriter::canConnectMyInputTo(
 {
    return (object&&(inputIndex == 0)&& 
            (PTR_CAST(ossimHistogramSource, object)||
-            PTR_CAST(ossimImageSourceInterface, object)));
+            PTR_CAST(ossimImageSource, object)));
 }
 
 const ossimObject* ossimHistogramWriter::getObject()const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimHsiRemapper.cpp b/Utilities/otbossim/src/ossim/imaging/ossimHsiRemapper.cpp
index b9c55a910554673ff1ec45e2a890fea8617bd9e0..8ad39d4ae4a827df6b3ddfa57c546e53c6115a43 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimHsiRemapper.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimHsiRemapper.cpp
@@ -12,7 +12,7 @@
 // Remapper to adjust hue, saturation and intensity.
 //
 //*************************************************************************
-// $Id: ossimHsiRemapper.cpp 12980 2008-06-04 00:50:33Z dburken $
+// $Id: ossimHsiRemapper.cpp 13764 2008-10-22 19:30:19Z gpotts $
 
 #include <cstdlib>
 #include <ossim/imaging/ossimHsiRemapper.h>
@@ -471,6 +471,11 @@ void ossimHsiRemapper::allocate(const ossimIrect& rect)
 
       ossim_uint32 width  = rect.width();
       ossim_uint32 height = rect.height();
+      if(theBuffer)
+      {
+         delete [] theBuffer;
+         theBuffer = 0;
+      }
       ossim_uint32 size = width * height * 3; // Buffer always 3 bands.
       theBuffer = new double[size];
       memset(theBuffer, '\0', sizeof(double) * size);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp b/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp
index 7c92e87a4ccebd0c744e68829da889e5f2d0f900..bf1bafc85ac09bd8f5f292ebb961ed8643c6b7ff 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimIgenGenerator.cpp
@@ -8,10 +8,10 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimIgenGenerator.cpp 11411 2007-07-27 13:53:51Z dburken $
+// $Id: ossimIgenGenerator.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimIgenGenerator.h>
 #include <ossim/base/ossimKeywordNames.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/imaging/ossimImageChain.h>
 #include <ossim/imaging/ossimGeoPolyCutter.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -77,7 +77,7 @@ void ossimIgenGenerator::setInput(ossimConnectableObject* input)
 {
    theSpecList.clear();
    generateInputKwl(input);
-   ossimImageSourceInterface* inputInterface = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inputInterface = PTR_CAST(ossimImageSource,
                                                         input);
    if(inputInterface)
    {
@@ -551,7 +551,7 @@ int ossimIgenGenerator::getTileId(const ossimDrect& rect,
 ossimIrect ossimIgenGenerator::getInputBoundingRect()const
 {
    ossimObject* obj = createInput();
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface, obj);
+   ossimImageSource* inter = PTR_CAST(ossimImageSource, obj);
    ossimIrect result;
 
    result.makeNan();
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp
index f36ceef241bff730c44a787c0475a511ae084cf5..c9e6f0494e51818efbbb8e0df971f0d40ec29289 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageChain.cpp
@@ -8,13 +8,14 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageChain.cpp 11949 2007-10-31 14:33:29Z gpotts $
+// $Id: ossimImageChain.cpp 13481 2008-08-22 16:23:15Z gpotts $
 #include <algorithm>
 #include <iostream>
 #include <iterator>
 
 #include <ossim/imaging/ossimImageChain.h>
 #include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimNotifyContext.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/base/ossimObjectFactoryRegistry.h>
@@ -37,16 +38,43 @@ public:
       :theChain(owner)
       {
       }
-   virtual void propertyEvent(ossimPropertyEvent& event);
-
+   virtual void processEvent(ossimEvent& event);
+//   virtual void propertyEvent(ossimPropertyEvent& event);
+//   virtual void refreshEvent(ossimRefreshEvent& /* event */);
    ossimImageChain* theChain;
 };
 
+void ossimImageChainChildListener::processEvent(ossimEvent& event)
+{
+   if(!theChain) return;
+   ossimConnectableObjectListener::processEvent(event);
+   ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject,
+                                          event.getCurrentObject());
+   
+   if((ossimConnectableObject*)theChain->getFirstSource() == obj)
+   {
+      if(event.isPropagatingToOutputs())
+      {
+         std::vector<ossimConnectableObject*>& outputList = theChain->getOutputList();
+         ossim_uint32 idx = 0;
+         for(idx = 0; idx < outputList.size();++idx)
+         {
+            if(outputList[idx])
+            {
+               outputList[idx]->fireEvent(event);
+               outputList[idx]->propagateEventToOutputs(event);
+            }
+         }
+      }
+   }
+}
+#if 0
 void ossimImageChainChildListener::propertyEvent(ossimPropertyEvent& event)
 {
    ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject,
                                           event.getObject());
    
+   
    // if it originated from within my chain then propagate up to parent
    // only if I have no outputs
    //
@@ -76,15 +104,20 @@ void ossimImageChainChildListener::propertyEvent(ossimPropertyEvent& event)
       }
    }
 }
+#endif
 
 ossimImageChain::ossimImageChain()
-   :ossimImageSource(),
+:ossimImageSource(0,
+                  0, // number of inputs
+                  0, // number of outputs
+                  false, // input's fixed
+                  false), // outputs ar not fixed
     ossimConnectableContainerInterface((ossimObject*)NULL),
     theBlankTile(NULL),
     theLoadStateFlag(false)
 {
    ossimConnectableContainerInterface::theBaseObject = this;
-   thePropagateEventFlag = false;
+   //thePropagateEventFlag = false;
    addListener((ossimConnectableObjectListener*)this);
    theChildListener = new ossimImageChainChildListener(this);
 }
@@ -114,7 +147,7 @@ bool ossimImageChain::addLast(ossimConnectableObject* obj)
    if(theImageChainList.size() > 0)
    {
       ossimConnectableObject* lastSource = theImageChainList[ theImageChainList.size() -1];
-      if(PTR_CAST(ossimImageSourceInterface, obj)&&lastSource)
+      if(PTR_CAST(ossimImageSource, obj)&&lastSource)
       {
          obj->disconnect();
          vector<ossimConnectableObject*> tempIn = getInputList();
@@ -140,11 +173,11 @@ bool ossimImageChain::addLast(ossimConnectableObject* obj)
    return false;;
 }
 
-ossimImageSourceInterface* ossimImageChain::getFirstSource()
+ossimImageSource* ossimImageChain::getFirstSource()
 {
    if(theImageChainList.size()>0)
    {
-      return PTR_CAST(ossimImageSourceInterface,
+      return PTR_CAST(ossimImageSource,
                       theImageChainList[0]);
    }
 
@@ -162,11 +195,11 @@ ossimObject* ossimImageChain::getFirstObject()
    return NULL;
 }
 
-ossimImageSourceInterface* ossimImageChain::getLastSource()
+ossimImageSource* ossimImageChain::getLastSource()
 {
    if(theImageChainList.size()>0)
    {
-      return PTR_CAST(ossimImageSourceInterface,
+      return PTR_CAST(ossimImageSource,
                       *(theImageChainList.end()-1));
    }
 
@@ -257,9 +290,9 @@ ossimConnectableObject* ossimImageChain::findObject(const ossimConnectableObject
    return NULL;
 }
 
-// ossimImageSourceInterface* ossimImageChain::findSource(const ossimId& id)
+// ossimImageSource* ossimImageChain::findSource(const ossimId& id)
 // {
-//    ossimImageSourceInterface* result = NULL;
+//    ossimImageSource* result = NULL;
 //    for(unsigned long index = 0; index < theImageChainList.size();++index)
 //    {
 //      ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject, theImageChainList[index]);
@@ -267,7 +300,7 @@ ossimConnectableObject* ossimImageChain::findObject(const ossimConnectableObject
 //        {
 // 	 if(id == obj->getId())
 // 	   {
-//               return PTR_CAST(ossimImageSourceInterface,
+//               return PTR_CAST(ossimImageSource,
 //                               theImageChainList[index];
 // 	   }
 //        }
@@ -289,16 +322,16 @@ ossimConnectableObject* ossimImageChain::findObject(const ossimConnectableObject
 //    return result;
 // }
 
-// ossimImageSourceInterface* ossimImageChain::findFirstSourceOfType(const RTTItypeid& typeInfo)
+// ossimImageSource* ossimImageChain::findFirstSourceOfType(const RTTItypeid& typeInfo)
 // {
-//    ossimImageSourceInterface* result = NULL;
+//    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(ossimImageSourceInterface,
+//          return PTR_CAST(ossimImageSource,
 //                          theImageChainList[index]);
 //       }
 //    }
@@ -498,9 +531,9 @@ std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const
    
 }
 
-// vector<ossimImageSourceInterface*> ossimImageChain::findAllSourcesOfType(const RTTItypeid& typeInfo)
+// vector<ossimImageSource*> ossimImageChain::findAllSourcesOfType(const RTTItypeid& typeInfo)
 // {
-//    vector<ossimImageSourceInterface*> result;
+//    vector<ossimImageSource*> result;
 //    long index = 0;
 
 //    for(index = 0; index < (long)theImageChainList.size();++index)
@@ -517,7 +550,7 @@ std::vector<ossimConnectableObject*> ossimImageChain::findAllObjectsOfType(const
       
 //       if(child)
 //       {
-//          vector<ossimImageSourceInterface*> temp;
+//          vector<ossimImageSource*> temp;
          
 //          temp =  child->findAllSourcesOfType(typeInfo);
 //          for(long index2=0; index2 < (long)temp.size();index2++)
@@ -724,7 +757,7 @@ void ossimImageChain::getChildren(vector<ossimConnectableObject*>& children,
 bool ossimImageChain::add(ossimConnectableObject* source)
 {
    bool result = false;
-   if(PTR_CAST(ossimImageSourceInterface, source))
+   if(PTR_CAST(ossimImageSource, source))
    {
      source->changeOwner(this);
      if(theImageChainList.size() > 0)
@@ -740,6 +773,27 @@ bool ossimImageChain::add(ossimConnectableObject* source)
      }
      else
      {
+#if 1
+        theInputListIsFixedFlag = false;
+        theOutputListIsFixedFlag = false;
+        
+        if(!theInputObjectList.empty())
+        {
+           source->connectInputList(getInputList());
+        }
+        else
+        {
+           theInputObjectList = source->getInputList();
+        }
+        theInputListIsFixedFlag = source->getInputListIsFixedFlag();
+        theOutputObjectList      = source->getOutputList();
+        theOutputListIsFixedFlag = source->getOutputListIsFixedFlag();
+        theImageChainList.push_back(source);
+        source->addListener((ossimConnectableObjectListener*)this);
+        theImageChainList[0]->addListener(theChildListener);
+        result = true;
+#endif
+#if 0
         theInputObjectList = source->getInputList();
         theInputListIsFixedFlag = source->getInputListIsFixedFlag();
         
@@ -750,6 +804,7 @@ bool ossimImageChain::add(ossimConnectableObject* source)
         source->addListener((ossimConnectableObjectListener*)this);
         theImageChainList[0]->addListener(theChildListener);
         result = true;
+#endif
      }
    }
 
@@ -785,7 +840,7 @@ bool ossimImageChain::insertRight(ossimConnectableObject* newObj,
       {
          return add(newObj);
       }
-      else if(PTR_CAST(ossimImageSourceInterface, newObj))
+      else if(PTR_CAST(ossimImageSource, newObj))
       {
          vector<ossimConnectableObject*> outputList = rightOfThisObj->getOutputList();
          rightOfThisObj->disconnectAllOutputs();
@@ -845,7 +900,7 @@ bool ossimImageChain::insertLeft(ossimConnectableObject* newObj,
       {
          return addLast(newObj);
       }
-      else if(PTR_CAST(ossimImageSourceInterface, newObj))
+      else if(PTR_CAST(ossimImageSource, newObj))
       {
          vector<ossimConnectableObject*> inputList = leftOfThisObj->getInputList();
          leftOfThisObj->disconnectAllInputs();
@@ -879,13 +934,37 @@ bool ossimImageChain::insertLeft(ossimConnectableObject* newObj,
    return false;
 }
 
+bool ossimImageChain::replace(ossimConnectableObject* newObj,
+                              ossimConnectableObject* oldObj)
+{
+   ossim_int32 idx = indexOf(oldObj);
+   if(idx >= 0)
+   {
+      std::vector<ossimConnectableObject*>& inputList = getInputList();
+      std::vector<ossimConnectableObject*>& outputList = oldObj->getOutputList();
+      oldObj->removeListener((ossimConnectableObjectListener*)this);
+      oldObj->removeListener(theChildListener);
+      theImageChainList[idx] = newObj;
+      newObj->connectInputList(inputList);
+      newObj->connectOutputList(outputList);
+      newObj->changeOwner(this);
+      newObj->addListener((ossimConnectableObjectListener*)this);
+      if(idx == 0)
+      {
+         newObj->addListener(theChildListener);
+      }
+   }
+   
+   return (idx >= 0);
+}
+
 ossimRefPtr<ossimImageData> ossimImageChain::getTile(
    const ossimIrect& tileRect,
    ossim_uint32 resLevel)
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          theImageChainList[0]);
 
          if(interface)
@@ -901,7 +980,7 @@ ossimRefPtr<ossimImageData> ossimImageChain::getTile(
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -925,7 +1004,7 @@ ossim_uint32 ossimImageChain::getNumberOfInputBands() const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -936,7 +1015,7 @@ ossim_uint32 ossimImageChain::getNumberOfInputBands() const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -952,7 +1031,7 @@ double ossimImageChain::getNullPixelValue(ossim_uint32 band)const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -963,7 +1042,7 @@ double ossimImageChain::getNullPixelValue(ossim_uint32 band)const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -979,7 +1058,7 @@ double ossimImageChain::getMinPixelValue(ossim_uint32 band)const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -990,7 +1069,7 @@ double ossimImageChain::getMinPixelValue(ossim_uint32 band)const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1006,7 +1085,7 @@ double ossimImageChain::getMaxPixelValue(ossim_uint32 band)const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                   theImageChainList[0]);
       if(inter)
       {
@@ -1017,7 +1096,7 @@ double ossimImageChain::getMaxPixelValue(ossim_uint32 band)const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1033,7 +1112,7 @@ void ossimImageChain::getOutputBandList(std::vector<ossim_uint32>& bandList) con
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                   theImageChainList[0]);
       if(inter)
       {
@@ -1046,7 +1125,7 @@ ossimScalarType ossimImageChain::getOutputScalarType() const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -1057,7 +1136,7 @@ ossimScalarType ossimImageChain::getOutputScalarType() const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1073,7 +1152,7 @@ ossim_uint32 ossimImageChain::getTileWidth()const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          theImageChainList[0]);
          if(interface)
          {
@@ -1084,7 +1163,7 @@ ossim_uint32 ossimImageChain::getTileWidth()const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1100,7 +1179,7 @@ ossim_uint32 ossimImageChain::getTileHeight()const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          theImageChainList[0]);
          if(interface)
          {
@@ -1111,7 +1190,7 @@ ossim_uint32 ossimImageChain::getTileHeight()const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1128,7 +1207,7 @@ ossimIrect ossimImageChain::getBoundingRect(ossim_uint32 resLevel)const
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
 
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
 
       if(interface)
@@ -1140,7 +1219,7 @@ ossimIrect ossimImageChain::getBoundingRect(ossim_uint32 resLevel)const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1161,7 +1240,7 @@ void ossimImageChain::getValidImageVertices(vector<ossimIpt>& validVertices,
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface =PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface =PTR_CAST(ossimImageSource,
                                                      theImageChainList[0]);
 
       if(interface)
@@ -1175,7 +1254,7 @@ void ossimImageChain::getValidImageVertices(vector<ossimIpt>& validVertices,
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1192,7 +1271,7 @@ bool ossimImageChain::getImageGeometry(ossimKeywordlist& kwl,
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -1204,7 +1283,7 @@ bool ossimImageChain::getImageGeometry(ossimKeywordlist& kwl,
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1222,7 +1301,7 @@ void ossimImageChain::getDecimationFactor(ossim_uint32 resLevel,
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -1235,7 +1314,7 @@ void ossimImageChain::getDecimationFactor(ossim_uint32 resLevel,
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1252,7 +1331,7 @@ void ossimImageChain::getDecimationFactors(vector<ossimDpt>& decimations) const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
       if(interface)
       {
@@ -1263,7 +1342,7 @@ void ossimImageChain::getDecimationFactors(vector<ossimDpt>& decimations) const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1278,7 +1357,7 @@ ossim_uint32 ossimImageChain::getNumberOfDecimationLevels()const
 {
    if((theImageChainList.size() > 0)&&(isSourceEnabled()))
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       theImageChainList[0]);
 
       if(interface)
@@ -1290,7 +1369,7 @@ ossim_uint32 ossimImageChain::getNumberOfDecimationLevels()const
    {
       if(getInput(0))
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+         ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                          getInput(0));
          if(interface)
          {
@@ -1357,7 +1436,7 @@ bool ossimImageChain::addAllSources(map<ossimId, vector<ossimId> >& idMapping,
          {
             CLOG << "Created source with prefix: " << newPrefix << std::endl;
          }
-         if(PTR_CAST(ossimImageSourceInterface, source))
+         if(PTR_CAST(ossimImageSource, source))
          {
             ossimId id = source->getId();
             inputConnectionIds.clear();
@@ -1449,7 +1528,8 @@ void ossimImageChain::findInputConnectionIds(vector<ossimId>& result,
       }
    }
 }
-                                             
+                    
+
 bool ossimImageChain::connectAllSources(const map<ossimId, vector<ossimId> >& idMapping)
 {
    if(idMapping.size())
@@ -1567,8 +1647,8 @@ void ossimImageChain::initialize()
       }
       if(theImageChainList[index])
       {
-         ossimImageSourceInterface* interface =
-            PTR_CAST(ossimImageSourceInterface, theImageChainList[index]);
+         ossimImageSource* interface =
+            PTR_CAST(ossimImageSource, theImageChainList[index]);
 
          if(interface)
          {
@@ -1739,7 +1819,7 @@ void ossimImageChain::connectOutputEvent(ossimConnectionEvent& event)
       
 //       if(obj)
 //       {
-//          ossimImageSourceInterface* interface = findSource(obj->getId());
+//          ossimImageSource* interface = findSource(obj->getId());
          
 //          if(interface)
 //          {
@@ -1764,12 +1844,11 @@ void ossimImageChain::objectDestructingEvent(ossimObjectDestructingEvent& event)
                            event.getObject()));
    }
 }
-
 void ossimImageChain::propagateEventToOutputs(ossimEvent& event)
 {
-   if(thePropagateEventFlag) return;
+   //if(thePropagateEventFlag) return;
 
-   thePropagateEventFlag = true;
+   //thePropagateEventFlag = true;
    if(theImageChainList.size())
    {
       if(theImageChainList[theImageChainList.size()-1])
@@ -1778,24 +1857,23 @@ void ossimImageChain::propagateEventToOutputs(ossimEvent& event)
          theImageChainList[theImageChainList.size()-1]->propagateEventToOutputs(event);
       }
    }
-   ossimConnectableObject::propagateEventToOutputs(event);
-   thePropagateEventFlag = false;
+   //ossimConnectableObject::propagateEventToOutputs(event);
+  // thePropagateEventFlag = false;
 }
-
 void ossimImageChain::propagateEventToInputs(ossimEvent& event)
 {
-   if(thePropagateEventFlag) return;
+//   if(thePropagateEventFlag) return;
 
-   thePropagateEventFlag = true;
+//   thePropagateEventFlag = true;
    if(theImageChainList.size())
    {
       if(theImageChainList[0])
       {
          theImageChainList[0]->fireEvent(event);
-         theImageChainList[0]->propagateEventToOutputs(event);
+         theImageChainList[0]->propagateEventToInputs(event);
       }
    }
-   thePropagateEventFlag = false;
+//   thePropagateEventFlag = false;
 }
 
 ossimConnectableObject* ossimImageChain::operator[](ossim_uint32 index)
@@ -1813,3 +1891,18 @@ ossimConnectableObject* ossimImageChain::getConnectableObject(
    
    return (ossimConnectableObject*)NULL; 
 }
+
+ossim_int32 ossimImageChain::indexOf(ossimConnectableObject* obj)const
+{
+   ossim_uint32 idx = 0;
+   
+   for(idx = 0; idx < theImageChainList.size();++idx)
+   {
+      if(theImageChainList[idx] == obj)
+      {
+         return (ossim_int32)idx;
+      }
+   }
+   
+   return -1;
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageCombiner.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageCombiner.cpp
index fc7d72eac8f90ccdc9e7e2ce35368c0ed1bb15ab..0a6f38ff324ca338b86b704eb2563cce79fd6e7b 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 11411 2007-07-27 13:53:51Z dburken $
+// $Id: ossimImageCombiner.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimImageCombiner.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimIrect.h>
@@ -85,7 +85,7 @@ void ossimImageCombiner::getDecimationFactor(ossim_uint32 resLevel,
 {
    if(getInput(0))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(0));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(0));
       if(temp)
       {
          temp->getDecimationFactor(resLevel, result);
@@ -102,7 +102,7 @@ void ossimImageCombiner::getDecimationFactors(vector<ossimDpt>& decimations) con
 {
    if(getInput(0))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(0));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(0));
       if(temp)
       {
          temp->getDecimationFactors(decimations);
@@ -118,7 +118,7 @@ ossim_uint32 ossimImageCombiner::getNumberOfDecimationLevels()const
 {
    if(getInput(0))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(0));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(0));
       if(temp)
       {
          return temp->getNumberOfDecimationLevels();
@@ -142,10 +142,10 @@ ossimIrect ossimImageCombiner::getBoundingRect(ossim_uint32 resLevel)const
    result.makeNan();
    
    ossim_uint32 inputIndex = 0;
-   ossimImageSourceInterface* interface;
+   ossimImageSource* interface;
    for(inputIndex = 0;inputIndex < getNumberOfInputs(); ++inputIndex)
    {
-      interface = PTR_CAST(ossimImageSourceInterface, getInput(inputIndex));
+      interface = PTR_CAST(ossimImageSource, getInput(inputIndex));
       if(interface)
       {
          ossimIrect rect  = theFullResBounds[inputIndex];
@@ -181,7 +181,7 @@ ossimScalarType ossimImageCombiner::getOutputScalarType() const
 {
    if(getInput(theInputToPassThrough))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(theInputToPassThrough));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(theInputToPassThrough));
       if(temp)
       {
          return temp->getOutputScalarType();
@@ -195,7 +195,7 @@ ossim_uint32 ossimImageCombiner::getTileWidth()const
 {
    if(getInput(theInputToPassThrough))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(theInputToPassThrough));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(theInputToPassThrough));
       if(temp)
       {
          return temp->getTileWidth();
@@ -209,7 +209,7 @@ ossim_uint32 ossimImageCombiner::getTileHeight()const
 {
    if(getInput(theInputToPassThrough))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(theInputToPassThrough));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(theInputToPassThrough));
       if(temp)
       {
          return temp->getTileHeight();
@@ -223,7 +223,7 @@ double ossimImageCombiner::getNullPixelValue(ossim_uint32 band)const
 {
    if(getInput(theInputToPassThrough))
    {
-      ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(theInputToPassThrough));
+      ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(theInputToPassThrough));
       if(temp)
       {
          ossim_uint32 bands = temp->getNumberOfOutputBands();
@@ -257,7 +257,7 @@ double ossimImageCombiner::getMinPixelValue(ossim_uint32 band)const
    
    for(ossim_uint32 index = 0; index < getNumberOfInputs();++index)
    {
-      ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(index));
+      ossimImageSource* input = PTR_CAST(ossimImageSource, getInput(index));
       if(input)
       {
          ossim_uint32 bands = input->getNumberOfOutputBands();
@@ -303,7 +303,7 @@ double ossimImageCombiner::getMaxPixelValue(ossim_uint32 band)const
    
    for(ossim_uint32 idx = 0; idx < getNumberOfInputs();++idx)
    {
-      ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(idx));
+      ossimImageSource* input = PTR_CAST(ossimImageSource, getInput(idx));
       if(input)
       {
          ossim_uint32 bands = input->getNumberOfOutputBands();
@@ -352,7 +352,7 @@ void ossimImageCombiner::initialize()
    {
       for(ossim_uint32 idx = 0; idx < size; ++idx)
       {
-         ossimImageSourceInterface* temp = PTR_CAST(ossimImageSourceInterface, getInput(idx));
+         ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(idx));
          if(temp)
          {
             ossim_uint32 numberOfBands = temp->getNumberOfOutputBands();
@@ -454,7 +454,7 @@ ossimRefPtr<ossimImageData> ossimImageCombiner::getNextTile(ossim_uint32& return
       precomputeBounds();
    }
    
-   ossimImageSourceInterface* temp = 0;
+   ossimImageSource* temp = 0;
    ossimRefPtr<ossimImageData> result = 0;
    ossimDataObjectStatus status = OSSIM_NULL;
 
@@ -467,7 +467,7 @@ ossimRefPtr<ossimImageData> ossimImageCombiner::getNextTile(ossim_uint32& return
       if(!rect.hasNans())
       {
          rect = rect * scalar;
-         temp = PTR_CAST(ossimImageSourceInterface,
+         temp = PTR_CAST(ossimImageSource,
                          getInput(theCurrentIndex));
          
          if(rect.intersects(tileRect)&&temp)
@@ -655,7 +655,7 @@ bool ossimImageCombiner::getImageGeometry(ossimKeywordlist& kwl,
 {
    if(getInput(0))
    {
-      ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                   getInput(0));
       if(inter)
       {
@@ -675,7 +675,7 @@ bool ossimImageCombiner::saveState(ossimKeywordlist& kwl,
 bool ossimImageCombiner::canConnectMyInputTo(ossim_int32 inputIndex,
                                              const ossimConnectableObject* object)const
 {
-   return (object&& PTR_CAST(ossimImageSourceInterface, object));
+   return (object&& PTR_CAST(ossimImageSource, object));
 }
 
 void ossimImageCombiner::precomputeBounds()const
@@ -685,14 +685,14 @@ void ossimImageCombiner::precomputeBounds()const
 
    if(inputSize)
    {
-      ossimImageSourceInterface* tempInterface=0;
+      ossimImageSource* tempInterface=0;
       if(theFullResBounds.size() != inputSize)
       {
          theFullResBounds.resize(inputSize);
       }
       for(ossim_uint32 inputIndex = 0; inputIndex < inputSize; ++inputIndex)
       {
-         tempInterface = PTR_CAST(ossimImageSourceInterface, getInput(inputIndex));
+         tempInterface = PTR_CAST(ossimImageSource, getInput(inputIndex));
          if(tempInterface)
          {
             theFullResBounds[inputIndex] = tempInterface->getBoundingRect();
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp
index 239443982382d9e8470f9e9c93160dc1e5cdf73e..ca567bd413fb4aa6c535eba7849b0378297542b6 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageData.cpp
@@ -5,7 +5,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageData.cpp 12038 2007-11-13 20:38:43Z gpotts $
+// $Id: ossimImageData.cpp 13763 2008-10-22 19:29:48Z gpotts $
 
 #include <iterator>
 
@@ -4350,6 +4350,7 @@ ossimImageData::unloadTileToBilTemplate(T,  // dummy template arg...
             d += buf_width;
          }
       }
+      delete [] nulls;
    }
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp
index d6ce3bd1760805034f12249e9db76953b9de19d3..a20e56932706981d72b8b5ede5b7b541e25b15c8 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageDataFactory.cpp
@@ -6,7 +6,7 @@
 // Contributor: David A. Horner (DAH) - http://dave.thehorners.com
 // 
 //*************************************************************************
-// $Id: ossimImageDataFactory.cpp 11349 2007-07-23 13:30:44Z gpotts $
+// $Id: ossimImageDataFactory.cpp 13474 2008-08-22 14:20:42Z gpotts $
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimU8ImageData.h>
 #include <ossim/imaging/ossimU11ImageData.h>
@@ -21,6 +21,7 @@
 static ossimTrace traceDebug("ossimImageDataFactory:debug");
 
 ossimImageDataFactory* ossimImageDataFactory::theInstance = 0;
+OpenThreads::Mutex ossimImageDataFactory::theInstanceMutex;
 ossimImageDataFactory::ossimImageDataFactory()
 {
    theInstance = 0;
@@ -30,18 +31,19 @@ ossimImageDataFactory::~ossimImageDataFactory()
 {
    if(theInstance)
    {
-      delete theInstance;
+      //delete theInstance;
       theInstance = 0;
    }
 }
 
 ossimImageDataFactory* ossimImageDataFactory::instance()
 {
+   theInstanceMutex.lock();
    if(!theInstance)
    {
       theInstance = new ossimImageDataFactory;
    }
-
+   theInstanceMutex.unlock();
    return theInstance;
 }
 
@@ -189,7 +191,7 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
 ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
    ossimSource* owner,
    ossim_uint32 bands,
-   ossimImageSourceInterface* inputSource)const
+   ossimImageSource* inputSource)const
 {
    ossimRefPtr<ossimImageData> result = 0;
 
@@ -220,7 +222,7 @@ ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
 
 ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
    ossimSource* owner,
-   ossimImageSourceInterface* inputSource)const
+   ossimImageSource* inputSource)const
 {
    ossimRefPtr<ossimImageData> result = 0;
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp
index 2f35b50a1d36fc183db62651dff7833065a594d4..61da88552a0d9d0e82118f7320e70b41b9ca534c 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageFileWriter.cpp
@@ -8,10 +8,10 @@
 //
 // Contains class declaration for ossimImageFileWriter.
 //*******************************************************************
-//  $Id: ossimImageFileWriter.cpp 11184 2007-06-08 02:21:08Z gpotts $
+//  $Id: ossimImageFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 
-#include <tiffio.h> /* for tiff compression defines */
+#include <tiff.h> /* for tiff compression defines */
 
 #include <ossim/ossimConfig.h>
 #include <ossim/imaging/ossimImageFileWriter.h>
@@ -50,7 +50,7 @@
 static ossimTrace traceDebug("ossimImageFileWriter:debug");
 
 #if OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimImageFileWriter.cpp 11184 2007-06-08 02:21:08Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimImageFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $";
 #endif
 
 RTTI_DEF3(ossimImageFileWriter,
@@ -655,9 +655,11 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
       if( writeExternalGeometryFile() == false)
       {
          status = false;
-
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of geometry file failed!" << endl;
+         }
       }
    }
    if(theWriteFgdcFlag)
@@ -665,9 +667,11 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
       if(writeFgdcFile() == false)
       {
          status = false;
-
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of fgdc file failed!" << endl;
+         }
       }
    }
    if(theWriteJpegWorldFileFlag)
@@ -675,9 +679,11 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
       if(writeJpegWorldFile() == false)
       {
          status = false;
-         
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of jpeg world file failed!" << endl;
+         }
       }
    }
    if(theWriteReadmeFlag)
@@ -686,8 +692,11 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
       {
          status = false;
          
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of readme file failed!" << endl;
+         }
       }
    }
    if(theWriteTiffWorldFileFlag)
@@ -695,9 +704,11 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
       if(writeTiffWorldFile() == false)
       {
          status = false;
-         
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of tiff world file failed!" << endl;
+         }
       }
    }
 
@@ -706,9 +717,11 @@ bool ossimImageFileWriter::writeMetaDataFiles() const
       if (!writeHistogramFile())
       {
          status = false;
-         
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of histogram file failed!" << endl;
+         }
       }
    }
 
@@ -1025,8 +1038,11 @@ bool ossimImageFileWriter::execute()
       if (!writeOverviewFile(theOverviewCompressType,
                              theOverviewJpegCompressQuality))
       {
-         ossimNotify(ossimNotifyLevel_WARN)
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_WARN)
             << "Write of overview file failed!" << endl;
+         }
       }
    }
 
@@ -1039,8 +1055,11 @@ bool ossimImageFileWriter::execute()
          {
             if (writeMetaDataFiles() == false)
             {
-               ossimNotify(ossimNotifyLevel_WARN)
-                  << "Write of overview file failed!" << endl;
+               if(traceDebug())
+               {
+                  ossimNotify(ossimNotifyLevel_WARN)
+                  << "Write of metadata file failed!" << endl;
+               }
                result = false;
             }
          }
@@ -1127,7 +1146,7 @@ bool ossimImageFileWriter::canConnectMyInputTo(ossim_int32 inputIndex,
                                                const ossimConnectableObject* object)const
 {
    return (object&&
-           ( (PTR_CAST(ossimImageSourceInterface, object)&&inputIndex == 0)||
+           ( (PTR_CAST(ossimImageSource, object)&&inputIndex == 0)||
              (PTR_CAST(ossimViewController, object)&&inputIndex == 1)) );
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp
index 3eff1fa5aa8a03bde5a00f640c09169a9a73aa80..dd4571ac8c2145d8e32402ed15d5725f93b43e5a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp
@@ -3,7 +3,7 @@
 // License:  See top level LICENSE.txt file.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimImageHandlerFactory.cpp 10845 2007-05-04 15:14:11Z dburken $
+// $Id: ossimImageHandlerFactory.cpp 13910 2008-12-03 21:13:09Z gpotts $
 #include <ossim/imaging/ossimImageHandlerFactory.h>
 #include <ossim/imaging/ossimAdrgTileSource.h>
 #include <ossim/imaging/ossimCcfTileSource.h>
@@ -568,7 +568,7 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    {
       return result;
    }
-
+   delete result;
    // Note:  SRTM should be in front of general raster...
    if(traceDebug())
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp
index 016f3bb4baa001c9065479b57c384ca2db1bae27..7cc7b766c84a2431d1873467580e8724d84e7a7d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerRegistry.cpp
@@ -9,7 +9,7 @@
 // Contains class definition for ImageHandlerRegistry.
 //
 //*******************************************************************
-//  $Id: ossimImageHandlerRegistry.cpp 10104 2006-12-14 16:13:05Z gpotts $
+//  $Id: ossimImageHandlerRegistry.cpp 13646 2008-10-01 15:52:51Z gpotts $
 #include <algorithm>
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
 #include <ossim/imaging/ossimImageHandlerFactory.h>
@@ -22,27 +22,24 @@ using namespace std;
 
 RTTI_DEF1(ossimImageHandlerRegistry, "ossimImageHandlerRegistry", ossimObjectFactory);
 
-ossimImageHandlerRegistry* ossimImageHandlerRegistry::theInstance = 0;
+//ossimImageHandlerRegistry* ossimImageHandlerRegistry::theInstance = 0;
 
 ossimImageHandlerRegistry::ossimImageHandlerRegistry()
-{  
+{
+   ossimObjectFactoryRegistry::instance()->registerFactory(this);
+   registerFactory(ossimImageHandlerFactory::instance());
 }
 
 ossimImageHandlerRegistry* ossimImageHandlerRegistry::instance()
 {
-   if (theInstance == 0)
-   {
-      theInstance = new ossimImageHandlerRegistry();
-      ossimObjectFactoryRegistry::instance()->registerFactory(theInstance);
-      theInstance->registerFactory(ossimImageHandlerFactory::instance());
-   }
-   return theInstance;
+   static ossimImageHandlerRegistry sharedInstance;
+   
+   return &sharedInstance;
 }
 
 ossimImageHandlerRegistry::~ossimImageHandlerRegistry()
 {
    clear();
-   theInstance = 0;
 }
 
 void ossimImageHandlerRegistry::addFactory(
@@ -155,6 +152,7 @@ void ossimImageHandlerRegistry::getSupportedExtensions(ossimImageHandlerFactoryB
 
 ossimImageHandler* ossimImageHandlerRegistry::open(const ossimFilename& fileName)const
 {
+   if(!fileName.exists()) return 0;
    ossimImageHandler*                   result = NULL;
    vector<ossimImageHandlerFactoryBase*>::const_iterator factory;
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHistogramSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHistogramSource.cpp
index b8f010953f50e1c77b7f177c0d3ec0c83433ff4e..6325fcee417bcb1941a849cf818d8df16185e787 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 12614 2008-04-03 19:13:53Z gpotts $
+// $Id: ossimImageHistogramSource.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimImageHistogramSource.h>
 #include <ossim/base/ossimMultiResLevelHistogram.h>
 #include <ossim/base/ossimMultiBandHistogram.h>
@@ -106,7 +106,7 @@ bool ossimImageHistogramSource::execute()
    {
       if(theAreaOfInterest.hasNans())
       {
-         ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface, getInput(0));
+         ossimImageSource* interface = PTR_CAST(ossimImageSource, getInput(0));
          if(interface)
          {
             theAreaOfInterest = interface->getBoundingRect();
@@ -144,7 +144,7 @@ bool ossimImageHistogramSource::execute()
 bool ossimImageHistogramSource::canConnectMyInputTo(ossim_int32 myInputIndex,
                                                     const ossimConnectableObject* object)const
 {
-   return ((myInputIndex==0)&&PTR_CAST(ossimImageSourceInterface,
+   return ((myInputIndex==0)&&PTR_CAST(ossimImageSource,
                                        object));
 }
 
@@ -196,7 +196,7 @@ void ossimImageHistogramSource::getBinInformation(ossim_uint32& numberOfBins,
 	minValue     = 0;
 	maxValue     = 0;
 	
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* input = PTR_CAST(ossimImageSource, getInput(0));
 	if(input)
 	{
 		switch(input->getOutputScalarType())
@@ -273,7 +273,7 @@ void ossimImageHistogramSource::computeNormalModeHistogram()
    // ref ptr, not a leak.
    theHistogram = new ossimMultiResLevelHistogram;
 	
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* input = PTR_CAST(ossimImageSource, getInput(0));
    if(!input)
    {
       setPercentComplete(100.0);
@@ -379,7 +379,7 @@ void ossimImageHistogramSource::computeFastModeHistogram()
    // ref ptr, not a leak.
    theHistogram = new ossimMultiResLevelHistogram;
 	theHistogram->create(resLevelsToCompute);
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* input = PTR_CAST(ossimImageSource, getInput(0));
    if(!input)
    {
       setPercentComplete(100.0);
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageMetaDataWriterRegistry.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageMetaDataWriterRegistry.cpp
index 1eb7fc593ef3bbfd4b6bafc58f7453a544a3611e..b3eaa06899854832320c33b9a170ebaca0745647 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageMetaDataWriterRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageMetaDataWriterRegistry.cpp
@@ -3,7 +3,7 @@
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //----------------------------------------------------------------------------
-// $Id: ossimImageMetaDataWriterRegistry.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageMetaDataWriterRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
 
 
 #include <ossim/imaging/ossimImageMetaDataWriterRegistry.h>
@@ -12,30 +12,25 @@
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <algorithm>
 
-ossimImageMetaDataWriterRegistry*
-ossimImageMetaDataWriterRegistry::theInstance= NULL;
+//ossimImageMetaDataWriterRegistry*
+//ossimImageMetaDataWriterRegistry::theInstance= NULL;
 
 ossimImageMetaDataWriterRegistry::ossimImageMetaDataWriterRegistry()
 {
-   theInstance = this;
+   registerFactory(ossimImageMetaDataWriterFactory::instance());
+   ossimObjectFactoryRegistry::instance()->registerFactory(this);
 }
 
 ossimImageMetaDataWriterRegistry::~ossimImageMetaDataWriterRegistry()
 {
-   ossimObjectFactoryRegistry::instance()->unregisterFactory(theInstance);
-   theInstance = NULL;
+   ossimObjectFactoryRegistry::instance()->unregisterFactory(this);
 }
 
 ossimImageMetaDataWriterRegistry* ossimImageMetaDataWriterRegistry::instance()
 {
-   if(!theInstance)
-   {
-      theInstance = new ossimImageMetaDataWriterRegistry;
-      theInstance->registerFactory(ossimImageMetaDataWriterFactory::instance());
-      ossimObjectFactoryRegistry::instance()->registerFactory(theInstance);
-   }
+   static ossimImageMetaDataWriterRegistry sharedInstance;
 
-   return theInstance;
+   return &sharedInstance;
 }
 
 void ossimImageMetaDataWriterRegistry::registerFactory(
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..edbf2ad9444440cb6c506dfb4ba9d281e9e08ec3
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageModel.cpp
@@ -0,0 +1,154 @@
+//-----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Class definition of ossimImageModel.
+//
+//-----------------------------------------------------------------------------
+// $Id$
+
+#include <string>
+
+#include <ossim/imaging/ossimImageModel.h>
+#include <ossim/base/ossimDrect.h>
+#include <ossim/base/ossimException.h>
+#include <ossim/imaging/ossimImageHandler.h>
+
+RTTI_DEF1(ossimImageModel, "ossimImageModel", ossimObject);
+
+ossimImageModel::ossimImageModel()
+   : ossimObject(),
+     theSubImageOffset(),
+     theDecimationFactors(),
+     theLines(0),
+     theSamples(0),
+     theTargetRrds(0)
+{
+}
+
+ossimImageModel::~ossimImageModel()
+{
+}
+
+void ossimImageModel::initialize(const ossimImageHandler& ih)
+{
+   theSubImageOffset = ih.getSubImageOffset(0);
+   theLines          = ih.getNumberOfLines(0);
+   theSamples        = ih.getNumberOfSamples(0);
+   ih.getDecimationFactors(theDecimationFactors);
+}
+
+void ossimImageModel::rnToR0(ossim_uint32 rrds,
+                             const ossimDpt& rnPt,
+                             ossimDpt& r0Pt) const
+{
+   if ( rrds < theDecimationFactors.size() )
+   {
+      r0Pt.x = rnPt.x / theDecimationFactors[rrds].x;
+      r0Pt.y = rnPt.y / theDecimationFactors[rrds].y;
+   }
+   else
+   {
+      std::string e = "ossimImageModel::rnToR0 rrds out of range!";
+      throw ossimException(e);
+   }
+}
+void ossimImageModel::rnToR0(const ossimDpt& rnPt, ossimDpt& r0Pt) const
+{
+   rnToR0(theTargetRrds, rnPt, r0Pt);
+}
+   
+void ossimImageModel::r0ToRn(ossim_uint32 rrds,
+                             const ossimDpt& r0Pt,
+                             ossimDpt& rnPt) const
+{
+   if ( rrds < theDecimationFactors.size() )
+   {
+      rnPt.x = r0Pt.x * theDecimationFactors[rrds].x;
+      rnPt.y = r0Pt.y * theDecimationFactors[rrds].y;
+   }
+   else
+   {
+      std::string e = "ossimImageModel::r0ToRn rrds out of range!";
+      throw ossimException(e);
+   }
+}
+
+void ossimImageModel::r0ToRn(const ossimDpt& r0Pt, ossimDpt& rnPt) const
+{
+   r0ToRn(theTargetRrds, r0Pt, rnPt);
+}
+
+void ossimImageModel::getSubImageOffset(ossim_uint32 rrds,
+                                        ossimDpt& offset) const
+{
+   if ( rrds < theDecimationFactors.size() )
+   {
+      offset.x = theSubImageOffset.x * theDecimationFactors[rrds].x;
+      offset.y = theSubImageOffset.y * theDecimationFactors[rrds].y;
+   }
+   else
+   {
+      std::string e = "ossimImageModel::getSubImageOffset rrds out of range!";
+      throw ossimException(e);
+   } 
+}
+
+void ossimImageModel::getImageRectangle(ossim_uint32 rrds,
+                                        ossimDrect& rect) const
+{
+   if ( rrds < theDecimationFactors.size() )
+   {
+      ossim_float64 lrX = theSamples * theDecimationFactors[rrds].x - 1.0;
+      ossim_float64 lrY = theLines   * theDecimationFactors[rrds].y - 1.0;
+      ossimDrect r(0.0, 0.0, lrX, lrY);
+      rect = r;
+   }
+   else
+   {
+      std::string e = "ossimImageModel::getImageRectangle rrds out of range!";
+      throw ossimException(e);
+   } 
+}
+
+void ossimImageModel::getBoundingRectangle(ossim_uint32 rrds,
+                                           ossimDrect& rect) const
+{
+   if ( rrds < theDecimationFactors.size() )
+   {
+      ossim_float64 urX = theSubImageOffset.x * theDecimationFactors[rrds].x;
+      ossim_float64 urY = theSubImageOffset.y * theDecimationFactors[rrds].y;
+      
+      ossim_float64 lrX = urX + theSamples*theDecimationFactors[rrds].x - 1.0;
+      ossim_float64 lrY = urY + theLines  *theDecimationFactors[rrds].y - 1.0;
+      ossimDrect r(0, 0, lrX, lrY);
+      rect = r;
+   }
+   else
+   {
+      std::string e =
+         "ossimImageModel::getBoundingRectangle rrds out of range!";
+      throw ossimException(e);
+   }  
+}
+ossim_uint32 ossimImageModel::getNumberOfDecimationLevels()const
+{
+   return theDecimationFactors.size();
+}
+
+void ossimImageModel::setTargetRrds(ossim_uint32 rrds)
+{
+   theTargetRrds = rrds;
+}
+
+ossim_uint32 ossimImageModel::getTargetRrds() const
+{
+   return theTargetRrds;
+}
+
+   
+
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp
index 12fe49625603230e80afc68be17e56c1e654e195..3c5cb44a8a2b6dd9f15fa0de6dc735a25900289f 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageRenderer.cpp
@@ -5,7 +5,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimImageRenderer.cpp 12738 2008-04-25 19:02:43Z gpotts $
+//  $Id: ossimImageRenderer.cpp 13905 2008-12-02 14:37:12Z gpotts $
 
 #include <iostream>
 using namespace std;
@@ -13,6 +13,7 @@ using namespace std;
 #include <ossim/imaging/ossimImageRenderer.h>
 #include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimDpt3d.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimCommon.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimProcessProgressEvent.h>
@@ -38,14 +39,13 @@ using namespace std;
 #include <ossim/projection/ossimEquDistCylProjection.h>
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimImageRenderer.cpp 12738 2008-04-25 19:02:43Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimImageRenderer.cpp 13905 2008-12-02 14:37:12Z gpotts $";
 #endif
 
 static ossimTrace traceDebug("ossimImageRenderer:debug");
 
 RTTI_DEF2(ossimImageRenderer, "ossimImageRenderer", ossimImageSourceFilter, ossimViewInterface);
 
-
 void ossimImageRenderer::ossimRendererSubRectInfo::splitView(ossimImageViewTransform* transform,
                                                              ossimRendererSubRectInfo& ulRect,
                                                              ossimRendererSubRectInfo& urRect,
@@ -817,6 +817,8 @@ void ossimImageRenderer::recursiveResample(ossimRefPtr<ossimImageData> outputDat
    }
 }
 
+#define RSET_SEARCH_THRESHHOLD 0.1
+
 void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
                                   const ossimRendererSubRectInfo& rectInfo)
 {
@@ -843,8 +845,69 @@ void ossimImageRenderer::fillTile(ossimRefPtr<ossimImageData> outputData,
    
    ossim_uint32 resLevel = closestFitResLevel<0 ? 0:closestFitResLevel;
    resLevel += theStartingResLevel;
+
+   //---
+   // ESH 11/2008: Check the rset at the calculated resLevel to see
+   // if it has the expected decimation factor. It it does, we can 
+   // use this rset and assume it is at resLevel.
+   //--- 
+   ossimDpt decimation;
+   decimation.makeNan(); // initialize to nan.
+   theInputConnection->getDecimationFactor(resLevel, decimation);
+   double requestScale = 1.0 / pow( (double)2.0, (double)resLevel );
+   double closestScale = decimation.hasNans() ? requestScale : decimation.x;
    
-   double closestScale = 1.0 / pow( (double)2.0, (double)resLevel );
+   double differenceTest = 0.0;
+   if (closestScale != 0.0)
+   {
+      differenceTest = (1.0/closestScale) - (1.0/requestScale);
+   }
+
+   //---
+   // ESH 11/2008: Add in threshold test so search only happens when 
+   //              necessary.
+   // We do an rset search if 1 of 2 conditions is met: either
+   //   1) the rset is really different in size from the requested size, or
+   //   2) they're similar in size, and the actual rset is smaller than 
+   //      the requested size.
+   //---
+   if ( (fabs(differenceTest) > RSET_SEARCH_THRESHHOLD) || 
+        ((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 )
+      {
+         theInputConnection->getDecimationFactor(i, decimation);
+         if(decimation.hasNans() == false )
+         {
+            double testDiscrepancy = decimation.x - requestScale;
+            if ( testDiscrepancy < 0.0 ) // we're done
+            {
+               break;
+            }
+            else
+            {
+               closestScale = decimation.x;
+               resLevel = i;
+            }
+         }
+         else // use the default value
+         {
+            closestScale = requestScale;
+            resLevel = savedResLevel;
+            break;
+         }
+      }
+   }
    
    ossimDpt nul(rectInfo.theIul.x*closestScale,
                 rectInfo.theIul.y*closestScale);
@@ -948,6 +1011,11 @@ ossimIrect ossimImageRenderer::getBoundingRect(ossim_uint32 resLevel)const
          << MODULE << "entered..." << endl;
    }
 #endif
+
+   if ( (isSourceEnabled() == false) && theInputConnection )
+   {
+      return theInputConnection->getBoundingRect(resLevel);
+   }
    
    if(!theBoundingViewRect.hasNans())
    {
@@ -1251,7 +1319,7 @@ bool ossimImageRenderer::getImageGeometry(ossimKeywordlist& kwl,
 
 void ossimImageRenderer::connectInputEvent(ossimConnectionEvent& event)
 {
-   theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   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.
@@ -1369,8 +1437,7 @@ void ossimImageRenderer::checkTransform()
    // tie to a projection source.
    ossimImageViewProjectionTransform* transform = PTR_CAST(ossimImageViewProjectionTransform,
                                                            theImageViewTransform);
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
-                                               getInput(0));
+   ossimImageSource* inter = PTR_CAST(ossimImageSource, getInput(0));
 
    // we will only check for projection transforms
    if(!transform||!inter) return;
@@ -1397,6 +1464,11 @@ void ossimImageRenderer::checkTransform()
    
    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;
@@ -1408,22 +1480,37 @@ void ossimImageRenderer::checkTransform()
          else
          {
             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);
+            }            
          }
-         mapProj = PTR_CAST(ossimMapProjection, newProj);
-         if(mapProj) 
-         {
-            ossimDpt meters = proj->getMetersPerPixel();
+
+         // 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);
-         }
+//             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);
       }
-//       }
    }
    else
    {
@@ -1575,8 +1662,8 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
          theTemporaryBuffer->makeBlank();
       }
       
-      ossim_uint32 totalCount   = ((requestedRectAtValidRLevel.lr().y-requestedRectAtValidRLevel.ul().y)*
-                                   (requestedRectAtValidRLevel.lr().x-requestedRectAtValidRLevel.ul().x));
+     // ossim_uint32 totalCount   = ((requestedRectAtValidRLevel.lr().y-requestedRectAtValidRLevel.ul().y)*
+   //                                (requestedRectAtValidRLevel.lr().x-requestedRectAtValidRLevel.ul().x));
       ossim_uint32 currentCount = 0;
       ossimIrect boundingRect = theInputConnection->getBoundingRect(levels-1);
       for(yIndex = requestedRectAtValidRLevel.ul().y;yIndex < requestedRectAtValidRLevel.lr().y; yIndex += tileSize.y)
@@ -1646,8 +1733,8 @@ ossimRefPtr<ossimImageData>  ossimImageRenderer::getTileAtResLevel(const ossimIr
                }
             }
             ++currentCount;
-            fireProgressEvent((double)currentCount/
-                              (double)totalCount);
+            //fireProgressEvent((double)currentCount/
+            //                  (double)totalCount);
             
          }
       }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageShapeFileIndex.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageShapeFileIndex.cpp
deleted file mode 100644
index 90dd48d374ba41121e428159fc1c93708d9e5d5e..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageShapeFileIndex.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-#include <ossim/imaging/ossimImageShapeFileIndex.h>
-#include <ossim/imaging/ossimImageHandlerRegistry.h>
-#include <ossim/imaging/ossimImageHandler.h>
-#include <ossim/projection/ossimProjectionFactoryRegistry.h>
-#include <ossim/projection/ossimProjection.h>
-#include <ossim/base/ossimTrace.h>
-
-#include <ossim/vec/shapefil.h>
-
-static ossimTrace traceDebug("ossimImageShapeFileIndex:debug");
-
-ossimImageShapeFileIndex::ossimImageShapeFileIndex(const ossimFilename& shapeFilename)
-   :theGlobalMinx(1.0/DBL_EPSILON),
-    theGlobalMiny(1.0/DBL_EPSILON),
-    theGlobalMaxx(-1.0/DBL_EPSILON),
-    theGlobalMaxy(-1.0/DBL_EPSILON)
-{
-   setFilename(shapeFilename);
-}
-
-void ossimImageShapeFileIndex::setFilename(const ossimFilename& shapeFilename)
-{
-   theFilename = shapeFilename;
-   theFilename = theFilename.setExtension("");
-}
-
-void ossimImageShapeFileIndex::add(const ossimFilename& filename,
-                                   const ossim_int32 entry, // default to all entries
-                                   const ossimString& groupName)
-{
-   if(traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageShapeFileIndex::add: Entered ...." << std::endl;
-   }
-   ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(filename);
-   ossimRefPtr<ossimProjection> proj;
-
-   if(h.valid())
-   {
-      std::vector<ossim_uint32> entryList;
-      if(entry < 0)
-      {
-         h->getEntryList(entryList);
-      }
-      else
-      {
-         entryList.push_back(static_cast<ossim_uint32>(entry));
-      }
-
-      ossim_uint32 idx = 0;
-      for(idx = 0; idx < entryList.size(); ++idx)
-      {
-         ossimKeywordlist kwl;
-         if(h->setCurrentEntry(entryList[idx]))
-         {
-            ossimIrect bounds = h->getBoundingRect();
-            
-            h->getImageGeometry(kwl);
-            proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
-            
-            if(proj.valid())
-            {
-               if(traceDebug())
-               {
-                  ossimNotify(ossimNotifyLevel_DEBUG) << "Adding file:  " << filename << std::endl
-                                                      << "       entry: " << entryList[idx] << std::endl;
-               }
-               std::vector<ossimDpt> points;
-               ossim_float64 minx;
-               ossim_float64 miny;
-               ossim_float64 maxx;
-               ossim_float64 maxy;
-               ossimGpt ulgpt;
-               ossimGpt urgpt;
-               ossimGpt lrgpt;
-               ossimGpt llgpt;
-               const ossimDatum* datum = ossimDatumFactory::instance()->wgs84();
-               proj->lineSampleToWorld(bounds.ul(), ulgpt);
-               proj->lineSampleToWorld(bounds.ur(), urgpt);
-               proj->lineSampleToWorld(bounds.lr(), lrgpt);
-               proj->lineSampleToWorld(bounds.ll(), llgpt);
-
-               ulgpt.changeDatum(datum);
-               urgpt.changeDatum(datum);
-               lrgpt.changeDatum(datum);
-               llgpt.changeDatum(datum);
-               
-               points.push_back(ossimDpt(ulgpt));
-               points.push_back(ossimDpt(urgpt));
-               points.push_back(ossimDpt(lrgpt));
-               points.push_back(ossimDpt(llgpt));
-
-               ossimDrect rect(points, OSSIM_RIGHT_HANDED);
-
-               minx = rect.ll().x;
-               miny = rect.ll().y;
-               maxx = rect.ur().x;
-               maxy = rect.ur().y;
-
-               if(minx < theGlobalMinx) theGlobalMinx = minx;
-               if(maxx > theGlobalMaxx) theGlobalMaxx = maxx;
-               if(miny < theGlobalMiny) theGlobalMiny = miny;
-               if(maxy > theGlobalMaxy) theGlobalMaxy = maxy;
-
-               theRecords.push_back(new ossimImageShapeFileIndexRecord(filename,
-                                                                       entryList[idx],
-                                                                       groupName,
-                                                                       minx,
-                                                                       miny,
-                                                                       maxx,
-                                                                       maxy));
-            }
-         }
-      }
-   }
-   if(traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageShapeFileIndex::add: Leaving ...." << std::endl;
-   }
-}
-
-void ossimImageShapeFileIndex::build(ossim_uint32 maxDepth)const
-{
-   if(theRecords.size())
-   {
-      ossim_SHPHandle hSHP = ossim_SHPCreate( theFilename.c_str(), ossim_SHPT_POLYGON);
-      ossim_DBFHandle hDBF = ossim_DBFCreate( theFilename.c_str());
-      
-      ossim_DBFAddField(hDBF, "GROUP", FTString, 256, 0);
-      ossim_DBFAddField(hDBF, "FILENAME", FTString, 256, 0);
-      ossim_DBFAddField(hDBF, "ENTRY", FTInteger, 10, 0);
-      ossim_DBFAddField(hDBF, "DATUM", FTString, 16, 0);
-      
-      double* x = new double[4];
-      double* y = new double[4];
-      int nVertices = 4;
-      ossim_uint32 idx = 0;
-      int iRecord = 0;
-      for(idx = 0; idx < theRecords.size(); ++idx)
-      {
-         x[0] = theRecords[idx]->theMinx;
-         x[1] = theRecords[idx]->theMaxx;
-         x[2] = theRecords[idx]->theMaxx;
-         x[3] = theRecords[idx]->theMinx;
-
-         y[0] = theRecords[idx]->theMaxy;
-         y[1] = theRecords[idx]->theMaxy;
-         y[2] = theRecords[idx]->theMiny;
-         y[3] = theRecords[idx]->theMiny;
-         
-         ossim_SHPObject* obj = ossim_SHPCreateSimpleObject(ossim_SHPT_POLYGON,
-                                                nVertices,
-                                                x,
-                                                y,
-                                                0);
-         ossim_SHPWriteObject( hSHP, -1, obj );
-         iRecord = ossim_DBFGetRecordCount( hDBF );
-         ossim_DBFWriteStringAttribute(hDBF, iRecord, 0, theRecords[idx]->theGroupName.c_str());
-         ossim_DBFWriteStringAttribute(hDBF, iRecord, 1, theRecords[idx]->theFilename.c_str());
-         ossim_DBFWriteIntegerAttribute(hDBF, iRecord, 2, (int)(theRecords[idx]->theEntry));
-         ossim_DBFWriteStringAttribute(hDBF, iRecord, 3, "WGE");
-         ossim_SHPDestroyObject(obj);
-      }
-
-      ossim_DBFClose(hDBF);
-      ossim_SHPTree * shpTree = 0;
-      double minV[4] = {0.0,0.0,0.0,0.0};
-      double maxV[4] = {0.0,0.0,0.0,0.0};
-      
-      minV[0] = theGlobalMinx;
-      minV[1] = theGlobalMiny;
-      
-      maxV[0] = theGlobalMaxx;
-      maxV[1] = theGlobalMaxy;
-      if(maxDepth>1)
-      {
-         if(traceDebug())
-         {
-            ossimNotify(ossimNotifyLevel_DEBUG) << "building quadtree with " << maxDepth << " levels." << std::endl
-                                                << "minx = " << theGlobalMinx << std::endl
-                                                << "miny = " << theGlobalMiny << std::endl
-                                                << "maxx = " << theGlobalMaxx << std::endl
-                                                << "maxy = " << theGlobalMaxy << std::endl;
-         }
-         shpTree = ossim_SHPCreateTree(hSHP, 2, maxDepth, minV, maxV);
-      }
-
-      if(shpTree)
-      {
-         ossim_SHPWriteTree(shpTree, (theFilename+".qtree").c_str());
-         ossim_SHPDestroyTree(shpTree);
-      }
-      ossim_SHPClose(hSHP);
-   }
-   
-}
-
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp
index 5ca7790ec548a0f9ab63be24cb2d7fe5d4c85167..15c238985a351046aeef5569faaa2fcf04bd85ea 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSource.cpp
@@ -8,17 +8,16 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageSource.cpp 11349 2007-07-23 13:30:44Z gpotts $
+// $Id: ossimImageSource.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimImageSource.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/base/ossimProperty.h>
 #include <ossim/base/ossimKeywordNames.h>
 
-RTTI_DEF2(ossimImageSource,
+RTTI_DEF1(ossimImageSource,
           "ossimImageSource" ,
-          ossimSource,
-          ossimImageSourceInterface)
+          ossimSource)
 
 ossimImageSource::ossimImageSource(ossimObject* owner)
    :ossimSource(owner, 0,0,false,false)
@@ -54,7 +53,7 @@ ossimRefPtr<ossimImageData> ossimImageSource::getTile(const ossimIpt& origin,
 ossimRefPtr<ossimImageData> ossimImageSource::getTile(const ossimIrect& rect,
                                                       ossim_uint32 resLevel)
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -66,7 +65,7 @@ ossimRefPtr<ossimImageData> ossimImageSource::getTile(const ossimIrect& rect,
 void ossimImageSource::getDecimationFactor(ossim_uint32 resLevel,
                                            ossimDpt& result)const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -74,9 +73,9 @@ void ossimImageSource::getDecimationFactor(ossim_uint32 resLevel,
    }
 }
 
-void ossimImageSource::getDecimationFactors(vector<ossimDpt>& decimations)const
+void ossimImageSource::getDecimationFactors(std::vector<ossimDpt>& decimations)const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -86,7 +85,7 @@ void ossimImageSource::getDecimationFactors(vector<ossimDpt>& decimations)const
 
 ossim_uint32 ossimImageSource::getNumberOfDecimationLevels() const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -97,7 +96,7 @@ ossim_uint32 ossimImageSource::getNumberOfDecimationLevels() const
 
 ossimScalarType ossimImageSource::getOutputScalarType() const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -109,7 +108,7 @@ ossimScalarType ossimImageSource::getOutputScalarType() const
 
 ossim_uint32 ossimImageSource::getTileWidth()  const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -123,7 +122,7 @@ ossim_uint32 ossimImageSource::getTileWidth()  const
 
 ossim_uint32 ossimImageSource::getTileHeight() const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -138,7 +137,7 @@ ossim_uint32 ossimImageSource::getTileHeight() const
 
 ossimIrect ossimImageSource::getBoundingRect(ossim_uint32 resLevel)const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -164,11 +163,11 @@ bool ossimImageSource::loadState(const ossimKeywordlist& kwl,
 //*****************************************************************************
 //  METHOD: ossimImageSource::getValidImageVertices()
 //*****************************************************************************
-void ossimImageSource::getValidImageVertices(vector<ossimIpt>& validVertices,
+void ossimImageSource::getValidImageVertices(std::vector<ossimIpt>& validVertices,
                                              ossimVertexOrdering ordering,
                                              ossim_uint32 resLevel)const
 {
-  ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+  ossimImageSource* inter = PTR_CAST(ossimImageSource,
 					      getInput(0));
   if(inter)
     {
@@ -197,7 +196,7 @@ void ossimImageSource::getValidImageVertices(vector<ossimIpt>& validVertices,
 
 double ossimImageSource::getNullPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -209,7 +208,7 @@ double ossimImageSource::getNullPixelValue(ossim_uint32 band)const
 
 double ossimImageSource::getMinPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -220,7 +219,7 @@ double ossimImageSource::getMinPixelValue(ossim_uint32 band)const
 
 double ossimImageSource::getMaxPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(inter)
    {
@@ -237,7 +236,7 @@ bool ossimImageSource::getImageGeometry(ossimKeywordlist& kwl,
    int i = 0;
    for(i = 0; i < (int)getNumberOfInputs(); ++i)
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       getInput(i));
       if(interface)
       {
@@ -250,7 +249,7 @@ bool ossimImageSource::getImageGeometry(ossimKeywordlist& kwl,
 
 void ossimImageSource::setImageGeometry(const ossimKeywordlist& kwl)
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if (inter)
    {
@@ -260,7 +259,7 @@ void ossimImageSource::setImageGeometry(const ossimKeywordlist& kwl)
 
 void ossimImageSource::saveImageGeometry() const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if (inter)
    {
@@ -270,7 +269,7 @@ void ossimImageSource::saveImageGeometry() const
 
 void ossimImageSource::saveImageGeometry(const ossimFilename& geometry_file) const
 {
-   ossimImageSourceInterface* inter = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if (inter)
    {
@@ -325,8 +324,7 @@ void ossimImageSource::getPropertyNames(std::vector<ossimString>& propertyNames)
 
 // Protected to hide from use...
 ossimImageSource::ossimImageSource (const ossimImageSource& rhs)
-   :ossimSource(),
-    ossimImageSourceInterface(rhs)
+   :ossimSource() 
 {}
 
 // Protected to hide from use...
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactory.cpp
index b7cdd0edbea44691d48f6774e1ee1a5a841b8c11..62692bb6eb548eebd9dc39ea2c5b6b20e01186e4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactory.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFactory.cpp
@@ -13,7 +13,7 @@
 //              and image handlers (image readers)
 //
 //*************************************************************************
-// $Id: ossimImageSourceFactory.cpp 12247 2008-01-03 19:42:33Z dburken $
+// $Id: ossimImageSourceFactory.cpp 13324 2008-07-28 16:00:58Z gpotts $
 
 #include <ossim/imaging/ossimImageSourceFactory.h>
 #include <ossim/imaging/ossimConvolutionFilter1D.h>
@@ -67,8 +67,6 @@
 #include <ossim/imaging/ossimElevImageSource.h>
 #include <ossim/imaging/ossimLandsatTopoCorrectionFilter.h>
 #include <ossim/imaging/ossimGeoAnnotationSource.h>
-#include <ossim/imaging/ossimEsriShapeFileFilter.h>
-#include <ossim/imaging/ossimEsriShapeFileCutter.h>
 #include <ossim/imaging/ossimMapCompositionSource.h>
 #include <ossim/imaging/ossimScaleFilter.h>
 #include <ossim/imaging/ossimEastingNorthingCutter.h>
@@ -76,6 +74,7 @@
 #include <ossim/imaging/ossimFftFilter.h>
 #include <ossim/imaging/ossimWatermarkFilter.h>
 #include <ossim/imaging/ossimTrimFilter.h>
+#include <ossim/imaging/ossimTwoColorView.h>
 
 #include <ossim/imaging/ossimGridRemapSource.h>
 
@@ -333,14 +332,6 @@ ossimObject* ossimImageSourceFactory::createObject(const ossimString& name)const
    {
       return new ossim3x3ConvolutionFilter;
    }
-   else if(name == STATIC_TYPE_NAME(ossimEsriShapeFileFilter))
-   {
-      return new ossimEsriShapeFileFilter;
-   }
-   else if(name == STATIC_TYPE_NAME(ossimEsriShapeFileCutter))
-   {
-      return new ossimEsriShapeFileCutter;
-   }
    else if(name == STATIC_TYPE_NAME(ossimOrthoImageMosaic))
    {
       return new ossimOrthoImageMosaic;
@@ -417,7 +408,10 @@ ossimObject* ossimImageSourceFactory::createObject(const ossimString& name)const
    {
       return new ossimTrimFilter();
    }
-
+   else if(name == STATIC_TYPE_NAME(ossimTwoColorView))
+   {
+      return new ossimTwoColorView;
+   }
    return NULL;
 }
 
@@ -522,8 +516,6 @@ void ossimImageSourceFactory::getTypeNameList(std::vector<ossimString>& typeList
    typeList.push_back(STATIC_TYPE_NAME(ossimValueAssignImageSourceFilter));
    typeList.push_back(STATIC_TYPE_NAME(ossimImageSharpenFilter));
    typeList.push_back(STATIC_TYPE_NAME(ossim3x3ConvolutionFilter));
-   typeList.push_back(STATIC_TYPE_NAME(ossimEsriShapeFileFilter));
-   typeList.push_back(STATIC_TYPE_NAME(ossimEsriShapeFileCutter));
    typeList.push_back(STATIC_TYPE_NAME(ossimOrthoImageMosaic));
    typeList.push_back(STATIC_TYPE_NAME(ossimMapCompositionSource));
    typeList.push_back(STATIC_TYPE_NAME(ossimCastTileSourceFilter));
@@ -546,6 +538,7 @@ void ossimImageSourceFactory::getTypeNameList(std::vector<ossimString>& typeList
    typeList.push_back(STATIC_TYPE_NAME(ossimWatermarkFilter));
    typeList.push_back(STATIC_TYPE_NAME(ossimImageGaussianFilter));
    typeList.push_back(STATIC_TYPE_NAME(ossimTrimFilter));
+   typeList.push_back(STATIC_TYPE_NAME(ossimTwoColorView));
 }
 
 // Hide from use...
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFilter.cpp
index 7b47b30fcd7c1369901960c5d07f4f587eded3dc..0e7b641dffec1e26651f52280d694a549a7b9800 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceFilter.cpp
@@ -11,7 +11,7 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimImageSourceFilter.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageSourceFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimImageSourceFilter.h>
 #include <ossim/base/ossimTrace.h>
@@ -181,7 +181,7 @@ ossim_uint32 ossimImageSourceFilter::getTileHeight() const
 
 void ossimImageSourceFilter::initialize()
 {
-   theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
 }
 
 bool ossimImageSourceFilter::loadState(const ossimKeywordlist& kwl,
@@ -212,7 +212,7 @@ bool ossimImageSourceFilter::canConnectMyInputTo(ossim_int32 inputIndex,
 						 const ossimConnectableObject* object)const
 {
   
-  return ((PTR_CAST(ossimImageSourceInterface, object)||!object) && ( inputIndex == 0 ) );
+  return ((PTR_CAST(ossimImageSource, object)||!object) && ( inputIndex == 0 ) );
 }
 
 void ossimImageSourceFilter::connectInputEvent(ossimConnectionEvent& event)
@@ -230,7 +230,7 @@ void ossimImageSourceFilter::connectInputEvent(ossimConnectionEvent& event)
           ossimNotify(ossimNotifyLevel_DEBUG) << "to NULL" << std::endl;
        }
     }
-  theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+  theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
   initialize();
   if(traceDebug())
   {
@@ -251,7 +251,7 @@ void ossimImageSourceFilter::disconnectInputEvent(ossimConnectionEvent& event)
    {
       ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageSourceFilter::disconnectInputEvent" << std::endl;
    }
-   theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
    initialize();
    if(traceDebug())
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceHistogramFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceHistogramFilter.cpp
index 6f0a23ae18509922e1c6f75462ef3e6f85ea0c42..8504b242c38c40084055561faeeb817e4675f2dd 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceHistogramFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceHistogramFilter.cpp
@@ -6,7 +6,7 @@
 // Description:
 //
 //*************************************************************************
-// $Id: ossimImageSourceHistogramFilter.cpp 11721 2007-09-13 13:19:34Z gpotts $
+// $Id: ossimImageSourceHistogramFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimImageSourceHistogramFilter.h>
 #include <ossim/base/ossimHistogramSource.h>
 #include <ossim/base/ossimMultiResLevelHistogram.h>
@@ -118,7 +118,7 @@ bool ossimImageSourceHistogramFilter::canConnectMyInputTo(ossim_int32 inputIndex
 {
    if(object)
    {
-      if(PTR_CAST(ossimImageSourceInterface, object) && ( inputIndex == 0 ))
+      if(PTR_CAST(ossimImageSource, object) && ( inputIndex == 0 ))
       {
          return true;
       }
@@ -133,7 +133,7 @@ bool ossimImageSourceHistogramFilter::canConnectMyInputTo(ossim_int32 inputIndex
 
 void ossimImageSourceHistogramFilter::connectInputEvent(ossimConnectionEvent& event)
 {
-   theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
    if(PTR_CAST(ossimHistogramSource, event.getNewObject()))
    {
       // only initialize if it's a new object
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceInterface.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceInterface.cpp
deleted file mode 100644
index 51a2e25dfec232a0aa10f57ea0be5a2052818259..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceInterface.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-//*******************************************************************
-// Copyright (C) 2000 ImageLinks Inc. 
-//
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
-//
-// Author: Garrett Potts
-//
-//*************************************************************************
-// $Id: ossimImageSourceInterface.cpp 9094 2006-06-13 19:12:40Z dburken $
-#include <ossim/imaging/ossimImageSourceInterface.h>
-
-RTTI_DEF(ossimImageSourceInterface, "ossimImageSourceInterface");
-
-ossimImageSourceInterface::~ossimImageSourceInterface()
-{
-}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp
index 3f17f6e1cec2f49fe5f4e37ea75d32086c3f11ff..d6636b93811ef34a13a0fb904b8e1c0151b55a63 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageSourceSequencer.cpp
@@ -10,10 +10,11 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimImageSourceSequencer.cpp 11349 2007-07-23 13:30:44Z gpotts $
+//  $Id: ossimImageSourceSequencer.cpp 13374 2008-08-04 13:02:22Z gpotts $
 #include <ossim/imaging/ossimImageSourceSequencer.h>
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/base/ossimIrect.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/imaging/ossimImageWriter.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
@@ -116,7 +117,7 @@ void ossimImageSourceSequencer::updateTileDimensions()
 
 void ossimImageSourceSequencer::initialize()
 {
-   theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
 
    if(theInputConnection)
    {
@@ -150,18 +151,18 @@ void ossimImageSourceSequencer::initialize()
 bool ossimImageSourceSequencer::canConnectMyInputTo(ossim_int32 inputIndex,
 						    const ossimConnectableObject* object)const
 {      
-  return (object&& PTR_CAST(ossimImageSourceInterface, object));
+  return (object&& PTR_CAST(ossimImageSource, object));
 }
 
 void ossimImageSourceSequencer::connectInputEvent(ossimConnectionEvent& event)
 {
-  theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+  theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
   initialize();
 }
 
 void ossimImageSourceSequencer::disconnectInputEvent(ossimConnectionEvent& event)
 {
-  theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput(0));
+  theInputConnection = PTR_CAST(ossimImageSource, getInput(0));
 }
 
 ossimIrect ossimImageSourceSequencer::getBoundingRect(ossim_uint32 resLevel)const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp
index 8bf4ce0e968672f2d905851037b7fa6fc8058de6..17904ed3c1a67f48efc2980836323d358c77eedc 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageStatisticsSource.cpp
@@ -8,7 +8,7 @@
 //
 //*************************************************************************
 #include <ossim/imaging/ossimImageStatisticsSource.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/imaging/ossimImageSourceSequencer.h>
 
 
@@ -28,7 +28,7 @@ ossimImageStatisticsSource::~ossimImageStatisticsSource()
 
 void ossimImageStatisticsSource::computeStatistics()
 {
-   ossimImageSourceInterface* anInterface = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* anInterface = PTR_CAST(ossimImageSource,
                                                      getInput());
 
    if(anInterface&&isSourceEnabled())
@@ -77,7 +77,7 @@ void ossimImageStatisticsSource::computeStatistics()
 bool ossimImageStatisticsSource::canConnectMyInputTo(ossim_int32 inputIndex,
                                                      const ossimConnectableObject* object)const
 {
-   return (PTR_CAST(ossimImageSourceInterface, object)&&(inputIndex < 1));
+   return (PTR_CAST(ossimImageSource, object)&&(inputIndex < 1));
 }
 
 template <class T>
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp
index ba4746c8bffe154bb2e1850219766a6f68af5391..19f7ebde3bd7d5c82dd555e2bd996e01d089efc4 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimImageToPlaneNormalFilter.cpp
@@ -8,12 +8,14 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimImageToPlaneNormalFilter.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimImageToPlaneNormalFilter.cpp 13382 2008-08-04 18:53:26Z gpotts $
 #include <ossim/imaging/ossimImageToPlaneNormalFilter.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimNumericProperty.h>
+#include <ossim/base/ossimBooleanProperty.h>
 
 static const char* SMOOTHNESS_FACTOR_KW="smoothness_factor";
 
@@ -430,3 +432,71 @@ double ossimImageToPlaneNormalFilter::getSmoothnessFactor()const
 {
    return theSmoothnessFactor;
 }
+
+void ossimImageToPlaneNormalFilter::setProperty(ossimRefPtr<ossimProperty> property)
+{
+   ossimString name = property->getName();
+   if(name == "smoothnessFactor")
+   {
+      theSmoothnessFactor = property->valueToString().toDouble();
+      initialize();
+   }
+   else if(name == "xscale")
+   {
+      theXScale = property->valueToString().toDouble();
+      initialize();
+   }
+   else if(name == "yscale")
+   {
+      theYScale = property->valueToString().toDouble();
+      initialize();
+   }
+   else if(name == "autoTrackScaleFlag")
+   {
+      theTrackScaleFlag = property->valueToString().toDouble();
+      initialize();
+   }
+   else
+   {
+      ossimImageSourceFilter::setProperty(property);
+   }
+}
+
+ossimRefPtr<ossimProperty> ossimImageToPlaneNormalFilter::getProperty(const ossimString& name)const
+{
+   if(name == "smoothnessFactor")
+   {
+      ossimNumericProperty* prop = new ossimNumericProperty(name, theSmoothnessFactor, .0001, 40);
+      prop->setCacheRefreshBit();
+      return prop;
+   }
+   else if(name == "xscale")
+   {
+      ossimNumericProperty* prop = new ossimNumericProperty(name, theXScale, .0001, 50000);
+      prop->setCacheRefreshBit();
+      return prop;
+   }
+   else if(name == "yscale")
+   {
+      ossimNumericProperty* prop = new ossimNumericProperty(name, theYScale, .0001, 50000);
+      prop->setCacheRefreshBit();
+      return prop;
+   }
+   else if(name == "autoTrackScaleFlag")
+   {
+      ossimBooleanProperty* prop = new ossimBooleanProperty(name, theTrackScaleFlag);
+      prop->setCacheRefreshBit();
+      return prop;
+   }
+   
+   return ossimImageSourceFilter::getProperty(name);
+}
+
+void ossimImageToPlaneNormalFilter::getPropertyNames(std::vector<ossimString>& propertyNames)const
+{
+   ossimImageSourceFilter::getPropertyNames(propertyNames);
+   propertyNames.push_back("smoothnessFactor");
+   propertyNames.push_back("xscale");
+   propertyNames.push_back("yscale");
+   propertyNames.push_back("autoTrackScaleFlag");
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageWriterFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageWriterFactory.cpp
index 6c8d9cf32eb9a04e183d7b642d54efd3ffca505d..0ea98563193536a8a05d3fc707bc6fa5649fafa4 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimImageWriterFactory.cpp 13619 2008-09-29 19:10:31Z gpotts $
 
 #include <ossim/imaging/ossimImageWriterFactory.h>
 #include <ossim/imaging/ossimImageWriterFactoryRegistry.h>
@@ -17,6 +17,7 @@
 #include <ossim/imaging/ossimJpegWriter.h>
 #include <ossim/imaging/ossimGeneralRasterWriter.h>
 #include <ossim/imaging/ossimNitfWriter.h>
+#include <ossim/imaging/ossimNitf20Writer.h>
 #include <ossim/base/ossimImageTypeLut.h>
 
 ossimImageWriterFactory* ossimImageWriterFactory::theInstance = (ossimImageWriterFactory*)NULL;
@@ -99,9 +100,20 @@ ossimImageWriterFactory::createWriter(const ossimKeywordlist& kwl,
 ossimImageFileWriter*
 ossimImageWriterFactory::createWriter(const ossimString& typeName)const
 {
+	ossimString mimeType = typeName;
+	mimeType = mimeType.downcase();
+	
    // Check for tiff writer.
-   ossimImageFileWriter* writer = new ossimTiffWriter;
-   if (writer->getClassName() == typeName )
+   ossimImageFileWriter* writer = createFromMimeType(mimeType);
+	
+	if(writer)
+	{
+		return writer;
+	}
+ 
+   writer = new ossimTiffWriter;
+	
+   if (STATIC_TYPE_NAME(ossimTiffWriter) == typeName )
    {
       return writer;
    }
@@ -114,13 +126,13 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
          return writer;
       }
    }
-   delete writer; // Not a tiff writer.
+   delete writer; // Not a tiff writer.   
 
    // Check for jpeg writer.
    writer = new ossimJpegWriter;
    if ( writer->getClassName() == typeName )
    {
-      return writer;
+      return new ossimJpegWriter;
    }
    else
    {
@@ -131,8 +143,8 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
          return writer;
       }
    }
-   delete writer; // Not a jpeg writer.
-
+	delete writer; // not a jpeg writer
+	
    // Check for general raster writer.
    writer = new ossimGeneralRasterWriter;
    if ( writer->getClassName() == typeName )
@@ -166,12 +178,62 @@ ossimImageWriterFactory::createWriter(const ossimString& typeName)const
       }
    }
    delete writer; // Not a nitf writer.   
-
-   writer = NULL;
+   // Check for nitf writer.
+   writer = new ossimNitf20Writer;
+   if ( writer->getClassName() == typeName )
+   {
+      return writer;
+   }
+   else
+   {
+      // See if the type name is supported by the writer.
+      if ( writer->hasImageType(typeName) )
+      {
+         writer->setOutputImageType(typeName);
+         return writer;
+      }
+   }
+   delete writer; // Not a nitf writer.   
+   
+   writer = 0;
 
    return writer; // Return a null writer.
 }
 
+ossimImageFileWriter* ossimImageWriterFactory::createFromMimeType(const ossimString& mimeType)const
+{
+	if((mimeType == "image/jpeg")||
+		(mimeType == "image/jpg"))
+	{
+		ossimJpegWriter* writer = new ossimJpegWriter;
+		writer->setOutputImageType("jpeg");
+		return writer;
+	}
+	else if((mimeType == "image/tiff")||
+			  (mimeType == "image/tif")||
+			  (mimeType == "image/gtif")||
+			  (mimeType == "image/gtiff"))
+	{
+		ossimTiffWriter* writer = new ossimTiffWriter;
+		writer->setOutputImageType("tiff_tiled_band_separate");
+		return writer;
+	}
+	else if((mimeType == "image/nitf") ||
+			  (mimeType == "image/ntf"))
+	{
+		ossimNitfWriter* writer = new ossimNitfWriter;
+		writer->setOutputImageType("nitf_block_band_separate");
+		return writer;
+	}
+	else if((mimeType == "image/ras"))
+	{
+		ossimGeneralRasterWriter* writer = new ossimGeneralRasterWriter;
+		writer->setOutputImageType("general_raster_bsq");
+		return writer;
+	}
+	return 0;
+}
+
 ossimObject* ossimImageWriterFactory::createObject(const ossimKeywordlist& kwl,
                                                    const char *prefix)const
 {
@@ -198,6 +260,7 @@ void ossimImageWriterFactory::getTypeNameList(std::vector<ossimString>& typeList
    typeList.push_back(STATIC_TYPE_NAME(ossimJpegWriter));
    typeList.push_back(STATIC_TYPE_NAME(ossimGeneralRasterWriter));
    typeList.push_back(STATIC_TYPE_NAME(ossimNitfWriter));
+   typeList.push_back(STATIC_TYPE_NAME(ossimNitf20Writer));
 }
 
 void ossimImageWriterFactory::getImageTypeList(std::vector<ossimString>& imageTypeList)const
@@ -223,4 +286,9 @@ void ossimImageWriterFactory::getImageTypeList(std::vector<ossimString>& imageTy
    writer->getImageTypeList(imageTypeList);
    delete writer;
    writer = NULL;
+   // Add the nitf writer types.
+   writer = new ossimNitf20Writer;
+   writer->getImageTypeList(imageTypeList);
+   delete writer;
+   writer = NULL;
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimIntensityAdjustmentFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimIntensityAdjustmentFilter.cpp
index 3f3fce99c2da008781393fb6b75611c46081e560..ad25eebe7bd9478fea41b943a30330ddaafaae83 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimIntensityAdjustmentFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimIntensityAdjustmentFilter.cpp
@@ -8,9 +8,10 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-// $Id: ossimIntensityAdjustmentFilter.cpp 11411 2007-07-27 13:53:51Z dburken $
+// $Id: ossimIntensityAdjustmentFilter.cpp 13330 2008-07-28 18:04:40Z dburken $
 #include <ossim/imaging/ossimIntensityAdjustmentFilter.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimHsvVector.h>
 #include <ossim/base/ossimRgbVector.h>
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp
index c9574444dcf7bd24b5abbb653c24fa08e10eb6d9..315c5f69a74eea091f704d6bb27fed616903d76d 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimJpegTileSource.cpp
@@ -8,7 +8,19 @@
 //
 // Contains class definition for JpegTileSource.
 //*******************************************************************
-//  $Id: ossimJpegTileSource.cpp 11349 2007-07-23 13:30:44Z gpotts $
+//  $Id: ossimJpegTileSource.cpp 13054 2008-06-23 13:55:13Z gpotts $
+#if defined(__BORLANDC__)
+#include <iostream>
+using std::size_t;
+#include <stdlib.h>
+#include <stdio.h>
+#endif
+extern "C"
+{
+#include <stdio.h>
+#include <jpeglib.h>
+#include <setjmp.h>
+}
 
 #include <ossim/imaging/ossimJpegTileSource.h>
 #include <ossim/imaging/ossimTiffTileSource.h>
@@ -22,12 +34,37 @@
 #include <ossim/imaging/ossimU8ImageData.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimNotifyContext.h>
-
+#include <ossim/base/ossimStringProperty.h>
+#include <ossim/base/ossimContainerProperty.h>
+//---
+// Using windows .NET compiler there is a conflict in the libjpeg with INT32
+// in the file jmorecfg.h.  Defining XMD_H fixes this.
+//---
 
 RTTI_DEF1_INST(ossimJpegTileSource, "ossimJpegTileSource", ossimImageHandler)
 
 static ossimTrace traceDebug("ossimJpegTileSource:degug");  
 
+class ossimJpegTileSource::PrivateData
+{
+public:
+	PrivateData()
+		:theCinfo(),
+		theJerr()
+	{
+
+	}
+	virtual ~PrivateData()
+	{
+		clear();
+	}
+	void clear()
+	{
+		jpeg_destroy_decompress( &theCinfo );
+	}
+   struct jpeg_decompress_struct theCinfo;
+   struct jpeg_error_mgr         theJerr;
+};
 //*******************************************************************
 // Public Constructor:
 //*******************************************************************
@@ -42,10 +79,10 @@ ossimJpegTileSource::ossimJpegTileSource()
       theImageRect(0, 0, 0, 0),
       theNumberOfBands(0),
       theCacheSize	(0),
-      theCinfo(),
-      theJerr(),
+	  thePrivateData(0),
       theCacheId(-1)
-{}
+{
+}
 
 //*******************************************************************
 // Public Constructor:
@@ -62,8 +99,7 @@ ossimJpegTileSource::ossimJpegTileSource(const ossimKeywordlist& kwl,
       theImageRect(0, 0, 0, 0),
       theNumberOfBands(0),
       theCacheSize	(0),
-      theCinfo(),
-      theJerr(),
+	  thePrivateData(0),
       theCacheId(-1)
 {
    if (loadState(kwl, prefix) == false)
@@ -86,8 +122,7 @@ ossimJpegTileSource::ossimJpegTileSource(const char* jpeg_file)
       theImageRect(0, 0, 0, 0),
       theNumberOfBands(0),
       theCacheSize(0),
-      theCinfo(),
-      theJerr(),
+	  thePrivateData(0),
       theCacheId(-1)
 {
    static const char MODULE[]
@@ -129,7 +164,11 @@ void ossimJpegTileSource::destroy()
       fclose(theFilePtr);
       theFilePtr = NULL;
    }
-   jpeg_destroy_decompress( &theCinfo );
+   if(thePrivateData)
+   {
+	   delete thePrivateData;
+	   thePrivateData = 0;
+   }
 }
 
 void ossimJpegTileSource::allocate()
@@ -268,7 +307,7 @@ void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
             theCacheTile->makeBlank();
          }
 
-         if (start_line < theCinfo.output_scanline)
+         if (start_line < thePrivateData->theCinfo.output_scanline)
          {
             // Must restart the compression process again.
             restart();
@@ -287,15 +326,15 @@ void ossimJpegTileSource::fillTile(const ossimIrect& clip_rect)
          jbuf[0] = (JSAMPROW) theLineBuffer;
 
          // Gobble any not needed lines.
-         while (theCinfo.output_scanline < start_line)
+         while (thePrivateData->theCinfo.output_scanline < start_line)
          {
-            jpeg_read_scanlines(&theCinfo, jbuf, 1);
+            jpeg_read_scanlines(&thePrivateData->theCinfo, jbuf, 1);
          }
 
-         while (theCinfo.output_scanline <= stop_line)
+         while (thePrivateData->theCinfo.output_scanline <= stop_line)
          {
             // Read a line from the jpeg file.
-            jpeg_read_scanlines(&theCinfo, jbuf, 1);
+            jpeg_read_scanlines(&thePrivateData->theCinfo, jbuf, 1);
             
             //---
             // Copy the line which if band interleaved by pixel the the band
@@ -382,7 +421,8 @@ bool ossimJpegTileSource::open(const ossimFilename& jpeg_file)
 }
 
 //*******************************************************************
-// Private method:
+// Private method:I have problems
+
 //*******************************************************************
 bool ossimJpegTileSource::open()
 {
@@ -390,7 +430,6 @@ bool ossimJpegTileSource::open()
 
    // Start with a clean slate.
    destroy();
-
    // Check for empty filename.
    if (theImageFile.empty())
    {
@@ -432,33 +471,34 @@ bool ossimJpegTileSource::open()
       return false;
    }
 
+   thePrivateData = new PrivateData();
    rewind(theFilePtr);
 
    //---
    // Step 1: allocate and initialize JPEG decompression object
    // We set up the normal JPEG error routines, then override error_exit.
    //---   
-   theCinfo.err = jpeg_std_error(&theJerr);
+   thePrivateData->theCinfo.err = jpeg_std_error(&thePrivateData->theJerr);
 
    // Initialize the JPEG decompression object.
-   jpeg_create_decompress(&theCinfo);
+   jpeg_create_decompress(&thePrivateData->theCinfo);
 
    // Specify data source.
-   jpeg_stdio_src(&theCinfo, theFilePtr);
+   jpeg_stdio_src(&thePrivateData->theCinfo, theFilePtr);
 
    // Read the file parameters with jpeg_read_header.
-   jpeg_read_header(&theCinfo, TRUE);
+   jpeg_read_header(&thePrivateData->theCinfo, TRUE);
 
-   jpeg_start_decompress(&theCinfo);
+   jpeg_start_decompress(&thePrivateData->theCinfo);
 
-   theNumberOfBands = theCinfo.output_components;
+   theNumberOfBands = thePrivateData->theCinfo.output_components;
 
    theImageRect = ossimIrect(0,
                              0,
-                             theCinfo.output_width  - 1,
-                             theCinfo.output_height - 1);
+                             thePrivateData->theCinfo.output_width  - 1,
+                             thePrivateData->theCinfo.output_height - 1);
    
-   theBufferRect.set_lrx(theCinfo.output_width  - 1);
+   theBufferRect.set_lrx(thePrivateData->theCinfo.output_width  - 1);
    
    completeOpen();
 
@@ -468,6 +508,21 @@ bool ossimJpegTileSource::open()
    return true;
 }
 
+ossimRefPtr<ossimProperty> ossimJpegTileSource::getProperty(const ossimString& name)const
+{
+	if(name == "file_type")
+	{
+		return new ossimStringProperty("file_type", "JPEG");
+	}
+	return ossimImageHandler::getProperty(name);
+}
+
+void ossimJpegTileSource::getPropertyNames(std::vector<ossimString>& propertyNames)const
+{
+	ossimImageHandler::getPropertyNames(propertyNames);
+	propertyNames.push_back("file_type");
+}
+
 //*******************************************************************
 // Public method:
 //*******************************************************************
@@ -589,20 +644,20 @@ bool ossimJpegTileSource::isOpen()const
 
 void ossimJpegTileSource::restart()
 {
-   jpeg_abort_decompress( &theCinfo );
-   jpeg_destroy_decompress( &theCinfo );
+   jpeg_abort_decompress( &thePrivateData->theCinfo );
+   jpeg_destroy_decompress( &thePrivateData->theCinfo );
    
    // Put the theFilePtr back to the start...
    rewind(theFilePtr);
 
    // Initialize the JPEG decompression object.
-   jpeg_create_decompress(&theCinfo);
+   jpeg_create_decompress(&thePrivateData->theCinfo);
 
    // Specify data source.
-   jpeg_stdio_src(&theCinfo, theFilePtr);
+   jpeg_stdio_src(&thePrivateData->theCinfo, theFilePtr);
 
    // Read the file parameters with jpeg_read_header.
-   jpeg_read_header(&theCinfo, TRUE);
+   jpeg_read_header(&thePrivateData->theCinfo, TRUE);
 
-   jpeg_start_decompress(&theCinfo);
+   jpeg_start_decompress(&thePrivateData->theCinfo);
 }
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimLandsatTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimLandsatTileSource.cpp
index 775584ac460acc8ecad3b81669e792ea822aea6f..5a06beef29272b4692c291577cf0d35986610953 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 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimLandsatTileSource.cpp 13468 2008-08-20 18:25:57Z gpotts $
 
 #include <ossim/imaging/ossimLandsatTileSource.h>
 #include <ossim/base/ossimDirectory.h>
@@ -212,6 +212,11 @@ void ossimLandsatTileSource::openHeader(const ossimFilename& file)
    //***
    ossimFilename hdr = file.file();
    hdr.downcase();
+   if(theFfHdr)
+   {
+      delete theFfHdr;
+      theFfHdr = 0;
+   }
    if ( hdr.contains("hpn") || hdr.contains("hrf") || hdr.contains("htm") )
    {
       theFfHdr = new ossimFfL7(file.c_str());      
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimLandsatTopoCorrectionFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimLandsatTopoCorrectionFilter.cpp
index 2222cfaae8b9642714e6dfd6032ea9edc3c7fcd3..a7f03b9d7ca625da424095519db864aea83e9d4f 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 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimLandsatTopoCorrectionFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimLandsatTopoCorrectionFilter.h>
 #include <ossim/imaging/ossimImageToPlaneNormalFilter.h>
 #include <ossim/support_data/ossimFfL7.h>
@@ -162,8 +162,8 @@ void ossimLandsatTopoCorrectionFilter::computeC()
    {
       std::vector<ossim2dLinearRegression> linearRegression(6);
       
-      ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
-      ossimImageSourceInterface* normalSource  = PTR_CAST(ossimImageSourceInterface, getInput(1));
+      ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
+      ossimImageSource* normalSource  = PTR_CAST(ossimImageSource, getInput(1));
       ossimFfL7 headerL7(theLandsatHeader.c_str());
 
       if(theLandsatHeader == "")
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMapCompositionSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMapCompositionSource.cpp
index 2a228be165c8148744062389f66747d526949a06..343957b6130bffe3ae428bc791697a85edc012b2 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 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimMapCompositionSource.cpp 13966 2009-01-14 16:31:17Z gpotts $
 
 #include <ossim/imaging/ossimMapCompositionSource.h>
 #include <ossim/imaging/ossimU8ImageData.h>
@@ -896,7 +896,7 @@ void ossimMapCompositionSource::addGeographicTopGridLabels()
                                    ossim::round<int>(rect.ul().y-(boundsD.height()/2)));
                
                   lonLabel->setColor(theTopGeographicLabelColor.getR(), theTopGeographicLabelColor.getG(), theTopGeographicLabelColor.getB());
-                  lonLabel->setPositionCenter(center);
+                  lonLabel->setCenterPosition(center);
                   lonLabel->computeBoundingRect();
 
                   ossimDrect labelRect;
@@ -909,7 +909,7 @@ void ossimMapCompositionSource::addGeographicTopGridLabels()
                   }
 
                   center.y -= 24; // this will need to be the tick height later;
-                  lonLabel->setPositionCenter(center);
+                  lonLabel->setCenterPosition(center);
                   lonLabel->computeBoundingRect();
                   
                   addFixedAnnotation(lonLabel);
@@ -1036,7 +1036,7 @@ void ossimMapCompositionSource::addGeographicBottomGridLabels()
                                    ossim::round<int>(rect.lr().y+(bounds.height()/2)));
                   
                   lonLabel->setColor(theBottomGeographicLabelColor.getR(), theBottomGeographicLabelColor.getG(), theBottomGeographicLabelColor.getB());
-                  lonLabel->setPositionCenter(center);
+                  lonLabel->setCenterPosition(center);
                   lonLabel->computeBoundingRect();
                   lonLabel->getBoundingRect(boundsD);
                   bounds = boundsD;
@@ -1051,7 +1051,7 @@ void ossimMapCompositionSource::addGeographicBottomGridLabels()
                   }
 
                   center.y += 24; // this will need to be the tick height later;
-                  lonLabel->setPositionCenter(center);
+                  lonLabel->setCenterPosition(center);
                   lonLabel->computeBoundingRect();
 
 
@@ -1172,7 +1172,7 @@ void ossimMapCompositionSource::addGeographicLeftGridLabels()
                                    rounded.y);
                   
                   latLabel->setColor(theLeftGeographicLabelColor.getR(), theLeftGeographicLabelColor.getG(), theLeftGeographicLabelColor.getB());
-                  latLabel->setPositionCenter(center);
+                  latLabel->setCenterPosition(center);
                   latLabel->computeBoundingRect();
                   latLabel->getBoundingRect(boundsD);
                   bounds = boundsD;
@@ -1187,7 +1187,7 @@ void ossimMapCompositionSource::addGeographicLeftGridLabels()
                   }
 
                   center.x -= 24; // this will need to be the tick height later;
-                  latLabel->setPositionCenter(center);
+                  latLabel->setCenterPosition(center);
                   latLabel->computeBoundingRect();
 
 
@@ -1310,7 +1310,7 @@ void ossimMapCompositionSource::addGeographicRightGridLabels()
                                    rounded.y);
                
                   latLabel->setColor(theRightGeographicLabelColor.getR(), theRightGeographicLabelColor.getG(), theRightGeographicLabelColor.getB());
-                  latLabel->setPositionCenter(center);
+                  latLabel->setCenterPosition(center);
                   latLabel->computeBoundingRect();
                   latLabel->getBoundingRect(boundsD);
                   bounds = boundsD;
@@ -1325,7 +1325,7 @@ void ossimMapCompositionSource::addGeographicRightGridLabels()
                   }
 
                   center.x += 24; // this will need to be the tick height later;
-                  latLabel->setPositionCenter(center);
+                  latLabel->setCenterPosition(center);
                   latLabel->computeBoundingRect();
                   
 
@@ -1765,7 +1765,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                   theTopMeterLabelColor.getB());
                
                
-               topLabel->setPositionCenter(centerTop);
+               topLabel->setCenterPosition(centerTop);
                topLabel->computeBoundingRect();
                
                topLabel->getBoundingRect(labelRect);
@@ -1777,7 +1777,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                }
                
                centerTop.y -= (24+extraTopDelta); // this will need to be the tick height later;
-               topLabel->setPositionCenter(centerTop);
+               topLabel->setCenterPosition(centerTop);
                topLabel->computeBoundingRect();
                addFixedAnnotation(topLabel);
 
@@ -1815,7 +1815,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                      theBottomMeterLabelColor.getB());
                
                
-               bottomLabel->setPositionCenter(centerBottom);
+               bottomLabel->setCenterPosition(centerBottom);
                bottomLabel->computeBoundingRect();
                
                bottomLabel->getBoundingRect(labelRect);
@@ -1827,7 +1827,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                }
                
                centerBottom.y += (24+extraBottomDelta); // this will need to be the tick height later;
-               bottomLabel->setPositionCenter(centerBottom);
+               bottomLabel->setCenterPosition(centerBottom);
                bottomLabel->computeBoundingRect();
                addFixedAnnotation(bottomLabel);
                if(theBottomMeterTickFlag)
@@ -1884,7 +1884,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                    theLeftMeterLabelColor.getB());
                
                
-               leftLabel->setPositionCenter(centerLeft);
+               leftLabel->setCenterPosition(centerLeft);
                leftLabel->computeBoundingRect();
                
                leftLabel->getBoundingRect(labelRect);
@@ -1896,7 +1896,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                }
                
                centerLeft.x -= (24+extraLeftDelta); // this will need to be the tick height later;
-               leftLabel->setPositionCenter(centerLeft);
+               leftLabel->setCenterPosition(centerLeft);
                leftLabel->computeBoundingRect();
                addFixedAnnotation(leftLabel);
                if(theLeftMeterTickFlag)
@@ -1932,7 +1932,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                                     theRightMeterLabelColor.getB());
                
                
-               rightLabel->setPositionCenter(centerRight);
+               rightLabel->setCenterPosition(centerRight);
                rightLabel->computeBoundingRect();
                
                rightLabel->getBoundingRect(labelRect);
@@ -1944,7 +1944,7 @@ void ossimMapCompositionSource::addMeterGridLabels()
                }
                
                centerRight.x += (24+extraRightDelta); // this will need to be the tick height later;
-               rightLabel->setPositionCenter(centerRight);
+               rightLabel->setCenterPosition(centerRight);
                rightLabel->computeBoundingRect();
                addFixedAnnotation(rightLabel);
                if(theRightMeterTickFlag)
@@ -2044,7 +2044,7 @@ void ossimMapCompositionSource::addTitle()
    title->setColor(theTitleColor.getR(),
                    theTitleColor.getG(),
                    theTitleColor.getB());
-   title->setPositionCenter(theTopBorder.midPoint());
+   title->setCenterPosition(theTopBorder.midPoint());
    title->computeBoundingRect();
 
    addFixedAnnotation(title);
@@ -3154,36 +3154,38 @@ bool ossimMapCompositionSource::loadState(const ossimKeywordlist& kwl,
    {
       istringstream in(borderColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
 
-      theBorderColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      theBorderColor = ossimRgbVector((ossim_uint8)r.toUInt32(), 
+                                      (ossim_uint8)g.toUInt32(), 
+                                      (ossim_uint8)b.toUInt32());
    }
 
    if(geoGridColor)
    {
       istringstream in(geoGridColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theGeographicGridColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theGeographicGridColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(meterGridColor)
    {
       istringstream in(meterGridColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theMeterGridColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);      
+      
+      theMeterGridColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());      
    }
 
    if(titleString)
@@ -3195,60 +3197,61 @@ bool ossimMapCompositionSource::loadState(const ossimKeywordlist& kwl,
    {
       istringstream in(titleColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theTitleColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      
+      theTitleColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(topGeoLabelColor)
    {
       istringstream in(topGeoLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theTopGeographicLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theTopGeographicLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(bottomGeoLabelColor)
    {
       istringstream in(bottomGeoLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theBottomGeographicLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theBottomGeographicLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(leftGeoLabelColor)
    {
       istringstream in(leftGeoLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
 
-      theLeftGeographicLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      theLeftGeographicLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(rightGeoLabelColor)
    {
       istringstream in(rightGeoLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theRightGeographicLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theRightGeographicLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
 
@@ -3257,48 +3260,48 @@ bool ossimMapCompositionSource::loadState(const ossimKeywordlist& kwl,
    {
       istringstream in(topMeterLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theTopMeterLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theTopMeterLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(bottomMeterLabelColor)
    {
       istringstream in(bottomMeterLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theBottomMeterLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theBottomMeterLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(leftMeterLabelColor)
    {
       istringstream in(leftMeterLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theLeftMeterLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theLeftMeterLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(rightMeterLabelColor)
    {
       istringstream in(rightMeterLabelColor);
 
-      int r;
-      int g;
-      int b;
+      ossimString r;
+      ossimString g;
+      ossimString b;
       in >> r >> g >> b;
-
-      theRightMeterLabelColor = ossimRgbVector((ossim_uint8)r, (ossim_uint8)g, (ossim_uint8)b);
+      
+      theRightMeterLabelColor = ossimRgbVector((ossim_uint8)r.toUInt32(), (ossim_uint8)g.toUInt32(), (ossim_uint8)b.toUInt32());
    }
 
    if(topGeoLabelFormat)
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMaskFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMaskFilter.cpp
index dd6944f99f78656164952683bf1cdfa01d57667d..46ece1f4cf2f1a388cb496db13d2bd3668f98a85 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimMaskFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimMaskFilter.cpp
@@ -10,11 +10,11 @@
 // Description: A brief description of the contents of the file.
 //
 //*************************************************************************
-// $Id: ossimMaskFilter.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimMaskFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimMaskFilter.h>
 #include <ossim/imaging/ossimImageData.h>
-#include <ossim/imaging/ossimImageSourceInterface.h>
+#include <ossim/imaging/ossimImageSource.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/base/ossimNotifyContext.h>
 
@@ -70,12 +70,12 @@ ossimMaskFilter::~ossimMaskFilter()
 ossimRefPtr<ossimImageData> ossimMaskFilter::getTile(const ossimIrect& rect,
                                                      ossim_uint32 resLevel)
 {
-   ossimImageSourceInterface* imageSource = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* imageSource = PTR_CAST(ossimImageSource,
                                                      getInput(0));
    
    // we will check to see if it's a fileMaskSource
    //
-   ossimImageSourceInterface* maskSource = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* maskSource = PTR_CAST(ossimImageSource,
                                                     getInput(1));
    
    ossimRefPtr<ossimImageData> imageSourceData;
@@ -132,7 +132,7 @@ ossimRefPtr<ossimImageData> ossimMaskFilter::getTile(const ossimIrect& rect,
 bool ossimMaskFilter::canConnectMyInputTo(ossim_int32 index,
                                           const ossimConnectableObject* object)const
 {
-   return (PTR_CAST(ossimImageSourceInterface, object)!= NULL);
+   return (PTR_CAST(ossimImageSource, object)!= NULL);
 }
 
 void ossimMaskFilter::initialize()
@@ -603,7 +603,7 @@ ossimIrect ossimMaskFilter::getBoundingRect(ossim_uint32 resLevel)const
    ossimIrect result;
    result.makeNan();
 
-   ossimImageSourceInterface* imageSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* imageSource = PTR_CAST(ossimImageSource, getInput(0));
    if(imageSource)
    {
       result = imageSource->getBoundingRect(resLevel);
@@ -676,7 +676,7 @@ bool ossimMaskFilter::saveState(ossimKeywordlist& kwl,
 void ossimMaskFilter::getDecimationFactor(ossim_uint32 resLevel,
                                           ossimDpt& result)const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -686,7 +686,7 @@ void ossimMaskFilter::getDecimationFactor(ossim_uint32 resLevel,
 
 void ossimMaskFilter::getDecimationFactors(vector<ossimDpt>& decimations)const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -696,7 +696,7 @@ void ossimMaskFilter::getDecimationFactors(vector<ossimDpt>& decimations)const
 
 ossim_uint32 ossimMaskFilter::getNumberOfDecimationLevels()const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -707,7 +707,7 @@ ossim_uint32 ossimMaskFilter::getNumberOfDecimationLevels()const
 
 ossim_uint32 ossimMaskFilter::getNumberOfOutputBands() const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -718,7 +718,7 @@ ossim_uint32 ossimMaskFilter::getNumberOfOutputBands() const
 
 ossimScalarType ossimMaskFilter::getOutputScalarType() const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -733,7 +733,7 @@ void ossimMaskFilter::getValidImageVertices(
    ossimVertexOrdering ordering,
    ossim_uint32 resLevel)const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -743,7 +743,7 @@ void ossimMaskFilter::getValidImageVertices(
 
 ossim_uint32 ossimMaskFilter::getTileWidth() const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -755,7 +755,7 @@ ossim_uint32 ossimMaskFilter::getTileWidth() const
 
 ossim_uint32 ossimMaskFilter::getTileHeight() const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -766,7 +766,7 @@ ossim_uint32 ossimMaskFilter::getTileHeight() const
 
 double ossimMaskFilter::getNullPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -777,7 +777,7 @@ double ossimMaskFilter::getNullPixelValue(ossim_uint32 band)const
 
 double ossimMaskFilter::getMinPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
@@ -788,7 +788,7 @@ double ossimMaskFilter::getMinPixelValue(ossim_uint32 band)const
 
 double ossimMaskFilter::getMaxPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* input = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* input = PTR_CAST(ossimImageSource,
                                                getInput(0));
    if(input)
    {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp
index 25597414b17e8bfeff9d364f5f901015bdce4f9d..0b8f99cfb5d16b061f1a2fac1fad89c98e4db550 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimMemoryImageSource.cpp
@@ -19,7 +19,7 @@ ossimMemoryImageSource::ossimMemoryImageSource()
 
 void ossimMemoryImageSource::setImage(ossimRefPtr<ossimImageData> image)
 {
-   theImage = image;
+   theImage = image.get();
 	if(theImage.valid())
 	{
 		theBoundingRect = theImage->getImageRectangle();
@@ -30,6 +30,35 @@ void ossimMemoryImageSource::setImage(ossimRefPtr<ossimImageData> image)
 	}
 }
 
+void ossimMemoryImageSource::setImage(ossimScalarType scalarType,
+                                      ossim_uint32 numberOfBands,
+                                      ossim_uint32 width,
+                                      ossim_uint32 height)
+{
+   theImage = new ossimImageData(0,
+                                 scalarType,
+                                 numberOfBands,
+                                 width,
+                                 height);
+   theImage->initialize();
+   
+   theBoundingRect = theImage->getImageRectangle();
+}
+
+void ossimMemoryImageSource::setRect(ossim_uint32 ulx,
+                                     ossim_uint32 uly,
+                                     ossim_uint32 width,
+                                     ossim_uint32 height)
+{
+   if(theImage.valid())
+   {
+      theImage->setImageRectangle(ossimIrect(ulx, uly,
+                                             ulx + (width-1),
+                                             uly + (height-1)));
+      theBoundingRect = theImage->getImageRectangle();
+   }
+}
+
 ossim_uint32 ossimMemoryImageSource::getNumberOfInputBands() const
 {
    if(theImage.valid())
@@ -136,3 +165,23 @@ bool ossimMemoryImageSource::canConnectMyInputTo(ossim_int32 myInputIndex,
 void ossimMemoryImageSource::initialize()
 {
 }
+
+ossim_uint32 ossimMemoryImageSource::getNumberOfDecimationLevels() const
+{
+   return 1;
+}
+
+void ossimMemoryImageSource::getDecimationFactor(ossim_uint32 resLevel,
+                                                 ossimDpt& result) const
+{
+   if (resLevel == 0)
+   {
+      result.x = 1.0;
+      result.y = 1.0;
+   }
+   else
+   {
+      result.x = 1.0 / pow((double)2, (double)resLevel);
+      result.y = result.x;
+   }
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimMetadataFileWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimMetadataFileWriter.cpp
index 86aad2cacd93d8515fd992172c5cc619b01d37c3..bc62419052760307af28b04db060b6059f73516e 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 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimMetadataFileWriter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <ossim/imaging/ossimMetadataFileWriter.h>
 #include <ossim/base/ossimTrace.h>
@@ -47,7 +47,7 @@ ossimMetadataFileWriter::~ossimMetadataFileWriter()
 
 void ossimMetadataFileWriter::initialize()
 {
-   theInputConnection = PTR_CAST(ossimImageSourceInterface,
+   theInputConnection = PTR_CAST(ossimImageSource,
                                  getInput());
 }
 
@@ -99,7 +99,7 @@ void ossimMetadataFileWriter::disconnectInputEvent(ossimConnectionEvent& event)
 
 void ossimMetadataFileWriter::connectInputEvent(ossimConnectionEvent& event)
 {
-   theInputConnection = PTR_CAST(ossimImageSourceInterface, getInput());
+   theInputConnection = PTR_CAST(ossimImageSource, getInput());
    initialize();
 }
 
@@ -222,7 +222,7 @@ bool ossimMetadataFileWriter::canConnectMyInputTo(ossim_int32 inputIndex,
                                                   const ossimConnectableObject* object) const
 {
    return (object &&
-           ((PTR_CAST(ossimImageSourceInterface, object) &&
+           ((PTR_CAST(ossimImageSource, object) &&
              inputIndex == 0)||
             (PTR_CAST(ossimViewController, object) &&
              inputIndex == 1)));
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed3ee412a17f5c572653dc9dd97b1250664ca632
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNitf20Writer.cpp
@@ -0,0 +1,1154 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file.
+//
+// Author:  Garrett Potts
+//
+//*******************************************************************
+//  $Id: ossimNitfWriter.cpp 11385 2007-07-25 13:56:38Z gpotts $
+
+#include <fstream>
+#include <algorithm>
+#include <sstream>
+#include <iomanip>
+#include <tiffio.h>
+#include <ossim/imaging/ossimNitf20Writer.h>
+#include <ossim/imaging/ossimNitfTileSource.h>
+#include <ossim/base/ossimDate.h>
+#include <ossim/base/ossimPreferences.h>
+#include <ossim/base/ossimRefPtr.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/ossimNitfGeoPositioningTag.h>
+#include <ossim/support_data/ossimNitfLocalGeographicTag.h>
+#include <ossim/support_data/ossimNitfLocalCartographicTag.h>
+#include <ossim/support_data/ossimNitfProjectionParameterTag.h>
+#include <ossim/support_data/ossimNitfNameConversionTables.h>
+#include <ossim/support_data/ossimNitfBlockaTag.h>
+
+RTTI_DEF1(ossimNitf20Writer, "ossimNitf20Writer", ossimImageFileWriter);
+
+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),
+     theFileHeader(),
+     theImageHeader(),
+     theEnableRpcbTagFlag(false),
+     theEnableBlockaTagFlag(true),
+     theCopyFieldsFlag(false)
+{
+   //---
+   // Since the internal nitf tags are not very accurate, write an external
+   // geometry out as default behavior.  Users can disable this via the
+   // property interface or keyword list.
+   //---
+   setWriteExternalGeometryFlag(true);
+   
+   theFileHeader      = new ossimNitfFileHeaderV2_0;
+   theImageHeader     = new ossimNitfImageHeaderV2_0;
+   theOutputImageType = "nitf20_block_band_separate";
+}
+
+ossimNitf20Writer::~ossimNitf20Writer()
+{
+   //---
+   // This looks like a leak but it's not as both of these are ossimRefPtr's.
+   //---
+   theFileHeader=NULL;
+   theImageHeader=NULL;
+   
+   close();
+}
+
+bool ossimNitf20Writer::isOpen()const
+{
+   return (theOutputStream != NULL);
+}
+
+bool ossimNitf20Writer::open()
+{
+   if(isOpen())
+   {
+      close();
+   }
+   theOutputStream = new std::ofstream;
+   theOutputStream->open(theFilename.c_str(), ios::out|ios::binary);
+   
+   return theOutputStream->good();
+}
+
+void ossimNitf20Writer::close()
+{
+   if(theOutputStream)
+   {
+      theOutputStream->close();
+      delete theOutputStream;
+      theOutputStream = (std::ofstream*)NULL;
+   }
+}
+
+bool ossimNitf20Writer::writeFile()
+{
+   if(!theInputConnection->isMaster())
+   {
+      theInputConnection->slaveProcessTiles();
+
+      return true;
+   }
+
+   open();
+
+   if (!isOpen())
+   {
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
+            << "ossimNitf20Writer::writeFile ERROR:"
+            << " Could not open!  Returning..."
+            << std::endl;
+      }
+
+      return false;
+   }
+
+   // Write out the geometry info.
+   writeGeometry();
+   addTags();
+   
+   bool result = false;
+   if((theOutputImageType == "nitf20_block_band_separate")||
+      (theOutputImageType == "image/nitf20"))
+   {
+      result =  writeBlockBandSeparate();
+   }
+   else if(theOutputImageType == "nitf20_block_band_sequential")
+   {
+      result =  writeBlockBandSequential();
+   }
+   
+   close();
+   
+   return result;
+}
+
+void ossimNitf20Writer::getImageTypeList(std::vector<ossimString>& imageTypeList)const
+{
+   imageTypeList.push_back(ossimString("nitf20_block_band_separate"));
+   imageTypeList.push_back(ossimString("nitf20_block_band_sequential"));
+}
+
+void ossimNitf20Writer::setProperty(ossimRefPtr<ossimProperty> property)
+{
+   if(!property) return;
+   
+   ossimString name = property->getName();
+   
+   if(name == "file_header")
+   {
+      ossimContainerProperty* containerProperty = PTR_CAST(ossimContainerProperty,
+                                                           property.get());
+      if(containerProperty)
+      {
+         std::vector<ossimRefPtr<ossimProperty> > propertyList;
+         containerProperty->getPropertyList(propertyList);
+         theFileHeader->setProperties(propertyList);
+      }
+   }
+   else if(name == "image_header")
+   {
+      ossimContainerProperty* containerProperty = PTR_CAST(ossimContainerProperty,
+                                                           property.get());
+      if(containerProperty)
+      {
+         std::vector<ossimRefPtr<ossimProperty> > propertyList;
+         containerProperty->getPropertyList(propertyList);
+         theImageHeader->setProperties(propertyList);
+      }
+   }
+   else if (name == "enable_rpcb_tag")
+   {
+      theEnableRpcbTagFlag = property->valueToString().toBool();
+   }
+   else if (name == "enable_blocka_tag")
+   {
+      theEnableBlockaTagFlag = property->valueToString().toBool();
+   }
+   else if(name == "copy_fields_flag")
+   {
+      theCopyFieldsFlag = property->valueToString().toBool();
+   }
+   else
+   {
+      // just in case it was an nitf specific tag we can pass it safely like this
+      theFileHeader->setProperty(property);
+      theImageHeader->setProperty(property);
+      ossimImageFileWriter::setProperty(property);
+   }
+}
+
+ossimRefPtr<ossimProperty> ossimNitf20Writer::getProperty(const ossimString& name)const
+{
+   ossimRefPtr<ossimProperty> result = NULL;
+   
+   if(name == "file_header")
+   {
+      ossimContainerProperty* container = new ossimContainerProperty(name);
+      std::vector<ossimRefPtr<ossimProperty> > propertyList;
+      
+      theFileHeader->getPropertyList(propertyList);
+      container->addChildren(propertyList);
+      
+      result = container;
+   }
+   else if(name == "image_header")
+   {
+      ossimContainerProperty* container = new ossimContainerProperty(name);
+      std::vector<ossimRefPtr<ossimProperty> > propertyList;
+      
+      theImageHeader->getPropertyList(propertyList);
+      container->addChildren(propertyList);
+      
+      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 if(name == "copy_fields_flag")
+   {
+      ossimBooleanProperty* boolProperty =
+      new ossimBooleanProperty(name, theCopyFieldsFlag);
+      
+      result = boolProperty;
+   }
+   else
+   {
+      return ossimImageFileWriter::getProperty(name);
+   }
+
+   return result;
+}
+
+void ossimNitf20Writer::getPropertyNames(std::vector<ossimString>& propertyNames)const
+{
+   ossimImageFileWriter::getPropertyNames(propertyNames);
+
+   propertyNames.push_back("file_header");
+   propertyNames.push_back("image_header");
+   propertyNames.push_back("enable_rpcb_tag");
+   propertyNames.push_back("enable_blocka_tag");
+   propertyNames.push_back("copy_fields_flag");
+}
+
+bool ossimNitf20Writer::writeBlockBandSeparate()
+{
+   ossimScalarType scalarType = theInputConnection->getOutputScalarType();
+   ossim_uint64 byteSize      = ossim::scalarSizeInBytes(scalarType);
+   ossimIrect rect            = theInputConnection->getBoundingRect();
+   ossim_uint64 bands         = theInputConnection->getNumberOfOutputBands();
+   ossim_uint64 idx           = 0;
+   ossim_uint64 headerStart   = (ossim_uint64)theOutputStream->tellp();
+
+   ossimIpt blockSize(64, 64);
+   ossim_uint64 blocksHorizontal = (ossim_uint32)ceil(((double)rect.width()/(double)blockSize.x));
+   ossim_uint64 blocksVertical   = (ossim_uint32)ceil(((double)rect.height()/(double)blockSize.y));
+
+   ossimNitfImageInfoRecordV2_0 imageInfoRecord;
+   //imageInfoRecord.setSubheaderLength(439); // ok if no tags
+   imageInfoRecord.setImageLength(bands*byteSize*blocksVertical*blockSize.y*blocksHorizontal*blockSize.x);
+
+   theFileHeader->addImageInfoRecord(imageInfoRecord);
+
+   //---
+   // This makes space for the file header; it is written again at the end of
+   // this method with updated values
+   // need a better way to get the length.  This should be queried on the
+   // header before writing
+   //---
+   theFileHeader->writeStream(*theOutputStream); 
+   ossim_uint64 headerLength = ((ossim_uint64)theOutputStream->tellp() - headerStart) /* + 1 */;
+   
+   ossimString representation;
+   theImageHeader->setActualBitsPerPixel(getActualBitsPerPixel());
+   theImageHeader->setBitsPerPixel(getBitsPerPixel());
+   theImageHeader->setPixelType(getNitfPixelType());
+   theImageHeader->setNumberOfBands(bands);
+   theImageHeader->setImageMode('B');// blocked
+
+   if((bands == 3)&&
+      (scalarType == OSSIM_UCHAR))
+   {
+      theImageHeader->setRepresentation("RGB");
+      theImageHeader->setCategory("VIS");
+   }
+   else if(bands == 1)
+   {
+      theImageHeader->setRepresentation("MONO");
+      theImageHeader->setCategory("MS");
+   }
+   else
+   {
+      theImageHeader->setRepresentation("MULTI");
+      theImageHeader->setCategory("MS");
+   }
+   
+   theImageHeader->setBlocksPerRow(blocksHorizontal);
+   theImageHeader->setBlocksPerCol(blocksVertical);
+   theImageHeader->setNumberOfPixelsPerBlockRow(blockSize.x);
+   theImageHeader->setNumberOfPixelsPerBlockCol(blockSize.y);
+   theImageHeader->setNumberOfRows(rect.height());
+   theImageHeader->setNumberOfCols(rect.width());
+
+   ossimNitfImageBandV2_0 bandInfo;
+   for(idx = 0; idx < bands; ++idx)
+   {
+      std::ostringstream out;
+      
+      out << std::setfill('0')
+          << std::setw(2)
+          << idx;
+      
+      bandInfo.setBandRepresentation(out.str().c_str());
+      theImageHeader->setBandInfo(idx,
+                              bandInfo);
+   }
+
+   ossim_uint64 imageHeaderStart = theOutputStream->tellp();
+   theImageHeader->writeStream(*theOutputStream);
+   ossim_uint64 imageHeaderEnd = theOutputStream->tellp();
+   ossim_uint64 imageHeaderSize = imageHeaderEnd - imageHeaderStart;
+
+   theInputConnection->setTileSize(blockSize);
+   ossim_uint64 numberOfTiles   = theInputConnection->getNumberOfTiles();
+   theInputConnection->setToStartOfSequence();
+   ossimRefPtr<ossimImageData> data = theInputConnection->getNextTile();
+   ossim_uint64 tileNumber = 1;
+   ossimEndian endian;
+
+   
+   while( data.valid() && !needsAborting())
+   {
+      if(endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN)
+      {
+         switch(data->getScalarType())
+         {
+            case OSSIM_USHORT16:
+            case OSSIM_USHORT11:
+            {
+               endian.swap((ossim_uint16*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            case OSSIM_SSHORT16:
+            {
+               endian.swap((ossim_sint16*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            case OSSIM_FLOAT:
+            case OSSIM_NORMALIZED_FLOAT:
+            {
+               endian.swap((ossim_float32*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            case OSSIM_DOUBLE:
+            case OSSIM_NORMALIZED_DOUBLE:
+            {
+               endian.swap((ossim_float64*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            default:
+               break;
+         }
+      }
+      
+      theOutputStream->write((char*)(data->getBuf()),
+                             data->getSizeInBytes());
+      
+      setPercentComplete(((double)tileNumber / (double)numberOfTiles) * 100);
+      
+      if(!needsAborting())
+      {
+         data = theInputConnection->getNextTile();
+      }
+      ++tileNumber;
+   }
+
+   ossim_uint64 pos = theOutputStream->tellp();
+
+   setComplexityLevel(pos);
+
+   /*
+    * 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->setHeaderLength(headerLength);
+   theOutputStream->seekp(0, ios::beg);
+   imageInfoRecord.setSubheaderLength(imageHeaderSize);
+   theFileHeader->replaceImageInfoRecord(0, imageInfoRecord);
+   theFileHeader->writeStream(*theOutputStream);
+   
+   return true;
+}
+
+bool ossimNitf20Writer::writeBlockBandSequential()
+{
+   ossimScalarType scalarType = theInputConnection->getOutputScalarType();
+   ossim_uint64    byteSize   = ossim::scalarSizeInBytes(scalarType);
+   ossimIrect      rect       = theInputConnection->getBoundingRect();
+   ossim_uint64    bands      = theInputConnection->getNumberOfOutputBands();
+   ossim_uint64    idx        = 0;
+   ossim_uint64    headerStart   = (ossim_uint64)theOutputStream->tellp();
+
+   ossimIpt blockSize(64, 64);
+
+   ossim_uint64 blocksHorizontal = theInputConnection->getNumberOfTilesHorizontal();
+   ossim_uint64 blocksVertical   = theInputConnection->getNumberOfTilesVertical();
+   theInputConnection->setTileSize(blockSize);
+   ossim_uint64 numberOfTiles   = theInputConnection->getNumberOfTiles();
+   theInputConnection->setToStartOfSequence();
+   
+   ossimNitfImageInfoRecordV2_0 imageInfoRecord;
+ //  imageInfoRecord.setSubheaderLength(439);
+   imageInfoRecord.setImageLength(bands*byteSize*blocksHorizontal*blocksVertical*blockSize.x*blockSize.y);
+
+   ossimDate currentDate;
+   
+   theFileHeader->setDate(currentDate);
+   theFileHeader->addImageInfoRecord(imageInfoRecord);
+
+   //---
+   // This makes space for the file header; it is written again at the end of
+   // this method with updated values
+   // need a better way to get the length.  This should be queried on the
+   // header before writing
+   //---  
+   theFileHeader->writeStream(*theOutputStream);
+   ossim_uint64 headerLength = ((ossim_uint64)theOutputStream->tellp() - headerStart) /* + 1 */;
+   
+   ossimString representation;
+   theImageHeader->setActualBitsPerPixel(getActualBitsPerPixel());
+   theImageHeader->setBitsPerPixel(getBitsPerPixel());
+   theImageHeader->setPixelType(getNitfPixelType());
+   theImageHeader->setNumberOfBands(bands);
+   theImageHeader->setImageMode('S');// blocked
+   
+   if((bands == 3)&&
+      (scalarType == OSSIM_UCHAR))
+   {
+      theImageHeader->setRepresentation("RGB");
+      theImageHeader->setCategory("VIS");
+   }
+   else if(bands == 1)
+   {
+      theImageHeader->setRepresentation("MONO");
+      theImageHeader->setCategory("MS");
+   }
+   else
+   {
+      theImageHeader->setRepresentation("MULTI");
+      theImageHeader->setCategory("MS");
+   }
+   theImageHeader->setBlocksPerRow(blocksHorizontal);
+   theImageHeader->setBlocksPerCol(blocksVertical);
+   theImageHeader->setNumberOfPixelsPerBlockRow(blockSize.x);
+   theImageHeader->setNumberOfPixelsPerBlockCol(blockSize.y);
+   theImageHeader->setNumberOfRows(rect.height());
+   theImageHeader->setNumberOfCols(rect.width());
+
+   ossimNitfImageBandV2_0 bandInfo;
+   for(idx = 0; idx < bands; ++idx)
+   {
+      std::ostringstream out;
+      
+      out << std::setfill('0')
+          << std::setw(2)
+          << idx;
+      
+      bandInfo.setBandRepresentation(out.str().c_str());
+      theImageHeader->setBandInfo(idx,
+                              bandInfo);
+   }
+
+   int imageHeaderStart = theOutputStream->tellp();
+   theImageHeader->writeStream(*theOutputStream);
+   int imageHeaderEnd = theOutputStream->tellp();
+   int imageHeaderSize = imageHeaderEnd - imageHeaderStart;
+
+   ossimIpt ul = rect.ul();
+   ossimRefPtr<ossimImageData> data = theInputConnection->getNextTile();
+   ossim_uint64 tileNumber = 0;
+   ossimEndian endian;
+
+   // get the start to the first band of data block
+   //
+   ossim_uint64 streamOffset = theOutputStream->tellp();
+   
+   // holds the total pixels to the next band
+
+   ossim_uint64 blockSizeInBytes = blockSize.x*blockSize.y*ossim::scalarSizeInBytes(data->getScalarType());
+   ossim_uint64 bandOffsetInBytes = (blockSizeInBytes*blocksHorizontal*blocksVertical);
+
+   bool needSwapping = endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN;
+   while(data.valid() && !needsAborting())
+   {
+      if(needSwapping)
+      {
+         switch(data->getScalarType())
+         {
+            case OSSIM_USHORT16:
+            case OSSIM_USHORT11:
+            {
+               endian.swap((ossim_uint16*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            case OSSIM_SSHORT16:
+            {
+               endian.swap((ossim_sint16*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            case OSSIM_FLOAT:
+            case OSSIM_NORMALIZED_FLOAT:
+            {
+               endian.swap((ossim_float32*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            case OSSIM_DOUBLE:
+            case OSSIM_NORMALIZED_DOUBLE:
+            {
+               endian.swap((ossim_float64*)data->getBuf(),
+                           data->getWidth()*data->getHeight()*data->getNumberOfBands());
+               break;
+            }
+            default:
+               break;
+         }
+      }
+
+      for(idx = 0; idx < bands; ++idx)
+      {
+         theOutputStream->seekp(streamOffset+ // start of image stream
+                                tileNumber*blockSizeInBytes + // start of block for band separate output
+                                bandOffsetInBytes*idx, // which band offset is it
+                                ios::beg); 
+         
+         theOutputStream->write((char*)(data->getBuf(idx)),
+                                blockSizeInBytes);
+      }
+      ++tileNumber;
+      
+      setPercentComplete(((double)tileNumber / (double)numberOfTiles) * 100);
+
+      if(!needsAborting())
+      {
+         data = theInputConnection->getNextTile();
+      }
+   }
+   
+   ossim_uint64 pos = theOutputStream->tellp();
+
+   setComplexityLevel(pos);
+
+   /*
+    * 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->setHeaderLength(headerLength);
+   theOutputStream->seekp(0, ios::beg);
+   imageInfoRecord.setSubheaderLength(imageHeaderSize);
+   theFileHeader->replaceImageInfoRecord(0, imageInfoRecord);
+   theFileHeader->writeStream(*theOutputStream);
+   
+   return true;
+}
+
+
+void ossimNitf20Writer::addRegisteredTag(
+   ossimRefPtr<ossimNitfRegisteredTag> registeredTag)
+{
+   ossimNitfTagInformation tagInfo;
+   tagInfo.setTagData(registeredTag.get());
+     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;
+   theFileHeader->setDate(currentDate);
+   
+   if(theCopyFieldsFlag)
+   {
+      ossimConnectableObject* obj = findObjectOfType("ossimImageHandler",
+                                                     ossimConnectableObject::CONNECTABLE_DIRECTION_INPUT);
+      ossimNitfTileSource* nitf = dynamic_cast<ossimNitfTileSource*>(obj);
+      if(nitf)
+      {
+         ossimString value;
+         ossimPropertyInterface* fileHeaderProperties = dynamic_cast<ossimPropertyInterface*>(theFileHeader.get());
+         ossimPropertyInterface* imageHeaderProperties = dynamic_cast<ossimPropertyInterface*>(theImageHeader.get());
+         bool nitf21Flag = false;
+         const ossimNitfFileHeader*   header      = nitf->getFileHeader();
+         const ossimNitfImageHeader*  imageHeader = nitf->getCurrentImageHeader();
+         if(header)
+         {
+            ossimString version = header->getPropertyValueAsString("fhdr");
+            nitf21Flag = version.contains("2.1");
+            value = header->getPropertyValueAsString("stype");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("stype", value);
+            }
+            value = header->getPropertyValueAsString("ostaid");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("ostaid", value);
+            }
+            value = header->getPropertyValueAsString("ftitle");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("ftitle", value);
+            }
+            value = header->getPropertyValueAsString("fsclas");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("fsclas", value);
+            }
+            value = header->getPropertyValueAsString("oname");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("oname", value);
+            }
+            value = header->getPropertyValueAsString("ophone");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("ophone", value);
+            }
+            int idx = 0;
+            for(idx = 0; idx < header->getNumberOfTags(); ++idx)
+            {
+               ossimNitfTagInformation info;
+               header->getTagInformation(info,
+                                         idx);
+               theFileHeader->addTag(info);
+            }
+            value = header->getPropertyValueAsString("");
+            if(value.size())
+            {
+               fileHeaderProperties->setProperty("", value);
+            }
+            value = header->getPropertyValueAsString("fdt");
+            if(value.size()==14)
+            {
+               if(nitf21Flag)
+               {
+                  ossimString year(value.begin()+2, value.begin()+4);
+                  ossimString mon(value.begin()+4, value.begin()+6);
+                  ossimString day(value.begin()+6, value.begin()+8);
+                  ossimString hour(value.begin()+8, value.begin()+10);
+                  ossimString min(value.begin()+10, value.begin()+12);
+                  ossimString sec(value.begin()+12, value.begin()+14);
+                  if(mon.toUInt32() < 13)
+                  {
+                     mon = monthConversionTable[mon.toUInt32()];
+                  }
+                  fileHeaderProperties->setProperty("fdt", day+hour+min+sec+"Z"+mon+year);
+               }
+               else
+               {
+                  fileHeaderProperties->setProperty("fdt", value);
+               }
+            }
+         }
+         if(imageHeader)
+         {
+            ossim_uint32 idx = 0;
+            for(idx = 0; idx < imageHeader->getNumberOfTags(); ++idx)
+            {
+               ossimNitfTagInformation info;
+               imageHeader->getTagInformation(info,
+                                              idx);
+               theImageHeader->addTag(info);
+            }
+            value = imageHeader->getPropertyValueAsString("tgtid");
+            if(value.size())
+            {
+               imageHeaderProperties->setProperty("tgtid", value);
+            }
+            value = imageHeader->getPropertyValueAsString("isclas");
+            if(value.size())
+            {
+               imageHeaderProperties->setProperty("isclas", value);
+            }
+            value = imageHeader->getPropertyValueAsString("igeolo");
+            if(value.size())
+            {
+               imageHeaderProperties->setProperty("igeolo", value);
+            }
+            value = imageHeader->getPropertyValueAsString("ititle");
+            if(nitf21Flag)
+            {
+               value = imageHeader->getPropertyValueAsString("iid2");
+            }
+            if(value.size())
+            {
+               imageHeaderProperties->setProperty("ititle", value);
+            }
+            if(!nitf21Flag)
+            {
+               value = imageHeader->getPropertyValueAsString("iscaut");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("iscaut", value);
+               }
+               value = imageHeader->getPropertyValueAsString("iscode");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("iscode", value);
+               }
+               value = imageHeader->getPropertyValueAsString("isctlh");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("isctlh", value);
+               }
+               value = imageHeader->getPropertyValueAsString("isrel");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("isrel", value);
+               }
+               value = imageHeader->getPropertyValueAsString("isctln");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("isctln", value);
+               }
+               value = imageHeader->getPropertyValueAsString("isdwng");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("isdevt", value);
+               }
+               value = imageHeader->getPropertyValueAsString("isorce");
+               if(value.size())
+               {
+                  imageHeaderProperties->setProperty("isorce", value);
+               }
+            }
+            value = imageHeader->getPropertyValueAsString("idatim");
+            if(value.size()==14)
+            {
+               if(nitf21Flag)
+               {
+                  ossimString year(value.begin()+2, value.begin()+4);
+                  ossimString mon(value.begin()+4, value.begin()+6);
+                  ossimString day(value.begin()+6, value.begin()+8);
+                  ossimString hour(value.begin()+8, value.begin()+10);
+                  ossimString min(value.begin()+10, value.begin()+12);
+                  ossimString sec(value.begin()+12, value.begin()+14);
+                  if(mon.toUInt32() < 13)
+                  {
+                     mon = monthConversionTable[mon.toUInt32()];
+                  }
+                  imageHeaderProperties->setProperty("idatim", day+hour+min+sec+"Z"+mon+year);
+               }
+               else
+               {
+                  imageHeaderProperties->setProperty("idatim", value);
+               }
+            }
+         }
+         
+         // we will port over only a selected few 
+      }
+   }
+}
+
+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
+{
+   kwl.add(prefix, "enable_rpcb_tag", theEnableRpcbTagFlag, true);
+   kwl.add(prefix, "enable_blocka_tag", theEnableBlockaTagFlag, true);
+
+   return ossimImageFileWriter::saveState(kwl, prefix);
+}
+
+bool ossimNitf20Writer::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);
+}
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp
index 7969ba73dffb5fdba674190d825b5a50a97b9057..d28e57466b40900bc7d04e3a935adb7f4ee7c5fc 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimNitfTileSource.cpp
@@ -7,18 +7,16 @@
 // Description:  Contains class definition for ossimNitfTileSource.
 // 
 //*******************************************************************
-//  $Id: ossimNitfTileSource.cpp 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimNitfTileSource.cpp 13943 2009-01-01 19:05:52Z dburken $
 #include <jerror.h>
 
 #include <ossim/imaging/ossimNitfTileSource.h>
 
 #include <ossim/base/ossimPackedBits.h>
-#include <ossim/support_data/ossimNitfFile.h>
-#include <ossim/support_data/ossimNitfFileHeader.h>
 #include <ossim/support_data/ossimNitfIchipbTag.h>
-#include <ossim/support_data/ossimNitfImageHeader.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 <ossim/base/ossimConstants.h>
@@ -44,7 +42,7 @@
 RTTI_DEF1_INST(ossimNitfTileSource, "ossimNitfTileSource", ossimImageHandler)
 
 #ifdef OSSIM_ID_ENABLED
-   static const char OSSIM_ID[] = "$Id: ossimNitfTileSource.cpp 12988 2008-06-04 16:49:43Z gpotts $";
+   static const char OSSIM_ID[] = "$Id: ossimNitfTileSource.cpp 13943 2009-01-01 19:05:52Z dburken $";
 #endif
    
 //---
@@ -123,27 +121,12 @@ void ossimNitfTileSource::destroy()
    }
 
    // Delete the list of image headers.
-   vector<ossimNitfImageHeader*>::iterator i = theNitfImageHeader.begin();
-   while (i != theNitfImageHeader.end())
-   {
-     if(*i)
-       {
-	 delete *i;
-	 (*i) = 0;
-       }
-      ++i;
-   }
    theNitfImageHeader.clear();
 
    if(theFileStr.is_open())
    {
       theFileStr.close();
    }
-   if (theNitfFile)
-   {
-      delete theNitfFile;
-      theNitfFile = 0;
-   }
 
    theCacheTile = 0;
    theTile      = 0;
@@ -271,14 +254,21 @@ bool ossimNitfTileSource::parseFile()
                << endl;
          }
       }
+
       if( !hdr->isCompressed() )
       {
-         theEntryList.push_back(i);
+         // Skip cloud mask images??? (drb)
+         if (hdr->getRepresentation() != "NODISPLY")
+         {
+            theEntryList.push_back(i);
+            theNitfImageHeader.push_back(hdr);
+         }
       }
       else if ( canUncompress(hdr) )
       {
          theEntryList.push_back(i);
          theCacheEnabledFlag = true;
+         theNitfImageHeader.push_back(hdr);
       }
       else
       {
@@ -289,8 +279,8 @@ bool ossimNitfTileSource::parseFile()
                <<" has an unsupported compression code = "
                << hdr->getCompressionCode() << std::endl;
          }
+         return false;
       }
-      theNitfImageHeader.push_back(hdr);
    }
    if(theEntryList.size()<1)
    {
@@ -458,10 +448,10 @@ bool ossimNitfTileSource::allocate()
    //---
    initializeCompressedBuf();
 
-   // Make the tiles.  Note the blank tile is intentionally left blank.
-   ossimImageDataFactory* idf = ossimImageDataFactory::instance();
-   theTile = idf->create(this, this);
-   theTile->initialize();
+   //---
+   // Make the output tile.
+   //---
+   initializeOutputTile();
 
    // Call base class complete open.
    completeOpen();
@@ -471,26 +461,28 @@ bool ossimNitfTileSource::allocate()
 
 bool ossimNitfTileSource::canUncompress(const ossimNitfImageHeader* hdr) const
 {
-   if (!hdr)
-   {
-      return false;
-   }
-   if (hdr->getCompressionCode() == "C3") // jpeg
+   bool result = false;
+   if (hdr)
    {
-      return true;
-   }
-   else if(isVqCompressed(hdr->getCompressionCode())&&
-           (hdr->getCompressionHeader().valid()))
-   {
-      // we will only support single band vq compressed NITFS
-      // basically CIB and CADRG products are single band code words.
-      //
-      if(hdr->getNumberOfBands() == 1)
+      ossimString code = hdr->getCompressionCode();
+      
+      if (code == "C3") // jpeg
       {
-         return true;
+         result = true;
+      }
+      else if(isVqCompressed( code ) &&
+              (hdr->getCompressionHeader().valid()) )
+      {
+         // we will only support single band vq compressed NITFS
+         // basically CIB and CADRG products are single band code words.
+         //
+         if(hdr->getNumberOfBands() == 1)
+         {
+            result = true;
+         }
       }
    }
-   return false;
+   return result;
 }
 
 void ossimNitfTileSource::initializeReadMode()
@@ -691,6 +683,10 @@ void ossimNitfTileSource::initializeBandCount()
    {
       theNumberOfInputBands = hdr->getNumberOfBands();
       theNumberOfOutputBands = hdr->getNumberOfBands();
+      if(hdr->getRepresentation().contains("LUT")&&(theNumberOfInputBands == 1))
+      {
+         theNumberOfOutputBands = 3;
+      }
    }
    else 
    {
@@ -863,56 +859,87 @@ void ossimNitfTileSource::initializeDecimationFactor()
 
 bool ossimNitfTileSource::initializeSubImageOffset()
 {
+   // Start with nan offset.
+   theSubImageOffset.makeNan();
+   
    const ossimNitfImageHeader* hdr = getCurrentImageHeader();
    if (!hdr)
    {
-      theSubImageOffset.makeNan();
       return false;
    }
 
-   // Set to upper left corner (typically 0,0)
-   theSubImageOffset = hdr->getImageRect().ul();
-
    //---
-   // 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.
+   // Look for the STDIDC tag for a sub image offset.
    //
-   // See trac # 1578
-   // http://trac.osgeo.org/ossim/ticket/1578
+   // See: STDI-002 Table 7.3 for documentation.
    //---
-   
-   const ossimRefPtr<ossimNitfRegisteredTag> tag =
-      hdr->getTagData(ossimString("ICHIPB"));
-   if (tag.valid())
+   ossimRefPtr<ossimNitfRegisteredTag> tag =
+      hdr->getTagData(ossimString("STDIDC"));
+   if (tag.valid() && (hdr->getIMode() == "B") )
    {
-      ossimNitfIchipbTag* ichipb = PTR_CAST(ossimNitfIchipbTag, tag.get());
-      if (ichipb)
+      ossimNitfStdidcTag* stdidc = PTR_CAST(ossimNitfStdidcTag, tag.get());
+      if (stdidc)
       {
-         const ossimRefPtr<ossimNitfRegisteredTag> blocka =
-            hdr->getTagData(ossimString("BLOCKA"));
-         const ossimRefPtr<ossimNitfRegisteredTag> rpc00a =
-            hdr->getTagData(ossimString("RPC00A"));              
-         const ossimRefPtr<ossimNitfRegisteredTag> rpc00b =
-            hdr->getTagData(ossimString("RPC00B"));
+         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();
+         }
+      }
+   }
 
-         //---
-         // If any of these tags are present we will use the sub image from
-         // the ichipb tag.
-         //---
-         if ( blocka.get() || rpc00a.get() || rpc00b.get() )
+   if (theSubImageOffset.hasNans())
+   {
+      //---
+      // 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())
+      {
+         ossimNitfIchipbTag* ichipb = PTR_CAST(ossimNitfIchipbTag, tag.get());
+         if (ichipb)
          {
-            ossimDpt pt;
-            ichipb->getSubImageOffset(pt);
-            theSubImageOffset = pt;
+            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() )
+            {
+               ossimDpt pt;
+               ichipb->getSubImageOffset(pt);
+               theSubImageOffset = pt;
+            }
          }
       }
    }
-   
+
+   // If still nan set to upper left corner (typically 0,0):
+   if (theSubImageOffset.hasNans())
+   {
+      theSubImageOffset = hdr->getImageRect().ul();
+   }
+
    if (traceDebug())
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -1096,6 +1123,15 @@ void ossimNitfTileSource::initializeCompressedBuf()
    }
 }
 
+void ossimNitfTileSource::initializeOutputTile()
+{
+   //---
+   // Make the output tile.  This implementation will use default tile size.
+   ossimImageDataFactory* idf = ossimImageDataFactory::instance();
+   theTile = idf->create(this, this);
+   theTile->initialize();
+}
+
 ossimRefPtr<ossimImageData> ossimNitfTileSource::getTile(
    const  ossimIrect& tileRect, ossim_uint32 resLevel)
 {
@@ -1661,7 +1697,7 @@ bool ossimNitfTileSource::getPosition(std::streamoff& streamPosition,
       return streamPosition;
    }
 
-   ossim_uint32 blockNumber = getBlockNumber(ossimIpt(x,y));
+   ossim_uint64 blockNumber = getBlockNumber(ossimIpt(x,y));
    
 
 #if 0
@@ -1669,10 +1705,10 @@ bool ossimNitfTileSource::getPosition(std::streamoff& streamPosition,
         << blockNumber << endl;
 #endif
    
-   streamPosition = hdr->getDataLocation(); // Position to first block.
+   streamPosition = (std::streamoff)hdr->getDataLocation(); // Position to first block.
    if(hdr->hasBlockMaskRecords())
    {
-      ossim_uint32 blockOffset = hdr->getBlockMaskRecordOffset(blockNumber,
+      ossim_uint64 blockOffset = hdr->getBlockMaskRecordOffset(blockNumber,
                                                                band);
       if(blockOffset == 0xffffffff)
       {
@@ -1688,12 +1724,13 @@ bool ossimNitfTileSource::getPosition(std::streamoff& streamPosition,
          if(!hdr->hasBlockMaskRecords())
          {
             streamPosition +=
-               (blockNumber * getBlockOffset()) +
-               (getBandOffset() * band);
+            (std::streamoff)((ossim_uint64)blockNumber * 
+                (ossim_uint64)getBlockOffset()) +
+               ((ossim_uint64)getBandOffset() * band);
          }
          else
          {
-            streamPosition += (getBandOffset() * band);
+            streamPosition += (std::streamoff)((ossim_uint64)getBandOffset() * (ossim_uint64)band);
             
          }
          break;
@@ -1702,8 +1739,8 @@ bool ossimNitfTileSource::getPosition(std::streamoff& streamPosition,
       case READ_BIB:
       {
          streamPosition +=
-            (blockNumber * theReadBlockSizeInBytes)+
-            (getBandOffset() * band);
+         (std::streamoff) ((ossim_uint64)blockNumber * (ossim_uint64)theReadBlockSizeInBytes)+
+            ((ossim_uint64)getBandOffset() * (ossim_uint64)band);
          break;
       }
       
@@ -1712,22 +1749,24 @@ bool ossimNitfTileSource::getPosition(std::streamoff& streamPosition,
          
          if(!hdr->hasBlockMaskRecords())
          {
-            streamPosition += (blockNumber * getBlockOffset()) +
-               (getBandOffset() * band);
+            streamPosition += (std::streamoff)((ossim_uint64)blockNumber * 
+                                               (ossim_uint64)getBlockOffset()) +
+                                              ((ossim_uint64)getBandOffset() * 
+                                               (ossim_uint64)band);
          }
          
          break;
       }
       case READ_JPEG_BLOCK:
       {
-         streamPosition += blockNumber * theReadBlockSizeInBytes;
+         streamPosition += (std::streamoff)((ossim_uint64)blockNumber * (ossim_uint64)theReadBlockSizeInBytes);
          break;
       }
       default:
       {
          if(!hdr->hasBlockMaskRecords())
          {
-            streamPosition += (blockNumber*getBlockOffset());
+            streamPosition += (std::streamoff)((ossim_uint64)blockNumber*(ossim_uint64)getBlockOffset());
          }
          
          break;
@@ -2186,9 +2225,19 @@ void ossimNitfTileSource::setCacheEnabledFlag(bool flag)
    }
 }
 
+const ossimNitfFileHeader* ossimNitfTileSource::getFileHeader()const
+{
+   if(theNitfFile.valid())
+   {
+      return theNitfFile->getHeader().get();
+   }
+   
+   return 0;
+}
+
 const ossimNitfImageHeader* ossimNitfTileSource::getCurrentImageHeader() const
 {
-   return theNitfImageHeader[theCurrentEntry];
+   return theNitfImageHeader[theCurrentEntry].get();
 }
 
 void ossimNitfTileSource::getDecimationFactor(ossim_uint32 resLevel,
@@ -2226,28 +2275,26 @@ ossimRefPtr<ossimProperty> ossimNitfTileSource::getProperty(const ossimString& n
    }
    else 
    {
-      if(theNitfFile)
+      if(theNitfFile.valid())
       {
          if(theNitfFile->getHeader().valid())
          {
             ossimRefPtr<ossimProperty> p = theNitfFile->getHeader()->getProperty(name);
-				if(p.valid())
-				{
-					return p;
-				}
+            if(p.valid())
+            {
+               return p;
+            }
          }
       }
-		const ossimNitfImageHeader* imageHeader = getCurrentImageHeader();
-		if(imageHeader)
+      const ossimNitfImageHeader* imageHeader = getCurrentImageHeader();
+      if(imageHeader)
       {
          ossimRefPtr<ossimProperty> p = imageHeader->getProperty(name);
-			if(p.valid())
-			{
-				return p;
-			}
-		}
-																		
-      return 0;
+         if(p.valid())
+         {
+            return p;
+         }
+      }
    }
 
    return ossimImageHandler::getProperty(name);
@@ -2278,16 +2325,15 @@ void ossimNitfTileSource::getPropertyNames(std::vector<ossimString>& propertyNam
 {
    ossimImageHandler::getPropertyNames(propertyNames);
    propertyNames.push_back(ossimKeywordNames::ENABLE_CACHE_KW);
-	if(theNitfFile->getHeader().valid())
-	{
-		theNitfFile->getHeader()->getPropertyNames(propertyNames);
-	}
-	const ossimNitfImageHeader* imageHeader = getCurrentImageHeader();
-	if(imageHeader)
-	{
-		imageHeader->getPropertyNames(propertyNames);
-	}
-
+   if(theNitfFile->getHeader().valid())
+   {
+      theNitfFile->getHeader()->getPropertyNames(propertyNames);
+   }
+   const ossimNitfImageHeader* imageHeader = getCurrentImageHeader();
+   if(imageHeader)
+   {
+      imageHeader->getPropertyNames(propertyNames);
+   }
 }
 
 ossimString ossimNitfTileSource::getSecurityClassification() const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp b/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp
index f2fd337e4bca93bff62efcc913c46cb76b714963..48842d8b7ac0a069677f00eec40f48449b3b7742 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimOrthoImageMosaic.cpp
@@ -5,7 +5,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimOrthoImageMosaic.cpp 10777 2007-04-25 14:49:17Z gpotts $
+//  $Id: ossimOrthoImageMosaic.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <ossim/imaging/ossimOrthoImageMosaic.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/base/ossimTrace.h>
@@ -41,7 +41,7 @@ ossim_uint32 ossimOrthoImageMosaic::getNumberOfOverlappingImages(const ossimIrec
    ossim_uint32 result = 0;
    for(ossim_uint32 i = 0; i < theInputTiePoints.size(); ++i)
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       getInput(i));
       if(interface&&
          !theInputTiePoints[i].hasNans())
@@ -68,7 +68,7 @@ void ossimOrthoImageMosaic::getOverlappingImages(std::vector<ossim_uint32>& resu
    result.clear();
    for(ossim_uint32 i = 0; i < theInputTiePoints.size(); ++i)
    {
-      ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                       getInput(i));
       if(interface&&
          !theInputTiePoints[i].hasNans())
@@ -90,7 +90,7 @@ bool ossimOrthoImageMosaic::getImageGeometry(ossimKeywordlist& kwl,
                                              const char* prefix)
 {
    bool result = true;
-   ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                    getInput(0));
    if(interface)
    {
@@ -168,7 +168,7 @@ ossimIrect ossimOrthoImageMosaic::getBoundingRect(ossim_uint32 resLevel) const
 
    decimation.makeNan();
 
-   ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                    getInput(0));
    if(interface)
    {
@@ -200,8 +200,8 @@ void ossimOrthoImageMosaic::initialize()
       theInputTiePoints.resize(getNumberOfInputs());
       for(ossim_uint32 i = 0; i < getNumberOfInputs(); ++i)
       {
-         ossimImageSourceInterface *interface =
-            PTR_CAST(ossimImageSourceInterface, getInput(i));
+         ossimImageSource *interface =
+            PTR_CAST(ossimImageSource, getInput(i));
          theInputTiePoints[i].makeNan();
          if(interface)
          {
@@ -307,13 +307,13 @@ ossimRefPtr<ossimImageData> ossimOrthoImageMosaic::getNextTile(ossim_uint32& ret
       return ossimRefPtr<ossimImageData>();
    }
    
-   ossimImageSourceInterface* temp = NULL;
+   ossimImageSource* temp = NULL;
    ossimRefPtr<ossimImageData> result;
    ossimDataObjectStatus status = OSSIM_NULL;
    
    do
    {
-      temp = PTR_CAST(ossimImageSourceInterface, getInput(theCurrentIndex));
+      temp = PTR_CAST(ossimImageSource, getInput(theCurrentIndex));
       if(temp)
       {
          ossimIrect relRect = getRelativeRect(theCurrentIndex, resLevel);
@@ -401,7 +401,7 @@ ossimIrect ossimOrthoImageMosaic::getRelativeRect(ossim_uint32 index,
                                                   ossim_uint32 resLevel)const
 {
    ossimIrect result;
-   ossimImageSourceInterface* interface = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* interface = PTR_CAST(ossimImageSource,
                                                    getInput(index));
    result.makeNan();
    if(interface&&
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimPixelFlipper.cpp b/Utilities/otbossim/src/ossim/imaging/ossimPixelFlipper.cpp
index dc7633941fe3ca77e2dddb3e4d25ae229acb89b0..7db8e70f0f871c598c2c087d17289269e1274861 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimPixelFlipper.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimPixelFlipper.cpp
@@ -9,7 +9,7 @@
 // Filter to toggle pixel values.
 //
 //*************************************************************************
-// $Id: ossimPixelFlipper.cpp 12983 2008-06-04 01:15:08Z dburken $
+// $Id: ossimPixelFlipper.cpp 13767 2008-10-22 19:31:51Z gpotts $
 
 #include <cstdlib>
 #include <ossim/imaging/ossimPixelFlipper.h>
@@ -31,7 +31,7 @@ static const char REPLACEMENT_MODE_KW[]  = "replacement_mode";
 static const char CLIP_MODE_KW[]  = "clip_mode";
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimPixelFlipper.cpp 12983 2008-06-04 01:15:08Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimPixelFlipper.cpp 13767 2008-10-22 19:31:51Z gpotts $";
 #endif
 
 ossimPixelFlipper::ossimPixelFlipper(ossimObject* owner)
@@ -180,6 +180,7 @@ void ossimPixelFlipper::flipPixels(T dummy,
          {
             if(!rect.intersects(theBoundingRects[resLevel]))
             {
+               delete [] buf;
                return;
             }
             else
@@ -202,6 +203,7 @@ void ossimPixelFlipper::flipPixels(T dummy,
                (!lrFlag)&&
                (!llFlag))
             {
+               delete [] buf;
                return; // none of the tile is inside so return
             }
             else
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimPolyCutter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimPolyCutter.cpp
index 3c2936b2b0ecb7a3845a06457aad13a0ac0e889e..3a1e5f12f9917edc8ac984e0350952d6d729e197 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimPolyCutter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimPolyCutter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimPolyCutter.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimPolyCutter.cpp 13660 2008-10-02 14:00:48Z gpotts $
 #include <ossim/imaging/ossimPolyCutter.h>
 #include <ossim/base/ossimPolyArea2d.h>
 #include <ossim/imaging/ossimImageData.h>
@@ -178,6 +178,11 @@ ossimIrect ossimPolyCutter::getBoundingRect(ossim_uint32 resLevel)const
          }
       }
    }
+   else if(isSourceEnabled())
+   {
+      return theBoundingRect;
+   }
+   
    return result;
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp
index 4c09035347480a475f94ae5ca69360e7549d395f..62f8581fe67e4220006d6e5b398562590132eefa 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimQuickbirdNitfTileSource.cpp
@@ -10,9 +10,10 @@
 // Description:
 //
 //*******************************************************************
-//  $Id: ossimQuickbirdNitfTileSource.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimQuickbirdNitfTileSource.cpp 13330 2008-07-28 18:04:40Z dburken $
 #include <ossim/imaging/ossimQuickbirdNitfTileSource.h>
 #include <ossim/support_data/ossimQuickbirdTile.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/support_data/ossimNitfImageHeader.h>
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimSFIMFusion.cpp b/Utilities/otbossim/src/ossim/imaging/ossimSFIMFusion.cpp
index cba5c59f72e1cbc545f11dbdd1215d03156197ea..7a5d300920af15ba283038c326f31c6c8dffd83e 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimSFIMFusion.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimSFIMFusion.cpp
@@ -6,10 +6,11 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimSFIMFusion.cpp 11347 2007-07-23 13:01:59Z gpotts $
+//  $Id: ossimSFIMFusion.cpp 13371 2008-08-02 13:42:42Z gpotts $
 #include <ossim/imaging/ossimSFIMFusion.h>
 #include <ossim/matrix/newmat.h>
 #include <ossim/matrix/newmatio.h>
+#include <ossim/base/ossimNumericProperty.h>
 #include <ossim/base/ossim2dLinearRegression.h>
 #include <ossim/base/ossimNormRgbVector.h>
 #include <ossim/base/ossimHsiVector.h>
@@ -19,11 +20,11 @@ RTTI_DEF2(ossimSFIMFusion, "ossimSFIMFusion", ossimFusionCombiner, ossimAdjustab
 
 
 static const ossim_uint32 HIGH_PASS_GAIN_OFFSET = 0;
-static const ossim_uint32 PAN_BLURR_WIDTH_OFFSET = 1;
+static const ossim_uint32 LOW_PASS_WIDTH_OFFSET = 1;
 static const ossim_uint32  NUMBER_OF_ADJUSTABLE_PARAMETERS = 2;
 
 ossimSFIMFusion::ossimSFIMFusion()
-   :theBlurrKernelWidth(1.5),
+   :theLowPassKernelWidth(1.5),
     theHighPassKernelWidth(3)
 {
    theLowPassFilter  = new ossimImageGaussianFilter;
@@ -168,10 +169,12 @@ ossimRefPtr<ossimImageData> ossimSFIMFusion::getTile(const ossimIrect& rect,
                if(*bands[idx] > 1.0) *bands[idx] = 1.0;
                if(*bands[idx] < normMinPix) *bands[idx] = normMinPix;
             }
-            else
-            {
-               *bands[idx] = 0.0;
-            }
+            // let's comment out the nulling and we will instead just pass the color on
+            //
+//            else
+//            {
+//               *bands[idx] = 0.0;
+//            }
             ++bands[idx];
          }
          ++panHigh;
@@ -207,7 +210,7 @@ void ossimSFIMFusion::initialize()
 
 void ossimSFIMFusion::setFilters()
 {
-   theLowPassFilter->setGaussStd(theBlurrKernelWidth);
+   theLowPassFilter->setGaussStd(theLowPassKernelWidth);
    
    theHighPassMatrix = NEWMAT::Matrix(theHighPassKernelWidth, theHighPassKernelWidth);
    theHighPassMatrix = 0;
@@ -250,26 +253,73 @@ void ossimSFIMFusion::initAdjustableParameters()
    setParameterCenter(HIGH_PASS_GAIN_OFFSET,
                       1.0);
 
-   setAdjustableParameter(PAN_BLURR_WIDTH_OFFSET,
+   setAdjustableParameter(LOW_PASS_WIDTH_OFFSET,
                           -1);
-   setParameterDescription(PAN_BLURR_WIDTH_OFFSET,
-                           "Blurring kernel width");
-   setParameterSigma(PAN_BLURR_WIDTH_OFFSET,
-                     7);
-   setParameterCenter(PAN_BLURR_WIDTH_OFFSET,
-                      7.5);
+   setParameterDescription(LOW_PASS_WIDTH_OFFSET,
+                           "Low pass kernel width");
+   setParameterSigma(LOW_PASS_WIDTH_OFFSET,
+                     40);
+   setParameterCenter(LOW_PASS_WIDTH_OFFSET,
+                      40.5);
    
 
-   setParameterOffset(PAN_BLURR_WIDTH_OFFSET,
+   setParameterOffset(LOW_PASS_WIDTH_OFFSET,
                       1.5);
 }
 
 void ossimSFIMFusion::adjustableParametersChanged()
 {
 //   std::cout << "Parameter offset = " << computeParameterOffset(2) << std::endl;
-   theBlurrKernelWidth = (ossim_uint32)(ossim::round<int>(computeParameterOffset(PAN_BLURR_WIDTH_OFFSET)));
+   theLowPassKernelWidth = (ossim_uint32)(ossim::round<int>(computeParameterOffset(LOW_PASS_WIDTH_OFFSET)));
+}
+
+void ossimSFIMFusion::setProperty(ossimRefPtr<ossimProperty> property)
+{
+   ossimString name = property->getName();
+   if(name=="lowPassKernelWidth")
+   {
+      setParameterOffset(LOW_PASS_WIDTH_OFFSET,
+                         property->valueToString().toDouble(),
+                         true);
+   }
+   else if(name=="highPassGain")
+   {
+      setParameterOffset(HIGH_PASS_GAIN_OFFSET,
+                         property->valueToString().toDouble(computeParameterOffset(HIGH_PASS_GAIN_OFFSET)),
+                         true);
+   }
+   else
+   {
+      ossimFusionCombiner::setProperty(property);
+   }
 }
 
+ossimRefPtr<ossimProperty> ossimSFIMFusion::getProperty(const ossimString& name)const
+{
+   if(name == "lowPassKernelWidth")
+   {
+      return new ossimNumericProperty(name, 
+                                      ossimString::toString(computeParameterOffset(LOW_PASS_WIDTH_OFFSET)),
+                                      getParameterCenter(LOW_PASS_WIDTH_OFFSET)-getParameterSigma(LOW_PASS_WIDTH_OFFSET),
+                                      getParameterCenter(LOW_PASS_WIDTH_OFFSET)+getParameterSigma(LOW_PASS_WIDTH_OFFSET));
+   }
+   else if(name == "highPassGain")
+   {
+      return new ossimNumericProperty(name, 
+                                      ossimString::toString(computeParameterOffset(HIGH_PASS_GAIN_OFFSET)),
+                                      getParameterCenter(HIGH_PASS_GAIN_OFFSET)-getParameterSigma(HIGH_PASS_GAIN_OFFSET),
+                                      getParameterCenter(HIGH_PASS_GAIN_OFFSET)+getParameterSigma(HIGH_PASS_GAIN_OFFSET));
+   }
+   
+   return ossimFusionCombiner::getProperty(name);
+}
+
+void ossimSFIMFusion::getPropertyNames(std::vector<ossimString>& propertyNames)const
+{
+   ossimFusionCombiner::getPropertyNames(propertyNames);
+   propertyNames.push_back("lowPassKernelWidth");
+   propertyNames.push_back("highPassGain");
+}
 
 bool ossimSFIMFusion::saveState(ossimKeywordlist& kwl,
                                             const char* prefix) const
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimSubImageTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimSubImageTileSource.cpp
index 46a8c77e5509e0dd5fcbaa78348a94cade016c67..6ffc444ff9c9a1552dd17bbb81dd03169bc52488 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimSubImageTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimSubImageTileSource.cpp
@@ -17,9 +17,10 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimSubImageTileSource.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimSubImageTileSource.cpp 13330 2008-07-28 18:04:40Z dburken $
 
 #include <ossim/imaging/ossimSubImageTileSource.h>
+#include <ossim/base/ossimDrect.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/imaging/ossimImageData.h>
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTableRemapper.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTableRemapper.cpp
index 522d52a26e9503fb4a0b41f68b1a9d6288329df5..27b262265a0458195741a1619193b5ed4384ff48 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTableRemapper.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTableRemapper.cpp
@@ -16,7 +16,7 @@
 // uses a normalized remap table (more scalar independent).
 //
 //*************************************************************************
-// $Id: ossimTableRemapper.cpp 11911 2007-10-28 18:21:41Z dburken $
+// $Id: ossimTableRemapper.cpp 13883 2008-11-19 14:21:16Z gpotts $
 
 #include <ossim/imaging/ossimTableRemapper.h>
 #include <ossim/base/ossimTrace.h>
@@ -35,20 +35,18 @@ ossimTableRemapper::ossimTableRemapper()
       ossimImageSourceFilter(),  // base class
       theTile(0),
       theTmpTile(0),
-      theTable(0),
       theNormBuf(0),
       theTableBinCount(0),
       theTableBandCount(0),
       theTableType(ossimTableRemapper::UKNOWN),
       theInputScalarType(OSSIM_SCALAR_UNKNOWN),
-      theOutputScalarType(OSSIM_SCALAR_UNKNOWN),
-      theTableOwnerFlag(true)
+      theOutputScalarType(OSSIM_SCALAR_UNKNOWN)
 {
    //***
    // Set the base class "theEnableFlag" to off since no adjustments have been
    // made yet.
    //***
-   disableSource();
+   //disableSource();
 }
 
 ossimTableRemapper::~ossimTableRemapper()
@@ -63,11 +61,6 @@ void ossimTableRemapper::destroy()
       delete [] theNormBuf;
       theNormBuf = 0;
    }
-   if (theTableOwnerFlag && theTable)
-   {
-      delete [] theTable;
-      theTable = 0;
-   }
    theTmpTile = 0;
    theTile    = 0;
 }
@@ -150,69 +143,54 @@ void ossimTableRemapper::allocate(const ossimIrect& rect)
 }
 
 ossimRefPtr<ossimImageData> ossimTableRemapper::getTile(
-   const ossimIrect& tile_rect,
-   ossim_uint32 resLevel)
+   const ossimIrect& tile_rect, ossim_uint32 resLevel)
 {
-   if(!theInputConnection)
+   ossimRefPtr<ossimImageData> result = 0;
+   
+   if(theInputConnection)
    {
-      return ossimRefPtr<ossimImageData>();
-   }
-
-   // Fetch tile from pointer from the input source.
-   ossimRefPtr<ossimImageData> inputTile =
-      theInputConnection->getTile(tile_rect, resLevel);
+      // Fetch tile from pointer from the input source.
+      result = theInputConnection->getTile(tile_rect, resLevel);
+      if (theEnableFlag&&result.valid())
+      {  
+         // Get its status of the input tile.
+         ossimDataObjectStatus tile_status = result->getDataObjectStatus();
+         
+         // Check for remap bypass:
+         if ( (tile_status != OSSIM_NULL) &&
+              (tile_status != OSSIM_EMPTY) && theTable.size() )
+         {
 
-   if (!inputTile.valid())  // Just in case...
-   {
-      if(traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN)
-            << "ossimTableRemapper::getTile ERROR:"
-            << "\nReceived null pointer to tile from input source!"
-            << "\nReturning blank tile.\n";
+            // OK we have an input tile... and it's not null or empty.
+            if(!theTile)
+            {
+               allocate(tile_rect);
+            }
+            if (theTile.valid())
+            {
+               theTile->setImageRectangle(tile_rect);
+               if(theTmpTile.valid()) // not mandatory for all modes.
+               {
+                  theTmpTile->setImageRectangle(tile_rect);
+               }   
+               // Think things are good.  Do the real work...
+               if (theTableType == ossimTableRemapper::NATIVE)
+               {
+                  // Most efficient case...
+                  remapFromNativeTable(result);
+               }
+               else
+               {
+                  remapFromNormalizedTable(result);
+               }
+              
+               theTile->validate();
+               result = theTile;
+            }
+         }
       }
-      return inputTile;
-   }
-
-   // Get its status.
-   ossimDataObjectStatus tile_status = inputTile->getDataObjectStatus();
-
-   // Check for remap bypass:
-   if ( !theEnableFlag ||
-        tile_status == OSSIM_NULL ||
-        tile_status == OSSIM_EMPTY )
-   {
-      return inputTile;
-   }
-
-   // OK we have an input tile... and it's not null or empty.
-
-   // Check for first time through or size or band change.
-   if ( !theTile ||  
-        tile_rect.height() != theTile->getHeight() ||
-        tile_rect.width()  != theTile->getWidth()  ||
-        inputTile->getNumberOfBands() != theTile->getNumberOfBands())
-   {
-      allocate(tile_rect);
-   }
-
-   // Set the origin of the output tile.
-   theTile->setImageRectangle(tile_rect);
-   
-   // Think things are good.  Do the real work...
-   if (theTableType == ossimTableRemapper::NATIVE)
-   {
-      // Most efficient case...
-      remapFromNativeTable(inputTile);
-   }
-   else
-   {
-      remapFromNormalizedTable(inputTile);
    }
-   
-   theTile->validate();
-
-   return theTile;
+   return result;
 }
 
 void ossimTableRemapper::remapFromNativeTable(
@@ -220,7 +198,7 @@ void ossimTableRemapper::remapFromNativeTable(
 {
    switch (theOutputScalarType)
    {
-      case OSSIM_UCHAR:
+      case OSSIM_UINT8:
       {
          remapFromNativeTable(ossim_uint8(0), inputTile);
          break;
@@ -282,8 +260,8 @@ template <class T> void ossimTableRemapper::remapFromNativeTable(
    const ossim_uint32 BAND_OFFSET =
       (theTableBandCount != 1) ? theTableBinCount: 0;
 
-   const T* rt = reinterpret_cast<T*>(theTable); // remap table (rt)
-   ossimRefPtr<ossimImageData> id = NULL;
+   const T* rt = reinterpret_cast<T*>(&theTable.front()); // remap table (rt)
+   ossimRefPtr<ossimImageData> id;
    if (theInputScalarType == theOutputScalarType)
    {
       id = theTile;
@@ -296,7 +274,7 @@ template <class T> void ossimTableRemapper::remapFromNativeTable(
    for (ossim_uint32 band = 0; band < BANDS; ++band)
    {
       const T NULL_PIX = static_cast<T>(id->getNullPix(band));
-      const T MIN_PIX  = static_cast<T>(id->getMinPix(band));
+      //const T MIN_PIX  = static_cast<T>(id->getMinPix(band));
 
       const T* s = static_cast<T*>(inputTile->getBuf(band)); // source (s)
       T*       d = static_cast<T*>(id->getBuf(band));   // destination (d)
@@ -310,22 +288,51 @@ template <class T> void ossimTableRemapper::remapFromNativeTable(
          T p = s[pixel];
          if (p == NULL_PIX)  // Null is not always zero (dted).
          {
-            p = 0;
+            d[pixel] = NULL_PIX;
+           // p = 0;
          }
          else
          {
-            p = (p+1-MIN_PIX);  // If min == 1 we want that to map to index 1.
+//         else
+//         {
+//            p = (p+1-MIN_PIX);  // If min == 1 we want that to map to index 1.
+//         }
+
+            ossim_uint32 table_index = static_cast<ossim_uint32>(p);
+            
+            //---
+            // If within range use to index the remap table; else, null.
+            // Note:
+            // There is no min, max range checking on value retrieved from table.
+            // Range checking should be performed when the table is built.
+            //---
+            if((table_index >=0) && (table_index < theTableBinCount))
+            {
+               d[pixel] = rt[table_index];
+            }
+            else if(table_index < 0)
+            {
+               if(theTableBinCount > 1)
+               {
+                  d[pixel] = rt[1];
+               }
+               else
+               {
+                  d[pixel] = table_index;
+               }
+            }
+            else
+            {
+               if(theTableBinCount>0)
+               {
+                  d[pixel] = rt[theTableBinCount-1];
+               }
+               else
+               {
+                  d[pixel] = table_index;
+              }
+            }
          }
-
-         ossim_uint32 table_index = static_cast<ossim_uint32>(p);
-
-         //---
-         // If within range use to index the remap table; else, null.
-         // Note:
-         // There is no min, max range checking on value retrieved from table.
-         // Range checking should be performed when the table is built.
-         //---
-         d[pixel] =(table_index < theTableBinCount) ? rt[table_index] : NULL_PIX;
       }
 
       rt += BAND_OFFSET; // Go to next band in the table.
@@ -363,10 +370,10 @@ void ossimTableRemapper::remapFromNormalizedTable(
    const ossim_uint32 BAND_OFFSET = (theTableBandCount == 1) ? 0 : PPB;
 
    // remap table (rt)
-   ossim_float64* rt = reinterpret_cast<ossim_float64*>(theTable); 
+   ossim_float64* rt = reinterpret_cast<ossim_float64*>(&theTable.front()); 
 
    ossim_float64* buf = theNormBuf;
-   
+   ossim_float64 p = 0.0;
    for (ossim_uint32 band = 0; band < BANDS; ++band)
    {
       for (ossim_uint32 pixel = 0; pixel < PPB; ++pixel)
@@ -375,12 +382,21 @@ void ossimTableRemapper::remapFromNormalizedTable(
          ossim_uint32 index
             = static_cast<ossim_uint32>(buf[pixel]*theTableBinCount+0.5);
 
-         // If within range use to index the remap table; else, null.
-         ossim_float64 p = (index < theTableBinCount) ? rt[index] : 0.0;
-
+         if((index < theTableBinCount) && (index >=0))
+         {
+            // If within range use to index the remap table; else, null.
+            p = (index < theTableBinCount) ? rt[index] : 0.0;
+         }
+         else if(index < 0)
+         {
+            p = 0.0;
+         }
+         else 
+         {
+            p = 1.0;
+         }
          // Range check (in case table bad) and assign to destination pixel.
-         buf[pixel]
-            = (p >= 0.0) ? ( (p <=1.0) ? p : 1) : 0.0;
+         buf[pixel] = (p >= 0.0) ? ( (p <=1.0) ? p : 1) : 0.0;
       }
 
       // Go to next band.
@@ -402,12 +418,11 @@ ossimScalarType ossimTableRemapper::getOutputScalarType() const
    return ossimImageSourceFilter::getOutputScalarType();
 }
 
-void ossimTableRemapper::setTable(ossim_uint8* table,
+void ossimTableRemapper::setTable(const std::vector<ossim_uint8>& table,
                                   ossim_uint32 table_bin_count,
                                   ossim_uint32 table_band_count,
                                   RemapTableType table_type,
-                                  ossimScalarType output_scalar_type,
-                                  bool own_table)
+                                  ossimScalarType output_scalar_type)
 {
    // Start with a clean slate...
    destroy();
@@ -417,11 +432,6 @@ void ossimTableRemapper::setTable(ossim_uint8* table,
    theTableBandCount   = table_band_count;
    theTableType        = table_type;
    theOutputScalarType = output_scalar_type;
-
-   if (theInputConnection)
-   {
-      theEnableFlag = true;
-   }
 }
 
 bool ossimTableRemapper::loadState(const ossimKeywordlist& kwl,
@@ -463,7 +473,6 @@ ostream& ossimTableRemapper::print(ostream& os) const
       << "\ntheTableType:        " << TABLE_TYPE[theTableType]
       << "\ntheInputScalarType:  " << (*sl)[theInputScalarType]
       << "\ntheOutputScalarType: " << (*sl)[theOutputScalarType]
-      << "\ntheTableOwnerFlag:   " << (theTableOwnerFlag ? "true" : "false")
       << endl;
    
    if (theTile.valid())
@@ -527,12 +536,12 @@ ostream& ossimTableRemapper::print(ostream& os) const
 template <class T> void ossimTableRemapper::dumpTable(T /*dummy*/,
                                                       ostream& os) const
 {
-   if (!theTable || !theTableBinCount || !theTableBandCount)
+   if (theTable.empty() || !theTableBinCount || !theTableBandCount)
    {
       return;
    }
 
-   T* table = reinterpret_cast<T*>(theTable);
+   const T* table = reinterpret_cast<const T*>(&theTable.front());
 
    ossim_uint32 table_index = 0;
    for (ossim_uint32 band = 0; band < theTableBandCount; ++band)
@@ -546,10 +555,6 @@ template <class T> void ossimTableRemapper::dumpTable(T /*dummy*/,
    }
 }
 
-void ossimTableRemapper::setTableOwnership(bool flag)
-{
-   theTableOwnerFlag = flag;
-}
 
 ostream& operator<<(ostream& os, const ossimTableRemapper& tr)
 {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp
index e98a43a0f6e2efbb0315acbd06dbc18726f535ca..2f441f0e161d2f4c16c826aca30f6a5f274fdc8a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiffOverviewBuilder.cpp
@@ -9,7 +9,7 @@
 // Contains class definition for TiffOverviewBuilder
 // 
 //*******************************************************************
-//  $Id: ossimTiffOverviewBuilder.cpp 11699 2007-09-10 15:23:26Z gpotts $
+//  $Id: ossimTiffOverviewBuilder.cpp 13155 2008-07-08 15:59:52Z gpotts $
 
 #include <cstring>
 #include <sstream>
@@ -49,7 +49,7 @@ RTTI_DEF1(ossimTiffOverviewBuilder,
 static ossimTrace traceDebug("ossimTiffOverviewBuilder:degug");
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimTiffOverviewBuilder.cpp 11699 2007-09-10 15:23:26Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimTiffOverviewBuilder.cpp 13155 2008-07-08 15:59:52Z gpotts $";
 #endif
 
 
@@ -397,9 +397,11 @@ bool ossimTiffOverviewBuilder::execute()
       }
 
       theOutputFileTmp.rename(theOutputFile);
-      ossimNotify(ossimNotifyLevel_INFO)
+		if(traceDebug())
+		{
+			ossimNotify(ossimNotifyLevel_INFO)
          << "Wrote file:  " << theOutputFile.c_str() << std::endl;
-   
+		}
       ossimFilename file=theOutputFile;
       file = file.setExtension("omd");
       ossimKeywordlist kwl;
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp
index 60bf6fad6d0210384b0bafea29b1115dfbf8d90a..54be0faaf26106d61915346464e53ecca3a39c9e 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiffTileSource.cpp
@@ -10,7 +10,7 @@
 // Contains class definition for TiffTileSource.
 //
 //*******************************************************************
-//  $Id: ossimTiffTileSource.cpp 12988 2008-06-04 16:49:43Z gpotts $
+//  $Id: ossimTiffTileSource.cpp 13482 2008-08-22 17:04:25Z gpotts $
 
 #include <cstdlib> /* for abs(int) */
 #include <ossim/imaging/ossimTiffTileSource.h>
@@ -206,15 +206,19 @@ ossimRefPtr<ossimImageData> ossimTiffTileSource::getTile(
       }
       else
       {
-         // Error in filling buffer.
-         ossimNotify(ossimNotifyLevel_WARN)
+         theTile->makeBlank();
+         if(traceDebug())
+         {
+            // Error in filling buffer.
+            ossimNotify(ossimNotifyLevel_WARN)
             << MODULE << " Returning blank tile..." << endl;
-         return ossimRefPtr<ossimImageData>();
+         }
+         return theTile;
       }
    }
-
+   theTile->makeBlank();
    // No part of requested tile within the image rectangle.
-   return ossimRefPtr<ossimImageData>();
+   return theTile;
 }
 
 //*******************************************************************
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp
index 5aca25ee1ce23d3019ceab34aa9ba587deb81b08..dc3a7c64be6fd4322604015754bd5ace964e7d3a 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiffWriter.cpp
@@ -613,7 +613,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-01 17:44:19 +0100 (Thu, 01 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: 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)";
 
       GTIFKeySet(gtif,
                  GeogCitationGeoKey,
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTilePatch.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTilePatch.cpp
index d73a448acb1190e9d75aa2a39d4348387775c9d3..4b8a3a1012f4de787a874b9f2bf02ebd6396743e 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTilePatch.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTilePatch.cpp
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimTilePatch.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimTilePatch.cpp 13312 2008-07-27 01:26:52Z gpotts $
 
 #include <vector>
 using namespace std;
@@ -20,7 +20,7 @@ using namespace std;
 #include <ossim/base/ossimErrorCodes.h>
 ossimDiscreteNearestNeighbor ossimTilePatch::nearestNeighborKernel;
 
-ossimTilePatch::ossimTilePatch(ossimImageSourceInterface* input)
+ossimTilePatch::ossimTilePatch(ossimImageSource* input)
 {
    thePatchData = ossimImageDataFactory::instance()->create(NULL, input);
    thePatchData->initialize();
@@ -65,7 +65,7 @@ ossimDrect ossimTilePatch::findBoundingRect(const ossimDpt &p1,
    return ossimDrect(points);
 }
 
-void ossimTilePatch::fillPatch(ossimImageSourceInterface* tileSource,
+void ossimTilePatch::fillPatch(ossimImageSource* tileSource,
                                long resLevel)
 {
    // long w = tileSource->getTileWidth();
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTiling.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTiling.cpp
index 704bc34dab5f72a7de37ba1b4daa9c025a330988..14eee6a06ae85dcaad26379eef6ba6e2c5523f46 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTiling.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTiling.cpp
@@ -10,7 +10,7 @@
 // Description: implementation for image generator
 //
 //*************************************************************************
-// $Id: ossimTiling.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimTiling.cpp 13711 2008-10-14 16:49:38Z gpotts $
 
 #include <sstream>
 #include <iomanip>
@@ -742,8 +742,11 @@ bool ossimTiling::loadState(const ossimKeywordlist& kwl,
                                               "padding_size_in_pixels");
    if (paddingSizeInPixels)
    {
+      ossimString x,y;
       std::istringstream padding(ossimString(paddingSizeInPixels).c_str());
-      padding >> thePaddingSizeInPixels.x >> thePaddingSizeInPixels.y;
+      padding >> x >> y;
+      thePaddingSizeInPixels.x = x.toFloat64();
+      thePaddingSizeInPixels.y = y.toFloat64();
    }
    
    // Check to tile by size in bytes.
@@ -816,10 +819,11 @@ bool ossimTiling::loadState(const ossimKeywordlist& kwl,
                                        "delta_type");
       
       result = tilingDistance&&tilingDistanceType&&delta&&deltaType&&paddingSizeInPixels;
-      
+      ossimString x,y;
       std::istringstream distance(ossimString(tilingDistance).c_str());
-      distance >> theTilingDistance.x >> theTilingDistance.y;
-      
+      distance >> x >> y;
+      theTilingDistance.x = x.toFloat64();
+      theTilingDistance.y = y.toFloat64();
       if(theTilingDistance.x <= 0.0)
       {
          theTilingDistance.x = 1.0;
@@ -836,9 +840,12 @@ bool ossimTiling::loadState(const ossimKeywordlist& kwl,
             ossimString(tilingDistanceType).c_str());
       
       theDelta = ossimDpt(0,0);
-      
+      x="";
+      y="";
       std::istringstream deltaValues(ossimString(delta).c_str());
-      deltaValues >> theDelta.x >> theDelta.y;
+      deltaValues >> x >> y;
+      theDelta.x = x.toFloat64();
+      theDelta.y = y.toFloat64();
       
       if(theDelta.x <= 0.0)
       {
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTopographicCorrectionFilter.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTopographicCorrectionFilter.cpp
index fd23777d0a769e57a14714d92968a8d2a4ede937..282cc86848937b344bd6023ae1230ad740495cd9 100644
--- a/Utilities/otbossim/src/ossim/imaging/ossimTopographicCorrectionFilter.cpp
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTopographicCorrectionFilter.cpp
@@ -8,7 +8,7 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimTopographicCorrectionFilter.cpp 11955 2007-10-31 16:10:22Z gpotts $
+// $Id: ossimTopographicCorrectionFilter.cpp 13312 2008-07-27 01:26:52Z gpotts $
 #include <algorithm>
 #include <sstream>
 #include <ossim/imaging/ossimTopographicCorrectionFilter.h>
@@ -68,9 +68,9 @@ ossimRefPtr<ossimImageData> ossimTopographicCorrectionFilter::getTile(
    const  ossimIrect& tileRect,
    ossim_uint32 resLevel)
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource,
                                                      getInput(0));
-   ossimImageSourceInterface* normalSource  = PTR_CAST(ossimImageSourceInterface,
+   ossimImageSource* normalSource  = PTR_CAST(ossimImageSource,
                                                        getInput(1));
 
    if(!isSourceEnabled()||!normalSource||!colorSource)
@@ -161,7 +161,7 @@ void ossimTopographicCorrectionFilter::allocate()
    theBandMapping.clear();
    if(isSourceEnabled())
    {
-      // ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+      // ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
 
       theTile = ossimImageDataFactory::instance()->create(this, this);
       theTile->initialize();
@@ -175,7 +175,7 @@ void ossimTopographicCorrectionFilter::allocate()
       //
       resizeArrays(arraySize);
 
-      ossimImageSourceInterface* input1 = PTR_CAST(ossimImageSourceInterface,
+      ossimImageSource* input1 = PTR_CAST(ossimImageSource,
                                                    getInput(0));
       if(input1)
       {
@@ -579,8 +579,8 @@ void ossimTopographicCorrectionFilter::computeC()
    theNdviLowTest  = 0.1;
    theNdviHighTest = 1;
 
-   ossimImageSourceInterface* colorSource  = PTR_CAST(ossimImageSourceInterface, getInput(0));
-   ossimImageSourceInterface* normalSource = PTR_CAST(ossimImageSourceInterface, getInput(1));
+   ossimImageSource* colorSource  = PTR_CAST(ossimImageSource, getInput(0));
+   ossimImageSource* normalSource = PTR_CAST(ossimImageSource, getInput(1));
 
    if(!colorSource || !normalSource)
    {
@@ -1069,7 +1069,7 @@ bool ossimTopographicCorrectionFilter::saveState(ossimKeywordlist& kwl,
 
 ossim_uint32 ossimTopographicCorrectionFilter::getNumberOfOutputBands() const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       return colorSource->getNumberOfOutputBands();
@@ -1079,7 +1079,7 @@ ossim_uint32 ossimTopographicCorrectionFilter::getNumberOfOutputBands() const
 
 ossimScalarType ossimTopographicCorrectionFilter::getOutputScalarType() const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       return colorSource->getOutputScalarType();
@@ -1089,7 +1089,7 @@ ossimScalarType ossimTopographicCorrectionFilter::getOutputScalarType() const
 
 double ossimTopographicCorrectionFilter::getNullPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       return colorSource->getNullPixelValue(band);
@@ -1099,7 +1099,7 @@ double ossimTopographicCorrectionFilter::getNullPixelValue(ossim_uint32 band)con
 
 double ossimTopographicCorrectionFilter::getMinPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       return colorSource->getMinPixelValue(band);
@@ -1109,7 +1109,7 @@ double ossimTopographicCorrectionFilter::getMinPixelValue(ossim_uint32 band)cons
 
 double ossimTopographicCorrectionFilter::getMaxPixelValue(ossim_uint32 band)const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       return colorSource->getMaxPixelValue(band);
@@ -1121,7 +1121,7 @@ ossimIrect ossimTopographicCorrectionFilter::getBoundingRect(ossim_uint32 resLev
 {
    ossimIrect result;
    result.makeNan();
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
 
    if(colorSource)
    {
@@ -1135,7 +1135,7 @@ void ossimTopographicCorrectionFilter::getDecimationFactor(ossim_uint32 resLevel
                                                            ossimDpt& result) const
 {
    result.makeNan();
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
 
    if(colorSource)
    {
@@ -1146,7 +1146,7 @@ void ossimTopographicCorrectionFilter::getDecimationFactor(ossim_uint32 resLevel
 
 void ossimTopographicCorrectionFilter::getDecimationFactors(vector<ossimDpt>& decimations) const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       colorSource->getDecimationFactors(decimations);
@@ -1155,7 +1155,7 @@ void ossimTopographicCorrectionFilter::getDecimationFactors(vector<ossimDpt>& de
 
 ossim_uint32 ossimTopographicCorrectionFilter::getNumberOfDecimationLevels()const
 {
-   ossimImageSourceInterface* colorSource = PTR_CAST(ossimImageSourceInterface, getInput(0));
+   ossimImageSource* colorSource = PTR_CAST(ossimImageSource, getInput(0));
    if(colorSource)
    {
       return colorSource->getNumberOfDecimationLevels();
@@ -1187,7 +1187,7 @@ bool ossimTopographicCorrectionFilter::canConnectMyInputTo(ossim_int32 inputInde
 {
    return (object&&
            ( (inputIndex>=0) && inputIndex < 2)&&
-           PTR_CAST(ossimImageSourceInterface, object));
+           PTR_CAST(ossimImageSource, object));
 
 }
 
diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTwoColorView.cpp b/Utilities/otbossim/src/ossim/imaging/ossimTwoColorView.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8ad091d838467966eb789476c240ace34978ee3e
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/imaging/ossimTwoColorView.cpp
@@ -0,0 +1,559 @@
+//-------------------------------------------------------------------
+// License:  LGPL.  See top level LICENSE.txt file.
+//
+// Author:  Garrett Potts
+//
+//-------------------------------------------------------------------
+//  $Id$
+#include <ossim/imaging/ossimTwoColorView.h>
+#include <ossim/imaging/ossimImageDataFactory.h>
+
+RTTI_DEF1(ossimTwoColorView,
+          "ossimTwoColorView" ,
+          ossimImageCombiner);
+
+ossimTwoColorView::ossimTwoColorView()
+:ossimImageCombiner(0, 2, 0, true, false) ,
+theByPassFlag(true),
+theNativeFlag(false),
+theNewInput(0),
+theOldInput(0),
+theNewBufferDestinationIndex(2),
+theOldBufferDestinationIndex(0),
+theMinBufferDestinationIndex(1){
+}
+
+ossim_uint32 ossimTwoColorView::getNumberOfOutputBands() const
+{
+   if(theByPassFlag||!isSourceEnabled())
+   {
+      return ossimImageCombiner::getNumberOfOutputBands();
+   }
+   return 3;
+}
+
+ossimScalarType ossimTwoColorView::getOutputScalarType() const
+{
+   if(theByPassFlag||!isSourceEnabled())
+   {
+      return ossimImageCombiner::getOutputScalarType();
+   }
+   return OSSIM_UINT8;
+}
+
+void ossimTwoColorView::setIndexMapping(ossim_uint32 newIndex,
+                                        ossim_uint32 oldIndex)
+{
+   if(((newIndex < 3)&&(oldIndex < 3))&&
+      (newIndex != oldIndex))
+   {
+      theNewBufferDestinationIndex = newIndex;
+      theOldBufferDestinationIndex = oldIndex;
+      if((theNewBufferDestinationIndex != 0)&&
+         (theOldBufferDestinationIndex != 0))
+      {
+         theMinBufferDestinationIndex = 0;
+      }
+      else if((theNewBufferDestinationIndex != 1)&&
+              (theOldBufferDestinationIndex != 1))
+      {
+         theMinBufferDestinationIndex = 1;
+      }
+      else if((theNewBufferDestinationIndex != 2)&&
+              (theOldBufferDestinationIndex != 2))
+      {
+         theMinBufferDestinationIndex = 2;
+      }
+   }
+}
+
+double ossimTwoColorView::getNullPixelValue(ossim_uint32 band)const
+{
+   if(theByPassFlag||!isSourceEnabled())
+   {
+      return ossimImageCombiner::getNullPixelValue(band);
+   }
+   return 0;
+}
+
+double ossimTwoColorView::getMinPixelValue(ossim_uint32 band)const
+{
+   if(theByPassFlag||!isSourceEnabled())
+   {
+      return ossimImageCombiner::getMinPixelValue(band);
+   }
+   return 1;
+}
+
+double ossimTwoColorView::getMaxPixelValue(ossim_uint32 band)const
+{
+   if(theByPassFlag||!isSourceEnabled())
+   {
+      return ossimImageCombiner::getMaxPixelValue(band);
+   }
+   return 256;
+}
+
+ossimRefPtr<ossimImageData> ossimTwoColorView::getTile(const ossimIrect& rect,
+                                                       ossim_uint32 resLevel)
+{
+   ossim_uint32 tileIdx = 0;
+   if(theByPassFlag||!isSourceEnabled())
+   {
+      return getNextTile(tileIdx, 0, rect, resLevel);
+   }
+   if(!theTwoColorTile.valid())
+   {
+      allocate();
+   }
+   if(!theTwoColorTile.valid())
+   {
+      return theTwoColorTile;
+   }
+   theTwoColorTile->setImageRectangle(rect);
+   theTwoColorTile->makeBlank();
+   
+   ossimRefPtr<ossimImageData> newData = theNewInput->getTile(rect, resLevel);
+   ossimRefPtr<ossimImageData> oldData = theOldInput->getTile(rect, resLevel);
+   runAlgorithm(newData.get(), oldData.get());
+   
+#if 0
+   // do the new band first
+   ossimRefPtr<ossimImageData> newData = getNextNormTile(tileIdx, 0, rect, resLevel);
+   newData = newData.valid()?(ossimImageData*)newData->dup():(ossimImageData*)0;
+   ossimRefPtr<ossimImageData> oldData = getNextNormTile(tileIdx,rect, resLevel);
+   oldData = oldData.valid()?(ossimImageData*)oldData->dup():(ossimImageData*)0;
+   
+   ossim_float32 newNullPix = 0.0;
+   ossim_float32 oldNullPix = 0.0;
+   const ossim_float32* newBuf = 0;
+   const ossim_float32* oldBuf = 0;
+   ossim_float32 tempValue = 0.0;
+   ossim_uint32 idx = 0;
+   ossim_uint32 maxIdx = theTwoColorTile->getWidth()*theTwoColorTile->getHeight();
+   ossim_uint8* newDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theNewBufferDestinationIndex));
+   ossim_uint8* oldDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theOldBufferDestinationIndex));
+   ossim_uint8* minDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theMinBufferDestinationIndex));
+   
+   
+   if(newData.valid())
+   {
+      newBuf     = static_cast<ossim_float32*>(newData->getBuf(0));
+      newNullPix = static_cast<ossim_float32>(newData->getNullPix(0));
+   }
+   if(oldData.valid())
+   {
+      oldBuf = static_cast<ossim_float32*>(oldData->getBuf(0));   
+      oldNullPix    = static_cast<ossim_float32>(oldData->getNullPix(0));
+   }
+   
+   if(!newBuf&&!oldBuf)
+   {
+      return theTwoColorTile;
+   }
+   if(newBuf&&oldBuf)
+   {
+      
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if((*newBuf == newNullPix)&&
+            (*oldBuf == oldNullPix))
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            if(*newBuf == newNullPix)
+            {
+               *newDestBuf = 1;
+            }
+            else
+            {
+               tempValue = (*newBuf)*255;
+               if(tempValue < 1) tempValue = 1;
+               else if(tempValue > 255) tempValue = 255;
+               
+               *newDestBuf = (ossim_uint8)(tempValue);
+            }
+            if(*oldBuf == oldNullPix)
+            {
+               *oldDestBuf = 1;
+            }
+            else
+            {
+               // do old buffer channel
+               tempValue = (*oldBuf)*255;
+               if(tempValue < 1) tempValue = 1;
+               else if(tempValue > 255) tempValue = 255;
+               
+               *oldDestBuf = (ossim_uint8)(tempValue);
+            }
+            *minDestBuf = 1;
+         }
+         ++newBuf;
+         ++oldBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   else if(newBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if(*newBuf == newNullPix)
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            tempValue = (*newBuf)*255;
+            if(tempValue < 1) tempValue = 1;
+            else if(tempValue > 255) tempValue = 255;
+            
+            *newDestBuf = (ossim_uint8)(tempValue);
+            *oldDestBuf = 1;
+            *minDestBuf = 1;
+         }
+         ++newBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   else if(oldBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if(*oldBuf == oldNullPix)
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            tempValue = (*oldBuf)*255;
+            if(tempValue < 1) tempValue = 1;
+            else if(tempValue > 255) tempValue = 255;
+            
+            *oldDestBuf = (ossim_uint8)(tempValue);
+            *newDestBuf = 1;
+            *minDestBuf = 1;
+         }
+         ++oldBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   
+#endif
+   theTwoColorTile->validate();
+   return theTwoColorTile;
+   
+}
+void ossimTwoColorView::runAlgorithm(ossimImageData* newData, ossimImageData* oldData)
+{
+   if(theNativeFlag)
+   {
+      runNative8(newData, oldData);
+   }
+   else 
+   {
+      runNorm(newData, oldData);
+   }
+}
+
+void ossimTwoColorView::runNative8(ossimImageData* newData, ossimImageData* oldData)
+{
+   // do the new band first
+   ossim_uint8 newNullPix = 0.0;
+   ossim_uint8 oldNullPix = 0.0;
+   const ossim_uint8* newBuf = 0;
+   const ossim_uint8* oldBuf = 0;
+   ossim_uint32 idx = 0;
+   ossim_uint32 maxIdx = theTwoColorTile->getWidth()*theTwoColorTile->getHeight();
+   ossim_uint8* newDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theNewBufferDestinationIndex));
+   ossim_uint8* oldDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theOldBufferDestinationIndex));
+   ossim_uint8* minDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theMinBufferDestinationIndex));
+   
+   if(newData)
+   {
+      newBuf     = static_cast<ossim_uint8*>(newData->getBuf(0));
+      newNullPix = static_cast<ossim_uint8>(newData->getNullPix(0));
+      
+   }
+   if(oldData)
+   {
+      oldBuf = static_cast<ossim_uint8*>(oldData->getBuf(0));   
+      oldNullPix    = static_cast<ossim_uint8>(oldData->getNullPix(0));
+   }
+   if(!newBuf&&!oldBuf)
+   {
+      return;
+   }
+   if(newBuf&&oldBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if((*newBuf == newNullPix)&&
+            (*oldBuf == oldNullPix))
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            if(*newBuf == newNullPix)
+            {
+               *newDestBuf = 1;
+            }
+            else
+            {
+               *newDestBuf = *newBuf;
+            }
+            if(*oldBuf == oldNullPix)
+            {
+               *oldDestBuf = 1;
+            }
+            else
+            {
+               *oldDestBuf = *oldBuf;
+            }
+            *minDestBuf = 1;
+         }
+         ++newBuf;
+         ++oldBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   else if(newBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if(*newBuf == newNullPix)
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            *newDestBuf = *newBuf;
+            *oldDestBuf = 1;
+            *minDestBuf = 1;
+         }
+         ++newBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   else if(oldBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if(*oldBuf == oldNullPix)
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            *oldDestBuf = *oldBuf;
+            *newDestBuf = 1;
+            *minDestBuf = 1;
+         }
+         ++oldBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+}
+
+void ossimTwoColorView::runNorm(ossimImageData* newData, ossimImageData* oldData)
+{
+   // do the new band first
+   ossim_float32 tempValue=0.0;
+   ossim_uint8 newNullPix = 0.0;
+   ossim_uint8 oldNullPix = 0.0;
+   std::vector<ossim_float32> newDataBuffer;
+   std::vector<ossim_float32> oldDataBuffer;
+   
+   ossim_float32* newBuf = 0;
+   ossim_float32* oldBuf = 0;
+   ossim_uint32 idx = 0;
+   ossim_uint32 maxIdx = theTwoColorTile->getWidth()*theTwoColorTile->getHeight();
+   ossim_uint8* newDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theNewBufferDestinationIndex));
+   ossim_uint8* oldDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theOldBufferDestinationIndex));
+   ossim_uint8* minDestBuf = static_cast<ossim_uint8*>(theTwoColorTile->getBuf(theMinBufferDestinationIndex));
+
+   if(newData&&newData->getBuf())
+   {
+      newDataBuffer.resize(theTwoColorTile->getWidth()*theTwoColorTile->getHeight());
+      newBuf     = &newDataBuffer.front();
+      newData->copyTileBandToNormalizedBuffer(0, newBuf);
+      newNullPix = 0;
+   }
+   if(oldData&&oldData->getBuf())
+   {
+      oldDataBuffer.resize(theTwoColorTile->getWidth()*theTwoColorTile->getHeight());
+      oldBuf     = &oldDataBuffer.front();
+      oldData->copyTileBandToNormalizedBuffer(0, oldBuf);
+      oldNullPix = 0;
+   }
+   if(!newBuf&&!oldBuf)
+   {
+      return;
+   }
+   if(newBuf&&oldBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if((*newBuf == newNullPix)&&
+            (*oldBuf == oldNullPix))
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            if(*newBuf == newNullPix)
+            {
+               *newDestBuf = 1;
+            }
+            else
+            {
+               tempValue = (*newBuf)*255;
+               if(tempValue < 1) tempValue = 1;
+               else if(tempValue > 255) tempValue = 255;
+               
+               *newDestBuf = (ossim_uint8)(tempValue);
+            }
+            if(*oldBuf == oldNullPix)
+            {
+               *oldDestBuf = 1;
+            }
+            else
+            {
+               // do old buffer channel
+               tempValue = (*oldBuf)*255;
+               if(tempValue < 1) tempValue = 1;
+               else if(tempValue > 255) tempValue = 255;
+               
+               *oldDestBuf = (ossim_uint8)(tempValue);
+            }
+            *minDestBuf = 1;
+         }
+         ++newBuf;
+         ++oldBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   else if(newBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if(*newBuf == newNullPix)
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            tempValue = (*newBuf)*255;
+            if(tempValue < 1) tempValue = 1;
+            else if(tempValue > 255) tempValue = 255;
+            
+            *newDestBuf = (ossim_uint8)(tempValue);
+            *oldDestBuf = 1;
+            *minDestBuf = 1;
+         }
+         ++newBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+   else if(oldBuf)
+   {
+      for(idx = 0; idx < maxIdx;++idx)
+      {
+         if(*oldBuf == oldNullPix)
+         {
+            *newDestBuf = 0;
+            *oldDestBuf = 0;
+            *minDestBuf = 0;
+         }
+         else
+         {
+            tempValue = (*oldBuf)*255;
+            if(tempValue < 1) tempValue = 1;
+            else if(tempValue > 255) tempValue = 255;
+            
+            *oldDestBuf = (ossim_uint8)(tempValue);
+            *newDestBuf = 1;
+            *minDestBuf = 1;
+         }
+         ++oldBuf;
+         ++minDestBuf;
+         ++newDestBuf;
+         ++oldDestBuf;
+      }
+   }
+}
+
+void ossimTwoColorView::allocate()
+{
+   theTwoColorTile = ossimImageDataFactory::instance()->create(this, this);
+   if(theTwoColorTile.valid())
+   {
+      theTwoColorTile->initialize();
+   }
+}
+
+
+void ossimTwoColorView::initialize()
+{
+   ossimImageCombiner::initialize();
+   theNewInput = 0;
+   theOldInput = 0;
+   theTwoColorTile = 0;
+   theNativeFlag = false;
+   theByPassFlag = false;
+   if(getNumberOfInputs() < 2)
+   {
+      theByPassFlag = true;
+   }
+   else 
+   {
+      theNewInput = PTR_CAST(ossimImageSource, getInput(0));
+      theOldInput = PTR_CAST(ossimImageSource, getInput(1));
+      if(!theNewInput||!theOldInput)
+      {
+         theByPassFlag = true;
+      }
+      else
+      {
+         if((theNewInput->getOutputScalarType() == OSSIM_UINT8)&&
+            (theOldInput->getOutputScalarType() == OSSIM_UINT8))
+         {
+            theNativeFlag = true;
+         }
+      }
+   }
+}
diff --git a/Utilities/otbossim/src/ossim/init/ossimInit.cpp b/Utilities/otbossim/src/ossim/init/ossimInit.cpp
index ad7be5d981e396efe5f06b0b2c38b9d99c7aaabf..6d7d2a6a0dad6679c0282afba5dab2c7aae92a29 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 13100 2008-07-01 17:42:50Z dburken $
+// $Id: ossimInit.cpp 13830 2008-11-02 18:02:03Z dburken $
 
 
 #include <ossim/init/ossimInit.h>
@@ -107,13 +107,6 @@ void ossimInit::addOptions(ossimArgumentParser& parser)
  *****************************************************************************/
 void ossimInit::initialize(int& argc, char** argv)
 {
-   if (traceExec())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "DEBUG ossimInit::initialize(argc, argv): entering..."
-         << std::endl;
-   }
-
    if(theInitializedFlag)
    {
       if (traceDebug())
@@ -144,23 +137,16 @@ void ossimInit::initialize(int& argc, char** argv)
       ossimNotify(ossimNotifyLevel_DEBUG)
          << "ossim preferences file: "
          << theInstance->thePreferences->getPreferencesFilename()
+         << "\nVersion: " << version()
+         << "\nossimInit::initialize(argc, argv) leaving..."
          << std::endl;
    }
-   
-   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG)
-      << "DEBUG ossimInit::initialize(argc, argv): leaving..." << std::endl;
 
    theInitializedFlag = true;
-   return;
 }
 
 void ossimInit::initialize(ossimArgumentParser& parser)
 {
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-      << "DEBUG ossimInit::initialize(parser): entering..." << endl;
-   }
    if(theInitializedFlag)
    {
       if (traceDebug())
@@ -198,7 +184,8 @@ void ossimInit::initialize(ossimArgumentParser& parser)
       ossimNotify(ossimNotifyLevel_DEBUG)
          << "ossim preferences file: "
          << theInstance->thePreferences->getPreferencesFilename()
-         << "\nDEBUG ossimInit::initialize(parser): leaving..." << endl;
+         << "\nVersion: " << version()
+         << "\nossimInit::initialize(parser): leaving..." << std::endl;
    }
    
    theInitializedFlag = true;
@@ -207,8 +194,6 @@ void ossimInit::initialize(ossimArgumentParser& parser)
 
 void ossimInit::initialize()
 {
-   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG)
-      << "DEBUG ossimInit::initialize(): entering..." << std::endl;
    if(theInitializedFlag)
    {
       if (traceDebug())
@@ -234,9 +219,18 @@ void ossimInit::initialize()
    {
       theInstance->initializePlugins();
    }
-   theInitializedFlag = true;
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "ossim preferences file: "
+         << theInstance->thePreferences->getPreferencesFilename()
+         << "\nVersion: " << version()
+         << "\nossimInit::initialize() leaving..."
+         << std::endl;
+   } 
    
-   return;
+   theInitializedFlag = true;
 }
 
 void ossimInit::finalize()
@@ -308,7 +302,7 @@ void ossimInit::loadPlugins(const ossimFilename& plugin)
 void ossimInit::parseOptions(ossimArgumentParser& parser)
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG)
-      << "DEBUG ossimInit::parseOptions: entering..." << endl;
+      << "DEBUG ossimInit::parseOptions: entering..." << std::endl;
    
    std::string tempString;
    ossimArgumentParser::ossimParameter stringParameter(tempString);
diff --git a/Utilities/otbossim/src/ossim/kbool/booleng.cpp b/Utilities/otbossim/src/ossim/kbool/booleng.cpp
index d79b8bba68c6f1bb99ed23a353f654860284fa68..f4ccd37a83399b1a03ac59b3b6dab615f1306e88 100644
--- a/Utilities/otbossim/src/ossim/kbool/booleng.cpp
+++ b/Utilities/otbossim/src/ossim/kbool/booleng.cpp
@@ -5,7 +5,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: booleng.cpp 9094 2006-06-13 19:12:40Z dburken $
+    RCS-ID: $Id: booleng.cpp 13795 2008-10-28 19:32:44Z gpotts $
 */
 
 #ifdef __GNUG__
@@ -23,12 +23,12 @@
 #include <ossim/kbool/graphlst.h>
 #include <iostream>
 
-B_INT bmin(B_INT const value1, B_INT const value2)
+B_INT bmin(B_INT value1, B_INT value2)
 {
 	return((value1 < value2) ? value1 : value2 );
 }
 
-B_INT bmax(B_INT const value1, B_INT const value2)
+B_INT bmax(B_INT value1, B_INT value2)
 {
 	return((value1 > value2) ? value1 : value2 );
 }
@@ -43,41 +43,24 @@ B_INT babs(B_INT a)
 //----------------- Bool_Engine_Error -------------------------------/
 //-------------------------------------------------------------------/
 
-Bool_Engine_Error::Bool_Engine_Error(char* message, char* header, int degree, int fatal)
+Bool_Engine_Error::Bool_Engine_Error(const char* message,
+                                     const char* header,
+                                     int degree,
+                                     int fatal)
 {
-	_message = new char[LINELENGTH];
-	_header  = new char[LINELENGTH];
-	if (message)
-		strcpy(_message, message);
-	else
-		strcpy(_message,"non specified");
-
-	if (header)
-		strcpy(_header, header);
-	else
-		strcpy(_header,"non specified");
-
-	_degree = degree;
-	_fatal = fatal;
+   _message = message;
+   _header  = header;
+   _degree = degree;
+   _fatal = fatal;
 
 }
 
 Bool_Engine_Error::Bool_Engine_Error(const Bool_Engine_Error& a)
 {
-	_message = new char[LINELENGTH];
-	_header  = new char[LINELENGTH];
-	if (a._message)
-		strcpy(_message, a._message);
-	else
-		strcpy(_message,"non specified");
-
-	if (a._header)
-		strcpy(_header, a._header);
-	else
-		strcpy(_header,"non specified");
-
-	_degree = a._degree;
-	_fatal = a._fatal;
+   _message = a._message;
+   _header  = a._header;
+   _degree = a._degree;
+   _fatal = a._fatal;
 
 }
 
@@ -123,38 +106,26 @@ Bool_Engine::Bool_Engine(const Bool_Engine& rhs)
 
 Bool_Engine_Error::~Bool_Engine_Error()
 {
-   strcpy(_message,"");
-   strcpy(_header,"");
-   if(_message)
-   {
-      delete _message;
-      _message = 0;
-   }
-   if(_header)
-   {
-      delete _header;
-      _header = 0;
-   }
 }
 
-char* Bool_Engine_Error::GetErrorMessage()
+const char* Bool_Engine_Error::GetErrorMessage()
 {
-	return _message;
+   return _message.c_str();
 }
 
-char* Bool_Engine_Error::GetHeaderMessage()
+const char* Bool_Engine_Error::GetHeaderMessage()
 {
-	return _header;
+   return _header.c_str();
 }
 
 int Bool_Engine_Error::GetErrorDegree()
 {
-	return _degree;
+   return _degree;
 }
 
 int Bool_Engine_Error::GetFatal()
 {
-	return _fatal;
+   return _fatal;
 }
 
 //-------------------------------------------------------------------/
@@ -233,19 +204,19 @@ void Bool_Engine::SetLog( bool OnOff )
 	}
 }
 
-void Bool_Engine::SetState( char* process )
+void Bool_Engine::SetState( const char* process )
 {
    Write_Log(process);
 }
 
-void Bool_Engine::error(char *text, char *title)
+void Bool_Engine::error(const char *text, const char *title)
 {
    Write_Log("FATAL ERROR: ", title);
    Write_Log("FATAL ERROR: ", text);
    throw Bool_Engine_Error(" Fatal Error", "Fatal Error", 9, 1);
 };
 
-void Bool_Engine::info(char *text, char *title)
+void Bool_Engine::info(const char *text, const char *title)
 {
    Write_Log("FATAL ERROR: ", title);
    Write_Log("FATAL ERROR: ", text);
@@ -681,7 +652,7 @@ kbEdgeType Bool_Engine::GetPolygonPointEdgeType()
 }
 
 
-void Bool_Engine::Write_Log(char *msg1)
+void Bool_Engine::Write_Log(const char *msg1)
 {
    if (m_logfile == NULL)
        return;
@@ -689,7 +660,7 @@ void Bool_Engine::Write_Log(char *msg1)
    fprintf(m_logfile,"%s \n",msg1);
 }
 
-void Bool_Engine::Write_Log(char *msg1, char*msg2)
+void Bool_Engine::Write_Log(const char *msg1, const char* msg2)
 {
    if (m_logfile == NULL)
        return;
@@ -697,7 +668,7 @@ void Bool_Engine::Write_Log(char *msg1, char*msg2)
    fprintf(m_logfile,"%s %s\n",msg1, msg2);
 }
 
-void Bool_Engine::Write_Log(char *fmt, double dval)
+void Bool_Engine::Write_Log(const char *fmt, double dval)
 {
    if (m_logfile == NULL)
        return;
@@ -705,7 +676,7 @@ void Bool_Engine::Write_Log(char *fmt, double dval)
    fprintf(m_logfile,fmt,dval);
 }
 
-void Bool_Engine::Write_Log(char *fmt, B_INT bval)
+void Bool_Engine::Write_Log(const char *fmt, B_INT bval)
 {
    if (m_logfile == NULL)
        return;
diff --git a/Utilities/otbossim/src/ossim/kbool/graph.cpp b/Utilities/otbossim/src/ossim/kbool/graph.cpp
index 6162415ff81d2a35d5606dbc26a1ffbc412c5014..7ee2f772fee71ed1969c66455f9d705473f09e32 100644
--- a/Utilities/otbossim/src/ossim/kbool/graph.cpp
+++ b/Utilities/otbossim/src/ossim/kbool/graph.cpp
@@ -6,7 +6,7 @@
 
     Licence: wxWidgets Licence
 
-    RCS-ID: $Id: graph.cpp 9567 2006-09-14 18:02:56Z gpotts $
+    RCS-ID: $Id: graph.cpp 13795 2008-10-28 19:32:44Z gpotts $
 */
 
 // Grpah is the structure used to store polygons
@@ -831,7 +831,7 @@ void Graph::SetGroup(GroupType newgroup)
 
 
 // Set the number of the links to the same as newnr
-void Graph::SetNumber(const int newnr)
+void Graph::SetNumber(int newnr)
 {
    TDLI<KBoolLink> _LI=TDLI<KBoolLink>(_linklist);
 	_LI.tohead();
diff --git a/Utilities/otbossim/src/ossim/parallel/ossimIgen.cpp b/Utilities/otbossim/src/ossim/parallel/ossimIgen.cpp
index 4723765fe135914fc152ad6e81237048dbe72573..3dcb634df28e1b8dda94d609e9f456accb9745b9 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 12100 2007-12-01 16:22:20Z dburken $
+// $Id: ossimIgen.cpp 13676 2008-10-03 17:35:02Z gpotts $
 
 #include <iterator>
 #include <sstream>
@@ -129,8 +129,13 @@ void ossimIgen::initializeAttributes()
          {
             theThumbnailResolution = ossimIpt(0,0);
             std::istringstream in(resStr);
-            in >> theThumbnailResolution.x >> theThumbnailResolution.y;
+            ossimString x,y;
+            
+            in >> x >> y;
 
+            theThumbnailResolution.x = x.toInt32();
+            theThumbnailResolution.y = y.toInt32();
+            
             if(theThumbnailResolution.x < 1)
             {
                theThumbnailResolution.x = 128;
@@ -139,7 +144,6 @@ void ossimIgen::initializeAttributes()
             {
                theThumbnailResolution.y = theThumbnailResolution.x;
             }
-//            theThumbnailResolution = ossimString(resStr).toInt32();
             
          }
          else
diff --git a/Utilities/otbossim/src/ossim/parallel/ossimMpi.cpp b/Utilities/otbossim/src/ossim/parallel/ossimMpi.cpp
index 973521fe6f86f93f9e7ffce4bb662513a936cf42..21ad7f01fda4e6d552185bbb814ed4b7ff8139c1 100644
--- a/Utilities/otbossim/src/ossim/parallel/ossimMpi.cpp
+++ b/Utilities/otbossim/src/ossim/parallel/ossimMpi.cpp
@@ -6,15 +6,18 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimMpi.cpp 10297 2007-01-18 14:12:41Z gpotts $
+// $Id: ossimMpi.cpp 13602 2008-09-25 14:23:32Z gpotts $
 
 #include <ossim/parallel/ossimMpi.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimNotifyContext.h>
 #include <time.h>
+#if OSSIM_HAS_MPI
+#  include <mpi.h>
+#endif
 
 #if OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimMpi.cpp 10297 2007-01-18 14:12:41Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimMpi.cpp 13602 2008-09-25 14:23:32Z gpotts $";
 #endif
 
 static ossimTrace traceDebug = ossimTrace("ossimMpi:debug");
diff --git a/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp b/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp
index bf9c74bd7e52c9ad4197c65b413d7131aea225a8..8b0d4dbae008bd59001f10745166a254749e2a13 100644
--- a/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp
+++ b/Utilities/otbossim/src/ossim/parallel/ossimOrthoIgen.cpp
@@ -1,4 +1,4 @@
-// $Id: ossimOrthoIgen.cpp 13103 2008-07-03 01:06:37Z gpotts $
+// $Id: ossimOrthoIgen.cpp 13706 2008-10-13 18:46:27Z gpotts $
 #include <sstream>
 #include <ossim/parallel/ossimOrthoIgen.h>
 #include <ossim/parallel/ossimIgen.h>
@@ -645,7 +645,6 @@ bool ossimOrthoIgen::setupIgenKwl(ossimKeywordlist& kwl)
                   ossimFilename inputHisto = handler->createDefaultHistogramFilename();
                   if(inputHisto.exists())
                   {
-                     tempChain->addLast(histRemapper);
                      histRemapper = new ossimHistogramRemapper;
                      tempChain->insertRight(histRemapper, h);
                      histRemapper->openHistogram(inputHisto);
@@ -1150,6 +1149,7 @@ bool ossimOrthoIgen::setupView(ossimKeywordlist& kwl)
                                          midGpt);
             
             utm->setZone(midGpt);
+            utm->setHemisphere(midGpt);
             ossimDpt eastingNorthing;
             
             utm->setMetersPerPixel(ossimDpt(ossimUnitConversionTool(gsd.x,
diff --git a/Utilities/otbossim/src/ossim/plugin/ossimDynamicLibrary.cpp b/Utilities/otbossim/src/ossim/plugin/ossimDynamicLibrary.cpp
index 49438243ea622337b281e6de11ab709341ba6908..140dc1bf16100f0d051662c7b0071362acf971b1 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 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimDynamicLibrary.cpp 13616 2008-09-29 15:32:12Z dburken $
 #include <ossim/plugin/ossimDynamicLibrary.h>
 #include <ossim/plugin/ossimSharedObjectBridge.h>
 #include <ossim/base/ossimTrace.h>
@@ -43,14 +43,12 @@ bool ossimDynamicLibrary::load()
 bool ossimDynamicLibrary::load(const ossimString& name)
 {
    ossimFilename libraryName = name;
-#if OSSIM_DYNAMIC_ENABLED
 #  if defined(__WIN32__) || defined(_WIN32)
    libraryName.convertForwardToBackSlashes();
    theLibrary = LoadLibrary(libraryName.c_str());
-#  elif HAVE_DLFCN_H
+#  else 
    libraryName.convertBackToForwardSlashes();
    theLibrary = dlopen(libraryName.c_str(), RTLD_LAZY);
-#  endif
 #endif
 
    if (isLoaded())
@@ -74,10 +72,8 @@ bool ossimDynamicLibrary::load(const ossimString& name)
             << "ossimDynamicLibrary::load DEBUG:"
             << "\nFailed to load library:  " << name
             << std::endl;
-#if OSSIM_DYNAMIC_ENABLED
-#  if HAVE_DLFCN_H
+#  if !defined(__WIN32__) && !defined(_WIN32)
          ossimNotify(ossimNotifyLevel_DEBUG) << dlerror() << std::endl;
-#  endif
 #endif
       }
       
@@ -90,12 +86,11 @@ void ossimDynamicLibrary::unload()
 {
    if(isLoaded())
    {
-#if OSSIM_DYNAMIC_ENABLED
-#  if defined(__WIN32__) || defined(_WIN32)
+#if defined(__WIN32__) || defined(_WIN32)
       FreeLibrary(theLibrary);
-#  elif HAVE_DLFCN_H
+// #else HAVE_DLFCN_H
+#else
       dlclose(theLibrary);
-#  endif
 #endif
       theLibrary = NULL;
    }
@@ -105,12 +100,10 @@ void *ossimDynamicLibrary::getSymbol(const ossimString& name) const
 {
    if(isLoaded())
    {
-#if OSSIM_DYNAMIC_ENABLED
-#  if defined(__WIN32__) || defined(_WIN32)
+#if defined(__WIN32__) || defined(_WIN32)
       return (void*)GetProcAddress( (HINSTANCE)theLibrary, name.c_str());
-#  elif HAVE_DLFCN_H
+#else
       return dlsym(theLibrary, name.c_str());
-#  endif
 #endif
    }
 
diff --git a/Utilities/otbossim/src/ossim/plugin/ossimSharedPluginRegistry.cpp b/Utilities/otbossim/src/ossim/plugin/ossimSharedPluginRegistry.cpp
index 33cb068aae7a5032eb0487a7235a935d202d72c1..1318a798167049c97b0e4bb2504a62b15360fc46 100644
--- a/Utilities/otbossim/src/ossim/plugin/ossimSharedPluginRegistry.cpp
+++ b/Utilities/otbossim/src/ossim/plugin/ossimSharedPluginRegistry.cpp
@@ -6,8 +6,9 @@
 // Author: Garrett Potts
 //
 //*************************************************************************
-// $Id: ossimSharedPluginRegistry.cpp 13070 2008-06-23 20:56:50Z dburken $
+// $Id: ossimSharedPluginRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
 #include <algorithm>
+#include <iterator>
 #include <ossim/plugin/ossimSharedPluginRegistry.h>
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimTrace.h>
@@ -15,26 +16,25 @@
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/plugin/ossimSharedObjectBridge.h>
 
-ossimSharedPluginRegistry* ossimSharedPluginRegistry::theInstance = NULL;
+//ossimSharedPluginRegistry* ossimSharedPluginRegistry::theInstance = NULL;
 //ossimPluginBridgeStructure ossimSharedPluginRegistry::thePluginBridgeFactoryPointers;
 
 static ossimTrace traceDebug("ossimSharedPluginRegistry:debug");
 
+ossimSharedPluginRegistry::ossimSharedPluginRegistry()
+{
+}
+
 ossimSharedPluginRegistry::~ossimSharedPluginRegistry()
 {
    theLibraryList.clear();
-
-   theInstance = NULL;
 }
 
 ossimSharedPluginRegistry* ossimSharedPluginRegistry::instance()
 {
-   if(!theInstance)
-   {
-      theInstance = new ossimSharedPluginRegistry;
-   }
+   static ossimSharedPluginRegistry sharedInstance;
 
-   return theInstance;
+   return &sharedInstance;//theInstance;
 }
 
 bool ossimSharedPluginRegistry::registerPlugin(const ossimFilename& filename, bool insertFrontFlag)
@@ -202,3 +202,27 @@ bool ossimSharedPluginRegistry::isLoaded(const ossimFilename& filename) const
    }
    return result;
 }
+
+void ossimSharedPluginRegistry::printAllPluginInformation(std::ostream& out)
+{
+   ossim_uint32 count = getNumberOfPlugins();
+   ossim_uint32 idx = 0;
+   
+   for(idx = 0; idx < count; ++idx)
+   {
+      std::vector<ossimString> classNames;
+      const ossimPluginLibrary* pi = getPlugin(idx);
+      if(pi)
+      {
+         pi->getClassNames(classNames);
+         out << "Plugin: " << pi->getName() << std::endl;
+         out << "DESCRIPTION: \n";
+         out << pi->getDescription() << "\n";
+         out << "CLASSES SUPPORTED\n     ";
+         std::copy(classNames.begin(),
+                   classNames.end(),
+                   std::ostream_iterator<ossimString>(out, "\n     "));
+         out << "\n";
+      }
+   }
+}
diff --git a/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp
index 61ed667fa6e3bb2b1ebe45281c91166fec788a68..ddb7b992489cddaf10b3193bde8ed8cf1f77f1ed 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimApplanixEcefModel.cpp
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimApplanixEcefModel.cpp 11483 2007-08-03 17:53:17Z gpotts $
+//  $Id: ossimApplanixEcefModel.cpp 13691 2008-10-07 12:46:58Z dburken $
 #include <sstream>
 #include <ossim/projection/ossimApplanixEcefModel.h>
 #include <ossim/base/ossimEllipsoid.h>
@@ -25,7 +25,7 @@ static ossimTrace traceDebug("ossimApplanixEcefModel:debug");
 RTTI_DEF1(ossimApplanixEcefModel, "ossimApplanixEcefModel", ossimSensorModel);
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimApplanixEcefModel.cpp 11483 2007-08-03 17:53:17Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimApplanixEcefModel.cpp 13691 2008-10-07 12:46:58Z dburken $";
 #endif
 
 ossimApplanixEcefModel::ossimApplanixEcefModel()
@@ -54,6 +54,40 @@ ossimApplanixEcefModel::ossimApplanixEcefModel()
 #endif
    }
 }
+ossimApplanixEcefModel::ossimApplanixEcefModel(const ossimDrect& imageRect,
+                                               const ossimGpt& platformPosition,
+                                               double roll,
+                                               double pitch,
+                                               double heading,
+                                               const ossimDpt& principalPoint, // in millimeters
+                                               double focalLength, // in millimeters
+                                               const ossimDpt& pixelSize) // in millimeters
+{
+   theImageClipRect = imageRect;
+   theRefImgPt      = theImageClipRect.midPoint();
+   theCompositeMatrix          = ossimMatrix4x4::createIdentity();
+   theCompositeMatrixInverse   = ossimMatrix4x4::createIdentity();
+   theRoll                     = roll;
+   thePitch                    = pitch;
+   theHeading                  = heading;
+   theFocalLength              = focalLength;
+   thePixelSize                = pixelSize;
+   theEcefPlatformPosition     = platformPosition;
+   theAdjEcefPlatformPosition  = platformPosition;
+   theLensDistortion           = new ossimMeanRadialLensDistortion;
+   initAdjustableParameters();
+   updateModel();
+   computeGsd();
+   
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+      << "ossimApplanixEcefModel::ossimApplanixEcefModel DEBUG:" << endl;
+#ifdef OSSIM_ID_ENABLED
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "OSSIM_ID:  " << OSSIM_ID << endl;
+#endif
+   }
+}
 
 ossimApplanixEcefModel::ossimApplanixEcefModel(const ossimApplanixEcefModel& src)
    :ossimSensorModel(src)
@@ -458,23 +492,29 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       }
       if(ecef_platform_position)
       {
-         std::istringstream in(ecef_platform_position);
-         double x,y,z;
-         in >> x
-            >> y
-            >> z;
-         
-         theEcefPlatformPosition = ossimEcefPoint(x,y,z);
+         std::vector<ossimString> splitString;
+         ossimString tempString(ecef_platform_position);
+         if(splitString.size() > 2)
+         {
+            theEcefPlatformPosition  = ossimEcefPoint(splitString[0].toDouble(),
+                                                      splitString[1].toDouble(),
+                                                      splitString[2].toDouble());
+         }
       }
       else if(latlonh_platform_position)
       {
-         std::istringstream in(latlonh_platform_position);
-         double lat,lon,hgt;
-         in >> lat
-            >> lon
-            >> hgt;
+         std::vector<ossimString> splitString;
+         ossimString tempString(latlonh_platform_position);
+         std::string datumString;
+         double lat=0.0, lon=0.0, h=0.0;
+         if(splitString.size() > 2)
+         {
+            lat = splitString[0].toDouble();
+            lon = splitString[1].toDouble();
+            h = splitString[2].toDouble();
+         }
          
-         theEcefPlatformPosition = ossimGpt(lat,lon,hgt);
+         theEcefPlatformPosition = ossimGpt(lat,lon,h);
       }
    }
 
@@ -504,9 +544,14 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       }
       if(image_size)
       {
-         std::istringstream in(image_size);
-         double w, h;
-         in>>w >> h;
+         std::vector<ossimString> splitString;
+         ossimString tempString(image_size);
+         double w=1, h=1;
+         if(splitString.size() == 2)
+         {
+            w = splitString[0].toDouble();
+            h = splitString[1].toDouble();
+         }
          theImageClipRect = ossimDrect(0,0,w-1,h-1);
          theRefImgPt      = ossimDpt(w/2.0, h/2.0);
       }
@@ -516,14 +561,28 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       }
       if(principal_point)
       {
-         std::istringstream in(principal_point);
-         in >>thePrincipalPoint.x >> thePrincipalPoint.y;
+         std::vector<ossimString> splitString;
+         ossimString tempString(principal_point);
+         if(splitString.size() == 2)
+         {
+            thePrincipalPoint.x = splitString[0].toDouble();
+            thePrincipalPoint.y = splitString[1].toDouble();
+         }
       }
       if(pixel_size)
       {
-         std::istringstream in(pixel_size);
-         in >> thePixelSize.x;
-         thePixelSize.y = thePixelSize.x;
+         std::vector<ossimString> splitString;
+         ossimString tempString(pixel_size);
+         if(splitString.size() == 1)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = thePixelSize.x;
+         }
+         else if(splitString.size() == 2)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = splitString[1].toDouble();
+         }
       }
       if(focal_length)
       {
@@ -537,10 +596,16 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
 
          if(value)
          {
-            std::istringstream in(value);
-            double distance, distortion;
+            std::vector<ossimString> splitString;
+            ossimString tempString(value);
+            double distance = 0.0;
+            double distortion = 0.0;
 
-            in >> distance >> distortion;
+            if(splitString.size() == 2)
+            {
+               distance = splitString[0].toDouble();
+               distortion = splitString[1].toDouble();
+            }
             tool.setValue(distortion, unitType);
             lensKwl.add(ossimString("distance") + ossimString::toString(idx),
                         distance,
@@ -575,8 +640,13 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       
       if(principal_point)
       {
-         std::istringstream in(principal_point);
-         in >>thePrincipalPoint.x >> thePrincipalPoint.y;
+         std::vector<ossimString> splitString;
+         ossimString tempString(principal_point);
+         if(splitString.size() == 2)
+         {
+            thePrincipalPoint.x = splitString[0].toDouble();
+            thePrincipalPoint.y = splitString[1].toDouble();
+         }
       }
       else
       {
@@ -588,8 +658,18 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
       }
       if(pixel_size)
       {
-         std::istringstream in(pixel_size);
-         in >> thePixelSize.x >> thePixelSize.y;
+         std::vector<ossimString> splitString;
+         ossimString tempString(pixel_size);
+         if(splitString.size() == 1)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = thePixelSize.x;
+         }
+         else if(splitString.size() == 2)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = splitString[1].toDouble();
+         }
       }
       else
       {
@@ -627,25 +707,11 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
 
    updateModel();
 
-   ossimGpt centerGpt;
-   lineSampleToWorld(theRefImgPt, centerGpt);
    if(compute_gsd_flag)
    {
       if(ossimString(compute_gsd_flag).toBool())
       {
-         ossimGpt right;
-         ossimGpt top;
-         lineSampleToWorld(theRefImgPt + ossimDpt(1.0, 0.0),
-                           right);
-         lineSampleToWorld(theRefImgPt + ossimDpt(0.0, -1.0),
-                           top);
-         
-         ossimEcefVector horizontal = ossimEcefPoint(centerGpt)-ossimEcefPoint(right);
-         ossimEcefVector vertical   = ossimEcefPoint(centerGpt)-ossimEcefPoint(top);
-
-         theGSD.x = horizontal.length();
-         theGSD.y = vertical.length();
-         theMeanGSD = (theGSD.x+theGSD.y)*.5;
+         computeGsd();
       }
    }
    if(traceDebug())
@@ -662,6 +728,25 @@ bool ossimApplanixEcefModel::loadState(const ossimKeywordlist& kwl,
    return result;
 }
 
+void ossimApplanixEcefModel::computeGsd()
+{
+   ossimGpt right;
+   ossimGpt top;
+   ossimGpt centerGpt;
+   lineSampleToWorld(theRefImgPt, centerGpt);
+   lineSampleToWorld(theRefImgPt + ossimDpt(1.0, 0.0),
+                     right);
+   lineSampleToWorld(theRefImgPt + ossimDpt(0.0, -1.0),
+                     top);
+   
+   ossimEcefVector horizontal = ossimEcefPoint(centerGpt)-ossimEcefPoint(right);
+   ossimEcefVector vertical   = ossimEcefPoint(centerGpt)-ossimEcefPoint(top);
+   
+   theGSD.x = horizontal.length();
+   theGSD.y = vertical.length();
+   theMeanGSD = (theGSD.x+theGSD.y)*.5;
+}
+
 bool ossimApplanixEcefModel::setupOptimizer(const ossimString& init_file)
 {
    ossimKeywordlist kwl;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimApplanixUtmModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimApplanixUtmModel.cpp
index 16b505c1b272017be040ccfe6bdba9aa7ac451b9..ca2fbff577ffc129759212c9be82cbb177787767 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimApplanixUtmModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimApplanixUtmModel.cpp
@@ -6,7 +6,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimApplanixUtmModel.cpp 11482 2007-08-03 15:18:45Z gpotts $
+//  $Id: ossimApplanixUtmModel.cpp 13665 2008-10-02 19:58:00Z gpotts $
 #include <sstream>
 #include <ossim/projection/ossimApplanixUtmModel.h>
 #include <ossim/base/ossimEllipsoid.h>
@@ -25,7 +25,7 @@ static ossimTrace traceDebug("ossimApplanixUtmModel:debug");
 RTTI_DEF1(ossimApplanixUtmModel, "ossimApplanixUtmModel", ossimSensorModel);
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimApplanixUtmModel.cpp 11482 2007-08-03 15:18:45Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimApplanixUtmModel.cpp 13665 2008-10-02 19:58:00Z gpotts $";
 #endif
 
 ossimApplanixUtmModel::ossimApplanixUtmModel()
@@ -263,6 +263,7 @@ void ossimApplanixUtmModel::updateModel()
    ossimUtmProjection utmProj;
    
    utmProj.setZone(theUtmZone);
+   utmProj.setZone(theUtmHemisphere);
    utmProj.setMetersPerPixel(ossimDpt(1.0,1.0));
    ossimDpt midPt  = utmProj.forward(theAdjEcefPlatformPosition);
    ossimDpt rPt    = midPt + ossimDpt(10, 0.0);
@@ -570,13 +571,16 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
    {
       if(shift_values)
       {
-         std::istringstream in(shift_values);
-         double x, y, z;
-
-         in >> x >> y >> z;
-
-         theShiftValues = ossimEcefVector(x,y,z);
-         
+         std::vector<ossimString> splitString;
+         ossimString tempString(shift_values);
+         tempString = tempString.trim();
+         tempString.split(splitString, " " );
+         if(splitString.size() == 3)
+         {
+            theShiftValues = ossimEcefVector(splitString[0].toDouble(),
+                                             splitString[1].toDouble(),
+                                             splitString[2].toDouble());
+         }
       }
       if(omega&&phi&&kappa)
       {
@@ -590,7 +594,7 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
          theBoreSightTy = ossimString(bore_sight_ty).toDouble()/60.0;
          theBoreSightTz = ossimString(bore_sight_tz).toDouble()/60.0;
       }
-      double lat, lon, h;
+      double lat=0.0, lon=0.0, h=0.0;
       if(utm_zone)
       {
          theUtmZone = ossimString(utm_zone).toInt32();
@@ -605,11 +609,23 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
       if(utm_platform_position)
       {
          ossimUtmProjection utmProj;
-         istringstream in(utm_platform_position);
+         std::vector<ossimString> splitString;
+         ossimString tempString(utm_platform_position);
+         tempString = tempString.trim();
          ossimString datumString;
          utmProj.setZone(theUtmZone);
          utmProj.setHemisphere((char)theUtmHemisphere);
-         in >> theUtmPlatformPosition.x >> theUtmPlatformPosition.y >> theUtmPlatformPosition.z >> datumString;
+         tempString.split(splitString, " ");
+         if(splitString.size() > 2)
+         {
+            theUtmPlatformPosition.x = splitString[0].toDouble();
+            theUtmPlatformPosition.y = splitString[1].toDouble();
+            theUtmPlatformPosition.z = splitString[2].toDouble();
+         }
+         if(splitString.size() > 3)
+         {
+            datumString = splitString[3];
+         }
          const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString);
          if(datum)
          {
@@ -634,13 +650,25 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
       }
       else if(latlonh_platform_position)
       {
-         std::istringstream in(latlonh_platform_position);
-         std::string datumCode;
-         in >> lat >> lon >> h >> datumCode;
+         std::vector<ossimString> splitString;
+         ossimString tempString(latlonh_platform_position);
+         std::string datumString;
+         tempString = tempString.trim();
+         tempString.split(splitString, " ");
+         if(splitString.size() > 2)
+         {
+            lat = splitString[0].toDouble();
+            lon = splitString[1].toDouble();
+            h = splitString[2].toDouble();
+         }
+         if(splitString.size() > 3)
+         {
+            datumString = splitString[3];
+         }
          thePlatformPosition.latd(lat);
          thePlatformPosition.lond(lon);
          thePlatformPosition.height(h);
-         const ossimDatum* datum = ossimDatumFactory::instance()->create(datumCode);
+         const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString);
          if(datum)
          {
             thePlatformPosition.datum(datum);
@@ -659,13 +687,27 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
    }
    if(principal_point)
    {
-      std::istringstream in(principal_point);
-      in >>thePrincipalPoint.x >> thePrincipalPoint.y;
+      std::vector<ossimString> splitString;
+      ossimString tempString(principal_point);
+      tempString = tempString.trim();
+      tempString.split(splitString, " ");
+      if(splitString.size() == 2)
+      {
+         thePrincipalPoint.x = splitString[0].toDouble();
+         thePrincipalPoint.y = splitString[1].toDouble();
+      }
    }
    if(pixel_size)
    {
-      std::istringstream in(pixel_size);
-      in >> thePixelSize.x >> thePixelSize.y;
+      std::vector<ossimString> splitString;
+      ossimString tempString(principal_point);
+      tempString = tempString.trim();
+      tempString.split(splitString, " ");
+      if(splitString.size() == 2)
+      {
+         thePixelSize.x = splitString[0].toDouble();
+         thePixelSize.y = splitString[1].toDouble();
+      }
    }
    if(focal_length)
    {
@@ -698,9 +740,16 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
       }
       if(image_size)
       {
-         std::istringstream in(image_size);
-         double w, h;
-         in>>w >> h;
+         std::vector<ossimString> splitString;
+         ossimString tempString(image_size);
+         tempString = tempString.trim();
+         tempString.split(splitString, " ");
+         double w=1, h=1;
+         if(splitString.size() == 2)
+         {
+            w = splitString[0].toDouble();
+            h = splitString[1].toDouble();
+         }
          theImageClipRect = ossimDrect(0,0,w-1,h-1);
          theRefImgPt      = ossimDpt(w/2.0, h/2.0);
       }
@@ -710,14 +759,32 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
       }
       if(principal_point)
       {
-         std::istringstream in(principal_point);
-         in >>thePrincipalPoint.x >> thePrincipalPoint.y;
+         std::vector<ossimString> splitString;
+         ossimString tempString(principal_point);
+         tempString = tempString.trim();
+         tempString.split(splitString, " ");
+         if(splitString.size() == 2)
+         {
+            thePrincipalPoint.x = splitString[0].toDouble();
+            thePrincipalPoint.y = splitString[1].toDouble();
+         }
       }
       if(pixel_size)
       {
-         std::istringstream in(pixel_size);
-         in >> thePixelSize.x;
-         thePixelSize.y = thePixelSize.x;
+         std::vector<ossimString> splitString;
+         ossimString tempString(pixel_size);
+         tempString = tempString.trim();
+         tempString.split(splitString, " ");
+         if(splitString.size() == 1)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = thePixelSize.x;
+         }
+         else if(splitString.size() == 2)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = splitString[1].toDouble();
+         }
       }
       if(focal_length)
       {
@@ -731,10 +798,17 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
 
          if(value)
          {
-            std::istringstream in(value);
-            double distance, distortion;
-
-            in >> distance >> distortion;
+            std::vector<ossimString> splitString;
+            ossimString tempString(value);
+            double distance=0.0, distortion=0.0;
+            tempString = tempString.trim();
+            tempString.split(splitString, " ");
+            if(splitString.size() == 2)
+            {
+               distance = splitString[0].toDouble();
+               distortion = splitString[1].toDouble();
+            }
+            
             tool.setValue(distortion, unitType);
             lensKwl.add(ossimString("distance") + ossimString::toString(idx),
                         distance,
@@ -769,8 +843,15 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
       
       if(principal_point)
       {
-         std::istringstream in(principal_point);
-         in >>thePrincipalPoint.x >> thePrincipalPoint.y;
+         std::vector<ossimString> splitString;
+         ossimString tempString(principal_point);
+         tempString = tempString.trim();
+         tempString.split(splitString, " ");
+         if(splitString.size() == 2)
+         {
+            thePrincipalPoint.x = splitString[0].toDouble();
+            thePrincipalPoint.y = splitString[1].toDouble();
+         }
       }
       else
       {
@@ -782,8 +863,20 @@ bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
       }
       if(pixel_size)
       {
-         std::istringstream in(pixel_size);
-         in >> thePixelSize.x >> thePixelSize.y;
+         std::vector<ossimString> splitString;
+         ossimString tempString(pixel_size);
+         tempString = tempString.trim();
+         tempString.split(splitString, " ");
+         if(splitString.size() == 1)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = thePixelSize.x;
+         }
+         else if(splitString.size() == 2)
+         {
+            thePixelSize.x = splitString[0].toDouble();
+            thePixelSize.y = splitString[1].toDouble();
+         }
       }
       else
       {
diff --git a/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66d2ef71c6c3db161a4b949a69fae69dbbe1361b
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/projection/ossimImageProjectionModel.cpp
@@ -0,0 +1,65 @@
+//-----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Class definition of ossimImageProjectionModel.
+//
+//-----------------------------------------------------------------------------
+// $Id$
+
+#include <string>
+
+#include <ossim/projection/ossimImageProjectionModel.h>
+#include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+
+RTTI_DEF1(ossimImageProjectionModel,
+          "ossimImageProjectionModel",
+          ossimImageModel)
+
+ossimImageProjectionModel::ossimImageProjectionModel()
+   : ossimImageModel(),
+     theProjection(0)
+{
+}
+
+ossimImageProjectionModel::~ossimImageProjectionModel()
+{
+   if (theProjection)
+   {
+      delete theProjection;
+      theProjection = 0;
+   }
+}
+
+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);
+
+   ossimKeywordlist kwl;
+   if ( iih->getImageGeometry(kwl, 0) )
+   {
+      theProjection = ossimProjectionFactoryRegistry::instance()->
+         createProjection(kwl);
+   }
+}
+
+const ossimProjection* ossimImageProjectionModel::getProjection() const
+{
+   return theProjection;
+}
diff --git a/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp b/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp
index a851eba078cc8431ba01bd934aa30099f1af0bd6..657567ceabc7bd4922fb01313c7cf161f2c8f9f6 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimImageViewProjectionTransform.cpp
@@ -15,7 +15,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimImageViewProjectionTransform.cpp 11412 2007-07-27 13:56:11Z dburken $
+//  $Id: ossimImageViewProjectionTransform.cpp 13516 2008-08-29 14:54:12Z dburken $
 //
 #include <ossim/projection/ossimImageViewProjectionTransform.h>
 #include <ossim/projection/ossimProjection.h>
@@ -70,6 +70,36 @@ ossimImageViewProjectionTransform::ossimImageViewProjectionTransform
    }
 }
 
+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)
+{
+   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
 //  
@@ -79,12 +109,12 @@ ossimImageViewProjectionTransform::~ossimImageViewProjectionTransform()
    if(theImageProjection && theOwnsImageProjFlag)
    {
       delete theImageProjection;
-      theImageProjection = NULL;
+      theImageProjection = 0;
    }
    if(theViewProjection && theOwnsViewProjFlag)
    {
       delete theViewProjection;
-      theViewProjection = NULL;
+      theViewProjection = 0;
    }
 }
 
@@ -204,7 +234,7 @@ void ossimImageViewProjectionTransform::setViewProjection(ossimProjection* viewP
       theOwnsViewProjFlag)
    {
       delete theViewProjection;
-      theViewProjection = (ossimProjection*)NULL;
+      theViewProjection = (ossimProjection*)0;
    }
    theOwnsViewProjFlag = ownsViewProjection;
    theViewProjection   = viewProjection;
@@ -242,7 +272,7 @@ bool ossimImageViewProjectionTransform::setView(ossimObject* baseObject,
    else
    {
       // if it's null we will just clear the view out
-      setViewProjection((ossimProjection*)NULL, true);
+      setViewProjection((ossimProjection*)0, true);
    }
 
    checkSameProjection();
@@ -260,7 +290,7 @@ void ossimImageViewProjectionTransform::setImageProjection(ossimProjection* imag
       theOwnsImageProjFlag)
    {
       delete theImageProjection;
-      theImageProjection = (ossimProjection*)NULL;
+      theImageProjection = (ossimProjection*)0;
    }
    theOwnsImageProjFlag = ownsImageProjection;
    theImageProjection = imageProjection;
@@ -286,7 +316,7 @@ void ossimImageViewProjectionTransform::setViewProjection(const ossimProjection&
    if(theViewProjection && theOwnsViewProjFlag)
    {
       delete theViewProjection;
-      theViewProjection = (ossimProjection*)NULL;
+      theViewProjection = (ossimProjection*)0;
    }
    theViewProjection   = (ossimProjection*)viewProjection.dup();
    theOwnsViewProjFlag = true;
@@ -423,12 +453,12 @@ bool ossimImageViewProjectionTransform::loadState(const ossimKeywordlist& kwl,
    if(theImageProjection)
    {
       delete theImageProjection;
-      theImageProjection = NULL;
+      theImageProjection = 0;
    }
    if(theViewProjection)
    {
       delete theViewProjection;
-      theViewProjection = NULL;
+      theViewProjection = 0;
    }
 
    newPrefix = ossimString(prefix) + "view_proj.";
diff --git a/Utilities/otbossim/src/ossim/projection/ossimLensDistortion.cpp b/Utilities/otbossim/src/ossim/projection/ossimLensDistortion.cpp
index 17b710fc47005294cab9602c49dcc95c3059d94a..3d2e3f231247c4890a883f1a9099ae087d9bfd21 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimLensDistortion.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimLensDistortion.cpp
@@ -9,7 +9,7 @@
 //
 // ossimLensDistortion
 //*******************************************************************
-//  $Id: ossimLensDistortion.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimLensDistortion.cpp 13665 2008-10-02 19:58:00Z gpotts $
 #include <sstream>
 #include <ossim/projection/ossimLensDistortion.h>
 #include <ossim/base/ossimKeywordlist.h>
@@ -39,9 +39,15 @@ bool ossimLensDistortion::loadState(const ossimKeywordlist& kwl,
    
    if(center)
    {
-      std::istringstream in(center);
-      
-      in >> theCenter.x >> theCenter.y;
+      std::vector<ossimString> splitString;
+      ossimString tempString(center);
+      tempString = tempString.trim();
+      tempString.split(splitString, " ");
+      if(splitString.size() == 2)
+      {
+         theCenter.x = splitString[0].toDouble();
+         theCenter.y = splitString[1].toDouble();
+      }
    }
 
    return ossim2dTo2dTransform::loadState(kwl, prefix);
diff --git a/Utilities/otbossim/src/ossim/projection/ossimMapProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimMapProjection.cpp
index 012c2b79cdd550b6517d9beea6cb2ba0bec84745..739c4dd3c7722b212c102e25040413af72287746 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 13025 2008-06-13 17:06:30Z sbortman $
+//  $Id: ossimMapProjection.cpp 13913 2008-12-04 19:16:38Z gpotts $
 
 #include <iostream>
 #include <cstdlib>
@@ -17,6 +17,7 @@
 #include <sstream>
 
 #include <ossim/projection/ossimMapProjection.h>
+#include <ossim/projection/ossimPcsCodeProjectionFactory.h>
 #include <ossim/projection/ossimStatePlaneProjectionFactory.h>
 #include <ossim/projection/ossimStatePlaneProjectionInfo.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -31,6 +32,9 @@
 #include <ossim/base/ossimMatrix3x3.h>
 #include <ossim/base/ossimUnitConversionTool.h>
 #include <ossim/base/ossimUnitTypeLut.h>
+#include <ossim/base/ossimTrace.h>
+
+static ossimTrace traceDebug("ossimMapProjection:debug");
 
 // RTTI information for the ossimMapProjection
 RTTI_DEF1(ossimMapProjection, "ossimMapProjection" , ossimProjection);
@@ -286,9 +290,29 @@ void ossimMapProjection::update()
       }
    }
 
-   if (thePcsCode)
+   //---
+   // Projection Coordinate System(PCS) code check:
+   //---
+   
+   // See if this projection has a pcs code.
+   ossim_uint16 pcsCode = ossimPcsCodeProjectionFactory::instance()->
+      getPcsCodeFromProjection(this);
+   
+   if (pcsCode)
    {
-      verifyPcsCodeMatches();
+      // If so store it.
+      thePcsCode = pcsCode;
+   }
+   else if (thePcsCode)
+   {
+      //---
+      // A code was stored previously.  Verify the projection parameters for
+      // the code.
+      //---
+      if ( verifyPcsCodeMatches() == false )
+      {
+         thePcsCode = 0;
+      }
    }
 }
 
@@ -684,6 +708,7 @@ void ossimMapProjection::lineSampleToEastingNorthing(const ossimDpt& lineSample,
    //   eastingNorthing.y += (-lineSample.y*theMetersPerPixel.y);
 }
 
+
 void ossimMapProjection::setMetersPerPixel(const ossimDpt& gsd)
 {
    theMetersPerPixel=gsd;
@@ -738,6 +763,19 @@ void ossimMapProjection::eastingNorthingToLineSample(const ossimDpt& eastingNort
    }
 }
 
+void ossimMapProjection::setUlTiePoints(const ossimGpt& gpt)
+{
+   setUlGpt(gpt);
+   setUlEastingNorthing(forward(gpt));
+}
+
+void ossimMapProjection::setUlTiePoints(const ossimDpt& eastingNorthing)
+{
+   setUlGpt(inverse(eastingNorthing));
+   setUlEastingNorthing(eastingNorthing);
+}
+
+
 //*****************************************************************************
 //  METHOD: ossimMapProjection::setUlEastingNorthing
 //
@@ -964,14 +1002,17 @@ bool ossimMapProjection::loadState(const ossimKeywordlist& kwl, const char* pref
             }
             default:
             {
-               // Unhandled unit type!
-               ossimNotify(ossimNotifyLevel_WARN)
+               if(traceDebug())
+               {
+                  // Unhandled unit type!
+                  ossimNotify(ossimNotifyLevel_WARN)
                   << "ossimMapProjection::loadState WARNING!"
                   << "Unhandled unit type for "
                   << ossimKeywordNames::PIXEL_SCALE_UNITS_KW << ":  "
                   << ( ossimUnitTypeLut::instance()->
-                       getEntryString(units).c_str() )
+                      getEntryString(units).c_str() )
                   << endl;
+               }
                break;
             }
          } // End of switch (units)
@@ -1054,14 +1095,17 @@ bool ossimMapProjection::loadState(const ossimKeywordlist& kwl, const char* pref
             }
             default:
             {
-               // Unhandled unit type!
-               ossimNotify(ossimNotifyLevel_WARN)
+               if(traceDebug())
+               {
+                  // Unhandled unit type!
+                  ossimNotify(ossimNotifyLevel_WARN)
                   << "ossimMapProjection::loadState WARNING!"
                   << "Unhandled unit type for "
                   << ossimKeywordNames::TIE_POINT_UNITS_KW << ": " 
                   << ( ossimUnitTypeLut::instance()->
-                       getEntryString(units).c_str() )
+                      getEntryString(units).c_str() )
                   << endl;
+               }
                break;
             }
          } // End of switch (units)
@@ -1133,15 +1177,18 @@ bool ossimMapProjection::loadState(const ossimKeywordlist& kwl, const char* pref
             }
             default:
             {
-               // Unhandled unit type!
-               ossimNotify(ossimNotifyLevel_WARN)
+               if(traceDebug())
+               {
+                  // Unhandled unit type!
+                  ossimNotify(ossimNotifyLevel_WARN)
                   << "ossimMapProjection::loadState WARNING!"
                   << "Unhandled unit type for "
                   << ossimKeywordNames::FALSE_EASTING_NORTHING_UNITS_KW
                   << ":  " 
                   << ( ossimUnitTypeLut::instance()->
-                       getEntryString(units).c_str() )
+                      getEntryString(units).c_str() )
                   << endl;
+               }
                break;
             }
          } // End of switch (units)
@@ -1155,13 +1202,13 @@ bool ossimMapProjection::loadState(const ossimKeywordlist& kwl, const char* pref
       lookup =  kwl.find(prefix, ossimKeywordNames::FALSE_EASTING_KW);
       if(lookup)
       {
-         theFalseEastingNorthing.x = fabs(ossimString(lookup).toFloat64());
+         theFalseEastingNorthing.x = (ossimString(lookup).toFloat64());
       }
       
       lookup =  kwl.find(prefix, ossimKeywordNames::FALSE_NORTHING_KW);
       if(lookup)
       {
-         theFalseEastingNorthing.y = fabs(ossimString(lookup).toFloat64());
+         theFalseEastingNorthing.y = (ossimString(lookup).toFloat64());
       }
    }            
 
@@ -1221,11 +1268,13 @@ bool ossimMapProjection::loadState(const ossimKeywordlist& kwl, const char* pref
       NEWMAT::Matrix& m = theModelTransform.getData();
       istringstream in(modelTransform);
       ossim_uint32 row, col;
+      ossimString value;
       for(row = 0; row < 4; ++row)
       {
          for(col = 0; col < 4; ++col)
          {
-            in >> m[row][col];
+            in >> value;
+            m[row][col] = value.toDouble();
          }
       }
       // make sure these have the identity and all unused are 0.0
@@ -1240,10 +1289,17 @@ bool ossimMapProjection::loadState(const ossimKeywordlist& kwl, const char* pref
       
       if(!in.fail())
       {
-         theInverseModelTransform = theModelTransform;
-         theInverseModelTransform.i();
-         theModelTransformUnitType = static_cast<ossimUnitType>(ossimUnitTypeLut::instance()->
-                                                                getEntryNumber(modelTransformUnit));
+         try
+         {
+            theInverseModelTransform = theModelTransform;
+            theInverseModelTransform.i();
+            theModelTransformUnitType = static_cast<ossimUnitType>(ossimUnitTypeLut::instance()->
+                                                                   getEntryNumber(modelTransformUnit));
+         }
+         catch(...)
+         {
+            theModelTransformUnitType = OSSIM_UNIT_UNKNOWN;   
+         }
       }
   }
    //---
@@ -1458,8 +1514,6 @@ void ossimMapProjection::snapTiePointTo(ossim_float64 multiple,
       convertedMultiple = convertor.getMeters();
    }
 
-   // cout << "multiple: " << convertedMultiple << endl;
-   
    // Convert the tie point.
    if (isGeographic())
    {
@@ -1493,6 +1547,42 @@ void ossimMapProjection::snapTiePointTo(ossim_float64 multiple,
    }
 }
 
+
+void ossimMapProjection::snapTiePointToOrigin()
+{
+   // Convert the tie point.
+   if (isGeographic())
+   {
+      // Snap the latitude.
+      ossim_float64 d = theUlGpt.latd();
+      d = ossim::round<int>(d / theDegreesPerPixel.y) * theDegreesPerPixel.y;
+      theUlGpt.latd(d);
+
+      // Snap the longitude.
+      d = theUlGpt.lond();
+      d = ossim::round<int>(d / theDegreesPerPixel.x) * theDegreesPerPixel.x;
+      theUlGpt.lond(d);
+
+      // Adjust the stored easting / northing.
+      theUlEastingNorthing = forward(theUlGpt);
+   }
+   else
+   {
+      // Snap the easting.
+      ossim_float64 d = theUlEastingNorthing.x - getFalseEasting();
+      d = ossim::round<int>(d / theMetersPerPixel.x) * theMetersPerPixel.x;
+      theUlEastingNorthing.x = d + getFalseEasting();
+
+      // Snap the northing.
+      d = theUlEastingNorthing.y - getFalseNorthing();
+      d = ossim::round<int>(d / theMetersPerPixel.y) * theMetersPerPixel.y;
+      theUlEastingNorthing.y = d + getFalseNorthing();
+
+      // Adjust the stored upper left ground point.
+      theUlGpt = inverse(theUlEastingNorthing);
+   }
+}
+
 void ossimMapProjection::setElevationLookupFlag(bool flag)
 {
    theElevationLookupFlag = flag;
@@ -1504,27 +1594,23 @@ bool ossimMapProjection::getElevationLookupFlag()const
 }
    
 
-bool ossimMapProjection::verifyPcsCodeMatches()
+bool ossimMapProjection::verifyPcsCodeMatches() const
 {
-   if (thePcsCode == 0)
+   bool result = false;
+   if ( thePcsCode )
    {
-      return false;
-   }
-
-   ossim_int32 code = static_cast<ossim_int32>(thePcsCode);
-   
-   const ossimStatePlaneProjectionInfo* info =
-      ossimStatePlaneProjectionFactory::instance()->getInfo(code);
-   if (info)
-   {
-      if (info->matchesProjection(this))
+      // See if it's a state plane.
+      ossim_int32 code = static_cast<ossim_int32>(thePcsCode);
+      
+      const ossimStatePlaneProjectionInfo* info =
+         ossimStatePlaneProjectionFactory::instance()->getInfo(code);
+      if (info)
       {
-         return true;
+         if (info->matchesProjection(this))
+         {
+            result = true;
+         }
       }
    }
-
-   // Reset to zero since it doesn't belong to this projection.
-   thePcsCode = 0;
-   
-   return false;
+   return result;
 }
diff --git a/Utilities/otbossim/src/ossim/projection/ossimNitfMapModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimNitfMapModel.cpp
index d75ca8822067b8328d959740b8bab9686aa5a549..db56c1e0a2c14728d293c1142edb8aa3893bfcdf 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimNitfMapModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimNitfMapModel.cpp
@@ -86,6 +86,7 @@ ossimNitfMapModel::ossimNitfMapModel(const ossimFilename& init_file)
                                              << "> as NITF2.00."<<endl;
       }
       theErrorStatus = 1;
+      delete [] header;
       return;
    }
 
@@ -273,6 +274,7 @@ ossimNitfMapModel::ossimNitfMapModel(const ossimFilename& init_file)
                                             << " Aborting with error..." << std::endl;
       }
       theErrorStatus = 1;
+      delete [] header;
       return;
    }
    
@@ -335,6 +337,7 @@ ossimNitfMapModel::ossimNitfMapModel(const ossimFilename& init_file)
                                                    << init_file << ">." << " Aborting with error..." << std::endl;
             }
             theErrorStatus = 1;
+            delete [] header;
             return;
          }
 
@@ -368,6 +371,7 @@ ossimNitfMapModel::ossimNitfMapModel(const ossimFilename& init_file)
    saveState(geom_kwl);
    geom_kwl.write(geom_filename.chars());
 
+   delete [] header;
 
    if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimNitfMapModel::ossimNitfMapModel: Exited..." << std::endl;
 }
diff --git a/Utilities/otbossim/src/ossim/projection/ossimNitfProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimNitfProjectionFactory.cpp
index 7c0ea35dc7df115f8f39c0091bac7438c06e4759..c7064b7b5c4f369dff1d66c04f9683a53526e31c 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 12276 2008-01-07 19:58:43Z dburken $
+// $Id: ossimNitfProjectionFactory.cpp 13909 2008-12-03 20:55:04Z gpotts $
 //----------------------------------------------------------------------------
 
 #include <fstream>
@@ -106,7 +106,7 @@ ossimNitfProjectionFactory::createProjection(const ossimFilename& filename,
       return result;
    }
 
-   ossimNitfImageHeader* imageHeader = nitf->getNewImageHeader(imageIndex);
+   ossimRefPtr<ossimNitfImageHeader> imageHeader = nitf->getNewImageHeader(imageIndex);
    {
       if (!imageHeader)
       {
@@ -115,14 +115,17 @@ ossimNitfProjectionFactory::createProjection(const ossimFilename& filename,
    }
 
    ossimString coordinateSystem   = imageHeader->getCoordinateSystem();
-   
+   ossimString version = nitf->getHeader()->getVersion();
    if (coordinateSystem == "G" || coordinateSystem == "D")
    {
-      result = makeGeographic(imageHeader, coordinateSystem, filename);
+      result = makeGeographic(imageHeader.get(), coordinateSystem, filename);
    }
    else if(coordinateSystem == "N" || coordinateSystem == "S")
    {
-      result = makeUtm(imageHeader, coordinateSystem, filename);
+      if((coordinateSystem == 'N') && (version.toDouble() > 2.0))
+      {
+         result = makeUtm(imageHeader.get(), coordinateSystem, filename);
+      }
    }
 
    if (traceDebug())
@@ -444,7 +447,10 @@ ossimProjection* ossimNitfProjectionFactory::makeBilinear(
    ossimDpt lr(cols-1.0, rows-1.0);
    ossimDpt ll(0.0, rows-1.0);
 
-   return new ossimBilinearProjection(ul,
+   ossimBilinearProjection* proj = 0;
+   try
+   {
+     proj = new ossimBilinearProjection(ul,
                                       ur,
                                       lr,
                                       ll,
@@ -452,6 +458,17 @@ ossimProjection* ossimNitfProjectionFactory::makeBilinear(
                                       gpts[1],
                                       gpts[2],
                                       gpts[3]);
+   }
+   catch(...)
+   {
+      if(proj)
+      {
+         delete proj;
+         proj = 0;
+      }
+   }
+   
+   return proj;
 }
 
 bool ossimNitfProjectionFactory::isSkewed(
diff --git a/Utilities/otbossim/src/ossim/projection/ossimPcsCodeProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimPcsCodeProjectionFactory.cpp
index 40d9c97638adaef5fa719ee9a7aa2db4b6393490..850f4f59dc6938783f68bc315c6f1a15cd99a810 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimPcsCodeProjectionFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimPcsCodeProjectionFactory.cpp
@@ -14,7 +14,7 @@
 // http://www.remotesensing.org/geotiff/spec/geotiff6.html#6.3.3.1
 // 
 //----------------------------------------------------------------------------
-//  $Id: ossimPcsCodeProjectionFactory.cpp 12082 2007-11-26 21:46:44Z dburken $
+//  $Id: ossimPcsCodeProjectionFactory.cpp 13819 2008-10-31 16:58:37Z dburken $
 
 #include <ossim/projection/ossimPcsCodeProjectionFactory.h>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
@@ -30,7 +30,7 @@ static const ossimTrace
 traceDebug(ossimString("ossimPcsCodeProjectionFactory:debug"));
 
 #if OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimPcsCodeProjectionFactory.cpp 12082 2007-11-26 21:46:44Z dburken $";
+static const char OSSIM_ID[] = "$Id: ossimPcsCodeProjectionFactory.cpp 13819 2008-10-31 16:58:37Z dburken $";
 #endif
 
 ossimPcsCodeProjectionFactory* ossimPcsCodeProjectionFactory::theInstance = 0;
@@ -318,10 +318,10 @@ void ossimPcsCodeProjectionFactory::getTypeNameList(
 {
 }
 
-ossim_int16 ossimPcsCodeProjectionFactory::getPcsCodeFromProjection(
+ossim_uint16 ossimPcsCodeProjectionFactory::getPcsCodeFromProjection(
    const ossimMapProjection* proj) const
 {
-   ossim_int16 pcsCode = 0;
+   ossim_uint16 pcsCode = 0;
    
    if (!proj)
    {
@@ -331,7 +331,7 @@ ossim_int16 ossimPcsCodeProjectionFactory::getPcsCodeFromProjection(
    ossimUtmProjection* utm = PTR_CAST(ossimUtmProjection, proj);
    if (utm)
    {
-      ossim_int32 mapZone    = utm->getZone();
+      ossim_uint16 mapZone   = static_cast<ossim_uint16>(utm->getZone());
       ossimString hemisphere = utm->getHemisphere();
       ossimString datumCode  = utm->getDatum()->code();
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryRegistry.cpp b/Utilities/otbossim/src/ossim/projection/ossimProjectionFactoryRegistry.cpp
index 11c4e18d1e89d104321de44aca330cd378534c7d..610c4e46a0a7156c89bbe37027c0d152ded987b8 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 12082 2007-11-26 21:46:44Z dburken $
+// $Id: ossimProjectionFactoryRegistry.cpp 13508 2008-08-27 15:51:38Z gpotts $
 #include <algorithm>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimProjectionFactoryBase.h>
@@ -19,24 +19,32 @@
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 
-ossimProjectionFactoryRegistry* ossimProjectionFactoryRegistry::theInstance=0;
+
+ossimProjectionFactoryRegistry::ossimProjectionFactoryRegistry()
+{
+   initializeDefaults();
+   ossimObjectFactoryRegistry::instance()->registerFactory(this);
+}
+
+ossimProjectionFactoryRegistry::ossimProjectionFactoryRegistry(const ossimProjectionFactoryRegistry& rhs)
+:
+ossimObjectFactory(rhs)
+{}
+
+void ossimProjectionFactoryRegistry::operator=(const ossimProjectionFactoryRegistry&)
+{}
 
 ossimProjectionFactoryRegistry::~ossimProjectionFactoryRegistry()
 {
    theFactoryList.clear();
-   theInstance = 0;
 }
 
 ossimProjectionFactoryRegistry* ossimProjectionFactoryRegistry::instance()
 {
-   if(!theInstance)
-   {
-      theInstance = new ossimProjectionFactoryRegistry;
-      theInstance->initializeDefaults();
-      ossimObjectFactoryRegistry::instance()->registerFactory(theInstance);
-   }
+   static ossimProjectionFactoryRegistry sharedInstance;
+   
 
-   return theInstance;
+   return &sharedInstance;
 }
 
 ossimProjection*
@@ -208,29 +216,16 @@ void ossimProjectionFactoryRegistry::getTypeNameList(
    }   
 }
 
-ossimProjectionFactoryRegistry::ossimProjectionFactoryRegistry()
-{}
-
-ossimProjectionFactoryRegistry::ossimProjectionFactoryRegistry(
-   const ossimProjectionFactoryRegistry& rhs)
-   :
-   ossimObjectFactory(rhs)
-{}
-
-void ossimProjectionFactoryRegistry::operator=(
-   const ossimProjectionFactoryRegistry&)
-{}
-
 void ossimProjectionFactoryRegistry::initializeDefaults()
 {
-   theInstance->registerFactory(ossimSensorModelFactory::instance());
-   theInstance->registerFactory(ossimMapProjectionFactory::instance());
-   theInstance->registerFactory(ossimSrsProjectionFactory::instance());
-   theInstance->registerFactory(ossimTiffProjectionFactory::instance());
-   theInstance->registerFactory(ossimPcsCodeProjectionFactory::instance());   
-   theInstance->registerFactory(ossimStatePlaneProjectionFactory::instance());
-   theInstance->registerFactory(ossimNitfProjectionFactory::instance());   
-   theInstance->registerFactory(ossimMiscProjectionFactory::instance());
+   registerFactory(ossimSensorModelFactory::instance());
+   registerFactory(ossimMapProjectionFactory::instance());
+   registerFactory(ossimSrsProjectionFactory::instance());
+   registerFactory(ossimTiffProjectionFactory::instance());
+   registerFactory(ossimPcsCodeProjectionFactory::instance());   
+   registerFactory(ossimStatePlaneProjectionFactory::instance());
+   registerFactory(ossimNitfProjectionFactory::instance());   
+   registerFactory(ossimMiscProjectionFactory::instance());
 }
 
 extern "C"
diff --git a/Utilities/otbossim/src/ossim/projection/ossimRpcProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimRpcProjection.cpp
index 3c36522e503fe8bff8ef2b0d614e88387bf8dec1..14fd890209b70592769b48700b3dbd4801dde9b9 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 12153 2007-12-10 15:13:54Z gpotts $
+//$Id: ossimRpcProjection.cpp 13770 2008-10-22 19:33:24Z gpotts $
 
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimRpcProjection.h>
@@ -1253,7 +1253,7 @@ ossimRpcProjection::buildNormalEquation(const ossimTieGptSet& tieSet,
    else
    {
       // ground observations
-      ossimGpt* gdDerp=new ossimGpt[np];
+      std::vector<ossimGpt> gdDerp(np);
       ossimGpt gd, resGd;
       // loop on tie points
       for (tit = theTPV.begin() ; tit != theTPV.end() ; ++tit)
diff --git a/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp b/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp
index 7bbebc93277f0e95a0e08b2bd546d00736ba6640..3dabb1b02c05d5c7a19aa63e359946d9c210aae2 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimRpcSolver.cpp
@@ -10,7 +10,7 @@
 // AUTHOR: Garrett Potts
 //
 //*****************************************************************************
-//  $Id: ossimRpcSolver.cpp 13010 2008-06-08 21:12:45Z dburken $
+//  $Id: ossimRpcSolver.cpp 13559 2008-09-10 11:16:12Z gpotts $
 
 #include <cstdlib>
 #include <ctime>
@@ -367,7 +367,7 @@ void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
       }
       else
       {
-         z = (z - theGroundOffset.height())/theHeightScale;
+         z = (z - theGroundOffset.height()/theHeightScale);
       }
        ossim_float64 imageX = ((eval(theXNumCoeffs, x, y, z)/
                                 eval(theXDenCoeffs, x, y, z))*theImageScale.x) + theImageOffset.x;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp
index 8873618ad65fc09aa591b0c04dc8d81b777ff0ae..3429ddfc4a56e8f3c3cd3399404beaf5efbcf36f 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimSensorModel.cpp
@@ -25,7 +25,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimSensorModel.cpp 12253 2008-01-03 21:40:15Z dburken $
+//  $Id: ossimSensorModel.cpp 13771 2008-10-22 19:33:54Z gpotts $
 #include <iostream>
 #include <sstream>
 using namespace std;
@@ -105,7 +105,9 @@ ossimSensorModel::ossimSensorModel()
    theRefImgPt         (0.0, 0.0),
    theBoundGndPolygon  (),
    theImageClipRect    (),
-   theNominalPosError  (0)
+   theNominalPosError  (0),
+   theExtrapolateImageFlag(false),
+   theExtrapolateGroundFlag(false)
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::ossimSensorModel(geom_kwl): entering..." << endl;
 
@@ -129,7 +131,9 @@ ossimSensorModel::ossimSensorModel(const ossimSensorModel& model)
    theRefImgPt        (model.theRefImgPt),
    theBoundGndPolygon (model.theBoundGndPolygon),
    theImageClipRect   (model.theImageClipRect),
-   theNominalPosError (model.theNominalPosError)
+theNominalPosError (model.theNominalPosError),
+theExtrapolateImageFlag(false),
+theExtrapolateGroundFlag(false)
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::ossimSensorModel(model): entering..." << std::endl;
 
@@ -159,7 +163,9 @@ ossimSensorModel::ossimSensorModel(const ossimKeywordlist& geom_kwl)
    theRefImgPt         (0.0, 0.0),
    theBoundGndPolygon  (),
    theImageClipRect    (),
-   theNominalPosError  (0)
+theNominalPosError  (0),
+theExtrapolateImageFlag(false),
+theExtrapolateGroundFlag(false)
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::ossimSensorModel(geom_kwl): entering..." << std::endl;
 
@@ -213,7 +219,7 @@ void ossimSensorModel::lineSampleToWorld(const ossimDpt& image_point,
    //***
    // Extrapolate if image point is outside image:
    //***
-   if (!insideImage(image_point))
+   if (!insideImage(image_point)&&(!theExtrapolateImageFlag))
    {
       gpt = extrapolate(image_point);
       return;
@@ -276,7 +282,8 @@ void ossimSensorModel::worldToLineSample(const ossimGpt& worldPoint,
          {
             theSeedFunction->worldToLineSample(worldPoint, ip);
          }
-         else
+         else if(!theExtrapolateGroundFlag) // if I am not already in the extrapolation routine
+
          {
          //      recursionFlag = true;
             ip = extrapolate(worldPoint);
@@ -779,10 +786,22 @@ bool ossimSensorModel::loadState(const ossimKeywordlist& kwl,
    const char* rect = kwl.find(prefix, "rect");
    if(rect)
    {
-      std::istringstream in(rect);
-      double ulx, uly, lrx, lry;
-      in >> ulx >> uly >> lrx >> lry;
-      theImageClipRect = ossimDrect(ulx, uly, lrx, lry);
+      std::vector<ossimString> splitArray;
+      ossimString rectString(rect);
+      rectString = rectString.trim();
+      rectString.split(splitArray, " ");
+      if(splitArray.size() == 4)
+      {
+         theImageClipRect = ossimDrect(splitArray[0].toDouble(),
+                                       splitArray[1].toDouble(),
+                                       splitArray[2].toDouble(),
+                                       splitArray[3].toDouble());
+      }
+      else
+      {
+         theImageClipRect = ossimDrect(0.0, 0.0,
+                                       theImageSize.samp-1, theImageSize.line-1);
+      }
    }
    else
    {
@@ -811,6 +830,7 @@ bool ossimSensorModel::loadState(const ossimKeywordlist& kwl,
 ossimGpt ossimSensorModel::extrapolate (const ossimDpt& imagePoint,
                                         const double&   height) const
 {
+   theExtrapolateImageFlag = true;
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) <<  "DEBUG ossimSensorModel::extrapolate: entering... " << std::endl;
 
    //---
@@ -820,6 +840,7 @@ ossimGpt ossimSensorModel::extrapolate (const ossimDpt& imagePoint,
    //---
    if (imagePoint.hasNans())
    {
+      theExtrapolateImageFlag = false;
       if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::extrapolate: returning..." << std::endl;
       return ossimGpt(ossim::nan(), ossim::nan(), ossim::nan());
    }
@@ -829,7 +850,7 @@ ossimGpt ossimSensorModel::extrapolate (const ossimDpt& imagePoint,
       ossimGpt wpt;
 
       theSeedFunction->lineSampleToWorld(imagePoint, wpt);
-
+      theExtrapolateImageFlag = false;
       return wpt;
    }
    //***
@@ -891,6 +912,7 @@ ossimGpt ossimSensorModel::extrapolate (const ossimDpt& imagePoint,
    {
       gpt.hgt = height;
    }
+   theExtrapolateImageFlag = false;
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::extrapolate: returning..." << std::endl;
    return gpt;
 }
@@ -905,7 +927,7 @@ ossimGpt ossimSensorModel::extrapolate (const ossimDpt& imagePoint,
 ossimDpt ossimSensorModel::extrapolate (const ossimGpt& gpt) const
 {
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) <<  "DEBUG ossimSensorModel::extrapolate: entering... " << std::endl;
-
+   theExtrapolateGroundFlag = true;
    double height = 0.0;
    //---
    // If ground point supplied has NaN components, return now with a NaN point.
@@ -913,6 +935,7 @@ ossimDpt ossimSensorModel::extrapolate (const ossimGpt& gpt) const
    if ( (ossim::isnan(gpt.lat)) || (ossim::isnan(gpt.lon)) )
 //       (gpt.hgt==OSSIM_DBL_NAN))
    {
+      theExtrapolateGroundFlag = false;
       if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::extrapolate: returning..." << std::endl;
       return ossimDpt(ossim::nan(), ossim::nan());
    }
@@ -927,7 +950,8 @@ ossimDpt ossimSensorModel::extrapolate (const ossimGpt& gpt) const
 
       theSeedFunction->worldToLineSample(gpt, ipt);
 
-      return ipt;
+      theExtrapolateGroundFlag = false;
+     return ipt;
    }
    //***
    // Determine which edge is intersected by the radial, and establish
@@ -975,6 +999,7 @@ ossimDpt ossimSensorModel::extrapolate (const ossimGpt& gpt) const
 
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::extrapolate: returning..." << std::endl;
 
+   theExtrapolateGroundFlag = false;
    return extrapolated_ip;
 }
 
@@ -1244,7 +1269,7 @@ ossimSensorModel::buildNormalEquation(const ossimTieGptSet& tieSet,
    if (useImageObs)
    { 
      //image observations 
-     ossimDpt* imDerp = new ossimDpt[np];
+      std::vector<ossimDpt> imDerp(np);
      ossimDpt resIm;
      // loop on tie points
       for (tit = theTPV.begin() ; tit != theTPV.end() ; ++tit)
@@ -1273,12 +1298,11 @@ ossimSensorModel::buildNormalEquation(const ossimTieGptSet& tieSet,
             }
          }
       }
-      delete []imDerp;
    }
    else
    {
       // ground observations
-      ossimGpt* gdDerp=new ossimGpt[np];
+      std::vector<ossimGpt>  gdDerp(np);
       ossimGpt gd, resGd;
       // loop on tie points
       for (tit = theTPV.begin() ; tit != theTPV.end() ; ++tit)
@@ -1308,6 +1332,7 @@ ossimSensorModel::buildNormalEquation(const ossimTieGptSet& tieSet,
             }
          }
       }
+
    } //end of if (useImageObs)
 }
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimSpot5Model.cpp b/Utilities/otbossim/src/ossim/projection/ossimSpot5Model.cpp
index a42837a4adead60c81df378d1dd574c001f34e14..f9307be77bb60ea8dbd0c98aaca8fb60c392e975 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 13027 2008-06-15 01:37:00Z dburken $
+// $Id: ossimSpot5Model.cpp 13976 2009-01-20 16:00:16Z gpotts $
 
 #include <iostream>
 #include <iomanip>
@@ -76,6 +76,8 @@ ossimSpot5Model::ossimSpot5Model()
    theRefImagingTime     (0.0),
    theRefImagingTimeLine (0.0),   
    theLineSamplingPeriod (0.0),
+//   theSatToOrbRotation   (3, 3),
+//   theOrbToEcfRotation   (3, 3),
    theRollOffset         (0.0),
    thePitchOffset        (0.0),
    theYawOffset          (0.0),
@@ -98,6 +100,8 @@ ossimSpot5Model::ossimSpot5Model(ossimSpotDimapSupportData* sd)
    theRefImagingTime     (0.0),
    theRefImagingTimeLine (0.0),   
    theLineSamplingPeriod (0.0),
+//   theSatToOrbRotation   (3, 3),
+//   theOrbToEcfRotation   (3, 3),
    theRollOffset         (0.0),
    thePitchOffset        (0.0),
    theYawOffset          (0.0),
@@ -161,10 +165,56 @@ ossimSpot5Model::ossimSpot5Model(const ossimSpot5Model& rhs)
    updateModel();
 }
 
+
+void ossimSpot5Model::computeSatToOrbRotation(NEWMAT::Matrix& result, ossim_float64 t)const
+{
+   if (traceExec())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+      << "DEBUG ossimSpot5Model::computeSatToOrbRotation(): entering..."
+      << std::endl;
+   }
+   //---
+   // Linearly interpolate attitudes angles:
+   //---
+   ossimDpt3d att;
+   theSupportData->getAttitude(t, att);
+   
+   //---
+   // Apply the attitude adjustable parameters:
+   //---
+   double dt = theRefImagingTime - t;
+   att.x     += thePitchOffset + dt*thePitchRate;
+   att.y     += theRollOffset  + dt*theRollRate;
+   att.z     += theYawOffset   + dt*theYawRate;
+   
+   //---
+   // Compute trig functions to populate rotation matrices: ANGLES IN RADIANS
+   //---
+   double cp = cos(att.x);
+   double sp = sin(att.x);
+   double cr = cos(att.y);
+   double sr = sin(att.y);
+   double cy = cos(att.z);
+   double sy = sin(att.z);
+   
+   //---
+   // Populate rotation matrix:
+   //---
+   result = NEWMAT::Matrix(3,3);
+   result << (cr*cy) << (-cr*sy) << (-sr)
+   << (cp*sy+sp*sr*cy) << (cp*cy-sp*sr*sy) << (sp*cr)
+   << (-sp*sy+cp*sr*cy) << (-sp*cy-cp*sr*sy) <<  cp*cr;
+   
+   
+   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::computeSatToOrbRotation(): returning..." << std::endl;
+}
+
+#if 0
 //*****************************************************************************
 //  METHOD
 //*****************************************************************************
-NEWMAT::Matrix ossimSpot5Model::computeSatToOrbRotation(ossim_float64 t)const
+void ossimSpot5Model::computeSatToOrbRotation(ossim_float64 t)const
 {
    if (traceExec())
    {
@@ -200,16 +250,15 @@ NEWMAT::Matrix ossimSpot5Model::computeSatToOrbRotation(ossim_float64 t)const
    //---
    // Populate rotation matrix:
    //---
-	NEWMAT::Matrix satToOrbRotation = NEWMAT::Matrix(3,3);
-    satToOrbRotation << (cr*cy) << (-cr*sy) << (-sr)
+    theSatToOrbRotation = NEWMAT::Matrix(3,3);
+    theSatToOrbRotation << (cr*cy) << (-cr*sy) << (-sr)
                         << (cp*sy+sp*sr*cy) << (cp*cy-sp*sr*sy) << (sp*cr)
                         << (-sp*sy+cp*sr*cy) << (-sp*cy-cp*sr*sy) <<  cp*cr;
     
    
     if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::computeSatToOrbRotation(): returning..." << std::endl;
-	return satToOrbRotation;
 }
-
+#endif
 //*****************************************************************************
 // PUBLIC METHOD: ossimSpot5Model::updateModel()
 //  
@@ -219,44 +268,53 @@ NEWMAT::Matrix ossimSpot5Model::computeSatToOrbRotation(ossim_float64 t)const
 //*****************************************************************************
 void ossimSpot5Model::updateModel()
 {
-   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): entering..." << std::endl;
-
-   if(getNumberOfAdjustableParameters() < 1)
+   clearErrorStatus();
+   
+   try
    {
-      theRollOffset     = 0;
-      thePitchOffset    = 0;
-      theYawOffset      = 0;
-      theRollRate       = 0;
-      thePitchRate      = 0;
-      theYawRate        = 0;
-      theFocalLenOffset = 0;
+      if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): entering..." << std::endl;
+      
+      if(getNumberOfAdjustableParameters() < 1)
+      {
+         theRollOffset     = 0;
+         thePitchOffset    = 0;
+         theYawOffset      = 0;
+         theRollRate       = 0;
+         thePitchRate      = 0;
+         theYawRate        = 0;
+         theFocalLenOffset = 0;
+      }
+      else
+      {
+         theRollOffset     = computeParameterOffset(0);
+         thePitchOffset    = computeParameterOffset(1);
+         theYawOffset      = computeParameterOffset(2);
+         theRollRate       = computeParameterOffset(3);
+         thePitchRate      = computeParameterOffset(4);
+         theYawRate        = computeParameterOffset(5);
+         theFocalLenOffset = computeParameterOffset(6);
+      }
+      theSeedFunction = 0;
+      ossimGpt ulg, urg, lrg, llg;
+      lineSampleToWorld(theImageClipRect.ul(), ulg);
+      lineSampleToWorld(theImageClipRect.ur(), urg);
+      lineSampleToWorld(theImageClipRect.lr(), lrg);
+      lineSampleToWorld(theImageClipRect.ll(), llg);
+      theSeedFunction = new ossimBilinearProjection(theImageClipRect.ul(),
+                                                    theImageClipRect.ur(),
+                                                    theImageClipRect.lr(),
+                                                    theImageClipRect.ll(),
+                                                    ulg,
+                                                    urg,
+                                                    lrg,
+                                                    llg);
+      
+      if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): returning..." << std::endl;   
    }
-   else
+   catch(...)
    {
-      theRollOffset     = computeParameterOffset(0);
-      thePitchOffset    = computeParameterOffset(1);
-      theYawOffset      = computeParameterOffset(2);
-      theRollRate       = computeParameterOffset(3);
-      thePitchRate      = computeParameterOffset(4);
-      theYawRate        = computeParameterOffset(5);
-      theFocalLenOffset = computeParameterOffset(6);
+      setErrorStatus(ossimErrorCodes::OSSIM_ERROR);
    }
-   theSeedFunction = 0;
-   ossimGpt ulg, urg, lrg, llg;
-   lineSampleToWorld(theImageClipRect.ul(), ulg);
-   lineSampleToWorld(theImageClipRect.ur(), urg);
-   lineSampleToWorld(theImageClipRect.lr(), lrg);
-   lineSampleToWorld(theImageClipRect.ll(), llg);
-   theSeedFunction = new ossimBilinearProjection(theImageClipRect.ul(),
-                                                 theImageClipRect.ur(),
-                                                 theImageClipRect.lr(),
-                                                 theImageClipRect.ll(),
-                                                 ulg,
-                                                 urg,
-                                                 lrg,
-                                                 llg);
-   
-   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSpot5Model::updateModel(): returning..." << std::endl;   
 }
 
 void ossimSpot5Model::initAdjustableParameters()
@@ -358,7 +416,6 @@ void ossimSpot5Model::loadSupportData()
       thePositionError = 200.0; // meters
    }
    updateModel();
-
    lineSampleToWorld(theImageClipRect.ul(), p1);
    lineSampleToWorld(theImageClipRect.ur(), p2);
    lineSampleToWorld(theImageClipRect.lr(), p3);
@@ -475,14 +532,14 @@ bool ossimSpot5Model::loadState(const ossimKeywordlist& kwl,
    loadSupportData();
    updateModel();
    
-   return true;
+   return (getErrorStatus()==ossimErrorCodes::OSSIM_OK);
 }
 
 void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
                                  ossimEcefRay&   image_ray) const
 {
    bool runtime_dbflag = 0;
-
+   NEWMAT::Matrix satToOrbit;
    ossimDpt iPt = image_point;
    iPt.samp += theSpotSubImageOffset.samp;
    iPt.line += theSpotSubImageOffset.line;
@@ -541,13 +598,13 @@ void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
    // 4. Transform vehicle LSR space look direction vector to orbital LSR space
    //    (S_orb):
    //
-	NEWMAT::Matrix satToOrbRotation = computeSatToOrbRotation(t_line);
+    computeSatToOrbRotation(satToOrbit, t_line);
     
-    ossimColumnVector3d u_orb = (satToOrbRotation*u_sat).unit();
+    ossimColumnVector3d u_orb = (satToOrbit*u_sat).unit();
     if (traceDebug() || runtime_dbflag)
     {
        ossimNotify(ossimNotifyLevel_DEBUG)
-          << "DEBUG:\n\t satToOrbRotation = " << satToOrbRotation
+          << "DEBUG:\n\t theSatToOrbRotation = " << satToOrbit
           << "\n\t u_orb = " << u_orb << endl;
     }
 
@@ -568,12 +625,12 @@ void ossimSpot5Model::imagingRay(const ossimDpt& image_point,
                                                     V_ecf.z()).cross(Z_orb).unit();
     ossimColumnVector3d Y_orb = Z_orb.cross(X_orb);
 
-	NEWMAT::Matrix orbToEcfRotation = NEWMAT::Matrix(3, 3);
+    NEWMAT::Matrix orbToEcfRotation = NEWMAT::Matrix(3, 3);
     orbToEcfRotation << X_orb[0] << Y_orb[0] << Z_orb[0]
                         << X_orb[1] << Y_orb[1] << Z_orb[1]
                         << X_orb[2] << Y_orb[2] << Z_orb[2];
     
-
+   
    ossimColumnVector3d u_ecf  = (orbToEcfRotation*u_orb);
     if (traceDebug() || runtime_dbflag)
     {
@@ -711,6 +768,8 @@ ossimSpot5Model::initFromMetadata(ossimSpotDimapSupportData* sd)
    thePositionError      = 0.0;
    theRefImagingTime     = 0.0;
    theLineSamplingPeriod = 0.0;
+//   theSatToOrbRotation   = 0.0; //matrix
+//   theOrbToEcfRotation   = 0.0; //matrix
    theRollOffset         = 0.0;
    thePitchOffset        = 0.0;
    theYawOffset          = 0.0;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimSrsProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimSrsProjectionFactory.cpp
index c5c2e515303474a33b6f128ce2e84d9616d8045e..b1fa195b044cefeb3ca1ca8c55cb6aa3a91810da 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimSrsProjectionFactory.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimSrsProjectionFactory.cpp
@@ -5,7 +5,7 @@
 //   Contains implementation of class ossimMapProjectionFactory
 //
 //*****************************************************************************
-//  $Id: ossimSrsProjectionFactory.cpp 12082 2007-11-26 21:46:44Z dburken $
+//  $Id: ossimSrsProjectionFactory.cpp 13459 2008-08-20 12:48:50Z gpotts $
 #include <sstream>
 #include <ossim/projection/ossimSrsProjectionFactory.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -79,6 +79,7 @@ ossimProjection* ossimSrsProjectionFactory::createProjection(const ossimString &
          {
             ossimUtmProjection* utm = new ossimUtmProjection;
             utm->setZone(origin);
+            utm->setHemisphere(origin);
             utm->setOrigin(origin);
             utm->update();
             return utm;
diff --git a/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionFactory.cpp
index 1b31248c9c067b6291eee34568465d14aa4f6f41..3551210c3e9174dea15d9ca259b848c3956e2307 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 12623 2008-04-07 14:10:08Z gpotts $
+//  $Id: ossimStatePlaneProjectionFactory.cpp 13401 2008-08-07 18:07:30Z dburken $
 
 #include <fstream>
 #include <sstream>
@@ -191,7 +191,8 @@ ossimObject* ossimStatePlaneProjectionFactory::createObject(
 void ossimStatePlaneProjectionFactory::getTypeNameList(
    std::vector<ossimString>& typeList)const
 {
-	OpenThreads::ScopedReadLock lock(theMutex);
+   OpenThreads::ScopedReadLock lock(theMutex);
+   
    // Iterate throught the cvs files to try and get the names.
    std::vector<ossimFilename>::const_iterator i = theCsvFiles.begin();
    while (i != theCsvFiles.end())
@@ -236,10 +237,11 @@ void ossimStatePlaneProjectionFactory::getTypeNameList(
 
 void ossimStatePlaneProjectionFactory::addCsvFile(const ossimFilename csvFile)
 {
-	OpenThreads::ScopedWriteLock lock(theMutex);
+   OpenThreads::ScopedWriteLock lock(theMutex);
+   
    std::vector<ossimFilename>::iterator iter = std::find(theCsvFiles.begin(),
-                                                theCsvFiles.end(),
-                                                csvFile);
+                                                         theCsvFiles.end(),
+                                                         csvFile);
    if(iter == theCsvFiles.end())
    {
       theCsvFiles.push_back(csvFile);
@@ -286,7 +288,8 @@ ossimStatePlaneProjectionInfo* ossimStatePlaneProjectionFactory::findInfo(
 ossimStatePlaneProjectionInfo*
 ossimStatePlaneProjectionFactory::findInInfoList(ossim_uint32 pcsCode)const
 {
-	OpenThreads::ScopedReadLock lock(theMutex);
+   OpenThreads::ScopedReadLock lock(theMutex);
+
    // See if it's in the list.
    std::vector<ossimStatePlaneProjectionInfo*>::const_iterator i =
       theInfos.begin();
diff --git a/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionInfo.cpp b/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionInfo.cpp
index ca20a79fd0d7ae1614fcc0527451812a2c3a579b..163c8e29ec2fee99fb35b576c87812c310c5f995 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionInfo.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimStatePlaneProjectionInfo.cpp
@@ -4,7 +4,7 @@
 //
 // Author: Garrett Potts
 //*******************************************************************
-//  $Id: ossimStatePlaneProjectionInfo.cpp 12442 2008-02-07 22:33:52Z dburken $
+//  $Id: ossimStatePlaneProjectionInfo.cpp 13400 2008-08-07 18:06:54Z dburken $
 
 #include <ossim/projection/ossimStatePlaneProjectionInfo.h>
 #include <ossim/projection/ossimTransMercatorProjection.h>
@@ -104,7 +104,9 @@ ossimStatePlaneProjectionInfo::ossimStatePlaneProjectionInfo(
       ossimUnitTypeLut::instance()->getEntryNumber(units.c_str()));
 
    // Currently only handle meters and us_survey_feet.
-   if ( (theUnits != OSSIM_METERS) && (theUnits != OSSIM_US_SURVEY_FEET) )
+   if ( (theUnits != OSSIM_METERS) &&
+        (theUnits != OSSIM_US_SURVEY_FEET) &&
+        (theUnits != OSSIM_FEET) )
    {
       ossimNotify(ossimNotifyLevel_WARN)
          << "ossimStatePlaneProjectionInfo unhandled unit type: "
@@ -190,22 +192,36 @@ bool ossimStatePlaneProjectionInfo::isSameCode(int pcsCode) const
 
 double ossimStatePlaneProjectionInfo::falseEastingInMeters() const
 {
-   if (theUnits == OSSIM_METERS)
+   double result = theFalseEasting;
+   switch (theUnits)
    {
-      return theFalseEasting;
+      case OSSIM_US_SURVEY_FEET:
+         result *= US_METERS_PER_FT;
+         break;
+      case OSSIM_FEET:
+         result *= MTRS_PER_FT;
+         break;
+      default:
+         break;
    }
-
-   return theFalseEasting * US_METERS_PER_FT;
+   return result;
 }
 
 double ossimStatePlaneProjectionInfo::falseNorthingInMeters() const
 {
-   if (theUnits == OSSIM_METERS)
+   double result = theFalseNorthing;
+   switch (theUnits)
    {
-      return theFalseNorthing;
+      case OSSIM_US_SURVEY_FEET:
+         result *= US_METERS_PER_FT;
+         break;
+      case OSSIM_FEET:
+         result *= MTRS_PER_FT;
+         break;
+      default:
+         break;
    }
-
-   return theFalseNorthing * US_METERS_PER_FT;
+   return result;
 }
 
 void ossimStatePlaneProjectionInfo::populateProjectionKeywords(
diff --git a/Utilities/otbossim/src/ossim/projection/ossimUtmProjection.cpp b/Utilities/otbossim/src/ossim/projection/ossimUtmProjection.cpp
index a76e36a7564db96936cdcf0aaabb3a2c1c07c211..4f1e04ae7f9f74abda1ac165df438d7776abdd24 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimUtmProjection.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimUtmProjection.cpp
@@ -8,7 +8,7 @@
 //
 // Calls Geotrans Utm projection code.  
 //*******************************************************************
-//  $Id: ossimUtmProjection.cpp 13012 2008-06-08 21:26:58Z dburken $
+//  $Id: ossimUtmProjection.cpp 13859 2008-11-11 14:45:00Z dburken $
 
 #include <cstdlib>
 #include <cmath>
@@ -81,6 +81,7 @@ ossimUtmProjection::ossimUtmProjection(const ossimEllipsoid& ellipsoid,
       
 {
    setZone(origin);
+   setHemisphere(origin);
    update();
 }
 
@@ -106,7 +107,7 @@ ossimUtmProjection::ossimUtmProjection(const ossimEllipsoid& ellipsoid,
       theTranMerc_Delta_Easting(40000000.0),
       theTranMerc_Delta_Northing(40000000.0),
       theZone(zone),
-      theHemisphere('N')      
+      theHemisphere(hemisphere)      
 {
    setZone(zone);
    setHemisphere(hemisphere);
@@ -135,7 +136,6 @@ ossimUtmProjection::ossimUtmProjection(ossim_int32 zone)
       theHemisphere('N')      
 {
    setZone(zone);
-   theOrigin.lond(computeZoneMeridian(theZone));
    update();
 }
 
@@ -159,16 +159,27 @@ ossimUtmProjection::ossimUtmProjection(const ossimUtmProjection& src)
       theZone(src.theZone),
       theHemisphere(src.theHemisphere)      
 {
+   setZone(theZone);
+   setHemisphere(theHemisphere);
+   update();
 }
 
 void ossimUtmProjection::update()
 {
+   ossimGpt origin = theOrigin;
+   origin.lond(computeZoneMeridian(theZone));
+   origin.latd(0.0);
+   double falseNorthing = 10000000.0;
+   if (theHemisphere == 'N')
+   {
+      falseNorthing = 0.0;
+   }
    Set_Transverse_Mercator_Parameters(theEllipsoid.getA(),
                                       theEllipsoid.getFlattening(),
-                                      theOrigin.latr(),
-                                      theOrigin.lonr(),
+                                      origin.latr(),
+                                      origin.lonr(),
                                       theTranMerc_False_Easting,
-                                      theTranMerc_False_Northing,
+                                      falseNorthing,
                                       theTranMerc_Scale_Factor);
 
    theFalseEastingNorthing.x = theTranMerc_False_Easting;
@@ -215,16 +226,6 @@ ossimDpt ossimUtmProjection::forward(const ossimGpt &latLon)const
 ossimObject* ossimUtmProjection::dup()const
 {
    ossimUtmProjection* proj = new ossimUtmProjection(*this);
-
-   //---
-   // TEMP:
-   // Set the projection up correctly.
-   // Note: The setZone sets the origin, but does not set all parameter
-   // needed; hence, the setZone, setOrigin.
-   //---
-   proj->setZone(theZone);
-   proj->setOrigin(proj->origin());
-   proj->setUlGpt(proj->origin());
    return proj;
 }
 
@@ -238,14 +239,25 @@ char ossimUtmProjection::getHemisphere() const
    return theHemisphere;
 }
 
+void ossimUtmProjection::setOrigin(const ossimGpt& origin)
+{
+   setZone(origin);
+   // NOTE: We will not set the hemisphere if the origin latitude is 0.0.
+   if (origin.latd() != 0.0)
+   {
+      setHemisphere(origin);
+   }
+   ossimMapProjection::setOrigin(theOrigin);
+}
+
 void ossimUtmProjection::setZone(const ossimGpt& ground)
 {
    theZone = computeZone(ground);
    theOrigin.lond(computeZoneMeridian(theZone));
    theOrigin.latd(0.0);
    theTranMerc_Origin_Long = theOrigin.lonr();
-   char hemisphere = theOrigin.latd() < 0.0?'S':'N';
-   setHemisphere(hemisphere);
+   //char hemisphere = theOrigin.latd() < 0.0?'S':'N';
+   //setHemisphere(hemisphere);
 }
 
 void ossimUtmProjection::setZone(ossim_int32 zone)
@@ -263,6 +275,12 @@ void ossimUtmProjection::setZone(ossim_int32 zone)
    theTranMerc_Origin_Long = theOrigin.lonr();
 }
 
+void ossimUtmProjection::setHemisphere(const ossimGpt& ground)
+{
+   char hemisphere = ground.latd()<0.0?'S':'N';
+   setHemisphere(hemisphere);
+}
+
 void ossimUtmProjection::setHemisphere(char hemisphere)
 {
    hemisphere = toupper(hemisphere);
@@ -344,7 +362,7 @@ bool ossimUtmProjection::loadState(const ossimKeywordlist& kwl,
 {
    const char* zone       = kwl.find(prefix, ossimKeywordNames::ZONE_KW);
    const char* hemisphere = kwl.find(prefix, ossimKeywordNames::HEMISPHERE_KW);
-   
+
    ossimMapProjection::loadState(kwl, prefix);
 
    // initialize zone to a dummy value.
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp b/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp
index 34a0a5cac8236f135e7abf2284030fbd8ff82b87..16c0df673b9b8fe0f770104e3d7db306f58d4203 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimDemHeader.cpp
@@ -8,7 +8,7 @@
 // Description: This class parses a DEM header.
 //
 //********************************************************************
-// $Id: ossimDemHeader.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimDemHeader.cpp 13694 2008-10-08 20:16:02Z dburken $
 
 #include <iostream>
 #include <iomanip>
@@ -590,18 +590,34 @@ bool ossimDemHeader::getImageGeometry(ossimKeywordlist& kwl,
 
    if (getGroundRefSysCode() == 0) // Geographic.
    {
+      // ESH 10/2008 -- The Dem ground units can be either radians or 
+      // arc seconds, so we have to convert parameters in these units 
+      // to degrees which is what OSSIM is assuming.
+      bool bIsArcSecs = (getGroundRefSysUnits() == 3) ? true : false;
+      bool bIsRadians = (getGroundRefSysUnits() == 0) ? true : false;
+
+      double convertFactor = 1.0;
+      if ( bIsArcSecs == true )
+      {
+         convertFactor = 1.0 / 3600;
+      }
+      else if ( bIsRadians == true )
+      {
+         convertFactor = 180.0 / M_PI;
+      }
+
       kwl.add(prefix,
               ossimKeywordNames::TIE_POINT_LON_KW,
-              tieX);
+              (tieX * convertFactor) );
       kwl.add(prefix,
               ossimKeywordNames::TIE_POINT_LAT_KW,
-              tieY);
+              (tieY * convertFactor) );
       kwl.add(prefix,
               ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON,
-              scaleX);
+              (scaleX * convertFactor) );
       kwl.add(prefix,
               ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT,
-              scaleY);
+              (scaleY * convertFactor) );
    }
    else if (getGroundRefSysCode() == 1) // UTM
    {
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimDoqq.cpp b/Utilities/otbossim/src/ossim/support_data/ossimDoqq.cpp
index 05b4265a2ae93703a641b4db2e02aed414739a82..c4e378a442a3b6c07e77c1ab3f4c514baca26305 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimDoqq.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimDoqq.cpp
@@ -11,7 +11,7 @@
 //              header.
 //
 //********************************************************************
-// $Id: ossimDoqq.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimDoqq.cpp 13175 2008-07-14 15:23:45Z gpotts $
 
 #include <fstream>
 #include <iostream>
@@ -99,7 +99,8 @@ void ossimDoqq::ldstr_v2(std::istream& in)
    }
 
    char line[100];
-   while(!strncmp(line, "END_USGS_HEADER", 15) == 0)
+   while((!strncmp(line, "END_USGS_HEADER", 15) == 0)&&
+			(in.good()))
    {
       // Read in one line of header at a time.
       in.getline(line, 100);
@@ -228,6 +229,19 @@ void ossimDoqq::ldstr_v2(std::istream& in)
       }
    }
 
+	if(!in.good())
+	{
+      theErrorStatus = OSSIM_ERROR;
+		
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+			<< MODULE << " ERROR:\n"
+			<< "\tHeader stream is bad."
+			<< std::endl;
+      }
+		return;
+	}
    // Check for valid lines and samples and header size.
    if(theLine <= 0 || theSample <= 0 || theHeaderSize <= 0)
    {
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimDtedAcc.cpp b/Utilities/otbossim/src/ossim/support_data/ossimDtedAcc.cpp
index 8e559c188da758361c9eeaded010dbc2e7aae60b..96f8ff2a1558a2cb273bbda1a4d098403a23e752 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimDtedAcc.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimDtedAcc.cpp
@@ -8,7 +8,7 @@
 //               (ACC) of a DTED Level 1 file.
 //
 //********************************************************************
-// $Id: ossimDtedAcc.cpp 13025 2008-06-13 17:06:30Z sbortman $
+// $Id: ossimDtedAcc.cpp 13571 2008-09-12 14:59:59Z gpotts $
 
 #include <cstdlib>
 #include <iostream>
@@ -22,28 +22,10 @@
 //**************************************************************************
 ossimDtedAcc::ossimDtedAcc(const ossimFilename& dted_file,
                            ossim_int32 offset)
-   :
-      theRecSen(),
-      theAbsoluteCE(),
-      theAbsoluteLE(),
-      theRelativeCE(),
-      theRelativeLE(),
-      theField6(),
-      theField7(),
-      theField8(),
-      theField9(),
-      theField10(),
-      theField11(),
-      theField12(),
-      theField13(),
-      theField14(),
-      theField15(),
-      theField16(),
-      theField17(),
-      theStartOffset(offset),
-      theStopOffset(0)
 {
-   // Check to see that dted file exists.
+	clearFields();
+	theStartOffset = offset;
+   // Check to see that dted file exists. 
    if(!dted_file.exists())
    {
       theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
@@ -71,32 +53,37 @@ ossimDtedAcc::ossimDtedAcc(const ossimFilename& dted_file,
    parse(in);
 }
 
+void ossimDtedAcc::clearFields()
+{
+   memset(theRecSen, '\0', FIELD1_SIZE+1);
+   memset(theAbsoluteCE, '\0',FIELD2_SIZE+1);
+   memset(theAbsoluteLE, '\0',FIELD3_SIZE+1);
+   memset(theRelativeCE, '\0',FIELD4_SIZE+1);
+   memset(theRelativeLE, '\0',FIELD5_SIZE+1);
+   memset(theField6, '\0',FIELD6_SIZE+1);
+   memset(theField7, '\0',FIELD7_SIZE+1);
+   memset(theField8, '\0',FIELD8_SIZE+1);
+   memset(theField9, '\0',FIELD9_SIZE+1);
+   memset(theField10, '\0',FIELD10_SIZE+1);
+   memset(theField11, '\0',FIELD11_SIZE+1);
+   memset(theField12, '\0',FIELD12_SIZE+1);
+   memset(theField13, '\0',FIELD13_SIZE+1);
+   memset(theField14, '\0',FIELD14_SIZE+1);
+   memset(theField15, '\0',FIELD15_SIZE+1);
+   memset(theField16, '\0',FIELD16_SIZE+1);
+   memset(theField17, '\0',FIELD17_SIZE+1);
+   
+   theStartOffset = 0;
+   theStopOffset = 0;
+}
 //**************************************************************************
 // CONSTRUCTOR
 //**************************************************************************
 ossimDtedAcc::ossimDtedAcc(std::istream& in,
                            ossim_int32 offset)
-   :
-      theRecSen(),
-      theAbsoluteCE(),
-      theAbsoluteLE(),
-      theRelativeCE(),
-      theRelativeLE(),
-      theField6(),
-      theField7(),
-      theField8(),
-      theField9(),
-      theField10(),
-      theField11(),
-      theField12(),
-      theField13(),
-      theField14(),
-      theField15(),
-      theField16(),
-      theField17(),
-      theStartOffset(offset),
-      theStopOffset(0)
 {
+	clearFields();
+	theStartOffset = offset;
    parse(in);
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimERS.cpp b/Utilities/otbossim/src/ossim/support_data/ossimERS.cpp
index a1176758dbdfd3ba9273803fc541568d9e6a0649..451e27961a054e1dca386eca78a2a46e1e82988d 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimERS.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimERS.cpp
@@ -10,7 +10,7 @@
 // file format header.
 //
 //********************************************************************
-// $Id: ossimERS.cpp 11347 2007-07-23 13:01:59Z gpotts $
+// $Id: ossimERS.cpp 13216 2008-07-23 18:56:53Z dburken $
 
 #include <fstream>
 #include <iostream>
@@ -62,7 +62,7 @@ ossimERS::ossimERS(const char* headerFile)
    }
 }
 
-void ossimERS::parseError(char *msg)
+void ossimERS::parseError(const char* /* msg*/ )
 {
    theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimFfL7.cpp b/Utilities/otbossim/src/ossim/support_data/ossimFfL7.cpp
index f38349db63d3385ad0da297b62aff586d7b2bb0d..7dbc220fe847212d12ab8a590a14591575c8e369 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimFfL7.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimFfL7.cpp
@@ -8,7 +8,7 @@
 // Description: Container class for LandSat7 Fast Format header files.
 //
 //********************************************************************
-// $Id: ossimFfL7.cpp 10835 2007-05-03 18:08:04Z dburken $
+// $Id: ossimFfL7.cpp 13663 2008-10-02 18:47:32Z gpotts $
 
   // #include <cstdlib>
 
@@ -355,12 +355,15 @@ void ossimFfL7::readRadiomRecord(FILE* fptr)
 
       if (blank_line == true) continue; // go to next line...
       
-      double d = 0.0;
-      std::istringstream is2(temp_chars);
-      is2 >> d;
-      theBias.push_back(d);
-      is2 >> d;
-      theGain.push_back(d);
+      std::vector<ossimString> splitString;
+      ossimString tempString(temp_chars);
+      tempString.split(splitString, " ");
+      
+      if(splitString.size() > 1)
+      {
+         theBias.push_back(splitString[0].toDouble());
+         theGain.push_back(splitString[1].toDouble());
+     }
    }
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimFfRevb.cpp b/Utilities/otbossim/src/ossim/support_data/ossimFfRevb.cpp
index fa1e716bb506d095ed8e09c3502e4a0fbc7c0f7f..e9c6d6c0bf00003fe78cadce44166614b9f88a36 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimFfRevb.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimFfRevb.cpp
@@ -7,7 +7,7 @@
 // Description: This class parses an EOSAT Fast Format rev b header.
 //
 //********************************************************************
-// $Id: ossimFfRevb.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimFfRevb.cpp 13217 2008-07-23 19:19:13Z dburken $
 
 #include <cstdlib>
 #include <cstring>
@@ -173,11 +173,7 @@ int ossimFfRevb::path() const
    {
       is.get(tmpBuff, 4);
       tmpBuff[3] = '\0';
-
-      if (tmpBuff)
-      {
-         path = atoi(tmpBuff);
-      }
+      path = atoi(tmpBuff);
    }
 
    return path;
@@ -204,11 +200,7 @@ int ossimFfRevb::row() const
       is.seekg(4, ios::beg);
       is.get(tmpBuff, 4);
       tmpBuff[3] = '\0';
-
-      if (tmpBuff)
-      {
-         row = atoi(tmpBuff);
-      }
+      row = atoi(tmpBuff);
    }
 
    return row;
@@ -235,11 +227,7 @@ int ossimFfRevb::fraction() const
       is.seekg(7, ios::beg);
       is.get(tmpBuff, 3);
       tmpBuff[2] = '\0';
-
-      if (tmpBuff)
-      {
-         fraction = atoi(tmpBuff);
-      }
+      fraction = atoi(tmpBuff);
    }
 
    return fraction;
@@ -850,44 +838,20 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(FIRST_LINE_IN_VOLUME_OFFSET, ios::beg);
    is.get(tmpBuff, FIRST_LINE_IN_VOLUME_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      the1stLineInVolume = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading 1st line in volume." << std::endl;
-   }
+
+   the1stLineInVolume = atoi(tmpBuff);
 
    is.seekg(LINES_PER_VOLUME_OFFSET, ios::beg);
    is.get(tmpBuff, LINES_PER_VOLUME_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theLinesPerVolume = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "\tDetected an error reading the lines per volume." << std::endl;
-   }
+
+   theLinesPerVolume = atoi(tmpBuff);
    
    is.seekg(ORIENTATION_ANGLE_OFFSET, ios::beg);
    is.get(tmpBuff, ORIENTATION_ANGLE_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theOrientationAngle = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading orientation angle." << std::endl;
-   }
+
+   theOrientationAngle = atof(tmpBuff);
 
    is.seekg(MAP_PROJ_NAME_OFFSET, ios::beg);
    is.get(theMapProjName, MAP_PROJ_NAME_SIZE + 1);
@@ -896,30 +860,14 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(USGS_PROJ_NUMBER_OFFSET, ios::beg);
    is.get(tmpBuff, USGS_PROJ_NUMBER_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theUsgsProjNumber = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading USGS Projection Number." << std::endl;
-   }
+
+   theUsgsProjNumber = atoi(tmpBuff);
 
    is.seekg(USGS_MAP_ZONE_OFFSET, ios::beg);
    is.get(tmpBuff, USGS_MAP_ZONE_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theUsgsMapZone = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading USGS Projection Number." << std::endl;
-   }
+
+   theUsgsMapZone = atoi(tmpBuff);
 
    //***
    // Get the fifteen projection parameters.
@@ -938,72 +886,32 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(MAJOR_AXIS_OFFSET, ios::beg);
    is.get(tmpBuff,  MAJOR_AXIS_SIZE+ 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theSemiMajorAxis = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading semi major axis." << std::endl;
-   }
+
+   theSemiMajorAxis = atof(tmpBuff);
    
    is.seekg(MINOR_AXIS_OFFSET, ios::beg);
    is.get(tmpBuff,  MINOR_AXIS_SIZE+ 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theSemiMinorAxis = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading semi minor axis." << std::endl;
-   }
+
+   theSemiMinorAxis = atof(tmpBuff);
 
    is.seekg(PIXEL_GSD_OFFSET, ios::beg);
    is.get(tmpBuff, PIXEL_GSD_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theGsd = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading pixel size." << std::endl;
-   }
+
+   theGsd = atof(tmpBuff);
    
    is.seekg(PIXELS_PER_LINE_OFFSET, ios::beg);
    is.get(tmpBuff, PIXELS_PER_LINE_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      thePixelsPerLine = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading pixels per line." << std::endl;
-   }
+
+   thePixelsPerLine = atoi(tmpBuff);
 
    is.seekg(LINES_PER_IMAGE_OFFSET, ios::beg);
    is.get(tmpBuff, LINES_PER_IMAGE_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theLinesPerImage = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream:"
-                                          << "Detected an error reading lines per image." << std::endl;
-   }
+
+   theLinesPerImage = atoi(tmpBuff);
 
    //***
    // Start of upper left data:  longitude, latitude, easting, and northing. 
@@ -1019,30 +927,15 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(UL_EASTING_OFFSET, ios::beg);
    is.get(tmpBuff, EASTING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theUlEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream:"
-                                          << "Detected an error reading UL easting." << std::endl;
-   }
+
+   theUlEasting = atof(tmpBuff);
 
    is.seekg(UL_NORTHING_OFFSET, ios::beg);
    is.get(tmpBuff, NORTHING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theUlNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream:: "
-                                          << "Detected an error reading UL northing." << std::endl;
-   }
+
+   theUlNorthing = atof(tmpBuff);
+
    //***
    // End of upper left data.
    //***
@@ -1061,30 +954,15 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(UR_EASTING_OFFSET, ios::beg);
    is.get(tmpBuff, EASTING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theUrEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading UR easting." << std::endl;
-   }
+
+   theUrEasting = atof(tmpBuff);
 
    is.seekg(UR_NORTHING_OFFSET, ios::beg);
    is.get(tmpBuff, NORTHING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theUrNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading UR northing." << std::endl;
-   }
+
+   theUrNorthing = atof(tmpBuff);
+   
    //***
    // End of upper right data.
    //***
@@ -1103,30 +981,15 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(LR_EASTING_OFFSET, ios::beg);
    is.get(tmpBuff, EASTING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theLrEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading LR easting." << std::endl;
-   }
+
+   theLrEasting = atof(tmpBuff);
 
    is.seekg(LR_NORTHING_OFFSET, ios::beg);
    is.get(tmpBuff, NORTHING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theLrNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading LR northing." << std::endl;
-   }
+
+   theLrNorthing = atof(tmpBuff);
+
    //***
    // End of lower right data.
    //***
@@ -1145,30 +1008,15 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(LL_EASTING_OFFSET, ios::beg);
    is.get(tmpBuff, EASTING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theLlEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading LL easting." << std::endl;
-   }
+
+   theLlEasting = atof(tmpBuff);
 
    is.seekg(LL_NORTHING_OFFSET, ios::beg);
    is.get(tmpBuff, NORTHING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theLlNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading LL northing." << std::endl;
-   }
+
+   theLlNorthing = atof(tmpBuff);
+
    //***
    // End of lower left data.
    //***
@@ -1180,58 +1028,26 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(BLOCKING_FACTOR_OFFSET, ios::beg);
    is.get(tmpBuff, BLOCKING_FACTOR_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theBlockingFactor = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading the blocking factor." << std::endl;
-   }
+
+   theBlockingFactor = atoi(tmpBuff);
 
    is.seekg(RECORD_LENGTH_OFFSET, ios::beg);
    is.get(tmpBuff, RECORD_LENGTH_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theRecordSize = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading record size." << std::endl;
-   }
+
+   theRecordSize = atoi(tmpBuff);
 
    is.seekg(SUN_ELEVATION_OFFSET, ios::beg);
    is.get(tmpBuff, SUN_ELEVATION_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theSunElevation = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading sun elevation angle." << std::endl;
-   }
+
+   theSunElevation = atoi(tmpBuff);
 
    is.seekg(SUN_AZIMUTH_OFFSET, ios::beg);
    is.get(tmpBuff, SUN_AZIMUTH_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theSunAzimuth = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL  ossimFfRevb::loadFromStream:"
-                                          << "\tDetected an error reading sun azimuth." << std::endl;
-   }
+
+   theSunAzimuth = atoi(tmpBuff);
 
    //***
    // Start of scene center data:  longitude, latitude, easting, northing,
@@ -1248,58 +1064,27 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(CENTER_EASTING_OFFSET, ios::beg);
    is.get(tmpBuff, EASTING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theCenterEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading center easting." << std::endl;
-   }
+
+   theCenterEasting = atof(tmpBuff);
 
    is.seekg(CENTER_NORTHING_OFFSET, ios::beg);
    is.get(tmpBuff, NORTHING_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theCenterNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading center northing." << std::endl;
-   }
+
+   theCenterNorthing = atof(tmpBuff);
 
    is.seekg(CENTER_SAMPLE_OFFSET, ios::beg);
    is.get(tmpBuff, CENTER_SAMPLE_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theCenterSample = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading center sample." << std::endl;
-   }
+
+   theCenterSample = atoi(tmpBuff);
 
    is.seekg(CENTER_LINE_OFFSET, ios::beg);
    is.get(tmpBuff, CENTER_LINE_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theCenterLine = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading center line." << std::endl;
-   }
+
+   theCenterLine = atoi(tmpBuff);
+
    //***
    // End of scene center data.
    //***
@@ -1307,16 +1092,8 @@ void ossimFfRevb::loadFromStream(istream& is)
    is.seekg(OFFSET_OFFSET, ios::beg);
    is.get(tmpBuff, OFFSET_SIZE + 1);
    if (checkStream(is)) return;
-   if (tmpBuff)
-   {
-      theOffset = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL  ossimFfRevb::loadFromStream: "
-                                          << "Detected an error reading horizontal offset." << std::endl;
-   }
+
+   theOffset = atoi(tmpBuff);
 
    is.seekg(FORMAT_VERSION_OFFSET, ios::beg);
    is.get(theFormatVersion, FORMAT_VERSION_SIZE + 1);
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimFfRevc.cpp b/Utilities/otbossim/src/ossim/support_data/ossimFfRevc.cpp
index f6304b8816b87f8c169365fa42b675f34f9d8e7c..b896a1824759ff423eb1922482c30d1faa108adc 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimFfRevc.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimFfRevc.cpp
@@ -7,7 +7,7 @@
 // Description: This class parses an EOSAT Fast Format rev c header.
 //
 //********************************************************************
-// $Id: ossimFfRevc.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimFfRevc.cpp 13217 2008-07-23 19:19:13Z dburken $
 
 #include <fstream>
 #include <sstream>
@@ -154,11 +154,7 @@ int ossimFfRevc::path(int sceneNbr) const
    if (is)
    {
       is.get(tmpBuff, 4);
-
-      if (tmpBuff)
-      {
-         path = atoi(tmpBuff);
-      }
+      path = atoi(tmpBuff);
    }
 
    return path;
@@ -184,11 +180,7 @@ int ossimFfRevc::row(int sceneNbr) const
    {
       is.seekg(4, ios::beg);
       is.get(tmpBuff, 4);
-
-      if (tmpBuff)
-      {
-         row = atoi(tmpBuff);
-      }
+      row = atoi(tmpBuff);
    }
 
    return row;
@@ -214,11 +206,7 @@ int ossimFfRevc::fraction(int sceneNbr) const
    {
       is.seekg(7, ios::beg);
       is.get(tmpBuff, 3);
-
-      if (tmpBuff)
-      {
-         fraction = atoi(tmpBuff);
-      }
+      fraction = atoi(tmpBuff);
    }
 
    return fraction;
@@ -244,11 +232,7 @@ ossimString ossimFfRevc::subScene(int sceneNbr) const
    {
       is.seekg(9, ios::beg);
       is.get(tmpBuff, 3);
-
-      if (tmpBuff)
-      {
-         subScene = tmpBuff;
-      }
+      subScene = tmpBuff;
    }
 
    return subScene;
@@ -1117,16 +1101,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
       if (checkStream(is)) return;
 
-      if (tmpBuff)
-      {
-         theAdminRecord.theOffNadirAngle[i] = atof(tmpBuff);
-      }
-      else
-      {
-         theErrorStatus = OSSIM_ERROR;
-         ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                             << "Detected an error reading the1stOffNadirAngle." << std::endl;
-      }
+      theAdminRecord.theOffNadirAngle[i] = atof(tmpBuff);
+
    } // End of scene loop.
    
    is.seekg(PRODUCT_TYPE_OFFSET, ios::beg);
@@ -1159,16 +1135,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theTapeVolumeNumber = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theTapeVolumeNumber." << std::endl;
-   }
+   theAdminRecord.theTapeVolumeNumber = atoi(tmpBuff);
 
    is.seekg(VOLUMES_PER_TAPE_OFFSET, ios::beg);
 
@@ -1176,16 +1143,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theNumberVolumesPerTape = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theNumberVolumesPerTape." << std::endl;
-   }
+   theAdminRecord.theNumberVolumesPerTape = atoi(tmpBuff);
     
    is.seekg(PIXELS_PER_LINE_OFFSET, ios::beg);
 
@@ -1193,16 +1151,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.thePixelsPerLine = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading thePixelsPerLine." << std::endl;
-   }
+   theAdminRecord.thePixelsPerLine = atoi(tmpBuff);
    
    is.seekg(LINES_PER_IMAGE_OFFSET, ios::beg);
 
@@ -1210,16 +1159,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theLinesPerImage = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theLinesPerImage." << std::endl;
-   }
+   theAdminRecord.theLinesPerImage = atoi(tmpBuff);
 
    is.seekg(FIRST_LINE_IN_VOLUME_OFFSET, ios::beg);
 
@@ -1227,16 +1167,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.the1stLineInVolume = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading the1stLineInVolume." << std::endl;
-   }
+   theAdminRecord.the1stLineInVolume = atoi(tmpBuff);
 
    is.seekg(BLOCKING_FACTOR_OFFSET, ios::beg);
 
@@ -1244,16 +1175,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theTapeBlockingFactor = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theTapeBlockingFactor." << std::endl;
-   }
+   theAdminRecord.theTapeBlockingFactor = atoi(tmpBuff);
    
    is.seekg(RECORD_LENGTH_OFFSET, ios::beg);
 
@@ -1261,16 +1183,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theRecordSize = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theRecordSize." << std::endl;
-   }
+   theAdminRecord.theRecordSize = atoi(tmpBuff);
    
    is.seekg(PIXEL_GSD_OFFSET, ios::beg);
 
@@ -1278,16 +1191,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theGsd = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theGsd." << std::endl;
-   }
+   theAdminRecord.theGsd = atof(tmpBuff);
    
    is.seekg(BITS_PER_PIXEL_OFFSET, ios::beg);
 
@@ -1295,16 +1199,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theOutputBitsPerPixel = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading theOutputBitsPerPixel." << std::endl;
-   }
+   theAdminRecord.theOutputBitsPerPixel = atoi(tmpBuff);
    
    is.seekg(ACQUIRED_BITS_PER_PIXEL_OFFSET, ios::beg);
 
@@ -1312,16 +1207,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theAdminRecord.theAcquiredBitsPerPixel = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream:"
-                                          << "Detected an error reading theAcquiredBitsPerPixel." << std::endl;
-   }
+   theAdminRecord.theAcquiredBitsPerPixel = atoi(tmpBuff);
    
    is.seekg(BANDS_PRESENT_OFFSET, ios::beg);
 
@@ -1350,17 +1236,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
       if (checkStream(is)) return;
    
-      if (tmpBuff)
-      {
-         theRadiomRecord.theBias[i] = atof(tmpBuff);
-      }
-      else
-      {
-         theErrorStatus = OSSIM_ERROR;
-         ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                             << "Detected an error reading bias for band:  "
-                                             << (i + 1) << endl;
-      }
+      theRadiomRecord.theBias[i] = atof(tmpBuff);
 
       is.seekg(GAIN_OFFSET[i], ios::beg);
 
@@ -1368,17 +1244,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
       if (checkStream(is)) return;
    
-      if (tmpBuff)
-      {
-         theRadiomRecord.theGain[i] = atof(tmpBuff);
-      }
-      else
-      {
-         theErrorStatus = OSSIM_ERROR;
-         ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream:"
-                                             << "Detected an error reading gain for band:  "
-                                             << i << std::endl;
-      }
+      theRadiomRecord.theGain[i] = atof(tmpBuff);
    }
    //***
    // End of radiometric record.
@@ -1418,16 +1284,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
       if (checkStream(is)) return;
 
-      if (tmpBuff)
-      {
-         theGeoRecord.theProjectionParams[i] = atof(tmpBuff);
-      }
-      else
-      {
-         theErrorStatus = OSSIM_ERROR;
-         ossimNotify(ossimNotifyLevel_FATAL) << "FATALossimFfRevc::loadFromStream: "
-                                             << "Detected an error reading ProjectionParams." << std::endl;
-      }
+      theGeoRecord.theProjectionParams[i] = atof(tmpBuff);
    }
 
    //***
@@ -1451,16 +1308,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theUlEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading UL easting." << std::endl;
-   }
+   theGeoRecord.theUlEasting = atof(tmpBuff);
 
    is.seekg(UL_NORTHING_OFFSET, ios::beg);
 
@@ -1468,16 +1316,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theUlNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading UL northing." << std::endl;
-   }
+   theGeoRecord.theUlNorthing = atof(tmpBuff);
+
    //***
    // End of upper left data.
    //***
@@ -1503,16 +1343,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theUrEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading UR easting." << std::endl;
-   }
+   theGeoRecord.theUrEasting = atof(tmpBuff);
 
    is.seekg(UR_NORTHING_OFFSET, ios::beg);
 
@@ -1520,16 +1351,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theUrNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream:"
-                                          << "Detected an error reading UR northing." << std::endl;
-   }
+   theGeoRecord.theUrNorthing = atof(tmpBuff);
+
    //***
    // End of upper right data.
    //***
@@ -1555,16 +1378,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theLrEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading LR easting." << std::endl;
-   }
+   theGeoRecord.theLrEasting = atof(tmpBuff);
 
    is.seekg(LR_NORTHING_OFFSET, ios::beg);
 
@@ -1572,16 +1386,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theLrNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading LR northing." << std::endl;
-   }
+   theGeoRecord.theLrNorthing = atof(tmpBuff);
+
    //***
    // End of lower right data.
    //***
@@ -1607,16 +1413,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theLlEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading LL easting." << std::endl;
-   }
+   theGeoRecord.theLlEasting = atof(tmpBuff);
 
    is.seekg(LL_NORTHING_OFFSET, ios::beg);
 
@@ -1624,16 +1421,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theLlNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading LL northing." << std::endl;
-   }
+   theGeoRecord.theLlNorthing = atof(tmpBuff);
+
    //***
    // End of lower left data.
    //***
@@ -1660,16 +1449,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theCenterEasting = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading center easting." << std::endl;
-   }
+   theGeoRecord.theCenterEasting = atof(tmpBuff);
 
    is.seekg(CENTER_NORTHING_OFFSET, ios::beg);
 
@@ -1677,16 +1457,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theCenterNorthing = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading center northing." << std::endl;
-   }
+   theGeoRecord.theCenterNorthing = atof(tmpBuff);
 
    is.seekg(CENTER_SAMPLE_OFFSET, ios::beg);
 
@@ -1694,16 +1465,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theCenterSample = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading center sample." << std::endl;
-   }
+   theGeoRecord.theCenterSample = atoi(tmpBuff);
 
    is.seekg(CENTER_LINE_OFFSET, ios::beg);
 
@@ -1711,16 +1473,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theCenterLine = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading center line." << std::endl;
-   }
+   theGeoRecord.theCenterLine = atoi(tmpBuff);
+
    //***
    // End of scene center data.
    //***
@@ -1731,16 +1485,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theHorizontalOffset = atoi(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading horizontal offset." << std::endl;
-   }
+   theGeoRecord.theHorizontalOffset = atoi(tmpBuff);
    
    is.seekg(ORIENTATION_ANGLE_OFFSET, ios::beg);
 
@@ -1748,16 +1493,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theOrientationAngle = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading orientation angle." << std::endl;
-   }
+   theGeoRecord.theOrientationAngle = atof(tmpBuff);
    
    is.seekg(SUN_ELEVATION_OFFSET, ios::beg);
 
@@ -1765,16 +1501,7 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theSunElevationAngle = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading sun elevation angle." << std::endl;
-   }
+   theGeoRecord.theSunElevationAngle = atof(tmpBuff);
    
    is.seekg(SUN_AZIMUTH_OFFSET, ios::beg);
 
@@ -1782,16 +1509,8 @@ void ossimFfRevc::loadFromStream(istream& is)
 
    if (checkStream(is)) return;
 
-   if (tmpBuff)
-   {
-      theGeoRecord.theSunAzimuth = atof(tmpBuff);
-   }
-   else
-   {
-      theErrorStatus = OSSIM_ERROR;
-      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevc::loadFromStream: "
-                                          << "Detected an error reading sun azimuth." << std::endl;
-   }
+   theGeoRecord.theSunAzimuth = atof(tmpBuff);
+
    //***
    // End of geometric record.
    //***
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp b/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp
index f966ddc78f44275b2a5623a017e4df5b44b55434..83601ec1f71c845100800734133bc6dda39bb3e5 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimGeoTiff.cpp
@@ -10,7 +10,7 @@
 // information.
 //
 //***************************************************************************
-// $Id: ossimGeoTiff.cpp 13038 2008-06-18 15:19:41Z gpotts $
+// $Id: ossimGeoTiff.cpp 13937 2008-12-29 22:16:08Z gpotts $
 
 #include <ossim/support_data/ossimGeoTiff.h>
 #include <ossim/base/ossimTrace.h>
@@ -33,6 +33,7 @@
 #include <ossim/base/ossimTieGptSet.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimUnitTypeLut.h>
+#include <tiff.h>
 #include <tiffio.h>
 #include <xtiffio.h>
 #include <geotiff.h>
@@ -40,6 +41,7 @@
 #include <geovalues.h>
 #include <string.h>
 #include <iomanip>
+#include <iterator>
 #include <sstream>
 #include <cstdlib>
 
@@ -47,14 +49,13 @@ static const ossimGeoTiffCoordTransformsLut COORD_TRANS_LUT;
 static const ossimGeoTiffDatumLut DATUM_LUT;
 
 #ifdef OSSIM_ID_ENABLED
-static const char OSSIM_ID[] = "$Id: ossimGeoTiff.cpp 13038 2008-06-18 15:19:41Z gpotts $";
+static const char OSSIM_ID[] = "$Id: ossimGeoTiff.cpp 13937 2008-12-29 22:16:08Z gpotts $";
 #endif
 
 //---
 // Static trace for debugging
 //---
 static ossimTrace traceDebug("ossimGeoTiff:debug");
-
 ossimGeoTiff::ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx)
    :
       theTiffPtr(0),
@@ -115,7 +116,10 @@ ossimGeoTiff::ossimGeoTiff(const ossimFilename& file, ossim_uint32 entryIdx)
             << "Unable to reade tags."
             << std::endl;
       }
-      // "FATAL: Unable to reade tags" warning removed by otb developpers
+      ossimNotify(ossimNotifyLevel_FATAL)
+         << "FATAL ossimGeoTiff::ossimGeoTiff: "
+         << "Unable to reade tags."
+         << std::endl;
    }
    if (traceDebug())
    {
@@ -147,13 +151,19 @@ int ossimGeoTiff::getPcsUnitType(ossim_int32 pcsCode)
    if (info)
    {
       ossimUnitType type = info->getUnitType();
-      if (type == OSSIM_METERS)
-      {
-         pcsUnits = ossimGeoTiff::LINEAR_METER;
-      }
-      else
+      switch (type)
       {
-         pcsUnits = ossimGeoTiff::LINEAR_FOOT_US_SURVEY;
+         case OSSIM_METERS:
+            pcsUnits = ossimGeoTiff::LINEAR_METER;
+            break;
+         case OSSIM_FEET:
+            pcsUnits = ossimGeoTiff::LINEAR_FOOT;
+            break;
+         case OSSIM_US_SURVEY_FEET:
+            pcsUnits = ossimGeoTiff::LINEAR_FOOT_US_SURVEY;
+            break;
+         default:
+            break; // Unhandled units!
       }
    }
 
@@ -396,7 +406,7 @@ bool ossimGeoTiff::writeTags(TIFF* tifPtr,
       gcs = USER_DEFINED;
 
       std::ostringstream os;
-      os << "IMAGINE GeoTIFF Support\nCopyright 1991 -  2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 13038 $ $Date: 2008-06-18 17:19:41 +0200 (Wed, 18 Jun 2008) $\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: 13937 $ $Date: 2008-12-30 06:16:08 +0800 (Tue, 30 Dec 2008) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)";
 
       GTIFKeySet(gtif,
                  GeogCitationGeoKey,
@@ -881,7 +891,7 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
    }
    
    char* buf = 0;
-   double tempDouble;
+   double tempDouble=0.0;
    theCenterLon = ossim::nan();
    theCenterLat = ossim::nan();
    theOriginLon = ossim::nan();
@@ -910,10 +920,18 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
    {
       theOriginLon = tempDouble;
    }
+   else if(GTIFKeyGet(gtif, ProjOriginLongGeoKey, &tempDouble, 0, 1))
+   {
+      theOriginLon = tempDouble;
+   }
    if(GTIFKeyGet(gtif, ProjNatOriginLatGeoKey, &tempDouble, 0, 1))
    {
       theOriginLat = tempDouble;
    }
+   else if(GTIFKeyGet(gtif, ProjOriginLatGeoKey, &tempDouble, 0, 1))
+   {
+      theOriginLat = tempDouble;
+   }
    if(GTIFKeyGet(gtif, ProjFalseEastingGeoKey, &theFalseEasting, 0, 1))
    {
    }
@@ -944,6 +962,19 @@ 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))
+      {
+         theOriginLat = tiepoints[4] + tiepoints[1] * fabs(pixScale[1]);
+      }
    }
    theModelTransformation.clear();
    ossim_uint16 transSize;
@@ -954,7 +985,6 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
       theModelTransformation.insert(theModelTransformation.begin(),
                                     trans, trans+transSize);
    }
-   
 //    if(!theTiePoint.size()&&(theModelTransform.size()==16))
 //    {
 //       // for now we will stuff the tie point with the model transform tie points.
@@ -974,7 +1004,12 @@ 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 = "";
 	
@@ -990,6 +1025,31 @@ 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
+      {
+         std::cout << "Need to add double param support for projection = " << projName << std::endl;
+      }
+   }
+   
    GTIFFree(gtif);
 
    
@@ -1235,11 +1295,11 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
             
             if(ossim::isnan(theOriginLat))
             {
-               theOriginLat = 0.0;
+               //theOriginLat = 0.0;
             }
             if(ossim::isnan(theOriginLon))
             {
-               theOriginLon = 0.0;
+               //theOriginLon = 0.0;
             }
             double olat = theOriginLat;
             double olon = theOriginLon;
@@ -1312,7 +1372,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist& kwl,
                  ossimKeywordNames::CENTRAL_MERIDIAN_KW,
                  theOriginLon);
       }
-      if(ossim::isnan(theCenterLon) == false)
+      else if(ossim::isnan(theCenterLon) == false)
       {
          kwl.add(copyPrefix.c_str(),
                  ossimKeywordNames::CENTRAL_MERIDIAN_KW,
@@ -1480,6 +1540,11 @@ 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;
 }
@@ -1546,6 +1611,7 @@ void ossimGeoTiff::setOssimProjectionName()
          << theProjectionName
          << std::endl;
    }
+   
 }
 
 ossimString ossimGeoTiff::getOssimDatumName() const
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6ad0a866ff5102e1b5ae98685a12b1d43fc6c07
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSizRecord.cpp
@@ -0,0 +1,154 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// Description: Container class for J2K Image and tile size (SIZ) record.
+//
+// See document BPJ2K01.00 Table 7-6 Image and tile size (15444-1 Annex A5.1)
+// 
+//----------------------------------------------------------------------------
+// $Id: ossimJ2kSizRecord.h,v 1.5 2005/10/13 21:24:47 dburken Exp $
+
+#include <iostream>
+#include <iomanip>
+
+#include <ossim/support_data/ossimJ2kSizRecord.h>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimEndian.h>
+
+
+ossimJ2kSizRecord::ossimJ2kSizRecord()
+   :
+   theSizMarker(0xff51),
+   theLsiz(0),
+   theRsiz(0),
+   theXsiz(0),
+   theYziz(0),
+   theXOsiz(0),
+   theYOsiz(0),
+   theXTsiz(0),
+   theYTsiz(0),
+   theXTOsiz(0),
+   theYTOsiz(0),
+   theCsiz(0),
+   theSsiz(0),
+   theXRsiz(0),
+   theYRsiz(0)
+{
+}
+
+ossimJ2kSizRecord::~ossimJ2kSizRecord()
+{
+}
+
+void ossimJ2kSizRecord::parseStream(std::istream& in)
+{
+   // 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*)&theXOsiz,     4);
+   in.read((char*)&theYOsiz,     4);
+   in.read((char*)&theXTsiz,     4);
+   in.read((char*)&theYTsiz,     4);
+   in.read((char*)&theXTOsiz,    4);
+   in.read((char*)&theYTOsiz,    4);
+   in.read((char*)&theCsiz,      2);
+   in.read((char*)&theSsiz,      1);
+   in.read((char*)&theXRsiz,     1);
+   in.read((char*)&theYRsiz,     1);
+
+   if (ossim::byteOrder() == OSSIM_LITTLE_ENDIAN)
+   {
+      // Stored big endian, must swap.
+      ossimEndian s;
+      s.swap(theLsiz);
+      s.swap(theRsiz);
+      s.swap(theXsiz);
+      s.swap(theYziz);
+      s.swap(theXOsiz);
+      s.swap(theYOsiz);
+      s.swap(theXTsiz);
+      s.swap(theYTsiz);
+      s.swap(theXTOsiz);
+      s.swap(theYTOsiz);
+      s.swap(theCsiz);
+   }
+}
+
+ossimScalarType ossimJ2kSizRecord::getScalarType() const
+{
+   ossimScalarType result = OSSIM_SCALAR_UNKNOWN;
+
+   // Bits per pixel first seven bits plus one.
+   ossim_uint8 bpp = ( theSsiz & 0x3f ) + 1;
+
+   // Signed bit is msb.
+   bool isSigned = ( theSsiz & 0x80 ) ? true : false;
+
+   // std::cout << "bpp: " << int(bpp) << " signed: " << isSigned << std::endl;
+      
+   if(bpp <= 8)
+   {
+      if(isSigned == 0)
+      {
+         result = OSSIM_UINT8;
+      }
+      else if(isSigned == 1)
+      {
+         result = OSSIM_SINT8;
+      }
+   }
+   else if(bpp <= 16)
+   {
+      if(isSigned == 0)
+      {
+         result = OSSIM_UINT16;
+      }
+      else if(isSigned == 1)
+      {
+         result = OSSIM_SINT16;
+      }
+   }
+   return result;
+}
+
+std::ostream& ossimJ2kSizRecord::print(std::ostream& out) 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::endl;
+
+   // Reset flags.
+   out.setf(f);
+
+   return out;
+}
+
+std::ostream& operator<<(std::ostream& out, const ossimJ2kSizRecord& obj)
+{
+   return obj.print(out);
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66d32d4828e8acc46bd5d4854fd02d160e81a12c
--- /dev/null
+++ b/Utilities/otbossim/src/ossim/support_data/ossimJ2kSotRecord.cpp
@@ -0,0 +1,74 @@
+//----------------------------------------------------------------------------
+//
+// License:  LGPL
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Author:  David Burken
+//
+// // Description: Container class for J2K "Start Of Tile" (SOT) record.
+//
+// See document BPJ2K01.00 Table 7-3 Image and tile size (15444-1 Annex A.4.2)
+// 
+//----------------------------------------------------------------------------
+// $Id: ossimJ2kSotRecord.h,v 1.5 2005/10/13 21:24:47 dburken Exp $
+
+#include <iostream>
+#include <iomanip>
+
+#include <ossim/support_data/ossimJ2kSotRecord.h>
+#include <ossim/base/ossimCommon.h>
+#include <ossim/base/ossimEndian.h>
+
+ossimJ2kSotRecord::ossimJ2kSotRecord()
+   :
+   theSotMarker(0xff90),
+   theLsot(0),
+   theIsot(0),
+   thePsot(0),
+   theTpsot(0),
+   theTnsot(0)
+{
+}
+
+ossimJ2kSotRecord::~ossimJ2kSotRecord()
+{
+}
+
+void ossimJ2kSotRecord::parseStream(std::istream& in)
+{
+   // Note: marker not read...
+   
+   in.read((char*)&theLsot,  2);
+   in.read((char*)&theIsot,  2);
+   in.read((char*)&thePsot,  4);
+   in.read((char*)&theTpsot, 1);
+   in.read((char*)&theTnsot, 1);
+
+   if (ossim::byteOrder() == OSSIM_LITTLE_ENDIAN)
+   {
+      // Stored big endian, must swap.
+      ossimEndian s;
+      s.swap(theLsot);
+      s.swap(theIsot);
+      s.swap(thePsot);
+   }
+}
+
+std::ostream& ossimJ2kSotRecord::print(std::ostream& out) 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)
+       << std::endl;
+
+   return out;
+}
+
+std::ostream& operator<<(std::ostream& out, const ossimJ2kSotRecord& obj)
+{
+   return obj.print(out);
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp
index 8f522c43a5ac35272f66ea383a8972b41fb21ff3..c2a5b316f9cde46d40a6eb3e5030f09aaa1f18fa 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfCommon.cpp
@@ -7,14 +7,17 @@
 // Description: Utility class for global nitf methods.
 //
 //----------------------------------------------------------------------------
-// $Id: ossimNitfCommon.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfCommon.cpp 13619 2008-09-29 19:10:31Z gpotts $
 
 #include <cstring> /* for memcpy */
 #include <sstream>
 #include <iomanip>
-
+#include <sstream>
+#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>
 
@@ -223,3 +226,235 @@ void ossimNitfCommon::setField(void* fieldDestination,
    
    memcpy(fieldDestination, out.str().c_str(), width);
 }
+
+ossimString ossimNitfCommon::encodeUtm(
+                                       ossim_uint32 zone,
+                                       const ossimDpt& ul,
+                                       const ossimDpt& ur,
+                                       const ossimDpt& lr,
+                                       const ossimDpt& ll)
+{
+   std::ostringstream out;
+   
+   if(zone > 60)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUTM zone greate than 60!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   ossim_float64 east  = ul.x;
+   ossim_float64 north = ul.y;
+   
+   if((ossim_uint32)(east+.5) > 999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper left easting too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   if((ossim_uint32)(north+.5) > 9999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper left northing too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   out << std::setw(2)
+   << std::setfill('0')
+   << zone
+   << std::setw(6)
+   << std::setfill('0')
+   <<(ossim_uint32)(east+.5)
+   << std::setw(7)
+   << std::setfill('0')
+   <<(ossim_uint32)(north+.5);
+   
+   
+   east  = ur.x;
+   north = ur.y;
+   
+   if((ossim_uint32)(east+.5) > 999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper right easting too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   if((ossim_uint32)(north+.5) > 9999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper right northing too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   out << std::setw(2)
+   << std::setfill('0')
+   << zone
+   << std::setw(6)
+   << std::setfill('0')
+   <<(ossim_uint32)(east+.5)
+   << std::setw(7)
+   << std::setfill('0')
+   <<(ossim_uint32)(north+.5);
+   east  = lr.x;
+   north = lr.y;
+   
+   if((ossim_uint32)(east+.5) > 999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower right easting too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   if((ossim_uint32)(north+.5) > 9999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower right northing too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }   
+   
+   out << std::setw(2)
+   << std::setfill('0')
+   << zone
+   << std::setw(6)
+   << std::setfill('0')
+   <<(ossim_uint32)(east+.5)
+   << std::setw(7)
+   << std::setfill('0')
+   <<(ossim_uint32)(north+.5);
+   
+   east  = ll.x;
+   north = ll.y;
+   
+   if((ossim_uint32)(east+.5) > 999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower left easting too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   if((ossim_uint32)(north+.5) > 9999999)
+   {
+      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower left northing too large for NITF field!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+   
+   out << std::setw(2)
+   << std::setfill('0')
+   << zone
+   << std::setw(6)
+   << std::setfill('0')
+   <<(ossim_uint32)(east+.5)
+   << std::setw(7)
+   << std::setfill('0')
+   <<(ossim_uint32)(north+.5);
+   
+   return out.str().c_str();
+}
+
+ossimString ossimNitfCommon::encodeGeographicDms(const ossimDpt& ul,
+                                                 const ossimDpt& ur,
+                                                 const ossimDpt& lr,
+                                                 const ossimDpt& ll)
+{
+   std::ostringstream out;
+   
+   out << ossimDms(ul.y, true).toString("ddmmssC").c_str();
+   out << ossimDms(ul.x, false).toString("dddmmssC").c_str();
+   out << ossimDms(ur.y, true).toString("ddmmssC").c_str();
+   out << ossimDms(ur.x, false).toString("dddmmssC").c_str();
+   out << ossimDms(lr.y, true).toString("ddmmssC").c_str();
+   out << ossimDms(lr.x, false).toString("dddmmssC").c_str();
+   out << ossimDms(ll.y, true).toString("ddmmssC").c_str();
+   out << ossimDms(ll.x, false).toString("dddmmssC").c_str();
+
+   return ossimString(out.str());
+}
+
+ossimString ossimNitfCommon::encodeGeographicDecimalDegrees(const ossimDpt& ul,
+                                                            const ossimDpt& ur,
+                                                            const ossimDpt& lr,
+                                                            const ossimDpt& ll)
+{
+   std::ostringstream out;
+   
+   out << (ul.lat >= 0.0?"+":"")
+   << std::setw(6)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << ul.lat
+   << (ul.lon >= 0.0?"+":"")
+   << std::setw(7)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << ul.lon;
+   out << (ur.lat >= 0.0?"+":"")
+   << std::setw(6)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << ur.lat
+   << (ur.lon >= 0.0?"+":"")
+   << std::setw(7)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << ur.lon;
+   out << (lr.lat >= 0.0?"+":"")
+   << std::setw(6)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << lr.lat
+   << (lr.lon >= 0.0?"+":"")
+   << std::setw(7)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << lr.lon;
+   out << (ll.lat >= 0.0?"+":"")
+   << std::setw(6)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << ll.lat
+   << (ll.lon >= 0.0?"+":"")
+   << std::setw(7)
+   << std::setfill('0')
+   << std::setprecision(3)
+   << std::setiosflags(std::ios::fixed)
+   << ll.lon;
+   
+   return ossimString(out.str());
+}
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.cpp
index 28a196db5885901b284e49923aae67199ece5394..44ce56ffa05d8e989bbf3da9132b928aa3079cc2 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfDataExtensionSegmentV2_0.cpp
@@ -8,7 +8,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfDataExtensionSegmentV2_0.cpp 9094 2006-06-13 19:12:40Z dburken $
+// $Id: ossimNitfDataExtensionSegmentV2_0.cpp 13218 2008-07-23 19:22:37Z dburken $
 
 #include <iostream>
 #include <ossim/support_data/ossimNitfDataExtensionSegmentV2_0.h>
@@ -115,7 +115,7 @@ void ossimNitfDataExtensionSegmentV2_0::clearFields()
    theIdentSecurityChunk.theDataExtDowngradingEvent[40] = '\0'; // 40 byte alpha num
    theOverflowedHeaderType[6] = '\0';
    theDataItemOverflowed[3]   = '\0';
-   theLengthOfUserDefinedSubheaderFields[5] = '\0';
+   theLengthOfUserDefinedSubheaderFields[4] = '\0';
    
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeader.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeader.cpp
index da316e71f03435ce4b3725bbad08dc0ce79be308..d386a1838b5d73ea71953209c51a4dea45266e6c 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeader.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeader.cpp
@@ -8,12 +8,10 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeader.cpp 10173 2007-01-03 18:21:26Z gpotts $
+// $Id: ossimNitfFileHeader.cpp 13874 2008-11-17 19:44:49Z dburken $
 #include <ossim/support_data/ossimNitfFileHeader.h>
 #include <ossim/base/ossimContainerProperty.h>
-#ifndef NULL
-#include <stddef.h>
-#endif
+#include <iostream>
 
 static const char* TAGS_KW = "tags";
 
@@ -83,6 +81,24 @@ bool ossimNitfFileHeader::hasDataExtSegments()const
    return (getNumberOfDataExtSegments() > 0);
 }
 
+void ossimNitfFileHeader::removeTag(const ossimString& tagName)
+{
+   ossim_uint32 idx = 0;
+   for(idx = 0; idx < theTagList.size(); ++idx)
+   {
+      if(theTagList[idx].getTagName() == tagName)
+      {
+         theTagList.erase(theTagList.begin() + idx);
+         return;
+      }
+   }
+}
+void ossimNitfFileHeader::addTag(const ossimNitfTagInformation& tag)
+{
+   removeTag(tag.getTagName());
+   theTagList.push_back(tag);
+}
+
 bool ossimNitfFileHeader::getTagInformation(ossimNitfTagInformation& tag,
                                             int idx) const
 {
@@ -121,7 +137,7 @@ void ossimNitfFileHeader::setProperty(ossimRefPtr<ossimProperty> property)
 
 ossimRefPtr<ossimProperty> ossimNitfFileHeader::getProperty(const ossimString& name)const
 {
-   ossimProperty* result = 0;
+   ossimRefPtr<ossimProperty> result = 0;
 
    if(name == TAGS_KW)
    {
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp
index a785cb411ba0163ef10766752296274995ef94e0..96e85074f116d71eb2a57da42959c01363ea6e46 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_0.cpp
@@ -7,14 +7,14 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_0.cpp 12988 2008-06-04 16:49:43Z gpotts $
+// $Id: ossimNitfFileHeaderV2_0.cpp 13953 2009-01-09 15:20:58Z gpotts $
 
 
 #include <sstream>
 #include <cstring> // for memset
 #include <iostream>
 #include <iomanip>
-
+#include <stdexcept>
 #include <ossim/support_data/ossimNitfCommon.h>
 #include <ossim/support_data/ossimNitfFileHeaderV2_0.h>
 #include <ossim/support_data/ossimNitfImageHeaderV2_0.h>
@@ -59,6 +59,32 @@ ossim_int32  ossimNitfImageInfoRecordV2_0::getTotalLength()const
    return (getHeaderLength() + getImageLength());
 }
 
+void ossimNitfImageInfoRecordV2_0::setSubheaderLength(ossim_uint32 length)
+{
+   ostringstream out;
+   
+   out << std::setw(6)
+   << std::setfill('0')
+   << std::setiosflags(ios::right)
+   << length;
+   
+   memcpy(theImageSubheaderLength, out.str().c_str(), 6);
+   theImageSubheaderLength[6] = '\0';
+}
+
+void ossimNitfImageInfoRecordV2_0::setImageLength(ossim_uint32 length)
+{
+   ostringstream out;
+   
+   out << std::setw(10)
+   << std::setfill('0')
+   << std::setiosflags(ios::right)
+   << length;
+   
+   memcpy(theImageLength, out.str().c_str(), 10);
+   theImageLength[10] = '\0';
+}
+
 std::ostream& operator <<(std::ostream& out,
                      const ossimNitfSymbolInfoRecordV2_0 &data)
 {
@@ -229,9 +255,9 @@ void ossimNitfFileHeaderV2_0::parseStream(std::istream &in)
    in.read(theOriginatorsPhone, 18);
    theHeaderSize+=18;
    
-   in.read(theNitfFileLength, 12);
+   in.read(theFileLength, 12);
    theHeaderSize+=12;
-   in.read(theNitfHeaderLength, 6);
+   in.read(theHeaderLength, 6);
    theHeaderSize+=6;
    
    // image description group
@@ -344,7 +370,165 @@ void ossimNitfFileHeaderV2_0::parseStream(std::istream &in)
 
 void ossimNitfFileHeaderV2_0::writeStream(std::ostream &out)
 {
+   // identification and origination group
+   out.write(theFileTypeVersion, 9);
+   out.write(theComplexityLevel, 2);
+   out.write(theSystemType, 4);
+   out.write(theOriginatingStationId, 10);
+   out.write(theDateTime, 14);
+   out.write(theFileTitle, 80);
    
+   // read security group
+   out.write(theSecurityClassification, 1);
+   out.write(theCodewords, 40);
+   out.write(theControlAndHandling, 40);
+   out.write(theReleasingInstructions, 40);
+   out.write(theClassificationAuthority, 20);
+   out.write(theSecurityControlNumber, 20);
+   out.write(theSecurityDowngrade, 6);
+   if(ossimString(theSecurityDowngrade) == "999998")
+   {
+      out.write(theDowngradingEvent, 40);
+   }      
+   out.write(theCopyNumber, 5);
+   out.write(theNumberOfCopies, 5);
+   out.write(theEncryption, 1);
+   out.write(theOriginatorsName, 27);
+   out.write(theOriginatorsPhone, 18);
+   
+   out.write(theFileLength, 12);
+   out.write(theHeaderLength, 6);   
+   ossim_uint32 idx = 0;
+   {
+      ostringstream outString;
+      
+      
+      outString << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << theNitfImageInfoRecords.size();
+      
+      out.write(outString.str().c_str(), 3);
+      
+      for(idx = 0; idx < theNitfImageInfoRecords.size(); ++idx)
+      {
+         out.write(theNitfImageInfoRecords[idx].theImageSubheaderLength, 6);
+         out.write(theNitfImageInfoRecords[idx].theImageLength, 10);
+      }
+   }
+   {
+      ostringstream outString;
+      
+      outString << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << theNitfSymbolInfoRecords.size();
+      
+      out.write(outString.str().c_str(), 3);
+      
+      for(idx = 0; idx < theNitfSymbolInfoRecords.size(); ++idx)
+      {
+         out.write(theNitfSymbolInfoRecords[idx].theSymbolSubheaderLength, 4);
+         out.write(theNitfSymbolInfoRecords[idx].theSymbolLength, 6);
+      }
+   }
+   {
+      ostringstream outString;
+      
+      outString << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << theNitfLabelInfoRecords.size();
+      
+      out.write(outString.str().c_str(), 3);
+      
+      for(idx = 0; idx < theNitfLabelInfoRecords.size(); ++idx)
+      {
+         out.write(theNitfLabelInfoRecords[idx].theLabelSubheaderLength, 4);
+         out.write(theNitfLabelInfoRecords[idx].theLabelLength, 3);
+      }
+   }
+   {
+      ostringstream outString;
+      
+      outString << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << theNitfTextInfoRecords.size();
+      
+      out.write(outString.str().c_str(), 3);
+      
+      for(idx = 0; idx < theNitfTextInfoRecords.size(); ++idx)
+      {
+         out.write(theNitfTextInfoRecords[idx].theTextSubheaderLength, 4);
+         out.write(theNitfTextInfoRecords[idx].theTextLength, 5);
+      }
+   }
+   {
+      ostringstream outString;
+      
+      outString << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << theNitfDataExtSegInfoRecords.size();
+      
+      out.write(outString.str().c_str(), 3);
+      
+      for(idx = 0; idx < theNitfDataExtSegInfoRecords.size(); ++idx)
+      {
+         out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegSubheaderLength, 4);
+         out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegLength, 9);
+      }
+   }
+   {
+      ostringstream outString;
+      
+      outString << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << theNitfResExtSegInfoRecords.size();
+      
+      out.write(outString.str().c_str(), 3);
+      
+      for(idx = 0; idx < theNitfResExtSegInfoRecords.size(); ++idx)
+      {
+         out.write(theNitfResExtSegInfoRecords[idx].theResExtSegSubheaderLength, 4);
+         out.write(theNitfResExtSegInfoRecords[idx].theResExtSegLength, 7);
+      }
+   }
+   out.write(theUserDefinedHeaderDataLength, 5);
+   if(ossimString(theUserDefinedHeaderDataLength).toInt32() > 0)
+   {
+      out.write(theUserDefinedHeaderOverflow, 3);
+   }
+   ossim_uint32 totalLength = getTotalTagLength();
+   if(totalLength <= 99999)
+   {
+      std::ostringstream tempOut;
+      
+      tempOut << std::setw(5)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << totalLength;
+      
+      memcpy(theExtendedHeaderDataLength, tempOut.str().c_str(), 5);
+      
+      out.write(theExtendedHeaderDataLength, 5);
+      
+      if(totalLength > 0)
+      {
+         ossim_uint32 i = 0;
+         
+         for(i = 0; i < theTagList.size(); ++i)
+         {
+            theTagList[i].writeStream(out);
+         }
+      }
+   }
+   else
+   {
+      ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_0::writeStream: Only support writing of total tag length < 99999" << std::endl;
+   }
 }
 
 std::ostream& ossimNitfFileHeaderV2_0::print(std::ostream& out)const
@@ -370,8 +554,8 @@ std::ostream& ossimNitfFileHeaderV2_0::print(std::ostream& out)const
        << std::setw(24) << "\nENCRYP:"   << theEncryption
        << std::setw(24) << "\nONAME:"    << theOriginatorsName
        << std::setw(24) << "\nOPHONE:"   << theOriginatorsPhone
-       << std::setw(24) << "\nFL:"       << theNitfFileLength
-       << std::setw(24) << "\nHL:"       << theNitfHeaderLength
+       << std::setw(24) << "\nFL:"       << theFileLength
+       << std::setw(24) << "\nHL:"       << theHeaderLength
        << std::setw(24) << "\nNUMI:"     << theNumberOfImageInfoRecords;
 
    ossim_uint32 index;
@@ -512,6 +696,18 @@ ossimDrect ossimNitfFileHeaderV2_0::getImageRect()const
    return theImageRect;
 }
 
+void ossimNitfFileHeaderV2_0::addImageInfoRecord(const ossimNitfImageInfoRecordV2_0& recordInfo)
+{
+   theNitfImageInfoRecords.push_back(recordInfo);
+   
+   setNumberOfImageInfoRecords(theNitfImageInfoRecords.size());
+}
+
+void ossimNitfFileHeaderV2_0::replaceImageInfoRecord(ossim_uint32 i, const ossimNitfImageInfoRecordV2_0& recordInfo)
+{
+   theNitfImageInfoRecords[i]=recordInfo;
+}
+
 ossimNitfImageHeader*
 ossimNitfFileHeaderV2_0::getNewImageHeader(ossim_int32 imageNumber,
                                            std::istream& in)const
@@ -528,9 +724,11 @@ ossimNitfFileHeaderV2_0::getNewImageHeader(ossim_int32 imageNumber,
    }
    else
    {
+#if 0
       ossimNotify(ossimNotifyLevel_FATAL) << "ossimNitfFileHeaderV2_0::getNewImageHeader ERROR:"
                                           << "\nNo images in file or image number (" << imageNumber
                                           << ") is out of range!\n";
+#endif
    }
    
    return result;
@@ -791,7 +989,7 @@ ossim_int32 ossimNitfFileHeaderV2_0::getHeaderSize()const
 
 ossim_int32 ossimNitfFileHeaderV2_0::getFileSize()const
 {
-   ossimString temp = theNitfFileLength;
+   ossimString temp = theFileLength;
    if(temp == "999999999999")
    {
       return -1;
@@ -832,7 +1030,7 @@ void ossimNitfFileHeaderV2_0::clearFields()
    theNitfResExtSegInfoRecords.clear();
    
    theFilename = "";
-   memset(theFileTypeVersion, ' ', 9);
+   memcpy(theFileTypeVersion, "NITF02.00", 9);
    memset(theComplexityLevel, ' ', 2);
    memset(theSystemType, ' ', 4);
    memset(theOriginatingStationId, ' ', 10);
@@ -851,17 +1049,17 @@ void ossimNitfFileHeaderV2_0::clearFields()
    memset(theEncryption, ' ', 1);
    memset(theOriginatorsName, ' ', 27);
    memset(theOriginatorsPhone, ' ', 18);
-   memset(theNitfFileLength, ' ', 12);
-   memset(theNitfHeaderLength, ' ', 6);
+   memset(theFileLength, ' ', 12);
+   memset(theHeaderLength, ' ', 6);
    memset(theNumberOfImageInfoRecords, ' ', 3);
    memset(theNumberOfSymbolInfoRecords, ' ', 3);
    memset(theNumberOfLabelInfoRecords, ' ', 3);
    memset(theNumberOfTextFileInfoRecords, ' ', 3);
    memset(theNumberOfDataExtSegInfoRecords, ' ', 3);
    memset(theNumberOfResExtSegInfoRecords, ' ', 3);
-   memset(theUserDefinedHeaderDataLength, ' ', 5);
+   memset(theUserDefinedHeaderDataLength, '0', 5);
    memset(theUserDefinedHeaderOverflow, ' ', 3);
-   memset(theExtendedHeaderDataLength, ' ', 5);
+   memset(theExtendedHeaderDataLength, '0', 5);
    memset(theExtendedHeaderOverflow, ' ', 3);
    
    theFileTypeVersion[9] = '\0';
@@ -883,8 +1081,8 @@ void ossimNitfFileHeaderV2_0::clearFields()
    theEncryption[1] = '\0';
    theOriginatorsName[27] = '\0';
    theOriginatorsPhone[18] = '\0';
-   theNitfFileLength[12]  = '\0';
-   theNitfHeaderLength[6] = '\0';
+   theFileLength[12]  = '\0';
+   theHeaderLength[6] = '\0';
    theNumberOfImageInfoRecords[3] = '\0';
    theNumberOfSymbolInfoRecords[3] = '\0';
    theNumberOfLabelInfoRecords[3] = '\0';
@@ -898,6 +1096,31 @@ void ossimNitfFileHeaderV2_0::clearFields()
    theHeaderSize = 0;
 }
 
+void ossimNitfFileHeaderV2_0::setNumberOfImageInfoRecords(ossim_uint64 num)
+{
+   if (num < 1000)
+   {
+      ostringstream out;
+      
+      out << std::setw(3)
+      << std::setfill('0')
+      << std::setiosflags(ios::right)
+      << num;
+      
+      memcpy(theNumberOfImageInfoRecords, out.str().c_str(), 3);
+   }
+   else
+   {
+      std::string s = "ossimNitfFileHeaderV2_0::setNumberOfImageInfoRecords:";
+      s += " ERROR\nExceeded max image info number of 999!";
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
+      }
+      throw std::out_of_range(s);
+   }
+}
+
 void ossimNitfFileHeaderV2_0::readImageInfoRecords(std::istream &in)
 {
    ossim_int32 numberOfImages = ossimString(theNumberOfImageInfoRecords).toInt32();
@@ -1075,6 +1298,30 @@ void ossimNitfFileHeaderV2_0::setDowngradingEvent(const ossimString& downgradeEv
    ossimNitfCommon::setField(theDowngradingEvent, downgradeEvent, 40);
 }
 
+void ossimNitfFileHeaderV2_0::setFileLength(ossim_uint64 fileLength)
+{
+   ostringstream out;
+   
+   out << std::setw(12)
+   << std::setfill('0')
+   << std::setiosflags(ios::right)
+   << fileLength;
+   
+   memcpy(theFileLength, out.str().c_str(), 12);
+}
+
+void ossimNitfFileHeaderV2_0::setHeaderLength(ossim_uint64 headerLength)
+{
+   ostringstream out;
+   
+   out << std::setw(6)
+   << std::setfill('0')
+   << std::setiosflags(ios::right)
+   << headerLength;
+   
+   memcpy(theHeaderLength, out.str().c_str(), 6);
+}
+
 ossimString ossimNitfFileHeaderV2_0::getComplianceLevel()const
 {
    return theComplexityLevel;
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp
index 0fed3b92fd444eee516442d49a8958b649f0fc7c..a2bef0980b9ff2910c621b8115458b89e1fbe9fb 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_1.cpp
@@ -7,7 +7,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfFileHeaderV2_1.cpp 12403 2008-02-04 17:59:13Z gpotts $
+// $Id: ossimNitfFileHeaderV2_1.cpp 13953 2009-01-09 15:20:58Z gpotts $
 
 #include <iostream>
 #include <iomanip>
@@ -24,9 +24,6 @@
 #include <ossim/base/ossimNotifyContext.h>
 #include <ossim/support_data/ossimNitfImageHeaderV2_1.h>
 
-#ifndef NULL
-#  include <cstddef>
-#endif
 
 RTTI_DEF1(ossimNitfFileHeaderV2_1,
           "ossimNitfFileHeaderV2_1",
@@ -614,13 +611,13 @@ ossimNitfImageHeader* ossimNitfFileHeaderV2_1::allocateImageHeader()const
 
 ossimNitfTextHeader *ossimNitfFileHeaderV2_1::allocateTextHeader()const
 {
-   return NULL;
+   return 0;
 }
 
 ossimNitfDataExtensionSegment*
 ossimNitfFileHeaderV2_1::allocateDataExtSegment()const
 {
-   return NULL;
+   return 0;
 }
 
 bool ossimNitfFileHeaderV2_1::isEncrypted()const
@@ -878,7 +875,7 @@ ossim_int32 ossimNitfFileHeaderV2_1::getNumberOfDataExtSegments()const
 
 const char* ossimNitfFileHeaderV2_1::getDateTime()const
 {
-   return NULL;
+   return 0;
 }
 
 ossimDrect ossimNitfFileHeaderV2_1::getImageRect()const
@@ -900,12 +897,12 @@ void ossimNitfFileHeaderV2_1::replaceImageInfoRecord(int i, const ossimNitfImage
 
 ossimNitfSymbolHeader *ossimNitfFileHeaderV2_1::allocateSymbolHeader()const
 {
-   return NULL;
+   return 0;
 }
 
 ossimNitfLabelHeader *ossimNitfFileHeaderV2_1::allocateLabelHeader()const
 {
-   return NULL;
+   return 0;
 }
 
 void ossimNitfFileHeaderV2_1::initializeAllOffsets()
@@ -929,7 +926,7 @@ ossimNitfImageHeader*
 ossimNitfFileHeaderV2_1::getNewImageHeader(ossim_int32 imageNumber,
                                            std::istream& in)const
 {
-   ossimNitfImageHeader *result = NULL;
+   ossimNitfImageHeader *result = 0;
    
    if((getNumberOfImages() > 0) &&
       (imageNumber < (ossim_int32)theImageOffsetList.size()) &&
@@ -941,9 +938,11 @@ ossimNitfFileHeaderV2_1::getNewImageHeader(ossim_int32 imageNumber,
    }
    else
    {
+#if 0
       ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimNitfFileHeaderV2_1::getNewImageHeader: "
                                           << "\nNo images in file or image number (" << imageNumber
                                           << ") is out of range!\n";
+#endif
    }
    
    return result;
@@ -955,7 +954,7 @@ ossimNitfFileHeaderV2_1::getNewSymbolHeader(ossim_int32 symbolNumber,
 {
    // Currently not implemented...
    
-   ossimNitfSymbolHeader *result = NULL;
+   ossimNitfSymbolHeader *result = 0;
    
    return result;
 }
@@ -965,7 +964,7 @@ ossimNitfFileHeaderV2_1::getNewLabelHeader(ossim_int32 labelNumber,
                                            std::istream& in)const
 {
    // Currently not implemented...
-   ossimNitfLabelHeader *result = NULL;
+   ossimNitfLabelHeader *result = 0;
    
    return result;
 }
@@ -975,7 +974,7 @@ ossimNitfFileHeaderV2_1::getNewTextHeader(ossim_int32 textNumber,
                                           std::istream& in)const
 {
    // Currently not implemented...
-   ossimNitfTextHeader *result = NULL;
+   ossimNitfTextHeader *result = 0;
    
    return result;
 }
@@ -985,7 +984,7 @@ ossimNitfFileHeaderV2_1::getNewDataExtensionSegment(ossim_int32 dataExtNumber,
                                                     std::istream& in)const
 {
    // Currently not implemented...
-   ossimNitfDataExtensionSegment *result = NULL;
+   ossimNitfDataExtensionSegment *result = 0;
    
    return result;
 }
@@ -1195,7 +1194,7 @@ void ossimNitfFileHeaderV2_1::setDeclassificationType(const ossimString& declass
 
 void ossimNitfFileHeaderV2_1::setDeclassificationDate(const ossimLocalTm& d)
 {
-   memcpy(theDeclassificationDate, formatDate(d).c_str(), 8);
+   memcpy(theDeclassificationDate, formatDate(getVersion(), d).c_str(), 8);
 }
 
 void ossimNitfFileHeaderV2_1::setDeclassificationDate(const ossimString& d)
@@ -1232,7 +1231,7 @@ void ossimNitfFileHeaderV2_1::setDowngrade(const ossimString& downgrade)
 
 void ossimNitfFileHeaderV2_1::setDowngradingDate(const ossimLocalTm& d)
 {
-   memcpy(theDowngradingDate, formatDate(d).c_str(), 8);
+   memcpy(theDowngradingDate, formatDate(getVersion(), d).c_str(), 8);
 }
 
 void ossimNitfFileHeaderV2_1::setDowngradingDate(const ossimString& d)
@@ -1293,7 +1292,7 @@ void ossimNitfFileHeaderV2_1::setClassificationReason(const ossimString& reason)
 
 void ossimNitfFileHeaderV2_1::setSecuritySourceDate(const ossimLocalTm& d)
 {
-   memcpy(theSecuritySourceDate, formatDate(d).c_str(), 8);
+   memcpy(theSecuritySourceDate, formatDate(getVersion(), d).c_str(), 8);
 }
 
 void ossimNitfFileHeaderV2_1::setSecuritySourceDate(const ossimString& d)
@@ -1397,12 +1396,15 @@ void ossimNitfFileHeaderV2_1::setProperty(ossimRefPtr<ossimProperty> property)
    else if(name == FBKGC_KW)
    {
       ossimString value = property->valueToString();
-      istringstream in(value);
-      ossim_uint8 r, g, b;
-
-      in >> r >> g >> b;
-      
-      setFileBackgroundColor(r, g, b);
+      std::vector<ossimString> splitString;
+      value = value.trim();
+      value.split(splitString, " ");
+      if(splitString.size() == 3)
+      {
+         setFileBackgroundColor((ossim_uint8)splitString[0].toUInt32(), 
+                                (ossim_uint8)splitString[1].toUInt32(), 
+                                (ossim_uint8)splitString[2].toUInt32());
+      }
    }
    else
    {
@@ -1412,9 +1414,9 @@ void ossimNitfFileHeaderV2_1::setProperty(ossimRefPtr<ossimProperty> property)
 
 ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_1::getProperty(const ossimString& name)const
 {
-   ossimProperty* property = NULL;
-   ossimStringProperty* stringProperty = NULL;
-   ossimColorProperty* colorProperty = NULL;
+   ossimProperty* property = 0;
+   ossimStringProperty* stringProperty = 0;
+   ossimColorProperty* colorProperty = 0;
 
    if(name == CLEVEL_KW)
    {
@@ -1518,7 +1520,7 @@ ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_1::getProperty(const ossimStrin
    }
    else
    {
-      return ossimNitfFileHeader::getProperty(name);
+      return ossimNitfFileHeaderV2_X::getProperty(name);
    }
    return property;
 }
@@ -1526,7 +1528,7 @@ ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_1::getProperty(const ossimStrin
 
 void ossimNitfFileHeaderV2_1::getPropertyNames(std::vector<ossimString>& propertyNames)const
 {
-   ossimNitfFileHeader::getPropertyNames(propertyNames);
+   ossimNitfFileHeaderV2_X::getPropertyNames(propertyNames);
 
    propertyNames.push_back(FSCLASY_KW);
    propertyNames.push_back(FSDCTP_KW);
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_X.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_X.cpp
index efabb743c6cb0b459e4034c8ff4a550bc0c7417f..2040ba0d918c1c4b19cca5dc3fb60742f4fa5f00 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_X.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfFileHeaderV2_X.cpp
@@ -12,6 +12,7 @@
 #include <ossim/support_data/ossimNitfCommon.h>
 
 RTTI_DEF1(ossimNitfFileHeaderV2_X, "ossimNitfFileHeaderV2_X", ossimNitfFileHeader);
+static ossimString monthConversionTable[] = {"   ", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
 
 const ossimString ossimNitfFileHeaderV2_X::FILE_TYPE_KW  = "file_type";
 const ossimString ossimNitfFileHeaderV2_X::VERSION_KW  = "version";
@@ -51,35 +52,60 @@ void ossimNitfFileHeaderV2_X::setOriginatingStationId(const ossimString& origina
    ossimNitfCommon::setField(theOriginatingStationId, originationId, 10);
 }
 
-ossimString ossimNitfFileHeaderV2_X::formatDate(const ossimLocalTm& d)
+ossimString ossimNitfFileHeaderV2_X::formatDate(const ossimString& version,
+                                                const ossimLocalTm& d)
 {
    std::ostringstream out;
 
-   out << std::setw(4)
-       << std::setfill('0')
-       << d.getYear()
-       << std::setw(2)
-       << std::setfill('0')
-       << d.getMonth()
-       << std::setw(2)
-       << std::setfill('0')
-       << d.getDay()
-       << std::setw(2)
-       << std::setfill('0')
-       << d.getHour()
-       << std::setw(2)
-       << std::setfill('0')
-       << d.getMin()
-       << std::setw(2)
-       << std::setfill('0')
-       << d.getSec();
-   
+   if(version.contains("2.1"))
+   {
+      out << std::setw(4)
+      << std::setfill('0')
+      << d.getYear()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getMonth()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getDay()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getHour()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getMin()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getSec();
+   }
+   else
+   {
+      out  << std::setw(2)
+      << std::setfill('0')
+      << d.getDay()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getHour()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getMin()
+      << std::setw(2)
+      << std::setfill('0')
+      << d.getSec()
+      << "Z"
+      <<monthConversionTable[d.getMonth()]
+      << std::setw(2)
+      << std::setfill('0')
+      <<d.getShortYear();
+      
+   }
+      
    return out.str();
 }
 
 void ossimNitfFileHeaderV2_X::setDate(const ossimLocalTm& d)
 {
-   memcpy(theDateTime, formatDate(d).c_str(), 14);
+   memcpy(theDateTime, formatDate(getVersion(), d).c_str(), 14);
 }
 
 void ossimNitfFileHeaderV2_X::setDate(const ossimString& d)
@@ -247,16 +273,16 @@ void ossimNitfFileHeaderV2_X::setProperty(ossimRefPtr<ossimProperty> property)
 
 ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_X::getProperty(const ossimString& name)const
 {
-   ossimProperty* property = NULL;
-
-	if(name == VERSION_KW)
-	{
+   ossimRefPtr<ossimProperty> property = 0;
+   
+   if(name == VERSION_KW)
+   {
       property = new ossimStringProperty(name, ossimString(getVersion()));
-	}
-	else if(name == FILE_TYPE_KW)
-	{
-		property = new ossimStringProperty(name, "NITF");
-	}
+   }
+   else if(name == FILE_TYPE_KW)
+   {
+      property = new ossimStringProperty(name, "NITF");
+   }
    else if(name == CLEVEL_KW)
    {
       ossimNumericProperty* numericProperty =
@@ -278,7 +304,7 @@ ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_X::getProperty(const ossimStrin
    }
    else if(name == FDT_KW)
    {
-      property = new ossimDateProperty(name, getDate());
+      property = new ossimStringProperty(name, getDate());
    }
    else if(name == FTITLE_KW)
    {
@@ -324,7 +350,7 @@ ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_X::getProperty(const ossimStrin
    {
       property = new ossimStringProperty(name,
                                          getSecurityControlNumber().trim());
-
+      
    }
    else if(name == FSCOP_KW)
    {
@@ -343,10 +369,10 @@ ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_X::getProperty(const ossimStrin
                                          false);
    }
    else
-	{
-		property = ossimNitfFileHeader::getProperty(name).get();
-	}
-
+   {
+      property = ossimNitfFileHeader::getProperty(name).get();
+   }
+   
    return property;
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp
index 177978fca73f8c871b9bdfea6deb067efff78bf7..ffaf722913a2bfe33fdcc21b1f04ff2c1bbc4681 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeader.cpp
@@ -7,7 +7,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeader.cpp 12403 2008-02-04 17:59:13Z gpotts $
+// $Id: ossimNitfImageHeader.cpp 13629 2008-09-30 17:39:20Z gpotts $
 
 #include <cmath> /* for fmod */
 #include <iomanip>
@@ -101,7 +101,7 @@ ossim_uint32 ossimNitfImageHeader::getNumberOfTags()const
    return static_cast<ossim_uint32>(theTagList.size());
 }
 
-void ossimNitfImageHeader::addTag(ossimNitfTagInformation tag)
+void ossimNitfImageHeader::addTag(const ossimNitfTagInformation& tag)
 {
    removeTag(tag.getTagName());
    theTagList.push_back(tag);
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp
index 92514871fe9e4069941ed5fc094b78dba5752f0d..4455870e86262cbeb25fbe108bc9448f71fe8de7 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_0.cpp
@@ -8,7 +8,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_0.cpp 13101 2008-07-01 18:44:31Z dburken $
+// $Id: ossimNitfImageHeaderV2_0.cpp 13931 2008-12-15 23:44:40Z dburken $
 
 
 #include <iomanip>
@@ -21,8 +21,13 @@
 #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>
-// static const ossimTrace traceDebug("ossimNitfFileHeaderV2_0:debug");
+#include <stdexcept>
+#include <sstream>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/support_data/ossimNitfCommon.h>
+static const ossimTrace traceDebug(ossimString("ossimNitfImageHeaderV2_0:debug"));
 
 RTTI_DEF1(ossimNitfImageHeaderV2_0,
           "ossimNitfImageHeaderV2_0",
@@ -226,6 +231,7 @@ void ossimNitfImageHeaderV2_0::parseStream(std::istream &in)
             }
             theBlockMaskRecords[idx] = blockRead[idx];
          }
+         delete [] blockRead;
       }
       if((thePadPixelMaskRecordLength > 0)||
          (( (getCompressionCode().upcase() == "M3"))&&
@@ -284,6 +290,106 @@ void ossimNitfImageHeaderV2_0::parseStream(std::istream &in)
 
 void ossimNitfImageHeaderV2_0::writeStream(std::ostream &out)
 {
+   out.write(theType, 2);
+   out.write(theImageId, 10);
+   out.write(theDateTime, 14);
+   out.write(theTargetId, 17);
+   out.write(theTitle, 80);
+   out.write(theSecurityClassification, 1);
+   out.write(theCodewords, 40);
+   out.write(theControlAndHandling, 40);
+   out.write(theReleasingInstructions, 40);
+   out.write(theClassificationAuthority, 20);
+   out.write(theSecurityControlNumber, 20);
+   out.write(theSecurityDowngrade, 6);
+   if(ossimString(theSecurityDowngrade) == "999998")
+   {
+      out.write(theDowngradingEvent, 40);
+   }
+   out.write(theEncryption, 1);
+   out.write(theImageSource, 42);
+   out.write(theSignificantRows, 8);
+   out.write(theSignificantCols, 8);
+   out.write(thePixelValueType, 3);
+   out.write(theRepresentation, 8);
+   out.write(theCategory, 8);
+   out.write(theActualBitsPerPixelPerBand, 2);
+   out.write(theJustification, 1);
+   out.write(theCoordinateSystem, 1);
+   if(theCoordinateSystem[0] != 'N')
+   {
+      out.write(theGeographicLocation, 60);
+   }
+   out.write(theNumberOfComments, 1);
+   out.write(theCompression, 2);
+   if(ossimString(theCompression) != "NC")
+   {
+      out.write(theCompressionRateCode, 4);
+   }
+   out.write(theNumberOfBands, 1);
+   ossim_uint32 bandIdx = 0;
+   for(bandIdx=0;bandIdx<theImageBands.size();++bandIdx)
+   {
+      theImageBands[bandIdx]->writeStream(out);
+   }
+   out.write(theImageSyncCode, 1);
+   out.write(theImageMode, 1);
+   out.write(theNumberOfBlocksPerRow, 4);
+   out.write(theNumberOfBlocksPerCol, 4);
+   out.write(theNumberOfPixelsPerBlockHoriz, 4);
+   out.write(theNumberOfPixelsPerBlockVert, 4);
+   out.write(theNumberOfBitsPerPixelPerBand, 2);
+   out.write(theDisplayLevel, 3);
+   out.write(theAttachmentLevel, 3);
+   out.write(theImageLocation, 10);
+   out.write(theImageMagnification, 4);
+   out.write(theUserDefinedImageDataLength, 5);
+   if(ossimString(theUserDefinedImageDataLength).toInt32() > 0)
+   {
+      out.write(theUserDefinedOverflow, 3);
+   }
+   ossim_uint32 totalLength = getTotalTagLength();
+   
+   if(totalLength == 0)
+   {
+      //memcpy(theExtendedSubheaderDataLen, "00000", 5);
+      out.write(theExtendedSubheaderDataLen, 5);
+   }
+   else
+   {
+      totalLength += 3; // per Table A-3 of MIL-STD-2500B
+      
+      if(totalLength <= 99999)
+      {
+         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)
+         {
+            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_0::writeStream: Only support writing of total tag length < 99999" << std::endl;
+      }
+   }
 }
 
 std::ostream& ossimNitfImageHeaderV2_0::print(std::ostream& out)const
@@ -653,7 +759,7 @@ void ossimNitfImageHeaderV2_0::clearFields()
 {
    theTagList.clear();
    
-   memset(theType, ' ', 2);
+   memcpy(theType, "IM", 2);
    memset(theImageId, ' ', 10);
    memset(theDateTime, ' ', 14);
    memset(theTargetId, ' ', 17);
@@ -666,7 +772,7 @@ void ossimNitfImageHeaderV2_0::clearFields()
    memset(theSecurityControlNumber, ' ', 20);
    memset(theSecurityDowngrade, ' ', 6);
    memset(theDowngradingEvent, ' ', 40);
-   memset(theEncryption, ' ', 1);
+   memset(theEncryption, '0', 1);
    memset(theImageSource, ' ', 42);
    memset(theSignificantRows, ' ', 8);
    memset(theSignificantCols, ' ', 8);
@@ -675,13 +781,13 @@ void ossimNitfImageHeaderV2_0::clearFields()
    memset(theCategory, ' ', 8);
    memset(theActualBitsPerPixelPerBand, ' ', 2);
    memset(theJustification, ' ', 1);
-   memset(theCoordinateSystem, ' ', 1);
+   memset(theCoordinateSystem, 'N', 1);
    memset(theGeographicLocation, ' ', 60);
-   memset(theNumberOfComments, ' ', 1);
-   memset(theCompression, ' ', 2);
+   memset(theNumberOfComments, '0', 1);
+   memcpy(theCompression, "NC", 2);
    memset(theCompressionRateCode, ' ', 4);
    memset(theNumberOfBands, ' ', 1);
-   memset(theImageSyncCode, ' ', 1);
+   memset(theImageSyncCode, '0', 1);
    memset(theImageMode, ' ', 1);
    memset(theNumberOfBlocksPerRow, ' ', 4);
    memset(theNumberOfBlocksPerCol, ' ', 4);
@@ -690,11 +796,11 @@ void ossimNitfImageHeaderV2_0::clearFields()
    memset(theNumberOfBitsPerPixelPerBand, ' ', 2);
    memset(theDisplayLevel, ' ', 3);
    memset(theAttachmentLevel, ' ', 3);
-   memset(theImageLocation, ' ', 10);
-   memset(theImageMagnification, ' ', 4);
-   memset(theUserDefinedImageDataLength, ' ', 5);
-   memset(theUserDefinedOverflow, ' ', 3);
-   memset(theExtendedSubheaderDataLen, ' ', 5);
+   memcpy(theImageLocation, "0000000000", 10);
+   memcpy(theImageMagnification, "1.00", 4);
+   memset(theUserDefinedImageDataLength, '0', 5);
+   memset(theUserDefinedOverflow, '0', 3);
+   memset(theExtendedSubheaderDataLen, '0', 5);
    memset(theExtendedSubheaderOverflow, ' ', 3);
    
    theBlockMaskRecords.clear();
@@ -766,6 +872,121 @@ const ossimRefPtr<ossimNitfImageBand> ossimNitfImageHeaderV2_0::getBandInformati
    
    return NULL;
 }
+
+void ossimNitfImageHeaderV2_0::setNumberOfBands(ossim_uint32 nbands)
+{
+   std::ostringstream out;
+   if(nbands > 9)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << "ossimNitfImageHeaderV2_0::setNumberOfBands: NBANDS is too large.  For 2.0 spec we can only have up to 9 bands\n";
+      }
+      std::string s = "ossimNitfImageHeaderV2_0::setNumberOfBands:";
+      s += " ERROR\nExceeded max number of bands of 9!";
+      throw std::out_of_range(s);
+   }
+   else
+   {
+      out << nbands;
+      theNumberOfBands[0] = out.str().c_str()[0];
+   }
+   
+   theImageBands.resize(getNumberOfBands());
+}
+
+void ossimNitfImageHeaderV2_0::setBandInfo(ossim_uint32 idx,
+                                           const ossimNitfImageBandV2_0& info)
+{
+   if(idx < theImageBands.size())
+   {
+      if(!theImageBands[idx].valid())
+      {
+         theImageBands[idx] = new ossimNitfImageBandV2_0;
+      }
+      (*theImageBands[idx]) = info;
+   }
+}
+void ossimNitfImageHeaderV2_0::setNumberOfRows(ossim_uint32 rows)
+{
+   std::ostringstream out;
+   if(rows > 99999999) rows = 99999999;
+   
+   out << rows;
+   ossimNitfCommon::setField(theSignificantRows, out.str(), 8, ios::right, '0');
+}
+
+void ossimNitfImageHeaderV2_0::setNumberOfCols(ossim_uint32 cols)
+{
+   std::ostringstream out;
+   if(cols > 99999999) cols = 99999999;
+   
+   out << 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 75212d314042c428f099f1dfde5cac54c74861ee..bc21af44dad021c1ac811ffc623ae9c5a8527580 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_1.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_1.cpp
@@ -7,7 +7,7 @@
 // Description: Nitf support class
 // 
 //********************************************************************
-// $Id: ossimNitfImageHeaderV2_1.cpp 13101 2008-07-01 18:44:31Z dburken $
+// $Id: ossimNitfImageHeaderV2_1.cpp 13931 2008-12-15 23:44:40Z dburken $
 #include <sstream>
 #include <iomanip>
 #include <cstring> // for memset
@@ -250,6 +250,7 @@ void ossimNitfImageHeaderV2_1::parseStream(std::istream &in)
             }
             theBlockMaskRecords[idx] = blockRead[idx];
          }
+         delete [] blockRead;
       }
       if((thePadPixelMaskRecordLength > 0)||
          (( (getCompressionCode().upcase() == "M3"))&&
@@ -345,8 +346,7 @@ void ossimNitfImageHeaderV2_1::writeStream(std::ostream &out)
       out.write(theGeographicLocation, 60);
    }
    // for now force the number of comments to be 0
-//   out.write(theNumberOfComments, 1);
-   out.write("0", 1);
+   out.write(theNumberOfComments, 1);
    
    out.write(theCompression, 2);
    ossimString compressionTest = theCompression;
@@ -732,7 +732,7 @@ void ossimNitfImageHeaderV2_1::clearFields()
    memcpy(theDisplayLevel, "001", 3);
    memset(theAttachmentLevel, '0', 3);
    memset(theImageLocation, '0', 10);
-   memcpy(theImageMagnification, "01.0", 4);
+   memcpy(theImageMagnification, "1.0 ", 4);
    
    memset(theUserDefinedImageDataLength,'0', 5);
    memset(theUserDefinedOverflow, '0', 3);
@@ -817,12 +817,25 @@ ossim_int32 ossimNitfImageHeaderV2_1::getNumberOfBlocksPerCol()const
 
 ossim_int32 ossimNitfImageHeaderV2_1::getNumberOfPixelsPerBlockHoriz()const
 {
-   return ossimString(theNumberOfPixelsPerBlockHoriz).toInt32();
+ //  return ossimString(theNumberOfPixelsPerBlockHoriz).toInt32();
+   ossim_int32 rval = ossimString(theNumberOfPixelsPerBlockHoriz).toInt32();
+   if ((rval == 0) && (getNumberOfBlocksPerCol() == 1))
+   {
+      rval = getNumberOfCols();
+   }
+   return rval;
+   
 }
 
 ossim_int32 ossimNitfImageHeaderV2_1::getNumberOfPixelsPerBlockVert()const
 {
-   return ossimString(theNumberOfPixelsPerBlockVert).toInt32();
+//   return ossimString(theNumberOfPixelsPerBlockVert).toInt32();
+   ossim_int32 rval = ossimString(theNumberOfPixelsPerBlockVert).toInt32();
+   if ((rval == 0) && (getNumberOfBlocksPerRow() == 1))
+   {
+      rval = getNumberOfRows();
+   }
+   return rval;
 }
 
 ossimDrect ossimNitfImageHeaderV2_1::getImageRect()const
@@ -939,18 +952,8 @@ void ossimNitfImageHeaderV2_1::setGeographicLocationDms(const ossimDpt& ul,
    }
       
    theCoordinateSystem[0] = 'G';
-   std::ostringstream out;
 
-   out << ossimDms(ul.y, true).toString("ddmmssC").c_str();
-   out << ossimDms(ul.x, false).toString("dddmmssC").c_str();
-   out << ossimDms(ur.y, true).toString("ddmmssC").c_str();
-   out << ossimDms(ur.x, false).toString("dddmmssC").c_str();
-   out << ossimDms(lr.y, true).toString("ddmmssC").c_str();
-   out << ossimDms(lr.x, false).toString("dddmmssC").c_str();
-   out << ossimDms(ll.y, true).toString("ddmmssC").c_str();
-   out << ossimDms(ll.x, false).toString("dddmmssC").c_str();
-
-   memcpy(theGeographicLocation, out.str().c_str(), 60);
+   memcpy(theGeographicLocation, ossimNitfCommon::encodeGeographicDms(ul, ur, lr, ll).c_str(), 60);
 }
 
 void ossimNitfImageHeaderV2_1::setGeographicLocationDecimalDegrees(
@@ -960,58 +963,8 @@ void ossimNitfImageHeaderV2_1::setGeographicLocationDecimalDegrees(
    const ossimDpt& ll)
 {
    theCoordinateSystem[0] = 'D';
-   ostringstream out;
-
-   out << (ul.lat >= 0.0?"+":"")
-       << std::setw(6)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << ul.lat
-       << (ul.lon >= 0.0?"+":"")
-       << std::setw(7)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << ul.lon;
-   out << (ur.lat >= 0.0?"+":"")
-       << std::setw(6)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << ur.lat
-       << (ur.lon >= 0.0?"+":"")
-       << std::setw(7)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << ur.lon;
-   out << (lr.lat >= 0.0?"+":"")
-       << std::setw(6)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << lr.lat
-       << (lr.lon >= 0.0?"+":"")
-       << std::setw(7)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << lr.lon;
-   out << (ll.lat >= 0.0?"+":"")
-       << std::setw(6)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << ll.lat
-       << (ll.lon >= 0.0?"+":"")
-       << std::setw(7)
-       << std::setfill('0')
-       << std::setprecision(3)
-       << std::setiosflags(std::ios::fixed)
-       << ll.lon;
-
-   memcpy(theGeographicLocation, out.str().c_str(), 60);
+
+   memcpy(theGeographicLocation, ossimNitfCommon::encodeGeographicDecimalDegrees(ul, ur, lr, ll).c_str(), 60);
 }
 
 void ossimNitfImageHeaderV2_1::setUtmNorth(ossim_uint32 zone,
@@ -1023,7 +976,7 @@ void ossimNitfImageHeaderV2_1::setUtmNorth(ossim_uint32 zone,
    theCoordinateSystem[0] = 'N';
    
    memcpy(theGeographicLocation,
-          encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
+          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
 }
 
 void ossimNitfImageHeaderV2_1::setUtmSouth(ossim_uint32 zone,
@@ -1035,7 +988,7 @@ void ossimNitfImageHeaderV2_1::setUtmSouth(ossim_uint32 zone,
    theCoordinateSystem[0] = 'S';
    
    memcpy(theGeographicLocation,
-          encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
+          ossimNitfCommon::encodeUtm(zone, ul, ur, lr, ll).c_str(), 60);
 }
 
 void ossimNitfImageHeaderV2_1::setSecurityClassificationSystem(const ossimString& value)
@@ -1295,160 +1248,6 @@ void ossimNitfImageHeaderV2_1::getPropertyNames(std::vector<ossimString>& proper
    propertyNames.push_back(XBANDS_KW);
 }
 
-ossimString ossimNitfImageHeaderV2_1::encodeUtm(
-   ossim_uint32 zone,
-   const ossimDpt& ul,
-   const ossimDpt& ur,
-   const ossimDpt& lr,
-   const ossimDpt& ll)const
-{
-   ostringstream out;
-
-   if(zone > 60)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUTM zone greate than 60!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   ossim_float64 east  = ul.x;
-   ossim_float64 north = ul.y;
-   
-   if((ossim_uint32)(east+.5) > 999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper left easting too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   if((ossim_uint32)(north+.5) > 9999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper left northing too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-
-   out << setw(2)
-       << setfill('0')
-       << zone
-       << setw(6)
-       << setfill('0')
-       <<(ossim_uint32)(east+.5)
-       << setw(7)
-          << setfill('0')
-       <<(ossim_uint32)(north+.5);
-
-   
-   east  = ur.x;
-   north = ur.y;
-   
-   if((ossim_uint32)(east+.5) > 999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper right easting too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   if((ossim_uint32)(north+.5) > 9999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper right northing too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   out << setw(2)
-       << setfill('0')
-       << zone
-       << setw(6)
-       << setfill('0')
-       <<(ossim_uint32)(east+.5)
-       << setw(7)
-       << setfill('0')
-       <<(ossim_uint32)(north+.5);
-   east  = lr.x;
-   north = lr.y;
-
-   if((ossim_uint32)(east+.5) > 999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower right easting too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   if((ossim_uint32)(north+.5) > 9999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower right northing too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }   
-
-   out << setw(2)
-       << setfill('0')
-       << zone
-       << setw(6)
-       << setfill('0')
-       <<(ossim_uint32)(east+.5)
-       << setw(7)
-       << setfill('0')
-       <<(ossim_uint32)(north+.5);
-   
-   east  = ll.x;
-   north = ll.y;
-
-   if((ossim_uint32)(east+.5) > 999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower left easting too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   if((ossim_uint32)(north+.5) > 9999999)
-   {
-      std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower left northing too large for NITF field!";
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
-      }
-      throw std::out_of_range(s);
-   }
-   
-   out << setw(2)
-       << setfill('0')
-       << zone
-       << setw(6)
-       << setfill('0')
-       <<(ossim_uint32)(east+.5)
-       << setw(7)
-       << setfill('0')
-       <<(ossim_uint32)(north+.5);
-   
-   return out.str().c_str();
-}
-
 const ossimRefPtr<ossimNitfCompressionHeader> ossimNitfImageHeaderV2_1::getCompressionHeader()const
 {
    return theCompressionHeader;
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp
index d36d75038a43844ea1fcba0a592af80d6e79b7d1..ab79837927989e93e6a1d7c946fc374914f2a8d2 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfImageHeaderV2_X.cpp
@@ -16,6 +16,7 @@ const ossimString ossimNitfImageHeaderV2_X::IID1_KW = "iid1";
 const ossimString ossimNitfImageHeaderV2_X::IDATIM_KW = "idatim";
 const ossimString ossimNitfImageHeaderV2_X::TGTID_KW = "tgtid";
 const ossimString ossimNitfImageHeaderV2_X::IID2_KW = "iid2";
+const ossimString ossimNitfImageHeaderV2_X::ITITLE_KW="ititle";
 const ossimString ossimNitfImageHeaderV2_X::ISCLAS_KW = "isclas";
 const ossimString ossimNitfImageHeaderV2_X::ENCRYP_KW = "encryp";
 const ossimString ossimNitfImageHeaderV2_X::ISORCE_KW = "isorce";
@@ -351,7 +352,8 @@ void ossimNitfImageHeaderV2_X::setProperty(ossimRefPtr<ossimProperty> property)
    {
       setTargetId(property->valueToString());
    }
-   else if(name.contains(IID2_KW))
+   else if(name.contains(IID2_KW)||
+           name.contains(ITITLE_KW))
    {
       setTitle(property->valueToString());
    }
@@ -450,7 +452,7 @@ void ossimNitfImageHeaderV2_X::setProperty(ossimRefPtr<ossimProperty> property)
    }
    else
    {
-      ossimNitfImageHeaderV2_X::setProperty(property);
+      ossimNitfImageHeader::setProperty(property);
    }
 }
 
@@ -473,7 +475,8 @@ ossimRefPtr<ossimProperty> ossimNitfImageHeaderV2_X::getProperty(const ossimStri
       property = new ossimStringProperty(name,
                                          ossimString(theTargetId).trim());
    }
-   else if(name == IID2_KW)
+   else if((name == IID2_KW)||
+           (name == ITITLE_KW))
    {
       property = new ossimStringProperty(name,
                                          ossimString(theTitle).trim());
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimNitfNameConversionTables.cpp b/Utilities/otbossim/src/ossim/support_data/ossimNitfNameConversionTables.cpp
index a4de76cf61e4b24bcbbe504063a61a15c3da68b0..d741fdaa82cb6549a93fc026c9d07acf5538813a 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimNitfNameConversionTables.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimNitfNameConversionTables.cpp
@@ -8,7 +8,7 @@
 // Author:  Garrett Potts
 //
 //*******************************************************************
-//  $Id: ossimNitfNameConversionTables.cpp 9094 2006-06-13 19:12:40Z dburken $
+//  $Id: ossimNitfNameConversionTables.cpp 13219 2008-07-23 19:27:49Z dburken $
 
 #include <cstddef>
 #include <ossim/support_data/ossimNitfNameConversionTables.h>
@@ -16,14 +16,14 @@
 
 struct ossimNitfMapProjectionCodeToOssimName
 {
-   char* nitfProjCode; // nitf code name
-   char* projectionName; // ossim projection name
+   const char* nitfProjCode; // nitf code name
+   const char* projectionName; // ossim projection name
 };
 
 struct ossimNitfMapProjectionCodeToNitfName
 {
-   char* nitfProjCode; // nitf code name
-   char* projectionName; // ossim projection name
+   const char* nitfProjCode; // nitf code name
+   const char* projectionName; // ossim projection name
 };
 
 static const ossimNitfMapProjectionCodeToOssimName mapProjectiontable[]=
@@ -51,7 +51,7 @@ static const ossimNitfMapProjectionCodeToOssimName mapProjectiontable[]=
    {"TC", "ossimTransMercatorProjection"},
    {"TX", "ossimTransCylEquAreaProjection"},
    {"VA", "ossimVanDerGrintenProjection"},
-   {(char*)NULL, (char*)NULL}
+   { 0, 0 }
 };
 
 static const ossimNitfMapProjectionCodeToNitfName nitfMapProjectiontable[]=
@@ -91,7 +91,7 @@ static const ossimNitfMapProjectionCodeToNitfName nitfMapProjectiontable[]=
    {"TX", "Transverse Cylindrical Equal Area"},
    {"VA", "Van der Grinten"},
    {"VX", "General Vertical NearSide Perspective"},
-   {(char*)NULL, (char*)NULL}
+   { 0, 0 }
 };
 
 ossimNitfNameConversionTables::ossimNitfNameConversionTables()
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimRpfColorConverterTable.cpp b/Utilities/otbossim/src/ossim/support_data/ossimRpfColorConverterTable.cpp
index cce776cd1a131ae8f56155a6dfebd666eeb7b45a..a8c2d19b5b97a25dcb8357615e1bf4a658269464 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimRpfColorConverterTable.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimRpfColorConverterTable.cpp
@@ -21,7 +21,7 @@ ossimRpfColorConverterTable::~ossimRpfColorConverterTable()
 {
    if(theColorGrayscaleTableEntryList)
    {
-      delete theColorGrayscaleTableEntryList;
+      delete [] theColorGrayscaleTableEntryList;
       theColorGrayscaleTableEntryList = NULL;
    }
 }
@@ -74,7 +74,7 @@ void ossimRpfColorConverterTable::setNumberOfEntries(ossim_uint32 entries)
 {
    if(theColorGrayscaleTableEntryList)
    {
-      delete theColorGrayscaleTableEntryList;
+      delete [] theColorGrayscaleTableEntryList;
       theColorGrayscaleTableEntryList = NULL;
    }
    theColorGrayscaleTableEntryList = new ossim_uint32[entries];
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimRpfColorGrayscaleTable.cpp b/Utilities/otbossim/src/ossim/support_data/ossimRpfColorGrayscaleTable.cpp
index d061a14c81a5b8903611eafdc91e09580aedff5b..6e6cadccc85a6e8cf68bee17aa30b5d7f1b5c0e3 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimRpfColorGrayscaleTable.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimRpfColorGrayscaleTable.cpp
@@ -34,7 +34,7 @@ ossimRpfColorGrayscaleTable::~ossimRpfColorGrayscaleTable()
 {
    if(theData)
    {
-      delete theData;
+      delete [] theData;
       theData = NULL;
    }
 }
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimRpfCompressionSection.cpp b/Utilities/otbossim/src/ossim/support_data/ossimRpfCompressionSection.cpp
index 1d86237fc2c92e2a190515fb540e48dd8700ec13..310ecebc0adebb564fb96f76644f71cb577d1341 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimRpfCompressionSection.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimRpfCompressionSection.cpp
@@ -52,8 +52,8 @@ const ossimRpfCompressionOffsetTableData& ossimRpfCompressionOffsetTableData::op
    {
       if(theData)
       {
-         delete theData;
-         theData = NULL;
+         delete [] theData;
+         theData = 0;
       }
 
       if(rhs.theData)
@@ -88,8 +88,8 @@ ossimRpfCompressionOffsetTableData::~ossimRpfCompressionOffsetTableData()
 {
    if(theData)
    {
-      delete theData;
-      theData = NULL;
+      delete [] theData;
+      theData = 0;
    }
 }
 
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp b/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp
index 0bfee4f947dd655f61ef6646612c00568dbe3d06..76eb782d623b173130ae2bdcfdc6931cd95fd6a2 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp
@@ -9,7 +9,7 @@
 // Contains definition of class ossimSpotDimapSupportData.
 //
 //*****************************************************************************
-// $Id: ossimSpotDimapSupportData.cpp 13025 2008-06-13 17:06:30Z sbortman $
+// $Id: ossimSpotDimapSupportData.cpp 13676 2008-10-03 17:35:02Z gpotts $
 
 
 #include <iostream>
@@ -1267,11 +1267,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double tempValue = 0.0;
+      ossimString tempValue;
       for(idx = 0; idx < thePixelLookAngleX.size();++idx)
       {
          in >> tempValue;
-         thePixelLookAngleX[idx] = tempValue;
+         thePixelLookAngleX[idx] = tempValue.toDouble();
       }
    }
 
@@ -1281,11 +1281,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double tempValue = 0.0;
+      ossimString tempValue;
       for(idx = 0; idx < thePixelLookAngleY.size();++idx)
       {
          in >> tempValue;
-         thePixelLookAngleY[idx] = tempValue;
+         thePixelLookAngleY[idx] = tempValue.toDouble();
       }
    }
 
@@ -1296,11 +1296,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double x, y, z = 0.0;
+      ossimString x, y, z;
       for(idx = 0; idx < theAttitudeSamples.size();++idx)
       {
          in >> x >> y >> z;
-         theAttitudeSamples[idx] =ossimDpt3d(x, y, z);
+         theAttitudeSamples[idx] =ossimDpt3d(x.toDouble(), y.toDouble(), z.toDouble());
       }
    }
 
@@ -1310,11 +1310,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double tempValue = 0.0;
+      ossimString tempValue;
       for(idx = 0; idx < theAttSampTimes.size();++idx)
       {
          in >> tempValue;
-         theAttSampTimes[idx] = tempValue;
+         theAttSampTimes[idx] = tempValue.toDouble();
       }
    }
 
@@ -1324,11 +1324,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double x, y, z = 0.0;
+      ossimString x, y, z;
       for(idx = 0; idx < thePosEcfSamples.size();++idx)
       {
          in >> x >> y >> z;
-         thePosEcfSamples[idx] = ossimDpt3d(x, y, z);
+         thePosEcfSamples[idx] = ossimDpt3d(x.toDouble(), y.toDouble(), z.toDouble());
       }
    }
 
@@ -1338,11 +1338,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double x, y, z = 0.0;
+      ossimString x, y, z;
       for(idx = 0; idx < theVelEcfSamples.size();++idx)
       {
          in >> x >> y >> z;
-         theVelEcfSamples[idx] = ossimDpt3d(x, y, z);
+         theVelEcfSamples[idx] = ossimDpt3d(x.toDouble(), y.toDouble(), z.toDouble());
       }
    }
 
@@ -1352,11 +1352,11 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
    if(tempString != "")
    {
       std::istringstream in(tempString);
-      double tempValue = 0.0;
+      ossimString tempValue;
       for(idx = 0; idx < theEphSampTimes.size();++idx)
       {
          in >> tempValue;
-         theEphSampTimes[idx] = tempValue;
+         theEphSampTimes[idx] = tempValue.toDouble();
       }
    }
 
@@ -1384,14 +1384,14 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl,
 ossimGpt ossimSpotDimapSupportData::createGround(const ossimString& s)const
 {
    std::istringstream in(s);
-   double lat, lon, height;
+   ossimString lat, lon, height;
    ossimString code;
 
    in >> lat >> lon >> height >> code;
 
-   return ossimGpt(lat,
-                   lon,
-                   height,
+   return ossimGpt(lat.toDouble(),
+                   lon.toDouble(),
+                   height.toDouble(),
                    ossimDatumFactory::instance()->create(code));
 
 }
@@ -1399,12 +1399,12 @@ ossimGpt ossimSpotDimapSupportData::createGround(const ossimString& s)const
 ossimDpt ossimSpotDimapSupportData::createDpt(const ossimString& s)const
 {
    std::istringstream in(s);
-   double x, y;
+   ossimString x, y;
    ossimString code;
 
    in >> x >> y;
 
-   return ossimDpt(x,y);
+   return ossimDpt(x.toDouble(), y.toDouble());
 
 }
 
diff --git a/Utilities/otbossim/src/ossim/vec/dbfopen.c b/Utilities/otbossim/src/ossim/vec/dbfopen.c
deleted file mode 100644
index 1ec330cd4fa7adbb98b17a54e280f875e1ddb200..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/vec/dbfopen.c
+++ /dev/null
@@ -1,1552 +0,0 @@
-/******************************************************************************
- * $Id: dbfopen.c 9094 2006-06-13 19:12:40Z dburken $
- *
- * Project:  Shapelib
- * Purpose:  Implementation of .dbf access API documented in dbf_api.html.
- * Author:   Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log$
- * Revision 1.6  2006/06/13 19:11:32  dburken
- * Global include path change.
- *
- * Revision 1.5  2005/10/08 12:57:26  gpotts
- * Added adiitional patches
- *
- * Revision 1.59  2005/03/14 15:20:28  fwarmerdam
- * Fixed last change.
- *
- * Revision 1.58  2005/03/14 15:18:54  fwarmerdam
- * Treat very wide fields with no decimals as double.  This is
- * more than 32bit integer fields.
- *
- * Revision 1.57  2005/02/10 20:16:54  fwarmerdam
- * Make the pszStringField buffer for ossim_DBFReadAttribute() static char [256]
- * as per bug 306.
- *
- * Revision 1.56  2005/02/10 20:07:56  fwarmerdam
- * Fixed bug 305 in ossim_DBFCloneEmpty() - header length problem.
- *
- * Revision 1.55  2004/09/26 20:23:46  fwarmerdam
- * avoid warnings with rcsid and signed/unsigned stuff
- *
- * Revision 1.54  2004/09/15 16:26:10  fwarmerdam
- * Treat all blank numeric fields as null too.
- *
- * Revision 1.53  2003/12/29 00:00:30  fwarmerdam
- * mark ossim_DBFWriteAttributeDirectly as ossim_SHPAPI_CALL
- *
- * Revision 1.52  2003/07/08 15:20:03  warmerda
- * avoid warnings about downcasting to unsigned char
- *
- * Revision 1.51  2003/07/08 13:50:15  warmerda
- * ossim_DBFIsAttributeNULL check for pszValue==NULL - bug 360
- *
- * Revision 1.50  2003/04/21 18:58:25  warmerda
- * ensure current record is flushed at same time as header is updated
- *
- * Revision 1.49  2003/04/21 18:30:37  warmerda
- * added header write/update public methods
- *
- * Revision 1.48  2003/03/10 14:51:27  warmerda
- * ossim_DBFWrite* calls now return FALSE if they have to truncate
- *
- * Revision 1.47  2002/11/20 03:32:22  warmerda
- * Ensure field name in ossim_DBFGetFieldIndex() is properly terminated.
- *
- * Revision 1.46  2002/10/09 13:10:21  warmerda
- * Added check that width is positive.
- *
- * Revision 1.45  2002/09/29 00:00:08  warmerda
- * added FTLogical and logical attribute read/write calls
- *
- * Revision 1.44  2002/05/07 13:46:11  warmerda
- * Added ossim_DBFWriteAttributeDirectly().
- *
- * Revision 1.43  2002/02/13 19:39:21  warmerda
- * Fix casting issues in ossim_DBFCloneEmpty().
- *
- * Revision 1.42  2002/01/15 14:36:07  warmerda
- * updated email address
- *
- * Revision 1.41  2002/01/15 14:31:49  warmerda
- * compute rather than copying nHeaderLength in ossim_DBFCloneEmpty()
- *
- * Revision 1.40  2002/01/09 04:32:35  warmerda
- * fixed to read correct amount of header
- *
- * Revision 1.39  2001/12/11 22:41:03  warmerda
- * improve io related error checking when reading header
- *
- * Revision 1.38  2001/11/28 16:07:31  warmerda
- * Cleanup to avoid compiler warnings as suggested by Richard Hash.
- *
- * Revision 1.37  2001/07/04 05:18:09  warmerda
- * do last fix properly
- *
- * Revision 1.36  2001/07/04 05:16:09  warmerda
- * fixed fieldname comparison in ossim_DBFGetFieldIndex
- *
- * Revision 1.35  2001/06/22 02:10:06  warmerda
- * fixed NULL shape support with help from Jim Matthews
- *
- * Revision 1.33  2001/05/31 19:20:13  warmerda
- * added ossim_DBFGetFieldIndex()
- *
- * Revision 1.32  2001/05/31 18:15:40  warmerda
- * Added support for NULL fields in ossim_DBF files
- *
- * Revision 1.31  2001/05/23 13:36:52  warmerda
- * added use of ossim_SHPAPI_CALL
- *
- * Revision 1.30  2000/12/05 14:43:38  warmerda
- * DBReadAttribute() white space trimming bug fix
- *
- * Revision 1.29  2000/10/05 14:36:44  warmerda
- * fix bug with writing very wide numeric fields
- *
- * Revision 1.28  2000/09/25 14:18:07  warmerda
- * Added some casts of strlen() return result to fix warnings on some
- * systems, as submitted by Daniel.
- *
- * Revision 1.27  2000/09/25 14:15:51  warmerda
- * added ossim_DBFGetNativeFieldType()
- *
- * Revision 1.26  2000/07/07 13:39:45  warmerda
- * removed unused variables, and added system include files
- *
- * Revision 1.25  2000/05/29 18:19:13  warmerda
- * avoid use of uchar, and adding casting fix
- *
- * Revision 1.24  2000/05/23 13:38:27  warmerda
- * Added error checks on return results of fread() and fseek().
- *
- * Revision 1.23  2000/05/23 13:25:49  warmerda
- * Avoid crashing if field or record are out of range in dbfread*attribute().
- *
- * Revision 1.22  1999/12/15 13:47:24  warmerda
- * Added stdlib.h to ensure that atof() is prototyped.
- *
- * Revision 1.21  1999/12/13 17:25:46  warmerda
- * Added support for upper case .DBF extention.
- *
- * Revision 1.20  1999/11/30 16:32:11  warmerda
- * Use atof() instead of sscanf().
- *
- * Revision 1.19  1999/11/05 14:12:04  warmerda
- * updated license terms
- *
- * Revision 1.18  1999/07/27 00:53:28  warmerda
- * ensure that whole old field value clear on write of string
- *
- * Revision 1.1  1999/07/05 18:58:07  warmerda
- * New
- *
- * Revision 1.17  1999/06/11 19:14:12  warmerda
- * Fixed some memory leaks.
- *
- * Revision 1.16  1999/06/11 19:04:11  warmerda
- * Remoted some unused variables.
- *
- * Revision 1.15  1999/05/11 03:19:28  warmerda
- * added new Tuple api, and improved extension handling - add from candrsn
- *
- * Revision 1.14  1999/05/04 15:01:48  warmerda
- * Added 'F' support.
- *
- * Revision 1.13  1999/03/23 17:38:59  warmerda
- * ossim_DBFAddField() now actually does return the new field number, or -1 if
- * it fails.
- *
- * Revision 1.12  1999/03/06 02:54:46  warmerda
- * Added logic to convert shapefile name to dbf filename in ossim_DBFOpen()
- * for convenience.
- *
- * Revision 1.11  1998/12/31 15:30:34  warmerda
- * Improved the interchangability of numeric and string attributes.  Add
- * white space trimming option for attributes.
- *
- * Revision 1.10  1998/12/03 16:36:44  warmerda
- * Use r+b instead of rb+ for binary access.
- *
- * Revision 1.9  1998/12/03 15:34:23  warmerda
- * Updated copyright message.
- *
- * Revision 1.8  1997/12/04 15:40:15  warmerda
- * Added newline character after field definitions.
- *
- * Revision 1.7  1997/03/06 14:02:10  warmerda
- * Ensure bUpdated is initialized.
- *
- * Revision 1.6  1996/02/12 04:54:41  warmerda
- * Ensure that ossim_DBFWriteAttribute() returns TRUE if it succeeds.
- *
- * Revision 1.5  1995/10/21  03:15:12  warmerda
- * Changed to use binary file access, and ensure that the
- * field name field is zero filled, and limited to 10 chars.
- *
- * Revision 1.4  1995/08/24  18:10:42  warmerda
- * Added use of SfRealloc() to avoid pre-ANSI realloc() functions such
- * as on the Sun.
- *
- * Revision 1.3  1995/08/04  03:15:16  warmerda
- * Fixed up header.
- *
- * Revision 1.2  1995/08/04  03:14:43  warmerda
- * Added header.
- */
-
-#include <ossim/vec/shapefil.h>
-
-#include <math.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-ossim_SHP_CVSID("$Id: dbfopen.c 9094 2006-06-13 19:12:40Z dburken $")
-
-#ifndef FALSE
-#  define FALSE		0
-#  define TRUE		1
-#endif
-
-/************************************************************************/
-/*                             SfRealloc()                              */
-/*                                                                      */
-/*      A realloc cover function that will access a NULL pointer as     */
-/*      a valid input.                                                  */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
-    if( pMem == NULL )
-        return( (void *) malloc(nNewSize) );
-    else
-        return( (void *) realloc(pMem,nNewSize) );
-}
-
-/************************************************************************/
-/*                           ossim_DBFWriteHeader()                           */
-/*                                                                      */
-/*      This is called to write out the file header, and field          */
-/*      descriptions before writing any actual data records.  This      */
-/*      also computes all the ossim_DBFDataSet field offset/size/decimals     */
-/*      and so forth values.                                            */
-/************************************************************************/
-
-static void ossim_DBFWriteHeader(ossim_DBFHandle psDBF)
-
-{
-    unsigned char	abyHeader[XBASE_FLDHDR_SZ];
-    int		i;
-
-    if( !psDBF->bNoHeader )
-        return;
-
-    psDBF->bNoHeader = FALSE;
-
-/* -------------------------------------------------------------------- */
-/*	Initialize the file header information.				*/
-/* -------------------------------------------------------------------- */
-    for( i = 0; i < XBASE_FLDHDR_SZ; i++ )
-        abyHeader[i] = 0;
-
-    abyHeader[0] = 0x03;		/* memo field? - just copying 	*/
-
-    /* write out a dummy date */
-    abyHeader[1] = 95;			/* YY */
-    abyHeader[2] = 7;			/* MM */
-    abyHeader[3] = 26;			/* DD */
-
-    /* record count preset at zero */
-
-    abyHeader[8] = (unsigned char) (psDBF->nHeaderLength % 256);
-    abyHeader[9] = (unsigned char) (psDBF->nHeaderLength / 256);
-
-    abyHeader[10] = (unsigned char) (psDBF->nRecordLength % 256);
-    abyHeader[11] = (unsigned char) (psDBF->nRecordLength / 256);
-
-/* -------------------------------------------------------------------- */
-/*      Write the initial 32 byte file header, and all the field        */
-/*      descriptions.                                     		*/
-/* -------------------------------------------------------------------- */
-    fseek( psDBF->fp, 0, 0 );
-    fwrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
-    fwrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp );
-
-/* -------------------------------------------------------------------- */
-/*      Write out the newline character if there is room for it.        */
-/* -------------------------------------------------------------------- */
-    if( psDBF->nHeaderLength > 32*psDBF->nFields + 32 )
-    {
-        char	cNewline;
-
-        cNewline = 0x0d;
-        fwrite( &cNewline, 1, 1, psDBF->fp );
-    }
-}
-
-/************************************************************************/
-/*                           ossim_DBFFlushRecord()                           */
-/*                                                                      */
-/*      Write out the current record if there is one.                   */
-/************************************************************************/
-
-static void ossim_DBFFlushRecord( ossim_DBFHandle psDBF )
-
-{
-    int		nRecordOffset;
-
-    if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
-    {
-	psDBF->bCurrentRecordModified = FALSE;
-
-	nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord
-	                                             + psDBF->nHeaderLength;
-
-	fseek( psDBF->fp, nRecordOffset, 0 );
-	fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-    }
-}
-
-/************************************************************************/
-/*                          ossim_DBFUpdateHeader()                           */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_DBFUpdateHeader( ossim_DBFHandle psDBF )
-
-{
-    unsigned char		abyFileHeader[32];
-
-    if( psDBF->bNoHeader )
-        ossim_DBFWriteHeader( psDBF );
-
-    ossim_DBFFlushRecord( psDBF );
-
-    fseek( psDBF->fp, 0, 0 );
-    fread( abyFileHeader, 32, 1, psDBF->fp );
-
-    abyFileHeader[4] = (unsigned char) (psDBF->nRecords % 256);
-    abyFileHeader[5] = (unsigned char) ((psDBF->nRecords/256) % 256);
-    abyFileHeader[6] = (unsigned char) ((psDBF->nRecords/(256*256)) % 256);
-    abyFileHeader[7] = (unsigned char) ((psDBF->nRecords/(256*256*256)) % 256);
-
-    fseek( psDBF->fp, 0, 0 );
-    fwrite( abyFileHeader, 32, 1, psDBF->fp );
-
-    fflush( psDBF->fp );
-}
-
-/************************************************************************/
-/*                              ossim_DBFOpen()                               */
-/*                                                                      */
-/*      Open a .dbf file.                                               */
-/************************************************************************/
-
-ossim_DBFHandle ossim_SHPAPI_CALL
-    ossim_DBFOpen( const char * pszFilename, const char * pszAccess )
-
-{
-    ossim_DBFHandle		psDBF;
-    unsigned char		*pabyBuf;
-    int			nFields, nHeadLen, nRecLen, iField, i;
-    char		*pszBasename, *pszFullname;
-
-/* -------------------------------------------------------------------- */
-/*      We only allow the access strings "rb" and "r+".                  */
-/* -------------------------------------------------------------------- */
-    if( strcmp(pszAccess,"r") != 0 && strcmp(pszAccess,"r+") != 0
-        && strcmp(pszAccess,"rb") != 0 && strcmp(pszAccess,"rb+") != 0
-        && strcmp(pszAccess,"r+b") != 0 )
-        return( NULL );
-
-    if( strcmp(pszAccess,"r") == 0 )
-        pszAccess = "rb";
-
-    if( strcmp(pszAccess,"r+") == 0 )
-        pszAccess = "rb+";
-
-/* -------------------------------------------------------------------- */
-/*	Compute the base (layer) name.  If there is any extension	*/
-/*	on the passed in filename we will strip it off.			*/
-/* -------------------------------------------------------------------- */
-    pszBasename = (char *) malloc(strlen(pszFilename)+5);
-    strcpy( pszBasename, pszFilename );
-    for( i = strlen(pszBasename)-1;
-	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
-	       && pszBasename[i] != '\\';
-	 i-- ) {}
-
-    if( pszBasename[i] == '.' )
-        pszBasename[i] = '\0';
-
-    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
-    sprintf( pszFullname, "%s.dbf", pszBasename );
-
-    psDBF = (ossim_DBFHandle) calloc( 1, sizeof(ossim_DBFInfo) );
-    psDBF->fp = fopen( pszFullname, pszAccess );
-
-    if( psDBF->fp == NULL )
-    {
-        sprintf( pszFullname, "%s.DBF", pszBasename );
-        psDBF->fp = fopen(pszFullname, pszAccess );
-    }
-
-    free( pszBasename );
-    free( pszFullname );
-
-    if( psDBF->fp == NULL )
-    {
-        free( psDBF );
-        return( NULL );
-    }
-
-    psDBF->bNoHeader = FALSE;
-    psDBF->nCurrentRecord = -1;
-    psDBF->bCurrentRecordModified = FALSE;
-
-/* -------------------------------------------------------------------- */
-/*  Read Table Header info                                              */
-/* -------------------------------------------------------------------- */
-    pabyBuf = (unsigned char *) malloc(500);
-    if( fread( pabyBuf, 32, 1, psDBF->fp ) != 1 )
-    {
-        fclose( psDBF->fp );
-        free( pabyBuf );
-        free( psDBF );
-        return NULL;
-    }
-
-    psDBF->nRecords =
-     pabyBuf[4] + pabyBuf[5]*256 + pabyBuf[6]*256*256 + pabyBuf[7]*256*256*256;
-
-    psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9]*256;
-    psDBF->nRecordLength = nRecLen = pabyBuf[10] + pabyBuf[11]*256;
-
-    psDBF->nFields = nFields = (nHeadLen - 32) / 32;
-
-    psDBF->pszCurrentRecord = (char *) malloc(nRecLen);
-
-/* -------------------------------------------------------------------- */
-/*  Read in Field Definitions                                           */
-/* -------------------------------------------------------------------- */
-
-    pabyBuf = (unsigned char *) SfRealloc(pabyBuf,nHeadLen);
-    psDBF->pszHeader = (char *) pabyBuf;
-
-    fseek( psDBF->fp, 32, 0 );
-    if( fread( pabyBuf, nHeadLen-32, 1, psDBF->fp ) != 1 )
-    {
-        fclose( psDBF->fp );
-        free( pabyBuf );
-        free( psDBF );
-        return NULL;
-    }
-
-    psDBF->panFieldOffset = (int *) malloc(sizeof(int) * nFields);
-    psDBF->panFieldSize = (int *) malloc(sizeof(int) * nFields);
-    psDBF->panFieldDecimals = (int *) malloc(sizeof(int) * nFields);
-    psDBF->pachFieldType = (char *) malloc(sizeof(char) * nFields);
-
-    for( iField = 0; iField < nFields; iField++ )
-    {
-	unsigned char		*pabyFInfo;
-
-	pabyFInfo = pabyBuf+iField*32;
-
-	if( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' )
-	{
-	    psDBF->panFieldSize[iField] = pabyFInfo[16];
-	    psDBF->panFieldDecimals[iField] = pabyFInfo[17];
-	}
-	else
-	{
-	    psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17]*256;
-	    psDBF->panFieldDecimals[iField] = 0;
-	}
-
-	psDBF->pachFieldType[iField] = (char) pabyFInfo[11];
-	if( iField == 0 )
-	    psDBF->panFieldOffset[iField] = 1;
-	else
-	    psDBF->panFieldOffset[iField] =
-	      psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1];
-    }
-
-    return( psDBF );
-}
-
-/************************************************************************/
-/*                              ossim_DBFClose()                              */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_DBFClose(ossim_DBFHandle psDBF)
-{
-/* -------------------------------------------------------------------- */
-/*      Write out header if not already written.                        */
-/* -------------------------------------------------------------------- */
-    if( psDBF->bNoHeader )
-        ossim_DBFWriteHeader( psDBF );
-
-    ossim_DBFFlushRecord( psDBF );
-
-/* -------------------------------------------------------------------- */
-/*      Update last access date, and number of records if we have	*/
-/*	write access.                					*/
-/* -------------------------------------------------------------------- */
-    if( psDBF->bUpdated )
-        ossim_DBFUpdateHeader( psDBF );
-
-/* -------------------------------------------------------------------- */
-/*      Close, and free resources.                                      */
-/* -------------------------------------------------------------------- */
-    fclose( psDBF->fp );
-
-    if( psDBF->panFieldOffset != NULL )
-    {
-        free( psDBF->panFieldOffset );
-        free( psDBF->panFieldSize );
-        free( psDBF->panFieldDecimals );
-        free( psDBF->pachFieldType );
-    }
-
-    free( psDBF->pszHeader );
-    free( psDBF->pszCurrentRecord );
-
-    free( psDBF );
-}
-
-/************************************************************************/
-/*                             ossim_DBFCreate()                              */
-/*                                                                      */
-/*      Create a new .dbf file.                                         */
-/************************************************************************/
-
-ossim_DBFHandle ossim_SHPAPI_CALL
-    ossim_DBFCreate( const char * pszFilename )
-
-{
-    ossim_DBFHandle	psDBF;
-    FILE	*fp;
-    char	*pszFullname, *pszBasename;
-    int		i;
-
-/* -------------------------------------------------------------------- */
-/*	Compute the base (layer) name.  If there is any extension	*/
-/*	on the passed in filename we will strip it off.			*/
-/* -------------------------------------------------------------------- */
-    pszBasename = (char *) malloc(strlen(pszFilename)+5);
-    strcpy( pszBasename, pszFilename );
-    for( i = strlen(pszBasename)-1;
-	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
-	       && pszBasename[i] != '\\';
-	 i-- ) {}
-
-    if( pszBasename[i] == '.' )
-        pszBasename[i] = '\0';
-
-    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
-    sprintf( pszFullname, "%s.dbf", pszBasename );
-    free( pszBasename );
-
-/* -------------------------------------------------------------------- */
-/*      Create the file.                                                */
-/* -------------------------------------------------------------------- */
-    fp = fopen( pszFullname, "wb" );
-    if( fp == NULL )
-        return( NULL );
-
-    fputc( 0, fp );
-    fclose( fp );
-
-    fp = fopen( pszFullname, "rb+" );
-    if( fp == NULL )
-        return( NULL );
-
-    free( pszFullname );
-
-/* -------------------------------------------------------------------- */
-/*	Create the info structure.					*/
-/* -------------------------------------------------------------------- */
-    psDBF = (ossim_DBFHandle) malloc(sizeof(ossim_DBFInfo));
-
-    psDBF->fp = fp;
-    psDBF->nRecords = 0;
-    psDBF->nFields = 0;
-    psDBF->nRecordLength = 1;
-    psDBF->nHeaderLength = 33;
-
-    psDBF->panFieldOffset = NULL;
-    psDBF->panFieldSize = NULL;
-    psDBF->panFieldDecimals = NULL;
-    psDBF->pachFieldType = NULL;
-    psDBF->pszHeader = NULL;
-
-    psDBF->nCurrentRecord = -1;
-    psDBF->bCurrentRecordModified = FALSE;
-    psDBF->pszCurrentRecord = NULL;
-
-    psDBF->bNoHeader = TRUE;
-
-    return( psDBF );
-}
-
-/************************************************************************/
-/*                            ossim_DBFAddField()                             */
-/*                                                                      */
-/*      Add a field to a newly created .dbf file before any records     */
-/*      are written.                                                    */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFAddField(ossim_DBFHandle psDBF, const char * pszFieldName,
-            ossim_DBFFieldType eType, int nWidth, int nDecimals )
-
-{
-    char	*pszFInfo;
-    int		i;
-
-/* -------------------------------------------------------------------- */
-/*      Do some checking to ensure we can add records to this file.     */
-/* -------------------------------------------------------------------- */
-    if( psDBF->nRecords > 0 )
-        return( -1 );
-
-    if( !psDBF->bNoHeader )
-        return( -1 );
-
-    if( eType != FTDouble && nDecimals != 0 )
-        return( -1 );
-
-    if( nWidth < 1 )
-        return -1;
-
-/* -------------------------------------------------------------------- */
-/*      SfRealloc all the arrays larger to hold the additional field      */
-/*      information.                                                    */
-/* -------------------------------------------------------------------- */
-    psDBF->nFields++;
-
-    psDBF->panFieldOffset = (int *)
-      SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
-
-    psDBF->panFieldSize = (int *)
-      SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
-
-    psDBF->panFieldDecimals = (int *)
-      SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
-
-    psDBF->pachFieldType = (char *)
-      SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields );
-
-/* -------------------------------------------------------------------- */
-/*      Assign the new field information fields.                        */
-/* -------------------------------------------------------------------- */
-    psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength;
-    psDBF->nRecordLength += nWidth;
-    psDBF->panFieldSize[psDBF->nFields-1] = nWidth;
-    psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals;
-
-    if( eType == FTLogical )
-        psDBF->pachFieldType[psDBF->nFields-1] = 'L';
-    else if( eType == FTString )
-        psDBF->pachFieldType[psDBF->nFields-1] = 'C';
-    else
-        psDBF->pachFieldType[psDBF->nFields-1] = 'N';
-
-/* -------------------------------------------------------------------- */
-/*      Extend the required header information.                         */
-/* -------------------------------------------------------------------- */
-    psDBF->nHeaderLength += 32;
-    psDBF->bUpdated = FALSE;
-
-    psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,psDBF->nFields*32);
-
-    pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields-1);
-
-    for( i = 0; i < 32; i++ )
-        pszFInfo[i] = '\0';
-
-    if( (int) strlen(pszFieldName) < 10 )
-        strncpy( pszFInfo, pszFieldName, strlen(pszFieldName));
-    else
-        strncpy( pszFInfo, pszFieldName, 10);
-
-    pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1];
-
-    if( eType == FTString )
-    {
-        pszFInfo[16] = (unsigned char) (nWidth % 256);
-        pszFInfo[17] = (unsigned char) (nWidth / 256);
-    }
-    else
-    {
-        pszFInfo[16] = (unsigned char) nWidth;
-        pszFInfo[17] = (unsigned char) nDecimals;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Make the current record buffer appropriately larger.            */
-/* -------------------------------------------------------------------- */
-    psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
-					       psDBF->nRecordLength);
-
-    return( psDBF->nFields-1 );
-}
-
-/************************************************************************/
-/*                          ossim_DBFReadAttribute()                          */
-/*                                                                      */
-/*      Read one of the attribute fields of a record.                   */
-/************************************************************************/
-
-static void *ossim_DBFReadAttribute(ossim_DBFHandle psDBF, int hEntity, int iField,
-                              char chReqType )
-
-{
-    int	       	nRecordOffset;
-    unsigned char	*pabyRec;
-    void	*pReturnField = NULL;
-
-    static double dDoubleField;
-    static char szStringField[257];
-
-/* -------------------------------------------------------------------- */
-/*      Verify selection.                                               */
-/* -------------------------------------------------------------------- */
-    if( hEntity < 0 || hEntity >= psDBF->nRecords )
-        return( NULL );
-
-    if( iField < 0 || iField >= psDBF->nFields )
-        return( NULL );
-
-/* -------------------------------------------------------------------- */
-/*	Have we read the record?					*/
-/* -------------------------------------------------------------------- */
-    if( psDBF->nCurrentRecord != hEntity )
-    {
-      ossim_DBFFlushRecord( psDBF );
-
-	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
-	if( fseek( psDBF->fp, nRecordOffset, 0 ) != 0 )
-        {
-            fprintf( stderr, "fseek(%d) failed on ossim_DBF file.\n",
-                     nRecordOffset );
-            return NULL;
-        }
-
-	if( fread( psDBF->pszCurrentRecord, psDBF->nRecordLength,
-                   1, psDBF->fp ) != 1 )
-        {
-            fprintf( stderr, "fread(%d) failed on ossim_DBF file.\n",
-                     psDBF->nRecordLength );
-            return NULL;
-        }
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-/* -------------------------------------------------------------------- */
-/*	Extract the requested field.					*/
-/* -------------------------------------------------------------------- */
-    strncpy( szStringField,
-	     ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
-	     psDBF->panFieldSize[iField] );
-    szStringField[psDBF->panFieldSize[iField]] = '\0';
-
-    pReturnField = szStringField;
-
-/* -------------------------------------------------------------------- */
-/*      Decode the field.                                               */
-/* -------------------------------------------------------------------- */
-    if( chReqType == 'N' )
-    {
-        dDoubleField = atof(szStringField);
-
-	pReturnField = &dDoubleField;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Should we trim white space off the string attribute value?      */
-/* -------------------------------------------------------------------- */
-#ifdef TRIM_DBF_WHITESPACE
-    else
-    {
-        char	*pchSrc, *pchDst;
-
-        pchDst = pchSrc = szStringField;
-        while( *pchSrc == ' ' )
-            pchSrc++;
-
-        while( *pchSrc != '\0' )
-            *(pchDst++) = *(pchSrc++);
-        *pchDst = '\0';
-
-        while( pchDst != szStringField && *(--pchDst) == ' ' )
-            *pchDst = '\0';
-    }
-#endif
-
-    return( pReturnField );
-}
-
-/************************************************************************/
-/*                        ossim_DBFReadIntAttribute()                         */
-/*                                                                      */
-/*      Read an integer attribute.                                      */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFReadIntegerAttribute( ossim_DBFHandle psDBF, int iRecord, int iField )
-
-{
-    double	*pdValue;
-
-    pdValue = (double *) ossim_DBFReadAttribute( psDBF, iRecord, iField, 'N' );
-
-    if( pdValue == NULL )
-        return 0;
-    else
-        return( (int) *pdValue );
-}
-
-/************************************************************************/
-/*                        ossim_DBFReadDoubleAttribute()                      */
-/*                                                                      */
-/*      Read a double attribute.                                        */
-/************************************************************************/
-
-double ossim_SHPAPI_CALL
-      ossim_DBFReadDoubleAttribute( ossim_DBFHandle psDBF, int iRecord, int iField )
-
-{
-    double	*pdValue;
-
-    pdValue = (double *) ossim_DBFReadAttribute( psDBF, iRecord, iField, 'N' );
-
-    if( pdValue == NULL )
-        return 0.0;
-    else
-        return( *pdValue );
-}
-
-/************************************************************************/
-/*                        ossim_DBFReadStringAttribute()                      */
-/*                                                                      */
-/*      Read a string attribute.                                        */
-/************************************************************************/
-
-const char ossim_SHPAPI_CALL1(*)
-    ossim_DBFReadStringAttribute( ossim_DBFHandle psDBF, int iRecord, int iField )
-
-{
-    return( (const char *) ossim_DBFReadAttribute( psDBF, iRecord, iField, 'C' ) );
-}
-
-/************************************************************************/
-/*                        ossim_DBFReadLogicalAttribute()                     */
-/*                                                                      */
-/*      Read a logical attribute.                                       */
-/************************************************************************/
-
-const char ossim_SHPAPI_CALL1(*)
-    ossim_DBFReadLogicalAttribute( ossim_DBFHandle psDBF, int iRecord, int iField )
-
-{
-    return( (const char *) ossim_DBFReadAttribute( psDBF, iRecord, iField, 'L' ) );
-}
-
-/************************************************************************/
-/*                         ossim_DBFIsAttributeNULL()                         */
-/*                                                                      */
-/*      Return TRUE if value for field is NULL.                         */
-/*                                                                      */
-/*      Contributed by Jim Matthews.                                    */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFIsAttributeNULL( ossim_DBFHandle psDBF, int iRecord, int iField )
-
-{
-    const char	*pszValue;
-    int i;
-
-    pszValue = ossim_DBFReadStringAttribute( psDBF, iRecord, iField );
-
-    if( pszValue == NULL )
-        return TRUE;
-
-    switch(psDBF->pachFieldType[iField])
-    {
-      case 'N':
-      case 'F':
-        /*
-        ** We accept all asterisks or all blanks as NULL
-        ** though according to the spec I think it should be all
-        ** asterisks.
-        */
-        if( pszValue[0] == '*' )
-            return TRUE;
-
-        for( i = 0; pszValue[i] != '\0'; i++ )
-        {
-            if( pszValue[i] != ' ' )
-                return FALSE;
-        }
-        return TRUE;
-
-      case 'D':
-        /* NULL date fields have value "00000000" */
-        return strncmp(pszValue,"00000000",8) == 0;
-
-      case 'L':
-        /* NULL boolean fields have value "?" */
-        return pszValue[0] == '?';
-
-      default:
-        /* empty string fields are considered NULL */
-        return strlen(pszValue) == 0;
-    }
-}
-
-/************************************************************************/
-/*                          ossim_DBFGetFieldCount()                          */
-/*                                                                      */
-/*      Return the number of fields in this table.                      */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFGetFieldCount( ossim_DBFHandle psDBF )
-
-{
-    return( psDBF->nFields );
-}
-
-/************************************************************************/
-/*                         ossim_DBFGetRecordCount()                          */
-/*                                                                      */
-/*      Return the number of records in this table.                     */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFGetRecordCount( ossim_DBFHandle psDBF )
-
-{
-    return( psDBF->nRecords );
-}
-
-/************************************************************************/
-/*                          ossim_DBFGetFieldInfo()                           */
-/*                                                                      */
-/*      Return any requested information about the field.               */
-/************************************************************************/
-
-ossim_DBFFieldType ossim_SHPAPI_CALL
-    ossim_DBFGetFieldInfo( ossim_DBFHandle psDBF, int iField, char * pszFieldName,
-                 int * pnWidth, int * pnDecimals )
-
-{
-    if( iField < 0 || iField >= psDBF->nFields )
-        return( FTInvalid );
-
-    if( pnWidth != NULL )
-        *pnWidth = psDBF->panFieldSize[iField];
-
-    if( pnDecimals != NULL )
-        *pnDecimals = psDBF->panFieldDecimals[iField];
-
-    if( pszFieldName != NULL )
-    {
-	int	i;
-
-	strncpy( pszFieldName, (char *) psDBF->pszHeader+iField*32, 11 );
-	pszFieldName[11] = '\0';
-	for( i = 10; i > 0 && pszFieldName[i] == ' '; i-- )
-	    pszFieldName[i] = '\0';
-    }
-
-    if ( psDBF->pachFieldType[iField] == 'L' )
-	return( FTLogical);
-
-    else if( psDBF->pachFieldType[iField] == 'N'
-             || psDBF->pachFieldType[iField] == 'F'
-             || psDBF->pachFieldType[iField] == 'D' )
-    {
-	if( psDBF->panFieldDecimals[iField] > 0
-            || psDBF->panFieldSize[iField] > 10 )
-	    return( FTDouble );
-	else
-	    return( FTInteger );
-    }
-    else
-    {
-	return( FTString );
-    }
-}
-
-/************************************************************************/
-/*                         ossim_DBFWriteAttribute()                          */
-/*									*/
-/*	Write an attribute record to the file.				*/
-/************************************************************************/
-
-static int ossim_DBFWriteAttribute(ossim_DBFHandle psDBF, int hEntity, int iField,
-			     void * pValue )
-
-{
-    int	       	nRecordOffset, i, j, nRetResult = TRUE;
-    unsigned char	*pabyRec;
-    char	szSField[400], szFormat[20];
-
-/* -------------------------------------------------------------------- */
-/*	Is this a valid record?						*/
-/* -------------------------------------------------------------------- */
-    if( hEntity < 0 || hEntity > psDBF->nRecords )
-        return( FALSE );
-
-    if( psDBF->bNoHeader )
-        ossim_DBFWriteHeader(psDBF);
-
-/* -------------------------------------------------------------------- */
-/*      Is this a brand new record?                                     */
-/* -------------------------------------------------------------------- */
-    if( hEntity == psDBF->nRecords )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	psDBF->nRecords++;
-	for( i = 0; i < psDBF->nRecordLength; i++ )
-	    psDBF->pszCurrentRecord[i] = ' ';
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Is this an existing record, but different than the last one     */
-/*      we accessed?                                                    */
-/* -------------------------------------------------------------------- */
-    if( psDBF->nCurrentRecord != hEntity )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
-	fseek( psDBF->fp, nRecordOffset, 0 );
-	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-    psDBF->bCurrentRecordModified = TRUE;
-    psDBF->bUpdated = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*      Translate NULL value to valid ossim_DBF file representation.          */
-/*                                                                      */
-/*      Contributed by Jim Matthews.                                    */
-/* -------------------------------------------------------------------- */
-    if( pValue == NULL )
-    {
-        switch(psDBF->pachFieldType[iField])
-        {
-          case 'N':
-          case 'F':
-	    /* NULL numeric fields have value "****************" */
-            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '*',
-                    psDBF->panFieldSize[iField] );
-            break;
-
-          case 'D':
-	    /* NULL date fields have value "00000000" */
-            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '0',
-                    psDBF->panFieldSize[iField] );
-            break;
-
-          case 'L':
-	    /* NULL boolean fields have value "?" */
-            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '?',
-                    psDBF->panFieldSize[iField] );
-            break;
-
-          default:
-            /* empty string fields are considered NULL */
-            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '\0',
-                    psDBF->panFieldSize[iField] );
-            break;
-        }
-        return TRUE;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Assign all the record fields.                                   */
-/* -------------------------------------------------------------------- */
-    switch( psDBF->pachFieldType[iField] )
-    {
-      case 'D':
-      case 'N':
-      case 'F':
-	if( psDBF->panFieldDecimals[iField] == 0 )
-	{
-            int		nWidth = psDBF->panFieldSize[iField];
-
-            if( (int) sizeof(szSField)-2 < nWidth )
-                nWidth = sizeof(szSField)-2;
-
-	    sprintf( szFormat, "%%%dd", nWidth );
-	    sprintf(szSField, szFormat, (int) *((double *) pValue) );
-	    if( (int)strlen(szSField) > psDBF->panFieldSize[iField] )
-            {
-	        szSField[psDBF->panFieldSize[iField]] = '\0';
-                nRetResult = FALSE;
-            }
-
-	    strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
-		    szSField, strlen(szSField) );
-	}
-	else
-	{
-            int		nWidth = psDBF->panFieldSize[iField];
-
-            if( (int) sizeof(szSField)-2 < nWidth )
-                nWidth = sizeof(szSField)-2;
-
-	    sprintf( szFormat, "%%%d.%df",
-                     nWidth, psDBF->panFieldDecimals[iField] );
-	    sprintf(szSField, szFormat, *((double *) pValue) );
-	    if( (int) strlen(szSField) > psDBF->panFieldSize[iField] )
-            {
-	        szSField[psDBF->panFieldSize[iField]] = '\0';
-                nRetResult = FALSE;
-            }
-	    strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
-		    szSField, strlen(szSField) );
-	}
-	break;
-
-      case 'L':
-        if (psDBF->panFieldSize[iField] >= 1  &&
-            (*(char*)pValue == 'F' || *(char*)pValue == 'T'))
-            *(pabyRec+psDBF->panFieldOffset[iField]) = *(char*)pValue;
-        break;
-
-      default:
-	if( (int) strlen((char *) pValue) > psDBF->panFieldSize[iField] )
-        {
-	    j = psDBF->panFieldSize[iField];
-            nRetResult = FALSE;
-        }
-	else
-        {
-            memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
-                    psDBF->panFieldSize[iField] );
-	    j = strlen((char *) pValue);
-        }
-
-	strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
-		(char *) pValue, j );
-	break;
-    }
-
-    return( nRetResult );
-}
-
-/************************************************************************/
-/*                     ossim_DBFWriteAttributeDirectly()                      */
-/*                                                                      */
-/*      Write an attribute record to the file, but without any          */
-/*      reformatting based on type.  The provided buffer is written     */
-/*      as is to the field position in the record.                      */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteAttributeDirectly(ossim_DBFHandle psDBF, int hEntity, int iField,
-                              void * pValue )
-
-{
-    int	       	nRecordOffset, i, j;
-    unsigned char	*pabyRec;
-
-/* -------------------------------------------------------------------- */
-/*	Is this a valid record?						*/
-/* -------------------------------------------------------------------- */
-    if( hEntity < 0 || hEntity > psDBF->nRecords )
-        return( FALSE );
-
-    if( psDBF->bNoHeader )
-        ossim_DBFWriteHeader(psDBF);
-
-/* -------------------------------------------------------------------- */
-/*      Is this a brand new record?                                     */
-/* -------------------------------------------------------------------- */
-    if( hEntity == psDBF->nRecords )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	psDBF->nRecords++;
-	for( i = 0; i < psDBF->nRecordLength; i++ )
-	    psDBF->pszCurrentRecord[i] = ' ';
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Is this an existing record, but different than the last one     */
-/*      we accessed?                                                    */
-/* -------------------------------------------------------------------- */
-    if( psDBF->nCurrentRecord != hEntity )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
-	fseek( psDBF->fp, nRecordOffset, 0 );
-	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-/* -------------------------------------------------------------------- */
-/*      Assign all the record fields.                                   */
-/* -------------------------------------------------------------------- */
-    if( (int)strlen((char *) pValue) > psDBF->panFieldSize[iField] )
-        j = psDBF->panFieldSize[iField];
-    else
-    {
-        memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
-                psDBF->panFieldSize[iField] );
-        j = strlen((char *) pValue);
-    }
-
-    strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
-            (char *) pValue, j );
-
-    psDBF->bCurrentRecordModified = TRUE;
-    psDBF->bUpdated = TRUE;
-
-    return( TRUE );
-}
-
-/************************************************************************/
-/*                      ossim_DBFWriteDoubleAttribute()                       */
-/*                                                                      */
-/*      Write a double attribute.                                       */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteDoubleAttribute( ossim_DBFHandle psDBF, int iRecord, int iField,
-                         double dValue )
-
-{
-    return( ossim_DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
-}
-
-/************************************************************************/
-/*                      ossim_DBFWriteIntegerAttribute()                      */
-/*                                                                      */
-/*      Write a integer attribute.                                      */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteIntegerAttribute( ossim_DBFHandle psDBF, int iRecord, int iField,
-                          int nValue )
-
-{
-    double	dValue = nValue;
-
-    return( ossim_DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
-}
-
-/************************************************************************/
-/*                      ossim_DBFWriteStringAttribute()                       */
-/*                                                                      */
-/*      Write a string attribute.                                       */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteStringAttribute( ossim_DBFHandle psDBF, int iRecord, int iField,
-                         const char * pszValue )
-
-{
-    return( ossim_DBFWriteAttribute( psDBF, iRecord, iField, (void *) pszValue ) );
-}
-
-/************************************************************************/
-/*                      ossim_DBFWriteNULLAttribute()                         */
-/*                                                                      */
-/*      Write a string attribute.                                       */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteNULLAttribute( ossim_DBFHandle psDBF, int iRecord, int iField )
-
-{
-    return( ossim_DBFWriteAttribute( psDBF, iRecord, iField, NULL ) );
-}
-
-/************************************************************************/
-/*                      ossim_DBFWriteLogicalAttribute()                      */
-/*                                                                      */
-/*      Write a logical attribute.                                      */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteLogicalAttribute( ossim_DBFHandle psDBF, int iRecord, int iField,
-		       const char lValue)
-
-{
-    return( ossim_DBFWriteAttribute( psDBF, iRecord, iField, (void *) (&lValue) ) );
-}
-
-/************************************************************************/
-/*                         ossim_DBFWriteTuple()                              */
-/*									*/
-/*	Write an attribute record to the file.				*/
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFWriteTuple(ossim_DBFHandle psDBF, int hEntity, void * pRawTuple )
-
-{
-    int	       	nRecordOffset, i;
-    unsigned char	*pabyRec;
-
-/* -------------------------------------------------------------------- */
-/*	Is this a valid record?						*/
-/* -------------------------------------------------------------------- */
-    if( hEntity < 0 || hEntity > psDBF->nRecords )
-        return( FALSE );
-
-    if( psDBF->bNoHeader )
-        ossim_DBFWriteHeader(psDBF);
-
-/* -------------------------------------------------------------------- */
-/*      Is this a brand new record?                                     */
-/* -------------------------------------------------------------------- */
-    if( hEntity == psDBF->nRecords )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	psDBF->nRecords++;
-	for( i = 0; i < psDBF->nRecordLength; i++ )
-	    psDBF->pszCurrentRecord[i] = ' ';
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Is this an existing record, but different than the last one     */
-/*      we accessed?                                                    */
-/* -------------------------------------------------------------------- */
-    if( psDBF->nCurrentRecord != hEntity )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
-	fseek( psDBF->fp, nRecordOffset, 0 );
-	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-    memcpy ( pabyRec, pRawTuple,  psDBF->nRecordLength );
-
-    psDBF->bCurrentRecordModified = TRUE;
-    psDBF->bUpdated = TRUE;
-
-    return( TRUE );
-}
-
-/************************************************************************/
-/*                          ossim_DBFReadTuple()                              */
-/*                                                                      */
-/*      Read one of the attribute fields of a record.                   */
-/************************************************************************/
-
-const char ossim_SHPAPI_CALL1(*)
-    ossim_DBFReadTuple(ossim_DBFHandle psDBF, int hEntity )
-
-{
-    int	       	nRecordOffset;
-    unsigned char	*pabyRec;
-    static char	*pReturnTuple = NULL;
-
-    static int	nTupleLen = 0;
-
-/* -------------------------------------------------------------------- */
-/*	Have we read the record?					*/
-/* -------------------------------------------------------------------- */
-    if( hEntity < 0 || hEntity >= psDBF->nRecords )
-        return( NULL );
-
-    if( psDBF->nCurrentRecord != hEntity )
-    {
-	ossim_DBFFlushRecord( psDBF );
-
-	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
-	fseek( psDBF->fp, nRecordOffset, 0 );
-	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
-	psDBF->nCurrentRecord = hEntity;
-    }
-
-    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-    if ( nTupleLen < psDBF->nRecordLength) {
-      nTupleLen = psDBF->nRecordLength;
-      pReturnTuple = (char *) SfRealloc(pReturnTuple, psDBF->nRecordLength);
-    }
-
-    memcpy ( pReturnTuple, pabyRec, psDBF->nRecordLength );
-
-    return( pReturnTuple );
-}
-
-/************************************************************************/
-/*                          ossim_DBFCloneEmpty()                              */
-/*                                                                      */
-/*      Read one of the attribute fields of a record.                   */
-/************************************************************************/
-
-ossim_DBFHandle ossim_SHPAPI_CALL
-    ossim_DBFCloneEmpty(ossim_DBFHandle psDBF, const char * pszFilename )
-{
-    ossim_DBFHandle	newDBF;
-
-   newDBF = ossim_DBFCreate ( pszFilename );
-   if ( newDBF == NULL ) return ( NULL );
-
-   newDBF->nFields = psDBF->nFields;
-   newDBF->nRecordLength = psDBF->nRecordLength;
-   newDBF->nHeaderLength = psDBF->nHeaderLength;
-
-   newDBF->pszHeader = (char *) malloc ( newDBF->nHeaderLength );
-   memcpy ( newDBF->pszHeader, psDBF->pszHeader, newDBF->nHeaderLength );
-
-   newDBF->panFieldOffset = (int *) malloc ( sizeof(int) * psDBF->nFields );
-   memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
-   newDBF->panFieldSize = (int *) malloc ( sizeof(int) * psDBF->nFields );
-   memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
-   newDBF->panFieldDecimals = (int *) malloc ( sizeof(int) * psDBF->nFields );
-   memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
-   newDBF->pachFieldType = (char *) malloc ( sizeof(int) * psDBF->nFields );
-   memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(int) * psDBF->nFields );
-
-   newDBF->bNoHeader = TRUE;
-   newDBF->bUpdated = TRUE;
-
-   ossim_DBFWriteHeader ( newDBF );
-   ossim_DBFClose ( newDBF );
-
-   newDBF = ossim_DBFOpen ( pszFilename, "rb+" );
-
-   return ( newDBF );
-}
-
-/************************************************************************/
-/*                       ossim_DBFGetNativeFieldType()                        */
-/*                                                                      */
-/*      Return the DBase field type for the specified field.            */
-/*                                                                      */
-/*      Value can be one of: 'C' (String), 'D' (Date), 'F' (Float),     */
-/*                           'N' (Numeric, with or without decimal),    */
-/*                           'L' (Logical),                             */
-/*                           'M' (Memo: 10 digits .DBT block ptr)       */
-/************************************************************************/
-
-char ossim_SHPAPI_CALL
-    ossim_DBFGetNativeFieldType( ossim_DBFHandle psDBF, int iField )
-
-{
-    if( iField >=0 && iField < psDBF->nFields )
-        return psDBF->pachFieldType[iField];
-
-    return  ' ';
-}
-
-/************************************************************************/
-/*                            str_to_upper()                            */
-/************************************************************************/
-
-static void str_to_upper (char *string)
-{
-    int len;
-    short i = -1;
-
-    len = strlen (string);
-
-    while (++i < len)
-        if (isalpha(string[i]) && islower(string[i]))
-            string[i] = (char) toupper ((int)string[i]);
-}
-
-/************************************************************************/
-/*                          ossim_DBFGetFieldIndex()                          */
-/*                                                                      */
-/*      Get the index number for a field in a .dbf file.                */
-/*                                                                      */
-/*      Contributed by Jim Matthews.                                    */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_DBFGetFieldIndex(ossim_DBFHandle psDBF, const char *pszFieldName)
-
-{
-    char          name[12], name1[12], name2[12];
-    int           i;
-
-    strncpy(name1, pszFieldName,11);
-    name1[11] = '\0';
-    str_to_upper(name1);
-
-    for( i = 0; i < ossim_DBFGetFieldCount(psDBF); i++ )
-    {
-        ossim_DBFGetFieldInfo( psDBF, i, name, NULL, NULL );
-        strncpy(name2,name,11);
-        str_to_upper(name2);
-
-        if(!strncmp(name1,name2,10))
-            return(i);
-    }
-    return(-1);
-}
diff --git a/Utilities/otbossim/src/ossim/vec/ossimShapeDatabase.cpp b/Utilities/otbossim/src/ossim/vec/ossimShapeDatabase.cpp
deleted file mode 100644
index 5ed5a2831d8eeb4d4ea27570ef3b3675f7cfd212..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/vec/ossimShapeDatabase.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-
-#include <iomanip>
-
-#include <ossim/vec/ossimShapeDatabase.h>
-#include <ossim/vec/ossimShapeFile.h>
-
-
-
-ossimString ossimShapeDatabaseField::fieldTypeAsString()const
-{
-   switch(theFieldType)
-   {
-   case FTString:
-   {
-      return "String";
-   }
-   case FTInteger:
-   {
-      return "Integer";
-   }
-   case FTDouble:
-   {
-      return "Double";
-   }
-   default:
-   {
-      return "Unknown";
-   }
-   };
-
-   return "";
-   
-}
-
-
-ossim_int32 ossimShapeDatabaseRecord::getFieldIdx(const ossimString& name,
-                                                  bool caseInsensitive)const
-{
-   ossimString searchString = name;
-   if(caseInsensitive) searchString = searchString.downcase();
-   ossim_int32 idx = 0;
-   for(idx = 0; idx < (int)theFieldArray.size(); ++idx)
-   {
-      if(caseInsensitive)
-      {
-         if(ossimString(theFieldArray[idx].theName).downcase() == searchString)
-         {
-            return idx;
-         }
-      }
-      else
-      {
-         if(theFieldArray[idx].theName == searchString)
-         {
-            return idx;
-         }
-      }
-   }
-   return -1;
-}
-
-ossimShapeDatabase::ossimShapeDatabase()
-   :theHandle(NULL),
-    theFilename("")
-{
-   theRecordNumber = -1;
-}
-
-ossimShapeDatabase::~ossimShapeDatabase()
-{
-   close();
-}
-
-bool ossimShapeDatabase::open(const ossimFilename& file,
-                              const ossimString& flags)
-{
-   if(isOpen()) close();
-
-   theHandle = ossim_DBFOpen(file.c_str(), flags.c_str());
-   if(theHandle)
-   {
-      theFilename = file;
-      theRecordNumber = -1;
-   }
-
-   return (theHandle != NULL);
-}
-
-void ossimShapeDatabase::close()
-{
-   if(isOpen())
-   {
-      ossim_DBFClose(theHandle);
-      theHandle = NULL;
-      theRecordNumber = -1;
-   }
-}
-int ossimShapeDatabase::getNumberOfRecords()const
-{
-   if(isOpen())
-   {
-      return theHandle->nRecords;
-   }
-
-   return 0;
-}
-bool ossimShapeDatabase::getRecord(ossimShapeDatabaseRecord& result)
-{
-   if(isOpen()&&( (theRecordNumber < theHandle->nRecords) ))
-   {
-      if(result.getNumberOfFields() != theHandle->nFields)
-      {
-         result.setNumberOfFields(theHandle->nFields);
-      }
-      
-      char name[1024] = {'\0'};
-      int width       = 0;
-      int decimals    = 0;
-      int iField      = 0;
-      std::vector<int>         fieldWidths;
-      
-      for(iField = 0; iField < theHandle->nFields; ++iField)
-      {   
-         ossim_DBFFieldType fieldType = ossim_DBFGetFieldInfo(theHandle,
-                                                  iField,
-                                                  name,
-                                                  &width,
-                                                  &decimals);
-         ossimShapeDatabaseField field;
-         field.theName = name;
-         field.theWidth = width;
-         field.theDecimals = decimals;
-         field.theFieldType = fieldType;
-            
-         ossimString key = "field";
-         key+=ossimString::toString(iField+1);
-         key+=(ossimString(".")+name+":");
-         
-         switch(fieldType)
-         {
-         case FTString:
-         {
-            field.theValue = ossim_DBFReadStringAttribute(theHandle, theRecordNumber, iField);
-            break;
-         }
-         case FTInteger:
-         {
-            field.theValue = ossimString::toString(ossim_DBFReadIntegerAttribute(theHandle, theRecordNumber, iField));
-            break;
-         }
-         case FTDouble:
-         {
-            field.theValue = ossimString::toString(ossim_DBFReadDoubleAttribute(theHandle, theRecordNumber, iField));
-            break;
-         }
-		 case FTLogical:
-		 {
-			 break;
-		 }
-		 case FTInvalid:
-		 {
-			 break;
-		 }
-         }
-
-         result.setField(field,
-                         iField);
-      }
-      return true;
-   }
-
-   return false;
-}
-
-void ossimShapeDatabase::print(std::ostream& out)const
-{
-   if(isOpen())
-   {
-      out << std::setw(15)<<setiosflags(std::ios::left)
-          <<"DB filename:" << theFilename << std::endl
-          << std::setw(15)<<setiosflags(std::ios::left)
-          <<"records:" << theHandle->nRecords << std::endl
-          << std::setw(15)<<setiosflags(std::ios::left)
-          <<"fields:" << theHandle->nFields << std::endl;
-
-      char name[1024] = {'\0'};
-      int width       = 0;
-      int decimals    = 0;
-      int iField      = 0;
-      std::vector<int>         fieldWidths;
-
-      
-      for(iField = 0; iField < theHandle->nFields; ++iField)
-      {
-         ossim_DBFFieldType fieldType = ossim_DBFGetFieldInfo(theHandle,
-                                                  iField,
-                                                  name,
-                                                  &width,
-                                                  &decimals);
-         ossimString s = "field " + ossimString::toString(iField+1) + " name:";
-         switch(fieldType)
-         {
-         case FTString:
-         case FTInteger:
-         case FTDouble:
-         {
-            out << std::setw(15) << setiosflags(std::ios::left) << s.c_str() << name << std::endl;
-            break;
-         }
-         default:
-         {
-            out << std::setw(15) << setiosflags(std::ios::left) << s.c_str() << "INVALID"<<std::endl;
-            break;
-         }
-         }
-      }
-      for(int iShape = 0; iShape < theHandle->nRecords; ++iShape)
-      {
-         for(iField = 0; iField < theHandle->nFields; ++iField)
-         {   
-            ossim_DBFFieldType fieldType = ossim_DBFGetFieldInfo(theHandle,
-                                                     iField,
-                                                     name,
-                                                     &width,
-                                                     &decimals);
-            
-            ossimString key = "field";
-            key+=ossimString::toString(iField+1);
-            key+=(ossimString(".")+name+":");
-            
-            switch(fieldType)
-            {
-            case FTString:
-            {
-               
-               out << std::setw(25) << setiosflags(std::ios::left) << key.c_str()
-                   << ossim_DBFReadStringAttribute(theHandle, iShape, iField) <<std::endl;
-               
-               break;
-            }
-            case FTInteger:
-            {
-               out << std::setw(25) << setiosflags(std::ios::left) << key.c_str()
-                   << ossim_DBFReadIntegerAttribute(theHandle, iShape, iField) << std::endl;
-               
-               break;
-            }
-            case FTDouble:
-            {
-               out << std::setw(25) << setiosflags(std::ios::left) << key.c_str()
-                   << ossim_DBFReadDoubleAttribute(theHandle, iShape, iField) << std::endl;
-               
-               break;
-            }
-			case FTLogical:
-			{
-				break;
-			}
-			case FTInvalid:
-			{
-				break;
-			}
-            }
-         }
-         out << "_________________________________"<<std::endl;
-      }
-   }
-}
diff --git a/Utilities/otbossim/src/ossim/vec/ossimShapeFile.cpp b/Utilities/otbossim/src/ossim/vec/ossimShapeFile.cpp
deleted file mode 100644
index 2b15932ea2d9e84bdbb2439003f807f453d1e87a..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/vec/ossimShapeFile.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-//*******************************************************************
-// License:  See top level LICENSE.txt file.
-//
-// Author: Garrett Potts
-// 
-// Description: This class extends the stl's string class.
-//
-//********************************************************************
-// $Id: ossimShapeFile.cpp 9963 2006-11-28 21:11:01Z gpotts $
-//
-
-#include <iomanip>
-#include <ossim/vec/ossimShapeFile.h>
-
-
-
-std::ostream& operator<<(std::ostream& out,
-                    const ossimShapeObject& rhs)
-{
-   if(rhs.isLoaded())
-   {
-      double minx, miny, minz, minm;
-      double maxx, maxy, maxz, maxm;
-      ossim_uint32 i = 0;
-      
-      rhs.getBounds(minx, miny, minz, minm,
-                    maxx, maxy, maxz, maxm);
-      
-      out << std::setw(15) << setiosflags(std::ios::left)<<"type:"<<rhs.getTypeByName() << std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"id:"<<rhs.getId()<<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"minx:"<<minx <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"miny:"<<miny <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"minz:"<<minz <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"minm:"<<minm <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"maxx:"<<maxx <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"maxy:"<<maxy <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"maxz:"<<maxz <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"maxm:"<<maxm <<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"parts:"<<rhs.getNumberOfParts()<<std::endl
-          << std::setw(15) << setiosflags(std::ios::left)<<"vertices:"<<rhs.getNumberOfVertices();
-
-      if(rhs.getNumberOfParts())
-      {
-         out << std::endl;
-         for(i = 0; i < rhs.getNumberOfParts()-1; ++i)
-         {
-            ossimString s1 = "part start ";
-            ossimString s2 = "part type ";
-            s1 += (ossimString::toString(i+1)+":");
-            s2 += (ossimString::toString(i+1)+":");
-            
-            out << std::setw(15) << setiosflags(std::ios::left) << s1.c_str() << rhs.theShape->panPartStart[i]<<std::endl;
-            out << std::setw(15) << setiosflags(std::ios::left) << s2.c_str() <<  ossim_SHPPartTypeName(rhs.theShape->panPartType[i])<<std::endl;
-         }
-         ossimString s1 = "part start ";
-         ossimString s2 = "part type ";
-         
-         s1 += (ossimString::toString(rhs.getNumberOfParts())+":");
-         out << std::setw(15) << setiosflags(std::ios::left) << s1.c_str() <<  rhs.theShape->panPartStart[i]<<std::endl;
-         out << std::setw(15) << setiosflags(std::ios::left) << s2.c_str() <<  ossim_SHPPartTypeName(rhs.theShape->panPartType[i]);
-      }
-
-      out << std::setw(0);
-      
-   }
-   return out;   
-}
-
-void ossimShapeObject::getBoundingRect(ossimDrect& result,
-                                       ossimCoordSysOrientMode orient)const
-{
-   double minx, miny, maxx, maxy;
-
-   if(theShape)
-   {
-      getBounds(minx, miny, maxx, maxy);
-      
-      if(orient == OSSIM_RIGHT_HANDED)
-      {
-         result = ossimDrect(minx, maxy, maxx, miny, orient);
-      }
-      else
-      {
-         result = ossimDrect(minx, miny, maxx, maxy, orient);         
-      }
-   }
-   else
-   {
-      result = ossimDrect(0,0,0,0,orient);
-      result.makeNan();
-   }
-}
-
-void ossimShapeObject::setShape(ossim_SHPObject* obj)
-{
-   if(theShape)
-   {
-      ossim_SHPDestroyObject(theShape);
-      theShape = NULL;            
-   }
-   
-   theShape = obj;
-}
-
-bool ossimShapeObject::loadShape(const ossimShapeFile& shapeFile,
-                                 long shapeRecord)
-{
-   if(theShape)
-   {
-      ossim_SHPDestroyObject(theShape);
-      theShape = NULL;            
-   }
-   if(shapeFile.isOpen())
-   {
-      theShape = ossim_SHPReadObject(shapeFile.getHandle(),
-                               shapeRecord);
-      theIndex = shapeRecord;
-   }
-   else
-   {
-      theIndex = -1;
-   }
-   return (theShape != (ossim_SHPObject*)NULL);
-}
-
-
-ossimShapeFile::ossimShapeFile()
-   :theHandle(NULL)
-{
-}
-
-ossimShapeFile::~ossimShapeFile()
-{
-   close();
-}
-
-void ossimShapeFile::close()
-{
-   if(theHandle)
-   {
-      ossim_SHPClose(theHandle);
-      theHandle = NULL;
-   }
-}
-
-bool ossimShapeFile::open(const ossimFilename& file,
-                          const ossimString& flags)
-{
-   if(isOpen()) close();
-   
-   theHandle = ossim_SHPOpen( file.c_str(),
-                        flags.c_str());
-   if(isOpen())
-   {
-      theFilename = file;
-   }
-   
-   return (theHandle != NULL);
-}
-
-
-
-void ossimShapeFile::print(std::ostream& out)const
-{
-   if(isOpen())
-   {
-      out << std::setw(15) << setiosflags(std::ios::left)<<"Shp filename:" << theFilename << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"Record count:" << theHandle->nRecords << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"File type:" << getShapeTypeString().c_str() << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"minx:" << theHandle->adBoundsMin[0] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"miny:" << theHandle->adBoundsMin[1] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"minz:" << theHandle->adBoundsMin[2] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"minm:" << theHandle->adBoundsMin[3] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"maxx:" << theHandle->adBoundsMax[0] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"maxy:" << theHandle->adBoundsMax[1] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"maxz:" << theHandle->adBoundsMax[2] << std::endl;
-      out << std::setw(15) << setiosflags(std::ios::left)<<"maxm:" << theHandle->adBoundsMax[3] << std::endl;
-
-      ossimShapeObject shape;
-
-      if(theHandle->nRecords)
-      {
-         out << std::setw(30) << std::setfill('_') << "" << std::setfill(' ')<<std::endl;
-      }
-      for(int i=0; i < theHandle->nRecords; ++i)
-      {
-         if(shape.loadShape(*this, i))
-         {
-            out << shape << std::endl;
-            out << std::setw(30) << std::setfill('_') << ""<<std::setfill(' ')<<std::endl;
-         }
-      }
-   }
-}
-
-
-ossimString ossimShapeFile::getShapeTypeString()const
-{
-   if(theHandle)
-   {
-      return ossim_SHPTypeName(theHandle->nShapeType);
-   }
-   return "";
-}
-
-void ossimShapeFile::getBoundingRect(ossimDrect& result,
-                                     ossimCoordSysOrientMode orient)const
-{
-   double minx, miny, maxx, maxy;
-   
-   getBounds(minx, miny, maxx, maxy);
-   if(orient == OSSIM_RIGHT_HANDED)
-   {
-      result = ossimDrect(minx, maxy, maxx, miny, orient);
-   }
-   else
-   {
-      result = ossimDrect(minx, miny, maxx, maxy, orient);         
-   }
-}
diff --git a/Utilities/otbossim/src/ossim/vec/ossimVpfDatabaseHeader.cpp b/Utilities/otbossim/src/ossim/vec/ossimVpfDatabaseHeader.cpp
index 70ac7b1408592589e8a7ce7d64ce9cdca85ee10e..4c90fe290754a9e9b7c8451c4ab568cd8289f4a6 100644
--- a/Utilities/otbossim/src/ossim/vec/ossimVpfDatabaseHeader.cpp
+++ b/Utilities/otbossim/src/ossim/vec/ossimVpfDatabaseHeader.cpp
@@ -6,7 +6,7 @@
 // Description: This class extends the stl's string class.
 //
 //********************************************************************
-// $Id: ossimVpfDatabaseHeader.cpp 9963 2006-11-28 21:11:01Z gpotts $
+// $Id: ossimVpfDatabaseHeader.cpp 13296 2008-07-25 17:51:10Z dburken $
 #include <ossim/vec/ossimVpfDatabaseHeader.h>
 #include <ossim/base/ossimErrorCodes.h>
 #include <ossim/vpfutil/vpftable.h>
@@ -23,9 +23,9 @@ ossimErrorCode ossimVpfDatabaseHeader::open(const ossimFilename& databaseHeaderT
 {
    vpf_table_type tableTypeData;
 
-   if(is_vpf_table(const_cast<char*>(databaseHeaderTable.c_str())))
+   if( is_vpf_table( databaseHeaderTable.c_str() ) )
    {
-      tableTypeData = vpf_open_table(const_cast<char*>(databaseHeaderTable.c_str()),
+      tableTypeData = vpf_open_table(databaseHeaderTable.c_str(),
                                      (storage_type)DISK,
                                      "rb",
                                      NULL);
diff --git a/Utilities/otbossim/src/ossim/vec/shpopen.c b/Utilities/otbossim/src/ossim/vec/shpopen.c
deleted file mode 100644
index a8aa5a1e10ea45fbbe4da9379995fe7e23ffd34a..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/vec/shpopen.c
+++ /dev/null
@@ -1,2021 +0,0 @@
-/******************************************************************************
- * $Id: shpopen.c 9094 2006-06-13 19:12:40Z dburken $
- *
- * Project:  Shapelib
- * Purpose:  Implementation of core Shapefile read/write functions.
- * Author:   Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, 2001, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log$
- * Revision 1.6  2006/06/13 19:11:33  dburken
- * Global include path change.
- *
- * Revision 1.5  2005/10/08 12:57:26  gpotts
- * Added adiitional patches
- *
- * Revision 1.46  2005/02/11 17:17:46  fwarmerdam
- * added panPartStart[0] validation
- *
- * Revision 1.45  2004/09/26 20:09:48  fwarmerdam
- * const correctness changes
- *
- * Revision 1.44  2003/12/29 00:18:39  fwarmerdam
- * added error checking for failed IO and optional CPL error reporting
- *
- * Revision 1.43  2003/12/01 16:20:08  warmerda
- * be careful of zero vertex shapes
- *
- * Revision 1.42  2003/12/01 14:58:27  warmerda
- * added degenerate object check in ossim_SHPRewindObject()
- *
- * Revision 1.41  2003/07/08 15:22:43  warmerda
- * avoid warning
- *
- * Revision 1.40  2003/04/21 18:30:37  warmerda
- * added header write/update public methods
- *
- * Revision 1.39  2002/08/26 06:46:56  warmerda
- * avoid c++ comments
- *
- * Revision 1.38  2002/05/07 16:43:39  warmerda
- * Removed debugging printf.
- *
- * Revision 1.37  2002/04/10 17:35:22  warmerda
- * fixed bug in ring reversal code
- *
- * Revision 1.36  2002/04/10 16:59:54  warmerda
- * added ossim_SHPRewindObject
- *
- * Revision 1.35  2001/12/07 15:10:44  warmerda
- * fix if .shx fails to open
- *
- * Revision 1.34  2001/11/01 16:29:55  warmerda
- * move pabyRec into ossim_SHPInfo for thread safety
- *
- * Revision 1.33  2001/07/03 12:18:15  warmerda
- * Improved cleanup if SHX not found, provied by Riccardo Cohen.
- *
- * Revision 1.32  2001/06/22 01:58:07  warmerda
- * be more careful about establishing initial bounds in face of NULL shapes
- *
- * Revision 1.31  2001/05/31 19:35:29  warmerda
- * added support for writing null shapes
- *
- * Revision 1.30  2001/05/28 12:46:29  warmerda
- * Add some checking on reasonableness of record count when opening.
- *
- * Revision 1.29  2001/05/23 13:36:52  warmerda
- * added use of ossim_SHPAPI_CALL
- *
- * Revision 1.28  2001/02/06 22:25:06  warmerda
- * fixed memory leaks when ossim_SHPOpen() fails
- *
- * Revision 1.27  2000/07/18 15:21:33  warmerda
- * added better enforcement of -1 for append in ossim_SHPWriteObject
- *
- * Revision 1.26  2000/02/16 16:03:51  warmerda
- * added null shape support
- *
- * Revision 1.25  1999/12/15 13:47:07  warmerda
- * Fixed record size settings in .shp file (was 4 words too long)
- * Added stdlib.h.
- *
- * Revision 1.24  1999/11/05 14:12:04  warmerda
- * updated license terms
- *
- * Revision 1.23  1999/07/27 00:53:46  warmerda
- * added support for rewriting shapes
- *
- * Revision 1.22  1999/06/11 19:19:11  warmerda
- * Cleanup pabyRec static buffer on ossim_SHPClose().
- *
- * Revision 1.21  1999/06/02 14:57:56  kshih
- * Remove unused variables
- *
- * Revision 1.20  1999/04/19 21:04:17  warmerda
- * Fixed syntax error.
- *
- * Revision 1.19  1999/04/19 21:01:57  warmerda
- * Force access string to binary in ossim_SHPOpen().
- *
- * Revision 1.18  1999/04/01 18:48:07  warmerda
- * Try upper case extensions if lower case doesn't work.
- *
- * Revision 1.17  1998/12/31 15:29:39  warmerda
- * Disable writing measure values to multipatch objects if
- * DISABLE_MULTIPATCH_MEASURE is defined.
- *
- * Revision 1.16  1998/12/16 05:14:33  warmerda
- * Added support to write MULTIPATCH.  Fixed reading Z coordinate of
- * MULTIPATCH. Fixed record size written for all feature types.
- *
- * Revision 1.15  1998/12/03 16:35:29  warmerda
- * r+b is proper binary access string, not rb+.
- *
- * Revision 1.14  1998/12/03 15:47:56  warmerda
- * Fixed setting of nVertices in ossim_SHPCreateObject().
- *
- * Revision 1.13  1998/12/03 15:33:54  warmerda
- * Made ossim_SHPCalculateExtents() separately callable.
- *
- * Revision 1.12  1998/11/11 20:01:50  warmerda
- * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
- *
- * Revision 1.11  1998/11/09 20:56:44  warmerda
- * Fixed up handling of file wide bounds.
- *
- * Revision 1.10  1998/11/09 20:18:51  warmerda
- * Converted to support 3D shapefiles, and use of ossim_SHPObject.
- *
- * Revision 1.9  1998/02/24 15:09:05  warmerda
- * Fixed memory leak.
- *
- * Revision 1.8  1997/12/04 15:40:29  warmerda
- * Fixed byte swapping of record number, and record length fields in the
- * .shp file.
- *
- * Revision 1.7  1995/10/21 03:15:58  warmerda
- * Added support for binary file access, the magic cookie 9997
- * and tried to improve the int32 selection logic for 16bit systems.
- *
- * Revision 1.6  1995/09/04  04:19:41  warmerda
- * Added fix for file bounds.
- *
- * Revision 1.5  1995/08/25  15:16:44  warmerda
- * Fixed a couple of problems with big endian systems ... one with bounds
- * and the other with multipart polygons.
- *
- * Revision 1.4  1995/08/24  18:10:17  warmerda
- * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc()
- * functions (such as on the Sun).
- *
- * Revision 1.3  1995/08/23  02:23:15  warmerda
- * Added support for reading bounds, and fixed up problems in setting the
- * file wide bounds.
- *
- * Revision 1.2  1995/08/04  03:16:57  warmerda
- * Added header.
- *
- */
-
-#include <ossim/vec/shapefil.h>
-
-#include <math.h>
-#include <limits.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-ossim_SHP_CVSID("$Id: shpopen.c 9094 2006-06-13 19:12:40Z dburken $")
-
-typedef unsigned char uchar;
-
-#if UINT_MAX == 65535
-typedef long	      int32;
-#else
-typedef int	      int32;
-#endif
-
-#ifndef FALSE
-#  define FALSE		0
-#  define TRUE		1
-#endif
-
-#define ByteCopy( a, b, c )	memcpy( b, a, c )
-#ifndef MAX
-#  define MIN(a,b)      ((a<b) ? a : b)
-#  define MAX(a,b)      ((a>b) ? a : b)
-#endif
-
-static int 	bBigEndian;
-
-
-/************************************************************************/
-/*                              SwapWord()                              */
-/*                                                                      */
-/*      Swap a 2, 4 or 8 byte word.                                     */
-/************************************************************************/
-
-static void	SwapWord( int length, void * wordP )
-
-{
-    int		i;
-    uchar	temp;
-
-    for( i=0; i < length/2; i++ )
-    {
-	temp = ((uchar *) wordP)[i];
-	((uchar *)wordP)[i] = ((uchar *) wordP)[length-i-1];
-	((uchar *) wordP)[length-i-1] = temp;
-    }
-}
-
-/************************************************************************/
-/*                             SfRealloc()                              */
-/*                                                                      */
-/*      A realloc cover function that will access a NULL pointer as     */
-/*      a valid input.                                                  */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
-    if( pMem == NULL )
-        return( (void *) malloc(nNewSize) );
-    else
-        return( (void *) realloc(pMem,nNewSize) );
-}
-
-/************************************************************************/
-/*                          ossim_SHPWriteHeader()                            */
-/*                                                                      */
-/*      Write out a header for the .shp and .shx files as well as the	*/
-/*	contents of the index (.shx) file.				*/
-/************************************************************************/
-
-void ossim_SHPWriteHeader( ossim_SHPHandle psSHP )
-
-{
-    uchar     	abyHeader[100];
-    int		i;
-    int32	i32;
-    double	dValue;
-    int32	*panSHX;
-
-/* -------------------------------------------------------------------- */
-/*      Prepare header block for .shp file.                             */
-/* -------------------------------------------------------------------- */
-    for( i = 0; i < 100; i++ )
-      abyHeader[i] = 0;
-
-    abyHeader[2] = 0x27;				/* magic cookie */
-    abyHeader[3] = 0x0a;
-
-    i32 = psSHP->nFileSize/2;				/* file size */
-    ByteCopy( &i32, abyHeader+24, 4 );
-    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
-    i32 = 1000;						/* version */
-    ByteCopy( &i32, abyHeader+28, 4 );
-    if( bBigEndian ) SwapWord( 4, abyHeader+28 );
-
-    i32 = psSHP->nShapeType;				/* shape type */
-    ByteCopy( &i32, abyHeader+32, 4 );
-    if( bBigEndian ) SwapWord( 4, abyHeader+32 );
-
-    dValue = psSHP->adBoundsMin[0];			/* set bounds */
-    ByteCopy( &dValue, abyHeader+36, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+36 );
-
-    dValue = psSHP->adBoundsMin[1];
-    ByteCopy( &dValue, abyHeader+44, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+44 );
-
-    dValue = psSHP->adBoundsMax[0];
-    ByteCopy( &dValue, abyHeader+52, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+52 );
-
-    dValue = psSHP->adBoundsMax[1];
-    ByteCopy( &dValue, abyHeader+60, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+60 );
-
-    dValue = psSHP->adBoundsMin[2];			/* z */
-    ByteCopy( &dValue, abyHeader+68, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+68 );
-
-    dValue = psSHP->adBoundsMax[2];
-    ByteCopy( &dValue, abyHeader+76, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+76 );
-
-    dValue = psSHP->adBoundsMin[3];			/* m */
-    ByteCopy( &dValue, abyHeader+84, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+84 );
-
-    dValue = psSHP->adBoundsMax[3];
-    ByteCopy( &dValue, abyHeader+92, 8 );
-    if( bBigEndian ) SwapWord( 8, abyHeader+92 );
-
-/* -------------------------------------------------------------------- */
-/*      Write .shp file header.                                         */
-/* -------------------------------------------------------------------- */
-    if( fseek( psSHP->fpSHP, 0, 0 ) != 0
-        || fwrite( abyHeader, 100, 1, psSHP->fpSHP ) != 1 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_OpenFailed,
-                  "Failure writing .shp header." );
-#endif
-        return;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Prepare, and write .shx file header.                            */
-/* -------------------------------------------------------------------- */
-    i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100)/2;   /* file size */
-    ByteCopy( &i32, abyHeader+24, 4 );
-    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
-    if( fseek( psSHP->fpSHX, 0, 0 ) != 0
-        || fwrite( abyHeader, 100, 1, psSHP->fpSHX ) != 1 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_OpenFailed,
-                  "Failure writing .shx header." );
-#endif
-        return;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Write out the .shx contents.                                    */
-/* -------------------------------------------------------------------- */
-    panSHX = (int32 *) malloc(sizeof(int32) * 2 * psSHP->nRecords);
-
-    for( i = 0; i < psSHP->nRecords; i++ )
-    {
-	panSHX[i*2  ] = psSHP->panRecOffset[i]/2;
-	panSHX[i*2+1] = psSHP->panRecSize[i]/2;
-	if( !bBigEndian ) SwapWord( 4, panSHX+i*2 );
-	if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 );
-    }
-
-    if( (int)fwrite( panSHX, sizeof(int32)*2, psSHP->nRecords, psSHP->fpSHX )
-        != psSHP->nRecords )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_OpenFailed,
-                  "Failure writing .shx contents." );
-#endif
-    }
-
-    free( panSHX );
-
-/* -------------------------------------------------------------------- */
-/*      Flush to disk.                                                  */
-/* -------------------------------------------------------------------- */
-    fflush( psSHP->fpSHP );
-    fflush( psSHP->fpSHX );
-}
-
-/************************************************************************/
-/*                              shpopen()                               */
-/*                                                                      */
-/*      Open the .shp and .shx files based on the basename of the       */
-/*      files or either file name.                                      */
-/************************************************************************/
-
-ossim_SHPHandle ossim_SHPAPI_CALL
-    ossim_SHPOpen( const char * pszLayer, const char * pszAccess )
-
-{
-    char		*pszFullname, *pszBasename;
-    ossim_SHPHandle		psSHP;
-
-    uchar		*pabyBuf;
-    int			i;
-    double		dValue;
-
-/* -------------------------------------------------------------------- */
-/*      Ensure the access string is one of the legal ones.  We          */
-/*      ensure the result string indicates binary to avoid common       */
-/*      problems on Windows.                                            */
-/* -------------------------------------------------------------------- */
-    if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0
-        || strcmp(pszAccess,"r+") == 0 )
-        pszAccess = "r+b";
-    else
-        pszAccess = "rb";
-
-/* -------------------------------------------------------------------- */
-/*	Establish the byte order on this machine.			*/
-/* -------------------------------------------------------------------- */
-    i = 1;
-    if( *((uchar *) &i) == 1 )
-        bBigEndian = FALSE;
-    else
-        bBigEndian = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*	Initialize the info structure.					*/
-/* -------------------------------------------------------------------- */
-    psSHP = (ossim_SHPHandle) calloc(sizeof(ossim_SHPInfo),1);
-
-    psSHP->bUpdated = FALSE;
-
-/* -------------------------------------------------------------------- */
-/*	Compute the base (layer) name.  If there is any extension	*/
-/*	on the passed in filename we will strip it off.			*/
-/* -------------------------------------------------------------------- */
-    pszBasename = (char *) malloc(strlen(pszLayer)+5);
-    strcpy( pszBasename, pszLayer );
-    for( i = strlen(pszBasename)-1;
-	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
-	       && pszBasename[i] != '\\';
-	 i-- ) {}
-
-    if( pszBasename[i] == '.' )
-        pszBasename[i] = '\0';
-
-/* -------------------------------------------------------------------- */
-/*	Open the .shp and .shx files.  Note that files pulled from	*/
-/*	a PC to Unix with upper case filenames won't work!		*/
-/* -------------------------------------------------------------------- */
-    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
-    sprintf( pszFullname, "%s.shp", pszBasename );
-    psSHP->fpSHP = fopen(pszFullname, pszAccess );
-    if( psSHP->fpSHP == NULL )
-    {
-        sprintf( pszFullname, "%s.SHP", pszBasename );
-        psSHP->fpSHP = fopen(pszFullname, pszAccess );
-    }
-
-    if( psSHP->fpSHP == NULL )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_OpenFailed,
-                  "Unable to open %s.shp or %s.SHP.",
-                  pszBasename, pszBasename );
-#endif
-        free( psSHP );
-        free( pszBasename );
-        free( pszFullname );
-        return( NULL );
-    }
-
-    sprintf( pszFullname, "%s.shx", pszBasename );
-    psSHP->fpSHX = fopen(pszFullname, pszAccess );
-    if( psSHP->fpSHX == NULL )
-    {
-        sprintf( pszFullname, "%s.SHX", pszBasename );
-        psSHP->fpSHX = fopen(pszFullname, pszAccess );
-    }
-
-    if( psSHP->fpSHX == NULL )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_OpenFailed,
-                  "Unable to open %s.shx or %s.SHX.",
-                  pszBasename, pszBasename );
-#endif
-        fclose( psSHP->fpSHP );
-        free( psSHP );
-        free( pszBasename );
-        free( pszFullname );
-        return( NULL );
-    }
-
-    free( pszFullname );
-    free( pszBasename );
-
-/* -------------------------------------------------------------------- */
-/*  Read the file size from the ossim_SHP file.				*/
-/* -------------------------------------------------------------------- */
-    pabyBuf = (uchar *) malloc(100);
-    fread( pabyBuf, 100, 1, psSHP->fpSHP );
-
-    psSHP->nFileSize = (pabyBuf[24] * 256 * 256 * 256
-			+ pabyBuf[25] * 256 * 256
-			+ pabyBuf[26] * 256
-			+ pabyBuf[27]) * 2;
-
-/* -------------------------------------------------------------------- */
-/*  Read SHX file Header info                                           */
-/* -------------------------------------------------------------------- */
-    if( fread( pabyBuf, 100, 1, psSHP->fpSHX ) != 1
-        || pabyBuf[0] != 0
-        || pabyBuf[1] != 0
-        || pabyBuf[2] != 0x27
-        || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  ".shx file is unreadable, or corrupt." );
-#endif
-	fclose( psSHP->fpSHP );
-	fclose( psSHP->fpSHX );
-	free( psSHP );
-
-	return( NULL );
-    }
-
-    psSHP->nRecords = pabyBuf[27] + pabyBuf[26] * 256
-      + pabyBuf[25] * 256 * 256 + pabyBuf[24] * 256 * 256 * 256;
-    psSHP->nRecords = (psSHP->nRecords*2 - 100) / 8;
-
-    psSHP->nShapeType = pabyBuf[32];
-
-    if( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Record count in .shp header is %d, which seems\n"
-                  "unreasonable.  Assuming header is corrupt.",
-                  psSHP->nRecords );
-#endif
-	fclose( psSHP->fpSHP );
-	fclose( psSHP->fpSHX );
-	free( psSHP );
-
-	return( NULL );
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Read the bounds.                                                */
-/* -------------------------------------------------------------------- */
-    if( bBigEndian ) SwapWord( 8, pabyBuf+36 );
-    memcpy( &dValue, pabyBuf+36, 8 );
-    psSHP->adBoundsMin[0] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+44 );
-    memcpy( &dValue, pabyBuf+44, 8 );
-    psSHP->adBoundsMin[1] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+52 );
-    memcpy( &dValue, pabyBuf+52, 8 );
-    psSHP->adBoundsMax[0] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+60 );
-    memcpy( &dValue, pabyBuf+60, 8 );
-    psSHP->adBoundsMax[1] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+68 );		/* z */
-    memcpy( &dValue, pabyBuf+68, 8 );
-    psSHP->adBoundsMin[2] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+76 );
-    memcpy( &dValue, pabyBuf+76, 8 );
-    psSHP->adBoundsMax[2] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+84 );		/* z */
-    memcpy( &dValue, pabyBuf+84, 8 );
-    psSHP->adBoundsMin[3] = dValue;
-
-    if( bBigEndian ) SwapWord( 8, pabyBuf+92 );
-    memcpy( &dValue, pabyBuf+92, 8 );
-    psSHP->adBoundsMax[3] = dValue;
-
-    free( pabyBuf );
-
-/* -------------------------------------------------------------------- */
-/*	Read the .shx file to get the offsets to each record in 	*/
-/*	the .shp file.							*/
-/* -------------------------------------------------------------------- */
-    psSHP->nMaxRecords = psSHP->nRecords;
-
-    psSHP->panRecOffset =
-        (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) );
-    psSHP->panRecSize =
-        (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) );
-
-    pabyBuf = (uchar *) malloc(8 * MAX(1,psSHP->nRecords) );
-    if( (int) fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX )
-			!= psSHP->nRecords )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Failed to read all values for %d records in .shx file.",
-                  psSHP->nRecords );
-#endif
-        /* SHX is short or unreadable for some reason. */
-	fclose( psSHP->fpSHP );
-	fclose( psSHP->fpSHX );
-        free( psSHP->panRecOffset );
-        free( psSHP->panRecSize );
-	free( psSHP );
-
-	return( NULL );
-    }
-
-    for( i = 0; i < psSHP->nRecords; i++ )
-    {
-	int32		nOffset, nLength;
-
-	memcpy( &nOffset, pabyBuf + i * 8, 4 );
-	if( !bBigEndian ) SwapWord( 4, &nOffset );
-
-	memcpy( &nLength, pabyBuf + i * 8 + 4, 4 );
-	if( !bBigEndian ) SwapWord( 4, &nLength );
-
-	psSHP->panRecOffset[i] = nOffset*2;
-	psSHP->panRecSize[i] = nLength*2;
-    }
-    free( pabyBuf );
-
-    return( psSHP );
-}
-
-/************************************************************************/
-/*                              ossim_SHPClose()                              */
-/*								       	*/
-/*	Close the .shp and .shx files.					*/
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPClose(ossim_SHPHandle psSHP )
-
-{
-    if( psSHP == NULL )
-        return;
-
-/* -------------------------------------------------------------------- */
-/*	Update the header if we have modified anything.			*/
-/* -------------------------------------------------------------------- */
-    if( psSHP->bUpdated )
-      ossim_SHPWriteHeader( psSHP );
-
-/* -------------------------------------------------------------------- */
-/*      Free all resources, and close files.                            */
-/* -------------------------------------------------------------------- */
-    free( psSHP->panRecOffset );
-    free( psSHP->panRecSize );
-
-    fclose( psSHP->fpSHX );
-    fclose( psSHP->fpSHP );
-
-    if( psSHP->pabyRec != NULL )
-    {
-        free( psSHP->pabyRec );
-    }
-
-    free( psSHP );
-}
-
-/************************************************************************/
-/*                             ossim_SHPGetInfo()                             */
-/*                                                                      */
-/*      Fetch general information about the shape file.                 */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPGetInfo(ossim_SHPHandle psSHP, int * pnEntities, int * pnShapeType,
-           double * padfMinBound, double * padfMaxBound )
-
-{
-    int		i;
-
-    if( psSHP == NULL )
-        return;
-
-    if( pnEntities != NULL )
-        *pnEntities = psSHP->nRecords;
-
-    if( pnShapeType != NULL )
-        *pnShapeType = psSHP->nShapeType;
-
-    for( i = 0; i < 4; i++ )
-    {
-        if( padfMinBound != NULL )
-            padfMinBound[i] = psSHP->adBoundsMin[i];
-        if( padfMaxBound != NULL )
-            padfMaxBound[i] = psSHP->adBoundsMax[i];
-    }
-}
-
-/************************************************************************/
-/*                             ossim_SHPCreate()                              */
-/*                                                                      */
-/*      Create a new shape file and return a handle to the open         */
-/*      shape file with read/write access.                              */
-/************************************************************************/
-
-ossim_SHPHandle ossim_SHPAPI_CALL
-    ossim_SHPCreate( const char * pszLayer, int nShapeType )
-
-{
-    char	*pszBasename, *pszFullname;
-    int		i;
-    FILE	*fpSHP, *fpSHX;
-    uchar     	abyHeader[100];
-    int32	i32;
-    double	dValue;
-
-/* -------------------------------------------------------------------- */
-/*      Establish the byte order on this system.                        */
-/* -------------------------------------------------------------------- */
-    i = 1;
-    if( *((uchar *) &i) == 1 )
-        bBigEndian = FALSE;
-    else
-        bBigEndian = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*	Compute the base (layer) name.  If there is any extension	*/
-/*	on the passed in filename we will strip it off.			*/
-/* -------------------------------------------------------------------- */
-    pszBasename = (char *) malloc(strlen(pszLayer)+5);
-    strcpy( pszBasename, pszLayer );
-    for( i = strlen(pszBasename)-1;
-	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
-	       && pszBasename[i] != '\\';
-	 i-- ) {}
-
-    if( pszBasename[i] == '.' )
-        pszBasename[i] = '\0';
-
-/* -------------------------------------------------------------------- */
-/*      Open the two files so we can write their headers.               */
-/* -------------------------------------------------------------------- */
-    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
-    sprintf( pszFullname, "%s.shp", pszBasename );
-    fpSHP = fopen(pszFullname, "wb" );
-    if( fpSHP == NULL )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Failed to create file %s.",
-                  pszFullname );
-#endif
-        return( NULL );
-    }
-
-    sprintf( pszFullname, "%s.shx", pszBasename );
-    fpSHX = fopen(pszFullname, "wb" );
-    if( fpSHX == NULL )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Failed to create file %s.",
-                  pszFullname );
-#endif
-        return( NULL );
-    }
-
-    free( pszFullname );
-    free( pszBasename );
-
-/* -------------------------------------------------------------------- */
-/*      Prepare header block for .shp file.                             */
-/* -------------------------------------------------------------------- */
-    for( i = 0; i < 100; i++ )
-      abyHeader[i] = 0;
-
-    abyHeader[2] = 0x27;				/* magic cookie */
-    abyHeader[3] = 0x0a;
-
-    i32 = 50;						/* file size */
-    ByteCopy( &i32, abyHeader+24, 4 );
-    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
-    i32 = 1000;						/* version */
-    ByteCopy( &i32, abyHeader+28, 4 );
-    if( bBigEndian ) SwapWord( 4, abyHeader+28 );
-
-    i32 = nShapeType;					/* shape type */
-    ByteCopy( &i32, abyHeader+32, 4 );
-    if( bBigEndian ) SwapWord( 4, abyHeader+32 );
-
-    dValue = 0.0;					/* set bounds */
-    ByteCopy( &dValue, abyHeader+36, 8 );
-    ByteCopy( &dValue, abyHeader+44, 8 );
-    ByteCopy( &dValue, abyHeader+52, 8 );
-    ByteCopy( &dValue, abyHeader+60, 8 );
-
-/* -------------------------------------------------------------------- */
-/*      Write .shp file header.                                         */
-/* -------------------------------------------------------------------- */
-    if( fwrite( abyHeader, 100, 1, fpSHP ) != 1 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Failed to write .shp header." );
-#endif
-        return NULL;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Prepare, and write .shx file header.                            */
-/* -------------------------------------------------------------------- */
-    i32 = 50;						/* file size */
-    ByteCopy( &i32, abyHeader+24, 4 );
-    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
-    if( fwrite( abyHeader, 100, 1, fpSHX ) != 1 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Failed to write .shx header." );
-#endif
-        return NULL;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Close the files, and then open them as regular existing files.  */
-/* -------------------------------------------------------------------- */
-    fclose( fpSHP );
-    fclose( fpSHX );
-
-    return( ossim_SHPOpen( pszLayer, "r+b" ) );
-}
-
-/************************************************************************/
-/*                           _SHPSetBounds()                            */
-/*                                                                      */
-/*      Compute a bounds rectangle for a shape, and set it into the     */
-/*      indicated location in the record.                               */
-/************************************************************************/
-
-static void	_SHPSetBounds( uchar * pabyRec, ossim_SHPObject * psShape )
-
-{
-    ByteCopy( &(psShape->dfXMin), pabyRec +  0, 8 );
-    ByteCopy( &(psShape->dfYMin), pabyRec +  8, 8 );
-    ByteCopy( &(psShape->dfXMax), pabyRec + 16, 8 );
-    ByteCopy( &(psShape->dfYMax), pabyRec + 24, 8 );
-
-    if( bBigEndian )
-    {
-        SwapWord( 8, pabyRec + 0 );
-        SwapWord( 8, pabyRec + 8 );
-        SwapWord( 8, pabyRec + 16 );
-        SwapWord( 8, pabyRec + 24 );
-    }
-}
-
-/************************************************************************/
-/*                         ossim_SHPComputeExtents()                          */
-/*                                                                      */
-/*      Recompute the extents of a shape.  Automatically done by        */
-/*      ossim_SHPCreateObject().                                              */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPComputeExtents( ossim_SHPObject * psObject )
-
-{
-    int		i;
-
-/* -------------------------------------------------------------------- */
-/*      Build extents for this object.                                  */
-/* -------------------------------------------------------------------- */
-    if( psObject->nVertices > 0 )
-    {
-        psObject->dfXMin = psObject->dfXMax = psObject->padfX[0];
-        psObject->dfYMin = psObject->dfYMax = psObject->padfY[0];
-        psObject->dfZMin = psObject->dfZMax = psObject->padfZ[0];
-        psObject->dfMMin = psObject->dfMMax = psObject->padfM[0];
-    }
-
-    for( i = 0; i < psObject->nVertices; i++ )
-    {
-        psObject->dfXMin = MIN(psObject->dfXMin, psObject->padfX[i]);
-        psObject->dfYMin = MIN(psObject->dfYMin, psObject->padfY[i]);
-        psObject->dfZMin = MIN(psObject->dfZMin, psObject->padfZ[i]);
-        psObject->dfMMin = MIN(psObject->dfMMin, psObject->padfM[i]);
-
-        psObject->dfXMax = MAX(psObject->dfXMax, psObject->padfX[i]);
-        psObject->dfYMax = MAX(psObject->dfYMax, psObject->padfY[i]);
-        psObject->dfZMax = MAX(psObject->dfZMax, psObject->padfZ[i]);
-        psObject->dfMMax = MAX(psObject->dfMMax, psObject->padfM[i]);
-    }
-}
-
-/************************************************************************/
-/*                          ossim_SHPCreateObject()                           */
-/*                                                                      */
-/*      Create a shape object.  It should be freed with                 */
-/*      ossim_SHPDestroyObject().                                             */
-/************************************************************************/
-
-ossim_SHPObject ossim_SHPAPI_CALL1(*)
-    ossim_SHPCreateObject( int nSHPType, int nShapeId, int nParts,
-                 const int * panPartStart, const int * panPartType,
-                 int nVertices, const double *padfX, const double *padfY,
-                 const double * padfZ, const double * padfM )
-
-{
-    ossim_SHPObject	*psObject;
-    int		i, bHasM, bHasZ;
-
-    psObject = (ossim_SHPObject *) calloc(1,sizeof(ossim_SHPObject));
-    psObject->nSHPType = nSHPType;
-    psObject->nShapeId = nShapeId;
-
-/* -------------------------------------------------------------------- */
-/*	Establish whether this shape type has M, and Z values.		*/
-/* -------------------------------------------------------------------- */
-    if( nSHPType == ossim_SHPT_ARCM
-        || nSHPType == ossim_SHPT_POINTM
-        || nSHPType == ossim_SHPT_POLYGONM
-        || nSHPType == ossim_SHPT_MULTIPOINTM )
-    {
-        bHasM = TRUE;
-        bHasZ = FALSE;
-    }
-    else if( nSHPType == ossim_SHPT_ARCZ
-             || nSHPType == ossim_SHPT_POINTZ
-             || nSHPType == ossim_SHPT_POLYGONZ
-             || nSHPType == ossim_SHPT_MULTIPOINTZ
-             || nSHPType == ossim_SHPT_MULTIPATCH )
-    {
-        bHasM = TRUE;
-        bHasZ = TRUE;
-    }
-    else
-    {
-        bHasM = FALSE;
-        bHasZ = FALSE;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Capture parts.  Note that part type is optional, and            */
-/*      defaults to ring.                                               */
-/* -------------------------------------------------------------------- */
-    if( nSHPType == ossim_SHPT_ARC || nSHPType == ossim_SHPT_POLYGON
-        || nSHPType == ossim_SHPT_ARCM || nSHPType == ossim_SHPT_POLYGONM
-        || nSHPType == ossim_SHPT_ARCZ || nSHPType == ossim_SHPT_POLYGONZ
-        || nSHPType == ossim_SHPT_MULTIPATCH )
-    {
-        psObject->nParts = MAX(1,nParts);
-
-        psObject->panPartStart = (int *)
-            malloc(sizeof(int) * psObject->nParts);
-        psObject->panPartType = (int *)
-            malloc(sizeof(int) * psObject->nParts);
-
-        psObject->panPartStart[0] = 0;
-        psObject->panPartType[0] = ossim_SHPP_RING;
-
-        for( i = 0; i < nParts; i++ )
-        {
-            psObject->panPartStart[i] = panPartStart[i];
-
-            if( panPartType != NULL )
-                psObject->panPartType[i] = panPartType[i];
-            else
-                psObject->panPartType[i] = ossim_SHPP_RING;
-        }
-
-        if( psObject->panPartStart[0] != 0 )
-        {
-#ifdef USE_CPL
-            CPLError( CE_Failure, CPLE_AppDefined,
-                      "panPartStart[0] != 0, patching internally.  Please fix your code!\n" );
-#else
-            fprintf( stderr, "panPartStart[0] != 0, patching internally.  Please fix your code!\n" );
-#endif
-            psObject->panPartStart[0] = 0;
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Capture vertices.  Note that Z and M are optional, but X and    */
-/*      Y are not.                                                      */
-/* -------------------------------------------------------------------- */
-    if( nVertices > 0 )
-    {
-        psObject->padfX = (double *) calloc(sizeof(double),nVertices);
-        psObject->padfY = (double *) calloc(sizeof(double),nVertices);
-        psObject->padfZ = (double *) calloc(sizeof(double),nVertices);
-        psObject->padfM = (double *) calloc(sizeof(double),nVertices);
-
-        assert( padfX != NULL );
-        assert( padfY != NULL );
-
-        for( i = 0; i < nVertices; i++ )
-        {
-            psObject->padfX[i] = padfX[i];
-            psObject->padfY[i] = padfY[i];
-            if( padfZ != NULL && bHasZ )
-                psObject->padfZ[i] = padfZ[i];
-            if( padfM != NULL && bHasM )
-                psObject->padfM[i] = padfM[i];
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Compute the extents.                                            */
-/* -------------------------------------------------------------------- */
-    psObject->nVertices = nVertices;
-    ossim_SHPComputeExtents( psObject );
-
-    return( psObject );
-}
-
-/************************************************************************/
-/*                       ossim_SHPCreateSimpleObject()                        */
-/*                                                                      */
-/*      Create a simple (common) shape object.  Destroy with            */
-/*      ossim_SHPDestroyObject().                                             */
-/************************************************************************/
-
-ossim_SHPObject ossim_SHPAPI_CALL1(*)
-    ossim_SHPCreateSimpleObject( int nSHPType, int nVertices,
-                       const double * padfX, const double * padfY,
-                       const double * padfZ )
-
-{
-    return( ossim_SHPCreateObject( nSHPType, -1, 0, NULL, NULL,
-                             nVertices, padfX, padfY, padfZ, NULL ) );
-}
-
-/************************************************************************/
-/*                           ossim_SHPWriteObject()                           */
-/*                                                                      */
-/*      Write out the vertices of a new structure.  Note that it is     */
-/*      only possible to write vertices at the end of the file.         */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_SHPWriteObject(ossim_SHPHandle psSHP, int nShapeId, ossim_SHPObject * psObject )
-
-{
-    int	       	nRecordOffset, i, nRecordSize=0;
-    uchar	*pabyRec;
-    int32	i32;
-
-    psSHP->bUpdated = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*      Ensure that shape object matches the type of the file it is     */
-/*      being written to.                                               */
-/* -------------------------------------------------------------------- */
-    assert( psObject->nSHPType == psSHP->nShapeType
-            || psObject->nSHPType == ossim_SHPT_NULL );
-
-/* -------------------------------------------------------------------- */
-/*      Ensure that -1 is used for appends.  Either blow an             */
-/*      assertion, or if they are disabled, set the shapeid to -1       */
-/*      for appends.                                                    */
-/* -------------------------------------------------------------------- */
-    assert( nShapeId == -1
-            || (nShapeId >= 0 && nShapeId < psSHP->nRecords) );
-
-    if( nShapeId != -1 && nShapeId >= psSHP->nRecords )
-        nShapeId = -1;
-
-/* -------------------------------------------------------------------- */
-/*      Add the new entity to the in memory index.                      */
-/* -------------------------------------------------------------------- */
-    if( nShapeId == -1 && psSHP->nRecords+1 > psSHP->nMaxRecords )
-    {
-	psSHP->nMaxRecords =(int) ( psSHP->nMaxRecords * 1.3 + 100);
-
-	psSHP->panRecOffset = (int *)
-            SfRealloc(psSHP->panRecOffset,sizeof(int) * psSHP->nMaxRecords );
-	psSHP->panRecSize = (int *)
-            SfRealloc(psSHP->panRecSize,sizeof(int) * psSHP->nMaxRecords );
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Initialize record.                                              */
-/* -------------------------------------------------------------------- */
-    pabyRec = (uchar *) malloc(psObject->nVertices * 4 * sizeof(double)
-			       + psObject->nParts * 8 + 128);
-
-/* -------------------------------------------------------------------- */
-/*  Extract vertices for a Polygon or Arc.				*/
-/* -------------------------------------------------------------------- */
-    if( psObject->nSHPType == ossim_SHPT_POLYGON
-        || psObject->nSHPType == ossim_SHPT_POLYGONZ
-        || psObject->nSHPType == ossim_SHPT_POLYGONM
-        || psObject->nSHPType == ossim_SHPT_ARC
-        || psObject->nSHPType == ossim_SHPT_ARCZ
-        || psObject->nSHPType == ossim_SHPT_ARCM
-        || psObject->nSHPType == ossim_SHPT_MULTIPATCH )
-    {
-	int32		nPoints, nParts;
-	int    		i;
-
-	nPoints = psObject->nVertices;
-	nParts = psObject->nParts;
-
-	_SHPSetBounds( pabyRec + 12, psObject );
-
-	if( bBigEndian ) SwapWord( 4, &nPoints );
-	if( bBigEndian ) SwapWord( 4, &nParts );
-
-	ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
-	ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
-
-        nRecordSize = 52;
-
-        /*
-         * Write part start positions.
-         */
-	ByteCopy( psObject->panPartStart, pabyRec + 44 + 8,
-                  4 * psObject->nParts );
-	for( i = 0; i < psObject->nParts; i++ )
-	{
-	    if( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i );
-            nRecordSize += 4;
-	}
-
-        /*
-         * Write multipatch part types if needed.
-         */
-        if( psObject->nSHPType == ossim_SHPT_MULTIPATCH )
-        {
-            memcpy( pabyRec + nRecordSize, psObject->panPartType,
-                    4*psObject->nParts );
-            for( i = 0; i < psObject->nParts; i++ )
-            {
-                if( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize );
-                nRecordSize += 4;
-            }
-        }
-
-        /*
-         * Write the (x,y) vertex values.
-         */
-	for( i = 0; i < psObject->nVertices; i++ )
-	{
-	    ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 );
-	    ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 );
-
-	    if( bBigEndian )
-                SwapWord( 8, pabyRec + nRecordSize );
-
-	    if( bBigEndian )
-                SwapWord( 8, pabyRec + nRecordSize + 8 );
-
-            nRecordSize += 2 * 8;
-	}
-
-        /*
-         * Write the Z coordinates (if any).
-         */
-        if( psObject->nSHPType == ossim_SHPT_POLYGONZ
-            || psObject->nSHPType == ossim_SHPT_ARCZ
-            || psObject->nSHPType == ossim_SHPT_MULTIPATCH )
-        {
-            ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            for( i = 0; i < psObject->nVertices; i++ )
-            {
-                ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
-                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-                nRecordSize += 8;
-            }
-        }
-
-        /*
-         * Write the M values, if any.
-         */
-        if( psObject->nSHPType == ossim_SHPT_POLYGONM
-            || psObject->nSHPType == ossim_SHPT_ARCM
-#ifndef DISABLE_MULTIPATCH_MEASURE
-            || psObject->nSHPType == ossim_SHPT_MULTIPATCH
-#endif
-            || psObject->nSHPType == ossim_SHPT_POLYGONZ
-            || psObject->nSHPType == ossim_SHPT_ARCZ )
-        {
-            ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            for( i = 0; i < psObject->nVertices; i++ )
-            {
-                ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
-                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-                nRecordSize += 8;
-            }
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*  Extract vertices for a MultiPoint.					*/
-/* -------------------------------------------------------------------- */
-    else if( psObject->nSHPType == ossim_SHPT_MULTIPOINT
-             || psObject->nSHPType == ossim_SHPT_MULTIPOINTZ
-             || psObject->nSHPType == ossim_SHPT_MULTIPOINTM )
-    {
-	int32		nPoints;
-	int    		i;
-
-	nPoints = psObject->nVertices;
-
-        _SHPSetBounds( pabyRec + 12, psObject );
-
-	if( bBigEndian ) SwapWord( 4, &nPoints );
-	ByteCopy( &nPoints, pabyRec + 44, 4 );
-
-	for( i = 0; i < psObject->nVertices; i++ )
-	{
-	    ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 );
-	    ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 );
-
-	    if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 );
-	    if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 );
-	}
-
-	nRecordSize = 48 + 16 * psObject->nVertices;
-
-        if( psObject->nSHPType == ossim_SHPT_MULTIPOINTZ )
-        {
-            ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            for( i = 0; i < psObject->nVertices; i++ )
-            {
-                ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
-                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-                nRecordSize += 8;
-            }
-        }
-
-        if( psObject->nSHPType == ossim_SHPT_MULTIPOINTZ
-            || psObject->nSHPType == ossim_SHPT_MULTIPOINTM )
-        {
-            ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-
-            for( i = 0; i < psObject->nVertices; i++ )
-            {
-                ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
-                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-                nRecordSize += 8;
-            }
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Write point.							*/
-/* -------------------------------------------------------------------- */
-    else if( psObject->nSHPType == ossim_SHPT_POINT
-             || psObject->nSHPType == ossim_SHPT_POINTZ
-             || psObject->nSHPType == ossim_SHPT_POINTM )
-    {
-	ByteCopy( psObject->padfX, pabyRec + 12, 8 );
-	ByteCopy( psObject->padfY, pabyRec + 20, 8 );
-
-	if( bBigEndian ) SwapWord( 8, pabyRec + 12 );
-	if( bBigEndian ) SwapWord( 8, pabyRec + 20 );
-
-        nRecordSize = 28;
-
-        if( psObject->nSHPType == ossim_SHPT_POINTZ )
-        {
-            ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-        }
-
-        if( psObject->nSHPType == ossim_SHPT_POINTZ
-            || psObject->nSHPType == ossim_SHPT_POINTM )
-        {
-            ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 );
-            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
-            nRecordSize += 8;
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Not much to do for null geometries.                             */
-/* -------------------------------------------------------------------- */
-    else if( psObject->nSHPType == ossim_SHPT_NULL )
-    {
-        nRecordSize = 12;
-    }
-
-    else
-    {
-        /* unknown type */
-        assert( FALSE );
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Establish where we are going to put this record. If we are      */
-/*      rewriting and existing record, and it will fit, then put it     */
-/*      back where the original came from.  Otherwise write at the end. */
-/* -------------------------------------------------------------------- */
-    if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 )
-    {
-        if( nShapeId == -1 )
-            nShapeId = psSHP->nRecords++;
-
-        psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize;
-        psSHP->panRecSize[nShapeId] = nRecordSize-8;
-        psSHP->nFileSize += nRecordSize;
-    }
-    else
-    {
-        nRecordOffset = psSHP->panRecOffset[nShapeId];
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Set the shape type, record number, and record size.             */
-/* -------------------------------------------------------------------- */
-    i32 = nShapeId+1;					/* record # */
-    if( !bBigEndian ) SwapWord( 4, &i32 );
-    ByteCopy( &i32, pabyRec, 4 );
-
-    i32 = (nRecordSize-8)/2;				/* record size */
-    if( !bBigEndian ) SwapWord( 4, &i32 );
-    ByteCopy( &i32, pabyRec + 4, 4 );
-
-    i32 = psObject->nSHPType;				/* shape type */
-    if( bBigEndian ) SwapWord( 4, &i32 );
-    ByteCopy( &i32, pabyRec + 8, 4 );
-
-/* -------------------------------------------------------------------- */
-/*      Write out record.                                               */
-/* -------------------------------------------------------------------- */
-    if( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0
-        || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_FileIO,
-                "Error in fseek() or fwrite() writing object to .shp file." );
-#endif
-        free( pabyRec );
-        return -1;
-    }
-
-    free( pabyRec );
-
-/* -------------------------------------------------------------------- */
-/*	Expand file wide bounds based on this shape.			*/
-/* -------------------------------------------------------------------- */
-    if( psSHP->adBoundsMin[0] == 0.0
-        && psSHP->adBoundsMax[0] == 0.0
-        && psSHP->adBoundsMin[1] == 0.0
-        && psSHP->adBoundsMax[1] == 0.0 )
-    {
-        if( psObject->nSHPType == ossim_SHPT_NULL || psObject->nVertices == 0 )
-        {
-            psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = 0.0;
-            psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = 0.0;
-            psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = 0.0;
-            psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = 0.0;
-        }
-        else
-        {
-            psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
-            psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
-            psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0];
-            psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0];
-        }
-    }
-
-    for( i = 0; i < psObject->nVertices; i++ )
-    {
-	psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0],psObject->padfX[i]);
-	psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1],psObject->padfY[i]);
-	psSHP->adBoundsMin[2] = MIN(psSHP->adBoundsMin[2],psObject->padfZ[i]);
-	psSHP->adBoundsMin[3] = MIN(psSHP->adBoundsMin[3],psObject->padfM[i]);
-	psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0],psObject->padfX[i]);
-	psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1],psObject->padfY[i]);
-	psSHP->adBoundsMax[2] = MAX(psSHP->adBoundsMax[2],psObject->padfZ[i]);
-	psSHP->adBoundsMax[3] = MAX(psSHP->adBoundsMax[3],psObject->padfM[i]);
-    }
-
-    return( nShapeId  );
-}
-
-/************************************************************************/
-/*                          ossim_SHPReadObject()                             */
-/*                                                                      */
-/*      Read the vertices, parts, and other non-attribute information	*/
-/*	for one shape.							*/
-/************************************************************************/
-
-ossim_SHPObject ossim_SHPAPI_CALL1(*)
-    ossim_SHPReadObject( ossim_SHPHandle psSHP, int hEntity )
-
-{
-    ossim_SHPObject		*psShape;
-
-/* -------------------------------------------------------------------- */
-/*      Validate the record/entity number.                              */
-/* -------------------------------------------------------------------- */
-    if( hEntity < 0 || hEntity >= psSHP->nRecords )
-        return( NULL );
-
-/* -------------------------------------------------------------------- */
-/*      Ensure our record buffer is large enough.                       */
-/* -------------------------------------------------------------------- */
-    if( psSHP->panRecSize[hEntity]+8 > psSHP->nBufSize )
-    {
-	psSHP->nBufSize = psSHP->panRecSize[hEntity]+8;
-	psSHP->pabyRec = (uchar *) SfRealloc(psSHP->pabyRec,psSHP->nBufSize);
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Read the record.                                                */
-/* -------------------------------------------------------------------- */
-    if( fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ) != 0
-        || fread( psSHP->pabyRec, psSHP->panRecSize[hEntity]+8, 1,
-                  psSHP->fpSHP ) != 1 )
-    {
-#ifdef USE_CPL
-        CPLError( CE_Failure, CPLE_FileIO,
-                "Error in fseek() or fread() reading object from .shp file." );
-#endif
-        return NULL;
-    }
-
-/* -------------------------------------------------------------------- */
-/*	Allocate and minimally initialize the object.			*/
-/* -------------------------------------------------------------------- */
-    psShape = (ossim_SHPObject *) calloc(1,sizeof(ossim_SHPObject));
-    psShape->nShapeId = hEntity;
-
-    memcpy( &psShape->nSHPType, psSHP->pabyRec + 8, 4 );
-    if( bBigEndian ) SwapWord( 4, &(psShape->nSHPType) );
-
-/* ==================================================================== */
-/*  Extract vertices for a Polygon or Arc.				*/
-/* ==================================================================== */
-    if( psShape->nSHPType == ossim_SHPT_POLYGON || psShape->nSHPType == ossim_SHPT_ARC
-        || psShape->nSHPType == ossim_SHPT_POLYGONZ
-        || psShape->nSHPType == ossim_SHPT_POLYGONM
-        || psShape->nSHPType == ossim_SHPT_ARCZ
-        || psShape->nSHPType == ossim_SHPT_ARCM
-        || psShape->nSHPType == ossim_SHPT_MULTIPATCH )
-    {
-	int32		nPoints, nParts;
-	int    		i, nOffset;
-
-/* -------------------------------------------------------------------- */
-/*	Get the X/Y bounds.						*/
-/* -------------------------------------------------------------------- */
-        memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 +  4, 8 );
-        memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
-        memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
-        memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
-
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
-
-/* -------------------------------------------------------------------- */
-/*      Extract part/point count, and build vertex and part arrays      */
-/*      to proper size.                                                 */
-/* -------------------------------------------------------------------- */
-	memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
-	memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
-
-	if( bBigEndian ) SwapWord( 4, &nPoints );
-	if( bBigEndian ) SwapWord( 4, &nParts );
-
-	psShape->nVertices = nPoints;
-        psShape->padfX = (double *) calloc(nPoints,sizeof(double));
-        psShape->padfY = (double *) calloc(nPoints,sizeof(double));
-        psShape->padfZ = (double *) calloc(nPoints,sizeof(double));
-        psShape->padfM = (double *) calloc(nPoints,sizeof(double));
-
-	psShape->nParts = nParts;
-        psShape->panPartStart = (int *) calloc(nParts,sizeof(int));
-        psShape->panPartType = (int *) calloc(nParts,sizeof(int));
-
-        for( i = 0; i < nParts; i++ )
-            psShape->panPartType[i] = ossim_SHPP_RING;
-
-/* -------------------------------------------------------------------- */
-/*      Copy out the part array from the record.                        */
-/* -------------------------------------------------------------------- */
-	memcpy( psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
-	for( i = 0; i < nParts; i++ )
-	{
-	    if( bBigEndian ) SwapWord( 4, psShape->panPartStart+i );
-	}
-
-	nOffset = 44 + 8 + 4*nParts;
-
-/* -------------------------------------------------------------------- */
-/*      If this is a multipatch, we will also have parts types.         */
-/* -------------------------------------------------------------------- */
-        if( psShape->nSHPType == ossim_SHPT_MULTIPATCH )
-        {
-            memcpy( psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
-            for( i = 0; i < nParts; i++ )
-            {
-                if( bBigEndian ) SwapWord( 4, psShape->panPartType+i );
-            }
-
-            nOffset += 4*nParts;
-        }
-
-/* -------------------------------------------------------------------- */
-/*      Copy out the vertices from the record.                          */
-/* -------------------------------------------------------------------- */
-	for( i = 0; i < nPoints; i++ )
-	{
-	    memcpy(psShape->padfX + i,
-		   psSHP->pabyRec + nOffset + i * 16,
-		   8 );
-
-	    memcpy(psShape->padfY + i,
-		   psSHP->pabyRec + nOffset + i * 16 + 8,
-		   8 );
-
-	    if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
-	    if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
-	}
-
-        nOffset += 16*nPoints;
-
-/* -------------------------------------------------------------------- */
-/*      If we have a Z coordinate, collect that now.                    */
-/* -------------------------------------------------------------------- */
-        if( psShape->nSHPType == ossim_SHPT_POLYGONZ
-            || psShape->nSHPType == ossim_SHPT_ARCZ
-            || psShape->nSHPType == ossim_SHPT_MULTIPATCH )
-        {
-            memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
-            memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
-
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
-
-            for( i = 0; i < nPoints; i++ )
-            {
-                memcpy( psShape->padfZ + i,
-                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
-                if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
-            }
-
-            nOffset += 16 + 8*nPoints;
-        }
-
-/* -------------------------------------------------------------------- */
-/*      If we have a M measure value, then read it now.  We assume      */
-/*      that the measure can be present for any shape if the size is    */
-/*      big enough, but really it will only occur for the Z shapes      */
-/*      (options), and the M shapes.                                    */
-/* -------------------------------------------------------------------- */
-        if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints )
-        {
-            memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
-            memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
-
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
-
-            for( i = 0; i < nPoints; i++ )
-            {
-                memcpy( psShape->padfM + i,
-                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
-                if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
-            }
-        }
-
-    }
-
-/* ==================================================================== */
-/*  Extract vertices for a MultiPoint.					*/
-/* ==================================================================== */
-    else if( psShape->nSHPType == ossim_SHPT_MULTIPOINT
-             || psShape->nSHPType == ossim_SHPT_MULTIPOINTM
-             || psShape->nSHPType == ossim_SHPT_MULTIPOINTZ )
-    {
-	int32		nPoints;
-	int    		i, nOffset;
-
-	memcpy( &nPoints, psSHP->pabyRec + 44, 4 );
-	if( bBigEndian ) SwapWord( 4, &nPoints );
-
-	psShape->nVertices = nPoints;
-        psShape->padfX = (double *) calloc(nPoints,sizeof(double));
-        psShape->padfY = (double *) calloc(nPoints,sizeof(double));
-        psShape->padfZ = (double *) calloc(nPoints,sizeof(double));
-        psShape->padfM = (double *) calloc(nPoints,sizeof(double));
-
-	for( i = 0; i < nPoints; i++ )
-	{
-	    memcpy(psShape->padfX+i, psSHP->pabyRec + 48 + 16 * i, 8 );
-	    memcpy(psShape->padfY+i, psSHP->pabyRec + 48 + 16 * i + 8, 8 );
-
-	    if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
-	    if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
-	}
-
-        nOffset = 48 + 16*nPoints;
-
-/* -------------------------------------------------------------------- */
-/*	Get the X/Y bounds.						*/
-/* -------------------------------------------------------------------- */
-        memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 +  4, 8 );
-        memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
-        memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
-        memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
-
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
-	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
-
-/* -------------------------------------------------------------------- */
-/*      If we have a Z coordinate, collect that now.                    */
-/* -------------------------------------------------------------------- */
-        if( psShape->nSHPType == ossim_SHPT_MULTIPOINTZ )
-        {
-            memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
-            memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
-
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
-
-            for( i = 0; i < nPoints; i++ )
-            {
-                memcpy( psShape->padfZ + i,
-                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
-                if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
-            }
-
-            nOffset += 16 + 8*nPoints;
-        }
-
-/* -------------------------------------------------------------------- */
-/*      If we have a M measure value, then read it now.  We assume      */
-/*      that the measure can be present for any shape if the size is    */
-/*      big enough, but really it will only occur for the Z shapes      */
-/*      (options), and the M shapes.                                    */
-/* -------------------------------------------------------------------- */
-        if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints )
-        {
-            memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
-            memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
-
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
-            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
-
-            for( i = 0; i < nPoints; i++ )
-            {
-                memcpy( psShape->padfM + i,
-                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
-                if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
-            }
-        }
-    }
-
-/* ==================================================================== */
-/*      Extract vertices for a point.                                   */
-/* ==================================================================== */
-    else if( psShape->nSHPType == ossim_SHPT_POINT
-             || psShape->nSHPType == ossim_SHPT_POINTM
-             || psShape->nSHPType == ossim_SHPT_POINTZ )
-    {
-        int	nOffset;
-
-	psShape->nVertices = 1;
-        psShape->padfX = (double *) calloc(1,sizeof(double));
-        psShape->padfY = (double *) calloc(1,sizeof(double));
-        psShape->padfZ = (double *) calloc(1,sizeof(double));
-        psShape->padfM = (double *) calloc(1,sizeof(double));
-
-	memcpy( psShape->padfX, psSHP->pabyRec + 12, 8 );
-	memcpy( psShape->padfY, psSHP->pabyRec + 20, 8 );
-
-	if( bBigEndian ) SwapWord( 8, psShape->padfX );
-	if( bBigEndian ) SwapWord( 8, psShape->padfY );
-
-        nOffset = 20 + 8;
-
-/* -------------------------------------------------------------------- */
-/*      If we have a Z coordinate, collect that now.                    */
-/* -------------------------------------------------------------------- */
-        if( psShape->nSHPType == ossim_SHPT_POINTZ )
-        {
-            memcpy( psShape->padfZ, psSHP->pabyRec + nOffset, 8 );
-
-            if( bBigEndian ) SwapWord( 8, psShape->padfZ );
-
-            nOffset += 8;
-        }
-
-/* -------------------------------------------------------------------- */
-/*      If we have a M measure value, then read it now.  We assume      */
-/*      that the measure can be present for any shape if the size is    */
-/*      big enough, but really it will only occur for the Z shapes      */
-/*      (options), and the M shapes.                                    */
-/* -------------------------------------------------------------------- */
-        if( psSHP->panRecSize[hEntity]+8 >= nOffset + 8 )
-        {
-            memcpy( psShape->padfM, psSHP->pabyRec + nOffset, 8 );
-
-            if( bBigEndian ) SwapWord( 8, psShape->padfM );
-        }
-
-/* -------------------------------------------------------------------- */
-/*      Since no extents are supplied in the record, we will apply      */
-/*      them from the single vertex.                                    */
-/* -------------------------------------------------------------------- */
-        psShape->dfXMin = psShape->dfXMax = psShape->padfX[0];
-        psShape->dfYMin = psShape->dfYMax = psShape->padfY[0];
-        psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0];
-        psShape->dfMMin = psShape->dfMMax = psShape->padfM[0];
-    }
-
-    return( psShape );
-}
-
-/************************************************************************/
-/*                            ossim_SHPTypeName()                             */
-/************************************************************************/
-
-const char ossim_SHPAPI_CALL1(*)
-    ossim_SHPTypeName( int nSHPType )
-
-{
-    switch( nSHPType )
-    {
-      case ossim_SHPT_NULL:
-        return "NullShape";
-
-      case ossim_SHPT_POINT:
-        return "Point";
-
-      case ossim_SHPT_ARC:
-        return "Arc";
-
-      case ossim_SHPT_POLYGON:
-        return "Polygon";
-
-      case ossim_SHPT_MULTIPOINT:
-        return "MultiPoint";
-
-      case ossim_SHPT_POINTZ:
-        return "PointZ";
-
-      case ossim_SHPT_ARCZ:
-        return "ArcZ";
-
-      case ossim_SHPT_POLYGONZ:
-        return "PolygonZ";
-
-      case ossim_SHPT_MULTIPOINTZ:
-        return "MultiPointZ";
-
-      case ossim_SHPT_POINTM:
-        return "PointM";
-
-      case ossim_SHPT_ARCM:
-        return "ArcM";
-
-      case ossim_SHPT_POLYGONM:
-        return "PolygonM";
-
-      case ossim_SHPT_MULTIPOINTM:
-        return "MultiPointM";
-
-      case ossim_SHPT_MULTIPATCH:
-        return "MultiPatch";
-
-      default:
-        return "UnknownShapeType";
-    }
-}
-
-/************************************************************************/
-/*                          ossim_SHPPartTypeName()                           */
-/************************************************************************/
-
-const char ossim_SHPAPI_CALL1(*)
-    ossim_SHPPartTypeName( int nPartType )
-
-{
-    switch( nPartType )
-    {
-      case ossim_SHPP_TRISTRIP:
-        return "TriangleStrip";
-
-      case ossim_SHPP_TRIFAN:
-        return "TriangleFan";
-
-      case ossim_SHPP_OUTERRING:
-        return "OuterRing";
-
-      case ossim_SHPP_INNERRING:
-        return "InnerRing";
-
-      case ossim_SHPP_FIRSTRING:
-        return "FirstRing";
-
-      case ossim_SHPP_RING:
-        return "Ring";
-
-      default:
-        return "UnknownPartType";
-    }
-}
-
-/************************************************************************/
-/*                          ossim_SHPDestroyObject()                          */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPDestroyObject( ossim_SHPObject * psShape )
-
-{
-    if( psShape == NULL )
-        return;
-
-    if( psShape->padfX != NULL )
-        free( psShape->padfX );
-    if( psShape->padfY != NULL )
-        free( psShape->padfY );
-    if( psShape->padfZ != NULL )
-        free( psShape->padfZ );
-    if( psShape->padfM != NULL )
-        free( psShape->padfM );
-
-    if( psShape->panPartStart != NULL )
-        free( psShape->panPartStart );
-    if( psShape->panPartType != NULL )
-        free( psShape->panPartType );
-
-    free( psShape );
-}
-
-/************************************************************************/
-/*                          ossim_SHPRewindObject()                           */
-/*                                                                      */
-/*      Reset the winding of polygon objects to adhere to the           */
-/*      specification.                                                  */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_SHPRewindObject( ossim_SHPHandle hSHP, ossim_SHPObject * psObject )
-
-{
-    int  iOpRing, bAltered = 0;
-
-/* -------------------------------------------------------------------- */
-/*      Do nothing if this is not a polygon object.                     */
-/* -------------------------------------------------------------------- */
-    if( psObject->nSHPType != ossim_SHPT_POLYGON
-        && psObject->nSHPType != ossim_SHPT_POLYGONZ
-        && psObject->nSHPType != ossim_SHPT_POLYGONM )
-        return 0;
-
-    if( psObject->nVertices == 0 || psObject->nParts == 0 )
-        return 0;
-
-/* -------------------------------------------------------------------- */
-/*      Process each of the rings.                                      */
-/* -------------------------------------------------------------------- */
-    for( iOpRing = 0; iOpRing < psObject->nParts; iOpRing++ )
-    {
-        int      bInner, iVert, nVertCount, nVertStart, iCheckRing;
-        double   dfSum, dfTestX, dfTestY;
-
-/* -------------------------------------------------------------------- */
-/*      Determine if this ring is an inner ring or an outer ring        */
-/*      relative to all the other rings.  For now we assume the         */
-/*      first ring is outer and all others are inner, but eventually    */
-/*      we need to fix this to handle multiple island polygons and      */
-/*      unordered sets of rings.                                        */
-/* -------------------------------------------------------------------- */
-        dfTestX = psObject->padfX[psObject->panPartStart[iOpRing]];
-        dfTestY = psObject->padfY[psObject->panPartStart[iOpRing]];
-
-        bInner = FALSE;
-        for( iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++ )
-        {
-            int iEdge;
-
-            if( iCheckRing == iOpRing )
-                continue;
-
-            nVertStart = psObject->panPartStart[iCheckRing];
-
-            if( iCheckRing == psObject->nParts-1 )
-                nVertCount = psObject->nVertices
-                    - psObject->panPartStart[iCheckRing];
-            else
-                nVertCount = psObject->panPartStart[iCheckRing+1]
-                    - psObject->panPartStart[iCheckRing];
-
-            for( iEdge = 0; iEdge < nVertCount; iEdge++ )
-            {
-                int iNext;
-
-                if( iEdge < nVertCount-1 )
-                    iNext = iEdge+1;
-                else
-                    iNext = 0;
-
-                if( (psObject->padfY[iEdge+nVertStart] < dfTestY
-                     && psObject->padfY[iNext+nVertStart] >= dfTestY)
-                    || (psObject->padfY[iNext+nVertStart] < dfTestY
-                        && psObject->padfY[iEdge+nVertStart] >= dfTestY) )
-                {
-                    if( psObject->padfX[iEdge+nVertStart]
-                        + (dfTestY - psObject->padfY[iEdge+nVertStart])
-                           / (psObject->padfY[iNext+nVertStart]
-                              - psObject->padfY[iEdge+nVertStart])
-                           * (psObject->padfX[iNext+nVertStart]
-                              - psObject->padfX[iEdge+nVertStart]) < dfTestX )
-                        bInner = !bInner;
-                }
-            }
-        }
-
-/* -------------------------------------------------------------------- */
-/*      Determine the current order of this ring so we will know if     */
-/*      it has to be reversed.                                          */
-/* -------------------------------------------------------------------- */
-        nVertStart = psObject->panPartStart[iOpRing];
-
-        if( iOpRing == psObject->nParts-1 )
-            nVertCount = psObject->nVertices - psObject->panPartStart[iOpRing];
-        else
-            nVertCount = psObject->panPartStart[iOpRing+1]
-                - psObject->panPartStart[iOpRing];
-
-        dfSum = 0.0;
-        for( iVert = nVertStart; iVert < nVertStart+nVertCount-1; iVert++ )
-        {
-            dfSum += psObject->padfX[iVert] * psObject->padfY[iVert+1]
-                - psObject->padfY[iVert] * psObject->padfX[iVert+1];
-        }
-
-        dfSum += psObject->padfX[iVert] * psObject->padfY[nVertStart]
-               - psObject->padfY[iVert] * psObject->padfX[nVertStart];
-
-/* -------------------------------------------------------------------- */
-/*      Reverse if necessary.                                           */
-/* -------------------------------------------------------------------- */
-        if( (dfSum < 0.0 && bInner) || (dfSum > 0.0 && !bInner) )
-        {
-            int   i;
-
-            bAltered++;
-            for( i = 0; i < nVertCount/2; i++ )
-            {
-                double dfSaved;
-
-                /* Swap X */
-                dfSaved = psObject->padfX[nVertStart+i];
-                psObject->padfX[nVertStart+i] =
-                    psObject->padfX[nVertStart+nVertCount-i-1];
-                psObject->padfX[nVertStart+nVertCount-i-1] = dfSaved;
-
-                /* Swap Y */
-                dfSaved = psObject->padfY[nVertStart+i];
-                psObject->padfY[nVertStart+i] =
-                    psObject->padfY[nVertStart+nVertCount-i-1];
-                psObject->padfY[nVertStart+nVertCount-i-1] = dfSaved;
-
-                /* Swap Z */
-                if( psObject->padfZ )
-                {
-                    dfSaved = psObject->padfZ[nVertStart+i];
-                    psObject->padfZ[nVertStart+i] =
-                        psObject->padfZ[nVertStart+nVertCount-i-1];
-                    psObject->padfZ[nVertStart+nVertCount-i-1] = dfSaved;
-                }
-
-                /* Swap M */
-                if( psObject->padfM )
-                {
-                    dfSaved = psObject->padfM[nVertStart+i];
-                    psObject->padfM[nVertStart+i] =
-                        psObject->padfM[nVertStart+nVertCount-i-1];
-                    psObject->padfM[nVertStart+nVertCount-i-1] = dfSaved;
-                }
-            }
-        }
-    }
-
-    return bAltered;
-}
diff --git a/Utilities/otbossim/src/ossim/vec/shptree.c b/Utilities/otbossim/src/ossim/vec/shptree.c
deleted file mode 100644
index 00f49cf92b74ce7b9b1dd85c6d24cc13a18bf954..0000000000000000000000000000000000000000
--- a/Utilities/otbossim/src/ossim/vec/shptree.c
+++ /dev/null
@@ -1,986 +0,0 @@
-/******************************************************************************
- * $Id: shptree.c 9094 2006-06-13 19:12:40Z dburken $
- *
- * Project:  Shapelib
- * Purpose:  Implementation of quadtree building and searching functions.
- * Author:   Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log$
- * Revision 1.6  2006/06/13 19:11:33  dburken
- * Global include path change.
- *
- * Revision 1.5  2005/10/08 12:57:26  gpotts
- * Added adiitional patches
- *
- * Revision 1.10  2005/01/03 22:30:13  fwarmerdam
- * added support for saved quadtrees
- *
- * Revision 1.9  2003/01/28 15:53:41  warmerda
- * Avoid build warnings.
- *
- * Revision 1.8  2002/05/07 13:07:45  warmerda
- * use qsort() - patch from Bernhard Herzog
- *
- * Revision 1.7  2002/01/15 14:36:07  warmerda
- * updated email address
- *
- * Revision 1.6  2001/05/23 13:36:52  warmerda
- * added use of ossim_SHPAPI_CALL
- *
- * Revision 1.5  1999/11/05 14:12:05  warmerda
- * updated license terms
- *
- * Revision 1.4  1999/06/02 18:24:21  warmerda
- * added trimming code
- *
- * Revision 1.3  1999/06/02 17:56:12  warmerda
- * added quad'' subnode support for trees
- *
- * Revision 1.2  1999/05/18 19:11:11  warmerda
- * Added example searching capability
- *
- * Revision 1.1  1999/05/18 17:49:20  warmerda
- * New
- *
- */
-
-#include <ossim/vec/shapefil.h>
-
-#include <math.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-ossim_SHP_CVSID("$Id: shptree.c 9094 2006-06-13 19:12:40Z dburken $")
-
-#ifndef TRUE
-#  define TRUE 1
-#  define FALSE 0
-#endif
-
-static int bBigEndian = 0;
-
-
-/* -------------------------------------------------------------------- */
-/*      If the following is 0.5, nodes will be split in half.  If it    */
-/*      is 0.6 then each subnode will contain 60% of the parent         */
-/*      node, with 20% representing overlap.  This can be help to       */
-/*      prevent small objects on a boundary from shifting too high      */
-/*      up the tree.                                                    */
-/* -------------------------------------------------------------------- */
-
-#define ossim_SHP_SPLIT_RATIO	0.55
-
-/************************************************************************/
-/*                             SfRealloc()                              */
-/*                                                                      */
-/*      A realloc cover function that will access a NULL pointer as     */
-/*      a valid input.                                                  */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
-    if( pMem == NULL )
-        return( (void *) malloc(nNewSize) );
-    else
-        return( (void *) realloc(pMem,nNewSize) );
-}
-
-/************************************************************************/
-/*                          ossim_SHPTreeNodeInit()                           */
-/*                                                                      */
-/*      Initialize a tree node.                                         */
-/************************************************************************/
-
-static ossim_SHPTreeNode *ossim_SHPTreeNodeCreate( double * padfBoundsMin,
-                                       double * padfBoundsMax )
-
-{
-    ossim_SHPTreeNode	*psTreeNode;
-
-    psTreeNode = (ossim_SHPTreeNode *) malloc(sizeof(ossim_SHPTreeNode));
-
-    psTreeNode->nShapeCount = 0;
-    psTreeNode->panShapeIds = NULL;
-    psTreeNode->papsShapeObj = NULL;
-
-    psTreeNode->nSubNodes = 0;
-
-    if( padfBoundsMin != NULL )
-        memcpy( psTreeNode->adfBoundsMin, padfBoundsMin, sizeof(double) * 4 );
-
-    if( padfBoundsMax != NULL )
-        memcpy( psTreeNode->adfBoundsMax, padfBoundsMax, sizeof(double) * 4 );
-
-    return psTreeNode;
-}
-
-
-/************************************************************************/
-/*                           ossim_SHPCreateTree()                            */
-/************************************************************************/
-
-ossim_SHPTree ossim_SHPAPI_CALL1(*)
-    ossim_SHPCreateTree( ossim_SHPHandle hSHP, int nDimension, int nMaxDepth,
-               double *padfBoundsMin, double *padfBoundsMax )
-
-{
-    ossim_SHPTree	*psTree;
-
-    if( padfBoundsMin == NULL && hSHP == NULL )
-        return NULL;
-
-/* -------------------------------------------------------------------- */
-/*      Allocate the tree object                                        */
-/* -------------------------------------------------------------------- */
-    psTree = (ossim_SHPTree *) malloc(sizeof(ossim_SHPTree));
-
-    psTree->hSHP = hSHP;
-    psTree->nMaxDepth = nMaxDepth;
-    psTree->nDimension = nDimension;
-    psTree->nTotalCount = 0;
-
-/* -------------------------------------------------------------------- */
-/*      If no max depth was defined, try to select a reasonable one     */
-/*      that implies approximately 8 shapes per node.                   */
-/* -------------------------------------------------------------------- */
-    if( psTree->nMaxDepth == 0 && hSHP != NULL )
-    {
-        int	nMaxNodeCount = 1;
-        int	nShapeCount;
-
-        ossim_SHPGetInfo( hSHP, &nShapeCount, NULL, NULL, NULL );
-        while( nMaxNodeCount*4 < nShapeCount )
-        {
-            psTree->nMaxDepth += 1;
-            nMaxNodeCount = nMaxNodeCount * 2;
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Allocate the root node.                                         */
-/* -------------------------------------------------------------------- */
-    psTree->psRoot = ossim_SHPTreeNodeCreate( padfBoundsMin, padfBoundsMax );
-
-/* -------------------------------------------------------------------- */
-/*      Assign the bounds to the root node.  If none are passed in,     */
-/*      use the bounds of the provided file otherwise the create        */
-/*      function will have already set the bounds.                      */
-/* -------------------------------------------------------------------- */
-    if( padfBoundsMin == NULL )
-    {
-        ossim_SHPGetInfo( hSHP, NULL, NULL,
-                    psTree->psRoot->adfBoundsMin,
-                    psTree->psRoot->adfBoundsMax );
-    }
-
-/* -------------------------------------------------------------------- */
-/*      If we have a file, insert all it's shapes into the tree.        */
-/* -------------------------------------------------------------------- */
-    if( hSHP != NULL )
-    {
-        int	iShape, nShapeCount;
-
-        ossim_SHPGetInfo( hSHP, &nShapeCount, NULL, NULL, NULL );
-
-        for( iShape = 0; iShape < nShapeCount; iShape++ )
-        {
-            ossim_SHPObject	*psShape;
-
-            psShape = ossim_SHPReadObject( hSHP, iShape );
-            ossim_SHPTreeAddShapeId( psTree, psShape );
-            ossim_SHPDestroyObject( psShape );
-        }
-    }
-
-    return psTree;
-}
-
-/************************************************************************/
-/*                         ossim_SHPDestroyTreeNode()                         */
-/************************************************************************/
-
-static void ossim_SHPDestroyTreeNode( ossim_SHPTreeNode * psTreeNode )
-
-{
-    int		i;
-
-    for( i = 0; i < psTreeNode->nSubNodes; i++ )
-    {
-        if( psTreeNode->apsSubNode[i] != NULL )
-            ossim_SHPDestroyTreeNode( psTreeNode->apsSubNode[i] );
-    }
-
-    if( psTreeNode->panShapeIds != NULL )
-        free( psTreeNode->panShapeIds );
-
-    if( psTreeNode->papsShapeObj != NULL )
-    {
-        for( i = 0; i < psTreeNode->nShapeCount; i++ )
-        {
-            if( psTreeNode->papsShapeObj[i] != NULL )
-                ossim_SHPDestroyObject( psTreeNode->papsShapeObj[i] );
-        }
-
-        free( psTreeNode->papsShapeObj );
-    }
-
-    free( psTreeNode );
-}
-
-/************************************************************************/
-/*                           ossim_SHPDestroyTree()                           */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPDestroyTree( ossim_SHPTree * psTree )
-
-{
-    ossim_SHPDestroyTreeNode( psTree->psRoot );
-    free( psTree );
-}
-
-/************************************************************************/
-/*                       ossim_SHPCheckBoundsOverlap()                        */
-/*                                                                      */
-/*      Do the given boxes overlap at all?                              */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_SHPCheckBoundsOverlap( double * padfBox1Min, double * padfBox1Max,
-                       double * padfBox2Min, double * padfBox2Max,
-                       int nDimension )
-
-{
-    int		iDim;
-
-    for( iDim = 0; iDim < nDimension; iDim++ )
-    {
-        if( padfBox2Max[iDim] < padfBox1Min[iDim] )
-            return FALSE;
-
-        if( padfBox1Max[iDim] < padfBox2Min[iDim] )
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
-/************************************************************************/
-/*                      ossim_SHPCheckObjectContained()                       */
-/*                                                                      */
-/*      Does the given shape fit within the indicated extents?          */
-/************************************************************************/
-
-static int ossim_SHPCheckObjectContained( ossim_SHPObject * psObject, int nDimension,
-                           double * padfBoundsMin, double * padfBoundsMax )
-
-{
-    if( psObject->dfXMin < padfBoundsMin[0]
-        || psObject->dfXMax > padfBoundsMax[0] )
-        return FALSE;
-
-    if( psObject->dfYMin < padfBoundsMin[1]
-        || psObject->dfYMax > padfBoundsMax[1] )
-        return FALSE;
-
-    if( nDimension == 2 )
-        return TRUE;
-
-    if( psObject->dfZMin < padfBoundsMin[2]
-        || psObject->dfZMax < padfBoundsMax[2] )
-        return FALSE;
-
-    if( nDimension == 3 )
-        return TRUE;
-
-    if( psObject->dfMMin < padfBoundsMin[3]
-        || psObject->dfMMax < padfBoundsMax[3] )
-        return FALSE;
-
-    return TRUE;
-}
-
-/************************************************************************/
-/*                         ossim_SHPTreeSplitBounds()                         */
-/*                                                                      */
-/*      Split a region into two subregion evenly, cutting along the     */
-/*      longest dimension.                                              */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPTreeSplitBounds( double *padfBoundsMinIn, double *padfBoundsMaxIn,
-                    double *padfBoundsMin1, double * padfBoundsMax1,
-                    double *padfBoundsMin2, double * padfBoundsMax2 )
-
-{
-/* -------------------------------------------------------------------- */
-/*      The output bounds will be very similar to the input bounds,     */
-/*      so just copy over to start.                                     */
-/* -------------------------------------------------------------------- */
-    memcpy( padfBoundsMin1, padfBoundsMinIn, sizeof(double) * 4 );
-    memcpy( padfBoundsMax1, padfBoundsMaxIn, sizeof(double) * 4 );
-    memcpy( padfBoundsMin2, padfBoundsMinIn, sizeof(double) * 4 );
-    memcpy( padfBoundsMax2, padfBoundsMaxIn, sizeof(double) * 4 );
-
-/* -------------------------------------------------------------------- */
-/*      Split in X direction.                                           */
-/* -------------------------------------------------------------------- */
-    if( (padfBoundsMaxIn[0] - padfBoundsMinIn[0])
-        			> (padfBoundsMaxIn[1] - padfBoundsMinIn[1]) )
-    {
-        double	dfRange = padfBoundsMaxIn[0] - padfBoundsMinIn[0];
-
-        padfBoundsMax1[0] = padfBoundsMinIn[0] + dfRange * ossim_SHP_SPLIT_RATIO;
-        padfBoundsMin2[0] = padfBoundsMaxIn[0] - dfRange * ossim_SHP_SPLIT_RATIO;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Otherwise split in Y direction.                                 */
-/* -------------------------------------------------------------------- */
-    else
-    {
-        double	dfRange = padfBoundsMaxIn[1] - padfBoundsMinIn[1];
-
-        padfBoundsMax1[1] = padfBoundsMinIn[1] + dfRange * ossim_SHP_SPLIT_RATIO;
-        padfBoundsMin2[1] = padfBoundsMaxIn[1] - dfRange * ossim_SHP_SPLIT_RATIO;
-    }
-}
-
-/************************************************************************/
-/*                       ossim_SHPTreeNodeAddShapeId()                        */
-/************************************************************************/
-
-static int
-    ossim_SHPTreeNodeAddShapeId( ossim_SHPTreeNode * psTreeNode, ossim_SHPObject * psObject,
-                       int nMaxDepth, int nDimension )
-
-{
-    int		i;
-
-/* -------------------------------------------------------------------- */
-/*      If there are subnodes, then consider wiether this object        */
-/*      will fit in them.                                               */
-/* -------------------------------------------------------------------- */
-    if( nMaxDepth > 1 && psTreeNode->nSubNodes > 0 )
-    {
-        for( i = 0; i < psTreeNode->nSubNodes; i++ )
-        {
-            if( ossim_SHPCheckObjectContained(psObject, nDimension,
-                                      psTreeNode->apsSubNode[i]->adfBoundsMin,
-                                      psTreeNode->apsSubNode[i]->adfBoundsMax))
-            {
-                return ossim_SHPTreeNodeAddShapeId( psTreeNode->apsSubNode[i],
-                                              psObject, nMaxDepth-1,
-                                              nDimension );
-            }
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Otherwise, consider creating four subnodes if could fit into    */
-/*      them, and adding to the appropriate subnode.                    */
-/* -------------------------------------------------------------------- */
-#if MAX_SUBNODE == 4
-    else if( nMaxDepth > 1 && psTreeNode->nSubNodes == 0 )
-    {
-        double	adfBoundsMinH1[4], adfBoundsMaxH1[4];
-        double	adfBoundsMinH2[4], adfBoundsMaxH2[4];
-        double	adfBoundsMin1[4], adfBoundsMax1[4];
-        double	adfBoundsMin2[4], adfBoundsMax2[4];
-        double	adfBoundsMin3[4], adfBoundsMax3[4];
-        double	adfBoundsMin4[4], adfBoundsMax4[4];
-
-        ossim_SHPTreeSplitBounds( psTreeNode->adfBoundsMin,
-                            psTreeNode->adfBoundsMax,
-                            adfBoundsMinH1, adfBoundsMaxH1,
-                            adfBoundsMinH2, adfBoundsMaxH2 );
-
-        ossim_SHPTreeSplitBounds( adfBoundsMinH1, adfBoundsMaxH1,
-                            adfBoundsMin1, adfBoundsMax1,
-                            adfBoundsMin2, adfBoundsMax2 );
-
-        ossim_SHPTreeSplitBounds( adfBoundsMinH2, adfBoundsMaxH2,
-                            adfBoundsMin3, adfBoundsMax3,
-                            adfBoundsMin4, adfBoundsMax4 );
-
-        if( ossim_SHPCheckObjectContained(psObject, nDimension,
-                                    adfBoundsMin1, adfBoundsMax1)
-            || ossim_SHPCheckObjectContained(psObject, nDimension,
-                                    adfBoundsMin2, adfBoundsMax2)
-            || ossim_SHPCheckObjectContained(psObject, nDimension,
-                                    adfBoundsMin3, adfBoundsMax3)
-            || ossim_SHPCheckObjectContained(psObject, nDimension,
-                                    adfBoundsMin4, adfBoundsMax4) )
-        {
-            psTreeNode->nSubNodes = 4;
-            psTreeNode->apsSubNode[0] = ossim_SHPTreeNodeCreate( adfBoundsMin1,
-                                                           adfBoundsMax1 );
-            psTreeNode->apsSubNode[1] = ossim_SHPTreeNodeCreate( adfBoundsMin2,
-                                                           adfBoundsMax2 );
-            psTreeNode->apsSubNode[2] = ossim_SHPTreeNodeCreate( adfBoundsMin3,
-                                                           adfBoundsMax3 );
-            psTreeNode->apsSubNode[3] = ossim_SHPTreeNodeCreate( adfBoundsMin4,
-                                                           adfBoundsMax4 );
-
-            /* recurse back on this node now that it has subnodes */
-            return( ossim_SHPTreeNodeAddShapeId( psTreeNode, psObject,
-                                           nMaxDepth, nDimension ) );
-        }
-    }
-#endif /* MAX_SUBNODE == 4 */
-
-/* -------------------------------------------------------------------- */
-/*      Otherwise, consider creating two subnodes if could fit into     */
-/*      them, and adding to the appropriate subnode.                    */
-/* -------------------------------------------------------------------- */
-#if MAX_SUBNODE == 2
-    else if( nMaxDepth > 1 && psTreeNode->nSubNodes == 0 )
-    {
-        double	adfBoundsMin1[4], adfBoundsMax1[4];
-        double	adfBoundsMin2[4], adfBoundsMax2[4];
-
-        ossim_SHPTreeSplitBounds( psTreeNode->adfBoundsMin, psTreeNode->adfBoundsMax,
-                            adfBoundsMin1, adfBoundsMax1,
-                            adfBoundsMin2, adfBoundsMax2 );
-
-        if( ossim_SHPCheckObjectContained(psObject, nDimension,
-                                 adfBoundsMin1, adfBoundsMax1))
-        {
-            psTreeNode->nSubNodes = 2;
-            psTreeNode->apsSubNode[0] = ossim_SHPTreeNodeCreate( adfBoundsMin1,
-                                                           adfBoundsMax1 );
-            psTreeNode->apsSubNode[1] = ossim_SHPTreeNodeCreate( adfBoundsMin2,
-                                                           adfBoundsMax2 );
-
-            return( ossim_SHPTreeNodeAddShapeId( psTreeNode->apsSubNode[0], psObject,
-                                           nMaxDepth - 1, nDimension ) );
-        }
-        else if( ossim_SHPCheckObjectContained(psObject, nDimension,
-                                         adfBoundsMin2, adfBoundsMax2) )
-        {
-            psTreeNode->nSubNodes = 2;
-            psTreeNode->apsSubNode[0] = ossim_SHPTreeNodeCreate( adfBoundsMin1,
-                                                           adfBoundsMax1 );
-            psTreeNode->apsSubNode[1] = ossim_SHPTreeNodeCreate( adfBoundsMin2,
-                                                           adfBoundsMax2 );
-
-            return( ossim_SHPTreeNodeAddShapeId( psTreeNode->apsSubNode[1], psObject,
-                                           nMaxDepth - 1, nDimension ) );
-        }
-    }
-#endif /* MAX_SUBNODE == 2 */
-
-/* -------------------------------------------------------------------- */
-/*      If none of that worked, just add it to this nodes list.         */
-/* -------------------------------------------------------------------- */
-    psTreeNode->nShapeCount++;
-
-    psTreeNode->panShapeIds = (int *)
-        SfRealloc( psTreeNode->panShapeIds,
-                   sizeof(int) * psTreeNode->nShapeCount );
-    psTreeNode->panShapeIds[psTreeNode->nShapeCount-1] = psObject->nShapeId;
-
-    if( psTreeNode->papsShapeObj != NULL )
-    {
-      psTreeNode->papsShapeObj = (ossim_SHPObject **)
-            SfRealloc( psTreeNode->papsShapeObj,
-                       sizeof(void *) * psTreeNode->nShapeCount );
-        psTreeNode->papsShapeObj[psTreeNode->nShapeCount-1] = NULL;
-    }
-
-    return TRUE;
-}
-
-/************************************************************************/
-/*                         ossim_SHPTreeAddShapeId()                          */
-/*                                                                      */
-/*      Add a shape to the tree, but don't keep a pointer to the        */
-/*      object data, just keep the shapeid.                             */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL
-    ossim_SHPTreeAddShapeId( ossim_SHPTree * psTree, ossim_SHPObject * psObject )
-
-{
-    psTree->nTotalCount++;
-
-    return( ossim_SHPTreeNodeAddShapeId( psTree->psRoot, psObject,
-                                   psTree->nMaxDepth, psTree->nDimension ) );
-}
-
-/************************************************************************/
-/*                      ossim_SHPTreeCollectShapesIds()                       */
-/*                                                                      */
-/*      Work function implementing ossim_SHPTreeFindLikelyShapes() on a       */
-/*      tree node by tree node basis.                                   */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPTreeCollectShapeIds( ossim_SHPTree *hTree, ossim_SHPTreeNode * psTreeNode,
-                        double * padfBoundsMin, double * padfBoundsMax,
-                        int * pnShapeCount, int * pnMaxShapes,
-                        int ** ppanShapeList )
-
-{
-    int		i;
-
-/* -------------------------------------------------------------------- */
-/*      Does this node overlap the area of interest at all?  If not,    */
-/*      return without adding to the list at all.                       */
-/* -------------------------------------------------------------------- */
-    if( !ossim_SHPCheckBoundsOverlap( psTreeNode->adfBoundsMin,
-                                psTreeNode->adfBoundsMax,
-                                padfBoundsMin,
-                                padfBoundsMax,
-                                hTree->nDimension ) )
-        return;
-
-/* -------------------------------------------------------------------- */
-/*      Grow the list to hold the shapes on this node.                  */
-/* -------------------------------------------------------------------- */
-    if( *pnShapeCount + psTreeNode->nShapeCount > *pnMaxShapes )
-    {
-        *pnMaxShapes = (*pnShapeCount + psTreeNode->nShapeCount) * 2 + 20;
-        *ppanShapeList = (int *)
-            SfRealloc(*ppanShapeList,sizeof(int) * *pnMaxShapes);
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Add the local nodes shapeids to the list.                       */
-/* -------------------------------------------------------------------- */
-    for( i = 0; i < psTreeNode->nShapeCount; i++ )
-    {
-        (*ppanShapeList)[(*pnShapeCount)++] = psTreeNode->panShapeIds[i];
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Recurse to subnodes if they exist.                              */
-/* -------------------------------------------------------------------- */
-    for( i = 0; i < psTreeNode->nSubNodes; i++ )
-    {
-        if( psTreeNode->apsSubNode[i] != NULL )
-            ossim_SHPTreeCollectShapeIds( hTree, psTreeNode->apsSubNode[i],
-                                    padfBoundsMin, padfBoundsMax,
-                                    pnShapeCount, pnMaxShapes,
-                                    ppanShapeList );
-    }
-}
-
-/************************************************************************/
-/*                      ossim_SHPTreeFindLikelyShapes()                       */
-/*                                                                      */
-/*      Find all shapes within tree nodes for which the tree node       */
-/*      bounding box overlaps the search box.  The return value is      */
-/*      an array of shapeids terminated by a -1.  The shapeids will     */
-/*      be in order, as hopefully this will result in faster (more      */
-/*      sequential) reading from the file.                              */
-/************************************************************************/
-
-/* helper for qsort */
-static int
-compare_ints( const void * a, const void * b)
-{
-    return (*(int*)a) - (*(int*)b);
-}
-
-int ossim_SHPAPI_CALL1(*)
-    ossim_SHPTreeFindLikelyShapes( ossim_SHPTree * hTree,
-                         double * padfBoundsMin, double * padfBoundsMax,
-                         int * pnShapeCount )
-
-{
-    int	*panShapeList=NULL, nMaxShapes = 0;
-
-/* -------------------------------------------------------------------- */
-/*      Perform the search by recursive descent.                        */
-/* -------------------------------------------------------------------- */
-    *pnShapeCount = 0;
-
-    ossim_SHPTreeCollectShapeIds( hTree, hTree->psRoot,
-                            padfBoundsMin, padfBoundsMax,
-                            pnShapeCount, &nMaxShapes,
-                            &panShapeList );
-
-/* -------------------------------------------------------------------- */
-/*      Sort the id array                                               */
-/* -------------------------------------------------------------------- */
-
-    qsort(panShapeList, *pnShapeCount, sizeof(int), compare_ints);
-
-    return panShapeList;
-}
-
-/************************************************************************/
-/*                          ossim_SHPTreeNodeTrim()                           */
-/*                                                                      */
-/*      This is the recurve version of ossim_SHPTreeTrimExtraNodes() that     */
-/*      walks the tree cleaning it up.                                  */
-/************************************************************************/
-
-static int ossim_SHPTreeNodeTrim( ossim_SHPTreeNode * psTreeNode )
-
-{
-    int		i;
-
-/* -------------------------------------------------------------------- */
-/*      Trim subtrees, and free subnodes that come back empty.          */
-/* -------------------------------------------------------------------- */
-    for( i = 0; i < psTreeNode->nSubNodes; i++ )
-    {
-        if( ossim_SHPTreeNodeTrim( psTreeNode->apsSubNode[i] ) )
-        {
-            ossim_SHPDestroyTreeNode( psTreeNode->apsSubNode[i] );
-
-            psTreeNode->apsSubNode[i] =
-                psTreeNode->apsSubNode[psTreeNode->nSubNodes-1];
-
-            psTreeNode->nSubNodes--;
-
-            i--; /* process the new occupant of this subnode entry */
-        }
-    }
-
-/* -------------------------------------------------------------------- */
-/*      We should be trimmed if we have no subnodes, and no shapes.     */
-/* -------------------------------------------------------------------- */
-    return( psTreeNode->nSubNodes == 0 && psTreeNode->nShapeCount == 0 );
-}
-
-/************************************************************************/
-/*                       ossim_SHPTreeTrimExtraNodes()                        */
-/*                                                                      */
-/*      Trim empty nodes from the tree.  Note that we never trim an     */
-/*      empty root node.                                                */
-/************************************************************************/
-
-void ossim_SHPAPI_CALL
-    ossim_SHPTreeTrimExtraNodes( ossim_SHPTree * hTree )
-
-{
-    ossim_SHPTreeNodeTrim( hTree->psRoot );
-}
-
-/************************************************************************/
-/*                              SwapWord()                              */
-/*                                                                      */
-/*      Swap a 2, 4 or 8 byte word.                                     */
-/************************************************************************/
-
-static void SwapWord( int length, void * wordP )
-
-{
-    int		i;
-    unsigned char	temp;
-
-    for( i=0; i < length/2; i++ )
-    {
-	temp = ((unsigned char *) wordP)[i];
-	((unsigned char *)wordP)[i] = ((unsigned char *) wordP)[length-i-1];
-	((unsigned char *) wordP)[length-i-1] = temp;
-    }
-}
-
-/************************************************************************/
-/*                       ossim_SHPSearchDiskTreeNode()                        */
-/************************************************************************/
-
-static int
-    ossim_SHPSearchDiskTreeNode( FILE *fp, double *padfBoundsMin, double *padfBoundsMax,
-                       int **ppanResultBuffer, int *pnBufferMax,
-                       int *pnResultCount, int bNeedSwap )
-
-{
-    int i;
-    int offset;
-    int numshapes, numsubnodes;
-    double adfNodeBoundsMin[2], adfNodeBoundsMax[2];
-
-/* -------------------------------------------------------------------- */
-/*      Read and unswap first part of node info.                        */
-/* -------------------------------------------------------------------- */
-    fread( &offset, 4, 1, fp );
-    if ( bNeedSwap ) SwapWord ( 4, &offset );
-
-    fread( adfNodeBoundsMin, sizeof(double), 2, fp );
-    fread( adfNodeBoundsMax, sizeof(double), 2, fp );
-    if ( bNeedSwap )
-    {
-        SwapWord( 8, adfNodeBoundsMin + 0 );
-        SwapWord( 8, adfNodeBoundsMin + 1 );
-        SwapWord( 8, adfNodeBoundsMax + 0 );
-        SwapWord( 8, adfNodeBoundsMax + 1 );
-    }
-
-    fread( &numshapes, 4, 1, fp );
-    if ( bNeedSwap ) SwapWord ( 4, &numshapes );
-
-/* -------------------------------------------------------------------- */
-/*      If we don't overlap this node at all, we can just fseek()       */
-/*      pass this node info and all subnodes.                           */
-/* -------------------------------------------------------------------- */
-    if( !ossim_SHPCheckBoundsOverlap( adfNodeBoundsMin, adfNodeBoundsMax,
-                                padfBoundsMin, padfBoundsMax, 2 ) )
-    {
-        offset += numshapes*sizeof(int) + sizeof(int);
-        fseek(fp, offset, SEEK_CUR);
-        return TRUE;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Add all the shapeids at this node to our list.                  */
-/* -------------------------------------------------------------------- */
-    if(numshapes > 0)
-    {
-        if( *pnResultCount + numshapes > *pnBufferMax )
-        {
-            *pnBufferMax = (int) ((*pnResultCount + numshapes + 100) * 1.25);
-            *ppanResultBuffer = (int *)
-                SfRealloc( *ppanResultBuffer, *pnBufferMax * sizeof(int) );
-        }
-
-        fread( *ppanResultBuffer + *pnResultCount,
-               sizeof(int), numshapes, fp );
-
-        if (bNeedSwap )
-        {
-            for( i=0; i<numshapes; i++ )
-                SwapWord( 4, *ppanResultBuffer + *pnResultCount + i );
-        }
-
-        *pnResultCount += numshapes;
-    }
-
-/* -------------------------------------------------------------------- */
-/*      Process the subnodes.                                           */
-/* -------------------------------------------------------------------- */
-    fread( &numsubnodes, 4, 1, fp );
-    if ( bNeedSwap  ) SwapWord ( 4, &numsubnodes );
-
-    for(i=0; i<numsubnodes; i++)
-    {
-      if( !ossim_SHPSearchDiskTreeNode( fp, padfBoundsMin, padfBoundsMax,
-                                    ppanResultBuffer, pnBufferMax,
-                                    pnResultCount, bNeedSwap ) )
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
-/************************************************************************/
-/*                         ossim_SHPSearchDiskTree()                          */
-/************************************************************************/
-
-int ossim_SHPAPI_CALL1(*)
-    ossim_SHPSearchDiskTree( FILE *fp,
-                   double *padfBoundsMin, double *padfBoundsMax,
-                   int *pnShapeCount )
-
-{
-    int i, bNeedSwap, nBufferMax = 0;
-    unsigned char abyBuf[16];
-    int *panResultBuffer = NULL;
-
-    *pnShapeCount = 0;
-
-/* -------------------------------------------------------------------- */
-/*	Establish the byte order on this machine.	  	        */
-/* -------------------------------------------------------------------- */
-    i = 1;
-    if( *((unsigned char *) &i) == 1 )
-        bBigEndian = FALSE;
-    else
-        bBigEndian = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*      Read the header.                                                */
-/* -------------------------------------------------------------------- */
-    fseek( fp, 0, SEEK_SET );
-    fread( abyBuf, 16, 1, fp );
-
-    if( memcmp( abyBuf, "SQT", 3 ) != 0 )
-        return NULL;
-
-    if( (abyBuf[3] == 2 && bBigEndian)
-        || (abyBuf[3] == 1 && !bBigEndian) )
-        bNeedSwap = FALSE;
-    else
-        bNeedSwap = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*      Search through root node and it's decendents.                   */
-/* -------------------------------------------------------------------- */
-    if( !ossim_SHPSearchDiskTreeNode( fp, padfBoundsMin, padfBoundsMax,
-                                &panResultBuffer, &nBufferMax,
-                                pnShapeCount, bNeedSwap ) )
-    {
-        if( panResultBuffer != NULL )
-            free( panResultBuffer );
-        *pnShapeCount = 0;
-        return NULL;
-    }
-/* -------------------------------------------------------------------- */
-/*      Sort the id array                                               */
-/* -------------------------------------------------------------------- */
-    qsort(panResultBuffer, *pnShapeCount, sizeof(int), compare_ints);
-
-    return panResultBuffer;
-}
-
-/************************************************************************/
-/*                        ossim_SHPGetSubNodeOffset()                         */
-/*                                                                      */
-/*      Determine how big all the subnodes of this node (and their      */
-/*      children) will be.  This will allow disk based searchers to     */
-/*      seek past them all efficiently.                                 */
-/************************************************************************/
-
-static int ossim_SHPGetSubNodeOffset( ossim_SHPTreeNode *node)
-{
-    int i;
-    long offset=0;
-
-    for(i=0; i<node->nSubNodes; i++ )
-    {
-        if(node->apsSubNode[i])
-        {
-            offset += 4*sizeof(double)
-                + (node->apsSubNode[i]->nShapeCount+3)*sizeof(int);
-            offset += ossim_SHPGetSubNodeOffset(node->apsSubNode[i]);
-        }
-    }
-
-    return(offset);
-}
-
-/************************************************************************/
-/*                          ossim_SHPWriteTreeNode()                          */
-/************************************************************************/
-
-static void ossim_SHPWriteTreeNode( FILE *fp, ossim_SHPTreeNode *node)
-{
-    int i,j;
-    int offset;
-    unsigned char *pabyRec = NULL;
-
-    offset = ossim_SHPGetSubNodeOffset(node);
-
-    pabyRec = (unsigned char *)
-        malloc(sizeof(double) * 4
-               + (3 * sizeof(int)) + (node->nShapeCount * sizeof(int)) );
-
-    memcpy( pabyRec, &offset, 4);
-
-    /* minx, miny, maxx, maxy */
-    memcpy( pabyRec+ 4, node->adfBoundsMin+0, sizeof(double) );
-    memcpy( pabyRec+12, node->adfBoundsMin+1, sizeof(double) );
-    memcpy( pabyRec+20, node->adfBoundsMax+0, sizeof(double) );
-    memcpy( pabyRec+28, node->adfBoundsMax+1, sizeof(double) );
-
-    memcpy( pabyRec+36, &node->nShapeCount, 4);
-    j = node->nShapeCount * sizeof(int);
-    memcpy( pabyRec+40, node->panShapeIds, j);
-    memcpy( pabyRec+j+40, &node->nSubNodes, 4);
-
-    fwrite( pabyRec, 44+j, 1, fp );
-    free (pabyRec);
-
-    for(i=0; i<node->nSubNodes; i++ )
-    {
-        if(node->apsSubNode[i])
-            ossim_SHPWriteTreeNode( fp, node->apsSubNode[i]);
-    }
-}
-
-/************************************************************************/
-/*                            ossim_SHPWriteTree()                            */
-/************************************************************************/
-
-int ossim_SHPWriteTree(ossim_SHPTree *tree, const char *filename )
-{
-    char		signature[4] = "SQT";
-    int		        i;
-    char		abyBuf[32];
-    FILE                *fp;
-
-/* -------------------------------------------------------------------- */
-/*      Open the output file.                                           */
-/* -------------------------------------------------------------------- */
-    fp = fopen(filename, "wb");
-    if( fp == NULL )
-    {
-        return FALSE;
-    }
-
-/* -------------------------------------------------------------------- */
-/*	Establish the byte order on this machine.	  	        */
-/* -------------------------------------------------------------------- */
-    i = 1;
-    if( *((unsigned char *) &i) == 1 )
-        bBigEndian = FALSE;
-    else
-        bBigEndian = TRUE;
-
-/* -------------------------------------------------------------------- */
-/*      Write the header.                                               */
-/* -------------------------------------------------------------------- */
-    memcpy( abyBuf+0, signature, 3 );
-
-    if( bBigEndian )
-        abyBuf[3] = 2; /* New MSB */
-    else
-        abyBuf[3] = 1; /* New LSB */
-
-    abyBuf[4] = 1; /* version */
-    abyBuf[5] = 0; /* next 3 reserved */
-    abyBuf[6] = 0;
-    abyBuf[7] = 0;
-
-    fwrite( abyBuf, 8, 1, fp );
-
-    fwrite( &(tree->nTotalCount), 4, 1, fp );
-
-    /* write maxdepth */
-
-    fwrite( &(tree->nMaxDepth), 4, 1, fp );
-
-/* -------------------------------------------------------------------- */
-/*      Write all the nodes "in order".                                 */
-/* -------------------------------------------------------------------- */
-
-    ossim_SHPWriteTreeNode( fp, tree->psRoot );
-
-    fclose( fp );
-
-    return TRUE;
-}
diff --git a/Utilities/otbossim/src/ossim/version-config.cpp b/Utilities/otbossim/src/ossim/version-config.cpp
index 0897a737571840619942ff92507498b84b0b694b..2554b2770957947e9543b208499c671693f847b6 100644
--- a/Utilities/otbossim/src/ossim/version-config.cpp
+++ b/Utilities/otbossim/src/ossim/version-config.cpp
@@ -19,12 +19,17 @@
 #include <string>
 #include <iostream>
 
-#include <ossim/ossimConfig.h>
-
-// Caller should pass in path to ossim/include/ossim/ossimVersion.h
+/**
+ * @brief main application for getting version / date and generating the
+ * ossimVersion.h file.
+ *
+ * @param argv[1] Path to ossim/include/ossim/ossimVersion.h
+ *
+ * @param argv[2] Version number string like "1.7.11"
+ */
 int main(int argc, char* argv[])
 {
-   if (argc < 2)
+   if (argc != 3)
    {
       return(1);
    }
@@ -32,21 +37,38 @@ int main(int argc, char* argv[])
    std::ofstream os(argv[1]);
    if (!os)
    {
-      return(12);
+      return(1);
    }
 
-   // Get the version from the ossimConfig.h
+   // Get the version.  This is now passed in from the make file.
    std::string versionString = "Version ";
-   std::string versionNumber = "";
-
-#ifdef OSSIM_VERSION
-   versionString += OSSIM_VERSION;
-   versionNumber =  OSSIM_VERSION;
-#else
-   versionString += "?.?.?";
-   versionNumber += "?.?.?";
-#endif
+   versionString += argv[2];
+   std::string versionNumber = argv[2];
+   std::string majorVersion;
+   std::string minorVersion = "0";
+   std::string releaseVersion = "0";
+   std::string::size_type pos1 = std::string::npos;
+   std::string::size_type pos2 = std::string::npos;
+   std::string::size_type pos3 = std::string::npos;
 
+   pos1 = versionNumber.find(".", 0);
+   if(pos1 != std::string::npos)
+   {
+      majorVersion = std::string(versionNumber.begin(),
+                                 versionNumber.begin()+pos1);
+      pos2 = versionNumber.find(".", pos1+1);
+      if(pos2 != std::string::npos)
+      {
+         minorVersion = std::string(versionNumber.begin()+pos1+1,
+                                    versionNumber.begin()+pos2);
+         releaseVersion = std::string(versionNumber.begin()+pos2+1,
+                                      versionNumber.end());
+      }
+   }
+   else
+   {
+      majorVersion = versionNumber;
+   }
    // Get the build date in the format of (yyyymmdd).
    char s[11];
    s[10] = '\0';
@@ -66,6 +88,9 @@ int main(int argc, char* argv[])
       << "#ifndef OSSIM_VERSION\n"
       << "#  define OSSIM_VERSION " << "\"" << versionString << "\"\n"
       << "#  define OSSIM_VERSION_NUMBER " << "\"" << versionNumber << "\"\n"
+      << "#  define OSSIM_MAJOR_VERSION_NUMBER " << majorVersion << "\n"
+      << "#  define OSSIM_MINOR_VERSION_NUMBER " << minorVersion << "\n"
+      << "#  define OSSIM_RELEASE_NUMBER " << releaseVersion << "\n"
       << "#endif\n"
       << "\n"
       << "// date format = (yyyymmdd)\n"
@@ -79,7 +104,6 @@ int main(int argc, char* argv[])
    os.close();
 
    std::cout << "wrote file: " << argv[1] << std::endl;
-//OTB Modifications
-//   exit(0);
+
    return(0);
 }
diff --git a/Utilities/otbossim/src/ossim/vpfutil/distance.c b/Utilities/otbossim/src/ossim/vpfutil/distance.c
index 853ecaea2c8a53758c8ba941b007f8834814e154..c3bf96e796bd3aa770eb99c10f3c2ae4c40c33b8 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/distance.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/distance.c
@@ -59,8 +59,8 @@
  *    Added kilometers option - May 1991 - BJM
  *E
  *************************************************************************/
-float distance( double lat1, double lon1, double lat2, double lon2,
-		int units )
+float distance(double lat1, double lon1, double lat2, double lon2,
+               int units )
 {
    double a,b,p,dtheta,d;
    double R[2] = { 3958.754, 6370.997 }
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfcntnt.c b/Utilities/otbossim/src/ossim/vpfutil/vpfcntnt.c
index 7a891b0800c23a0b3edf647cb58aa61ee0c325ab..9f16ab3ea7bc5e5276883b34ed32081345ed1542 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfcntnt.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfcntnt.c
@@ -62,6 +62,7 @@
 #include <ossim/vpfutil/vpfmisc.h>
 #include <ossim/vpfutil/vpfdisp.h>
 
+#include <ossim/vpfutil/vpfapi.h>
 
 
 
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfdisp.c b/Utilities/otbossim/src/ossim/vpfutil/vpfdisp.c
index 484dd47edb71c6d0d5f9955a2bdb770139f5861a..e45a4679ce95a31abc9dfbc250599af4ad775836 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfdisp.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfdisp.c
@@ -63,13 +63,12 @@
 #else
 #include <ossim/vpfutil/values.h>
 #endif
+#include <ossim/vpfutil/vpfapi.h>
 #include <ossim/vpfutil/vpftable.h>
 #include <ossim/vpfutil/vpfview.h>
 
-#ifdef HAVE_UNISTD_H
-#  if HAVE_UNISTD_H
+#if (!defined(_WIN32)||defined(__CYGWIN__))
 #    include <unistd.h>  /* For "access" function. */
-#  endif
 #endif
 
 extern color_type menucolor, menubordercolor, menutextcolor;
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfnear.c b/Utilities/otbossim/src/ossim/vpfutil/vpfnear.c
index b24dd69bdc66217c1e37a04fc240e2b7dc70e183..eacca1ef6cd77b4128930c3f7fa44b7f1a34505e 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfnear.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfnear.c
@@ -46,6 +46,7 @@
 #ifdef __MSDOS__
 #include <graphics.h>
 #endif
+#include <ossim/vpfutil/vpfapi.h>
 #include <ossim/vpfutil/vpftable.h>
 #include <ossim/vpfutil/vpfprim.h>
 #include <ossim/vpfutil/vpfview.h>
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c b/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c
index 2a4199e79ba04fb2f0c79a3c1da5c23c8431dab9..bf271a2d32459ce7d2663380720c83a7a923be61 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfquery.c
@@ -187,9 +187,9 @@ static void return_token( char *expr, char *token )
       for (j=0;j<ndelim;j++) {
 	 if (ossim_strncasecmp(expr,delimstr[j],strlen(delimstr[j]))==0) {
 	    if (n>0)
-	       token[i] = (char)NULL;
+	       token[i] = '\0';
 	    else
-	       token[strlen(delimstr[j])] = (char)NULL;
+	       token[strlen(delimstr[j])] = '\0';
 	    found = 1;
 	    break;
 	 }
@@ -253,7 +253,7 @@ static char *get_token( char *expression,
 
    *token_type = (int)NULL;
 
-   if (*expression == (char)NULL) {
+   if (*expression == '\0') {
       *token_type = FINISHED;
       *token_value = (int)NULL;
       return expression;
@@ -281,9 +281,9 @@ static char *get_token( char *expression,
    return_token( expression, token );
    expression += strlen(token);
 
-   if (*token == (char)NULL) {
+   if (*token == '\0') {
       *token_type = FINISHED;
-      *expression = (char)NULL;
+      *expression = '\0';
       return expression;
    }
 
@@ -313,7 +313,7 @@ static char *get_token( char *expression,
 	 token[i] = *expression;
 	 i++;
 	 expression++;
-	 if (*expression == (char)NULL) {
+	 if (*expression == '\0') {
 	    *token_type = ERROR;
 	    *token_value = ERROR;
 	    return expression;
@@ -458,7 +458,7 @@ static linked_list_type parse_expression( char *expression, vpf_table_type table
 	 expression = get_token( expression, token, &token_type,
 				 &token_value );
       } else if (token_type == FINISHED) {
-	 expr.join = (char)NULL;
+	 expr.join = '\0';
 	 ll_insert( &expr, sizeof(expr), pos );
       } else {
 	 display_message("Expression syntax error");
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpfread.c b/Utilities/otbossim/src/ossim/vpfutil/vpfread.c
index 40a062329af7e8e3c25e7558d829c77bb01b3c09..6486205ce003e688d02c601b151a1b2242c35d4d 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpfread.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpfread.c
@@ -142,7 +142,7 @@ static char * get_line (FILE *fp)
 
   }  /* end of for count */
 
-  CurrentLine[count] = (char) NULL ;  /* terminate string */
+  CurrentLine[count] = '\0';  /* terminate string */
   return CurrentLine ;
 
 }
@@ -1281,8 +1281,7 @@ row_type get_row( long int row_number,
  *    This module should be ANSI C compatible.
  *E
  *************************************************************************/
-long int table_pos( char           * field_name,
-		    vpf_table_type   table )
+long int table_pos( const char* field_name, vpf_table_type table )
 {
    register long int i;
    long int col;
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpftable.c b/Utilities/otbossim/src/ossim/vpfutil/vpftable.c
index 2e4220fd242b0a92905fe567849033807b34f662..b5f5ad51bd596636103a4135ac4f7ebb6bdc75a8 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpftable.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpftable.c
@@ -201,7 +201,8 @@ static char *cpy_del(char *src, char delimiter, long int *ind )
 
   temp = &src[skipchar];
 
-  /* If the first character is a COMMENT, goto LINE_CONTINUE */
+  /* If t
+  he first character is a COMMENT, goto LINE_CONTINUE */
 
   if ( *temp == COMMENT ) {
     while ( *temp != LINE_CONTINUE && *temp != END_OF_FIELD && *temp != '\0'){
@@ -230,7 +231,7 @@ static char *cpy_del(char *src, char delimiter, long int *ind )
       /* Now copy the char into the output string */
       tempstr[i] = *temp ;
     }
-    tempstr[i] = (char) NULL ;		/* terminate string */
+    tempstr[i] = '\0';		/* terminate string */
     *ind += ( i + skipchar + 2) ;	/* Increment position locate past */
     return tempstr ;			/* quote and semicolon */
   }
@@ -254,7 +255,7 @@ static char *cpy_del(char *src, char delimiter, long int *ind )
                              /* Eat the delimiter from ind also */
     *ind += ( i + skipchar + 1) ;	/* Increment position locate */
   }	
-  tempstr[i] = (char) NULL ;		/* terminate string */   
+  tempstr[i] = '\0';		/* terminate string */   
   return tempstr;
 }
 /***********Mody B*********/
@@ -472,35 +473,35 @@ long int parse_data_def( vpf_table_type *table )
 	   (char *) vpfmalloc ( table->header[i].count + 1 ) ;
 	 for ( k=0; k < table->header[i].count; k++ )
 	   table->header[i].nullval.Char[k] = NULLCHAR ;
-	 table->header[i].nullval.Char[k] = (char) NULL ;
+	 table->header[i].nullval.Char[k] = '\0';
        } else {			/* variable length */
 	 table->header[i].nullval.Char =
 	   (char *) vpfmalloc ( VARIABLE_STRING_NULL_LENGTH + 1 ) ;
 	 for ( k=0; k < VARIABLE_STRING_NULL_LENGTH ; k++ )
 	   table->header[i].nullval.Char[k] = NULLCHAR ;
-	 table->header[i].nullval.Char[k] = (char) NULL ;
+	 table->header[i].nullval.Char[k] = '\0';
        }
        break;
      case 'C':
        if ( reclen >= 0 )
 	 reclen += (sizeof(coordinate_type)*table->header[i].count);
-       table->header[i].nullval.Other = (char) NULL ;
+       table->header[i].nullval.Other = '\0';
        break;
      case 'Z':
        if ( reclen >= 0 )
 	 reclen += (sizeof(tri_coordinate_type)*table->header[i].count);
-       table->header[i].nullval.Other = (char) NULL ;
+       table->header[i].nullval.Other = '\0' ;
        break;
      case 'B':
        if ( reclen >= 0 )
 	 reclen += (sizeof(double_coordinate_type)*table->header[i].count);
-       table->header[i].nullval.Other = (char) NULL ;
+       table->header[i].nullval.Other = '\0' ;
        break;
      case 'Y':
        if ( reclen >= 0 )
 	 reclen +=
 	   (sizeof(double_tri_coordinate_type)*table->header[i].count);
-       table->header[i].nullval.Other =(char) NULL;
+       table->header[i].nullval.Other ='\0';
        break;
      case 'D':
        if ( reclen >= 0 )
@@ -509,11 +510,11 @@ long int parse_data_def( vpf_table_type *table )
        break;
      case 'K':
        reclen = -1;
-       table->header[i].nullval.Other = (char) NULL ;
+       table->header[i].nullval.Other = '\0' ;
        break;
      case 'X':
        /* do nothing */
-       table->header[i].nullval.Other = (char) NULL ;
+       table->header[i].nullval.Other = '\0' ;
        break ;
      default:
        status = 1;
@@ -646,11 +647,12 @@ static int vpfhandler(long int errval, long int ax, long int bp, long int si)
  *    Dave Flinn        July 1991     Updated for UNIX
  *E
  *************************************************************************/
-FILE *vpfopencheck( char *filename,
-		    char *mode,
-		    char *diskname )
+FILE *vpfopencheck( const char *filename,
+		    const char *mode,
+		    const char *diskname )
 {
    FILE *fp;
+   char* tmpFilename = (char*) malloc ( strlen(filename) + 1 );
 /*
    char *text[] = {"Please insert",
 		   "                                        ",
@@ -669,25 +671,38 @@ FILE *vpfopencheck( char *filename,
    strcpy(text[3],filename);
 #endif
    fp = NULL;
-   while (fp == NULL) {
-      fp = fopen(filename,mode);
-      if (fp == NULL) {
+
+
+   /* copy the filename because we might modify it. */
+   tmpFilename[strlen(filename)] = '\0'; /* just in case */
+   strcpy(tmpFilename, filename);
+   
+   while (fp == NULL)
+   {
+      fp = fopen(tmpFilename,mode);
+      if (fp == NULL)
+      {
 #ifdef __MSDOS__
-	 if ( toupper(home[0]) != toupper(filename[0]) )
+	 if ( toupper(home[0]) != toupper(tmpFilename[0]) )
 	    retry = displayerror(text,   4);
 	 else
 #else
-	     /* give names ending in dot another chance without the dot */
-	     if (filename[strlen(filename)-1] == '.') {
-		 filename[strlen(filename)-1] = '\0';
-		 retry = TRUE;
-	     }
-	 else
+            /* give names ending in dot another chance without the dot */
+            if (tmpFilename[strlen(tmpFilename)-1] == '.')
+            {
+               tmpFilename[strlen(tmpFilename)-1] = '\0';
+               retry = TRUE;
+            }
+            else
 #endif
-	    retry = FALSE;
+               retry = FALSE;
 	 if (!retry) break;
       }
    }
+
+   free(tmpFilename);
+   tmpFilename = 0;
+   
 #ifdef __MSDOS__
    setvect(36,doshandler);
 #endif
@@ -710,10 +725,10 @@ FILE *vpfopencheck( char *filename,
  *
  *   Parameters:
  *A
- *    tablename <input> == (char *) file name of the table.
+ *    tablename <input> == (const char *) file name of the table.
  *    storage   <input> == (storage_type) table storage mode -
  *                                        either ram or disk.
- *    mode      <input> == (char *) file mode for opening the table -
+ *    mode      <input> == (const char *) file mode for opening the table -
  *                                  same as fopen() mode in C.
  *    defstr    <input> == (char *) table definition string used for
  *                                  creating a writable table.
@@ -744,9 +759,9 @@ FILE *vpfopencheck( char *filename,
  *    This module should be ANSI C compatible.
  *E
  *************************************************************************/
-vpf_table_type vpf_open_table( char         * tablename,
+vpf_table_type vpf_open_table( const char * tablename,
 			       storage_type   storage ,
-			       char         * mode,
+			       const char * mode,
 			       char         * defstr )
 {
    vpf_table_type   table;
@@ -1046,7 +1061,7 @@ void vpf_close_table( vpf_table_type *table )
 
 
 
-long int is_vpf_table( char *fname )
+long int is_vpf_table( const char *fname )
 {
    FILE *fp;
    long int n, ok;
diff --git a/Utilities/otbossim/src/ossim/vpfutil/vpftidx.c b/Utilities/otbossim/src/ossim/vpfutil/vpftidx.c
index c978d366272eacc3e4f93d7218ac2c22b67418db..0f9d5144398179444b25d14acec690764c915222 100644
--- a/Utilities/otbossim/src/ossim/vpfutil/vpftidx.c
+++ b/Utilities/otbossim/src/ossim/vpfutil/vpftidx.c
@@ -272,7 +272,7 @@ long int create_thematic_index ( char indextype,
 #endif
   }	/* end of for loop */
 
-  table = vpf_open_table ( tablename, disk, "rb", (char) NULL ) ;
+  table = vpf_open_table ( tablename, disk, "rb", NULL ) ;
 
 
   /* Determine the id_data_size. This will save 50% of file size  */
@@ -492,7 +492,7 @@ long int create_thematic_index ( char indextype,
   if ( h.column_type == 'K' )		/* It's really an I */
     h.column_type = 'I' ;
   for ( i=0; i < 4; i++ )
-    h.padding[i] = (char) NULL ;
+    h.padding[i] = '\0' ;
 
   /* only write the table name, no pathname */
 
@@ -1141,7 +1141,7 @@ long int create_gazetteer_index (char *tablename,
   unsigned long int l,
                     set_byte_size;
 
-  t = vpf_open_table(tablename, disk, "rb", (char) NULL);
+  t = vpf_open_table(tablename, disk, "rb", NULL);
   c = table_pos(strupr(columnname), t);
 
   if (t.header[c].type != 'T') {