From 8455ab72321893e9c92a1b64d74a296035f6277b Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Tue, 23 Mar 2010 10:36:34 +0800
Subject: [PATCH] OSSIM: include ossim modif after integration (QB)

---
 .../ossim/projection/ossimQuickbirdRpcModel.h |   17 +-
 .../support_data/ossimQuickbirdMetaData.h     |   11 +-
 .../projection/ossimQuickbirdRpcModel.cpp     |   23 +-
 .../support_data/ossimQuickbirdMetaData.cpp   | 1132 +++++++++--------
 4 files changed, 596 insertions(+), 587 deletions(-)

diff --git a/Utilities/otbossim/include/ossim/projection/ossimQuickbirdRpcModel.h b/Utilities/otbossim/include/ossim/projection/ossimQuickbirdRpcModel.h
index 2f7a6ebdec..9797853c3b 100644
--- a/Utilities/otbossim/include/ossim/projection/ossimQuickbirdRpcModel.h
+++ b/Utilities/otbossim/include/ossim/projection/ossimQuickbirdRpcModel.h
@@ -14,7 +14,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimQuickbirdRpcModel.h 11720 2007-09-12 14:59:30Z gpotts $
+//  $Id: ossimQuickbirdRpcModel.h 16878 2010-03-18 00:10:32Z gpotts $
 #ifndef ossimQuickbirdRpcModel_HEADER
 #define ossimQuickbirdRpcModel_HEADER
 
@@ -45,7 +45,18 @@ public:
 
    virtual bool parseFile(const ossimFilename& file);
    
-   
+   void setSupportData(ossimQuickbirdMetaData* supportData)
+   {
+      theSupportData = supportData;
+   }
+   ossimQuickbirdMetaData* getSupportData()
+   {
+      return theSupportData.get();
+   }
+   const ossimQuickbirdMetaData* getSupportData()const
+   {
+      return theSupportData.get();
+   }
 protected:
    //void finishConstruction();
    void parseMetaData(const ossimFilename& metadata);
@@ -59,7 +70,7 @@ protected:
     return theSupportData;
   }
 */
-   ossimQuickbirdMetaData* theSupportData;
+   ossimRefPtr<ossimQuickbirdMetaData> theSupportData;
 
 TYPE_DATA
 };
diff --git a/Utilities/otbossim/include/ossim/support_data/ossimQuickbirdMetaData.h b/Utilities/otbossim/include/ossim/support_data/ossimQuickbirdMetaData.h
index dc34bdbc72..4c8f5e4355 100644
--- a/Utilities/otbossim/include/ossim/support_data/ossimQuickbirdMetaData.h
+++ b/Utilities/otbossim/include/ossim/support_data/ossimQuickbirdMetaData.h
@@ -92,12 +92,13 @@ public:
 
    bool parseEPHData(const ossimFilename& data_file);
 
-   ossimString getSatID()
-   {
-		return theSatID;
-   }
+   /** @return theSatID */
+   ossimString getSatID() const;
 
-   bool getEndOfLine( char * fileBuf, ossimString lineBeginning, char * format, ossimString & name );
+   bool getEndOfLine( char * fileBuf,
+                      ossimString lineBeginning,
+                      const char * format,
+                      ossimString & name );
 
  
 
diff --git a/Utilities/otbossim/src/ossim/projection/ossimQuickbirdRpcModel.cpp b/Utilities/otbossim/src/ossim/projection/ossimQuickbirdRpcModel.cpp
index 2040ea9981..e627da818b 100644
--- a/Utilities/otbossim/src/ossim/projection/ossimQuickbirdRpcModel.cpp
+++ b/Utilities/otbossim/src/ossim/projection/ossimQuickbirdRpcModel.cpp
@@ -10,7 +10,7 @@
 // LIMITATIONS: None.
 //
 //*****************************************************************************
-//  $Id: ossimQuickbirdRpcModel.cpp 12105 2007-12-02 17:01:48Z dburken $
+//  $Id: ossimQuickbirdRpcModel.cpp 16891 2010-03-19 20:00:57Z dburken $
 
 #include <ossim/projection/ossimQuickbirdRpcModel.h>
 #include <ossim/base/ossimException.h>
@@ -51,11 +51,7 @@ ossimQuickbirdRpcModel::ossimQuickbirdRpcModel(const ossimQuickbirdRpcModel& rhs
 
 ossimQuickbirdRpcModel::~ossimQuickbirdRpcModel()
 {
-   if (theSupportData)
-   {
-      delete theSupportData;
-      theSupportData = 0;
-   }
+   theSupportData = 0;
 }
 
 ossimObject* ossimQuickbirdRpcModel::dup() const
@@ -122,10 +118,8 @@ bool ossimQuickbirdRpcModel::parseNitfFile(const ossimFilename& file)
          return false;
       }
    }
-   else
-   {
-       theSensorID = theSupportData->getSatID();
-   }
+   
+   theSensorID = theSupportData->getSatID();
 
    if(!hdr.open(rpcFile))
    {
@@ -398,11 +392,8 @@ bool ossimQuickbirdRpcModel::parseTiffFile(const ossimFilename& file)
          return false;
       }
    }
-   else
-   {
-       theSensorID = theSupportData->getSatID();
-   }
 
+   theSensorID = theSupportData->getSatID();
 
    if(!hdr.open(rpcFile))
    {
@@ -552,7 +543,7 @@ bool ossimQuickbirdRpcModel::parseTiffFile(const ossimFilename& file)
 bool ossimQuickbirdRpcModel::saveState(ossimKeywordlist& kwl,
                                        const char* prefix) const
 {
- if(theSupportData)
+ if(theSupportData.valid())
    {
       ossimString supportPrefix = ossimString(prefix) + "support_data.";
       theSupportData->saveState(kwl, supportPrefix);
@@ -564,7 +555,7 @@ bool ossimQuickbirdRpcModel::saveState(ossimKeywordlist& kwl,
 bool ossimQuickbirdRpcModel::loadState(const ossimKeywordlist& kwl,
                                        const char* prefix)
 {
- if(theSupportData)
+ if(theSupportData.valid())
    {
       ossimString supportPrefix = ossimString(prefix) + "support_data.";
       theSupportData->loadState(kwl, supportPrefix);
diff --git a/Utilities/otbossim/src/ossim/support_data/ossimQuickbirdMetaData.cpp b/Utilities/otbossim/src/ossim/support_data/ossimQuickbirdMetaData.cpp
index 45103c802a..8ef9ab4cd7 100644
--- a/Utilities/otbossim/src/ossim/support_data/ossimQuickbirdMetaData.cpp
+++ b/Utilities/otbossim/src/ossim/support_data/ossimQuickbirdMetaData.cpp
@@ -23,28 +23,28 @@
 
 
 RTTI_DEF1(ossimQuickbirdMetaData, "ossimQuickbirdMetaData", ossimObject);
-
+ 
 // Define Trace flags for use within this file:
 static ossimTrace traceExec  ("ossimQuickbirdMetaData:exec");
 static ossimTrace traceDebug ("ossimQuickbirdMetaData:debug");
 
 ossimQuickbirdMetaData::ossimQuickbirdMetaData()
-  :
-  theGenerationDate("Unknown"),
-  theBandId("Unknown"),
-  theBitsPerPixel(0),
-  theSatID("Unknown"),
-  theTLCDate("Unknown"),
-  theSunAzimuth(0.0),
-  theSunElevation(0.0),
-  theSatAzimuth(0.0),
-  theSatElevation(0.0),
-  theTDILevel(0),
-  theAbsCalFactors()
+   :
+   theGenerationDate("Unknown"),
+   theBandId("Unknown"),
+   theBitsPerPixel(0),
+   theSatID("Unknown"),
+   theTLCDate("Unknown"),
+   theSunAzimuth(0.0),
+   theSunElevation(0.0),
+   theSatAzimuth(0.0),
+   theSatElevation(0.0),
+   theTDILevel(0),
+   theAbsCalFactors()
 {
-  //theBitsPerPixel = ossim_0;
-  //theTDILevel = 0;
-  theAbsCalFactors.clear();
+   //theBitsPerPixel = ossim_0;
+   //theTDILevel = 0;
+   theAbsCalFactors.clear();
 }
 
 ossimQuickbirdMetaData::~ossimQuickbirdMetaData()
@@ -53,70 +53,70 @@ ossimQuickbirdMetaData::~ossimQuickbirdMetaData()
 
 bool ossimQuickbirdMetaData::open(const ossimFilename& imageFile)
 {
-  static const char MODULE[] = "ossimQuickbirdMetaData::open";
+   static const char MODULE[] = "ossimQuickbirdMetaData::open";
 
-  clearFields();
+   clearFields();
 
-  //retrieve information from the metadata file
-  //if the Quickbird tif is 02APR01105228-M1BS-000000128955_01_P001.TIF
-  //the metadata file will be 02APR01105228-M1BS-000000128955_01_P001.IMD
+   //retrieve information from the metadata file
+   //if the Quickbird tif is 02APR01105228-M1BS-000000128955_01_P001.TIF
+   //the metadata file will be 02APR01105228-M1BS-000000128955_01_P001.IMD
 
-  ossimFilename metadatafile = imageFile;
-  metadatafile.setExtension(ossimString("IMD"));
+   ossimFilename metadatafile = imageFile;
+   metadatafile.setExtension(ossimString("IMD"));
 
-  if( parseMetaData(metadatafile) == false )
-    {
+   if( parseMetaData(metadatafile) == false )
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_WARN)
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
 	    << MODULE << " errors parsing metadata" << std::endl;
-	}
+      }
       return false;
-    }
+   }
 
-  return true;
+   return true;
 }
 
 void ossimQuickbirdMetaData::clearFields()
 {
-  theGenerationDate = "Unknown";
-  theBitsPerPixel = 0;
-  theBandId = "Unknown";
-  theSatID = "Unknown";
-  theTLCDate = "Unknown",
-  theSunAzimuth = 0.0;
-  theSunElevation = 0.0;
-  theSatAzimuth = 0.0;
-  theSatElevation = 0.0;
-  theTDILevel = 0;
-  theAbsCalFactors.clear();
+   theGenerationDate = "Unknown";
+   theBitsPerPixel = 0;
+   theBandId = "Unknown";
+   theSatID = "Unknown";
+   theTLCDate = "Unknown",
+      theSunAzimuth = 0.0;
+   theSunElevation = 0.0;
+   theSatAzimuth = 0.0;
+   theSatElevation = 0.0;
+   theTDILevel = 0;
+   theAbsCalFactors.clear();
 }
 
 std::ostream& ossimQuickbirdMetaData::print(std::ostream& out) const
 {
 
-  out << "\n----------------- Info on Quickbird Image -------------------"
-      << "\n  "
-      << "\n  Generation date:   " << theGenerationDate
-      << "\n  Band Id:   " << theBandId
-      << "\n  Bits per pixel: " << theBitsPerPixel
-      << "\n  Sat Id:   " << theSatID
-      << "\n  TLC date:   " << theTLCDate
-      << "\n  Sun Azimuth:    " << theSunAzimuth
-      << "\n  Sun Elevation:   " << theSunElevation
-      << "\n  Sat Azimuth:    " << theSatAzimuth
-      << "\n  Sat Elevation:   " << theSatElevation
-      << "\n  TDI Level: " << theTDILevel
-      << "\n  abs Calibration Factors:   " 
-      << std::endl;
-      for(unsigned int i=0; i<theAbsCalFactors.size(); i++)
-      {
-      	out<<theAbsCalFactors[i] << "   ";
-      }
-      out<< "\n"
+   out << "\n----------------- Info on Quickbird Image -------------------"
+       << "\n  "
+       << "\n  Generation date:   " << theGenerationDate
+       << "\n  Band Id:   " << theBandId
+       << "\n  Bits per pixel: " << theBitsPerPixel
+       << "\n  Sat Id:   " << theSatID
+       << "\n  TLC date:   " << theTLCDate
+       << "\n  Sun Azimuth:    " << theSunAzimuth
+       << "\n  Sun Elevation:   " << theSunElevation
+       << "\n  Sat Azimuth:    " << theSatAzimuth
+       << "\n  Sat Elevation:   " << theSatElevation
+       << "\n  TDI Level: " << theTDILevel
+       << "\n  abs Calibration Factors:   " 
+       << std::endl;
+   for(unsigned int i=0; i<theAbsCalFactors.size(); i++)
+   {
+      out<<theAbsCalFactors[i] << "   ";
+   }
+   out<< "\n"
       << "\n---------------------------------------------------------"
       << "\n  " << std::endl;
-  return out;
+   return out;
 }
 
 bool ossimQuickbirdMetaData::saveState(ossimKeywordlist& kwl,
@@ -124,216 +124,216 @@ bool ossimQuickbirdMetaData::saveState(ossimKeywordlist& kwl,
 {
 
 
-  kwl.add(prefix,
-          ossimKeywordNames::TYPE_KW,
-          "ossimQuickbirdMetaData",
-          true);
-
-  kwl.add(prefix,
-          "generation_date",
-          theGenerationDate,
-          true);
-
-  kwl.add(prefix,
-          "bits_per_pixel",
-          theBitsPerPixel,
-          true);
-
-  kwl.add(prefix,
-          "band_id",
-          theBandId,
-          true);
-
-  kwl.add(prefix,
-          "sat_id",
-          theSatID,
-          true);
-
-  kwl.add(prefix,
-          "tlc_date",
-          theTLCDate,
-          true);
-
-  kwl.add(prefix,
-          ossimKeywordNames::AZIMUTH_ANGLE_KW,
-          theSunAzimuth,
-          true);
-
-  kwl.add(prefix,
-          ossimKeywordNames::ELEVATION_ANGLE_KW,
-          theSunElevation,
-          true);
-
-  kwl.add(prefix,
-          "sat_azimuth_angle",
-          theSatAzimuth,
-          true);
-
-  kwl.add(prefix,
-          "sat_elevation_angle",
-          theSatElevation,
-          true);
+   kwl.add(prefix,
+           ossimKeywordNames::TYPE_KW,
+           "ossimQuickbirdMetaData",
+           true);
+
+   kwl.add(prefix,
+           "generation_date",
+           theGenerationDate,
+           true);
+
+   kwl.add(prefix,
+           "bits_per_pixel",
+           theBitsPerPixel,
+           true);
+
+   kwl.add(prefix,
+           "band_id",
+           theBandId,
+           true);
+
+   kwl.add(prefix,
+           "sat_id",
+           theSatID,
+           true);
+
+   kwl.add(prefix,
+           "tlc_date",
+           theTLCDate,
+           true);
+
+   kwl.add(prefix,
+           ossimKeywordNames::AZIMUTH_ANGLE_KW,
+           theSunAzimuth,
+           true);
+
+   kwl.add(prefix,
+           ossimKeywordNames::ELEVATION_ANGLE_KW,
+           theSunElevation,
+           true);
+
+   kwl.add(prefix,
+           "sat_azimuth_angle",
+           theSatAzimuth,
+           true);
+
+   kwl.add(prefix,
+           "sat_elevation_angle",
+           theSatElevation,
+           true);
           
-  kwl.add(prefix,
-          "TDI_level",
-          theTDILevel,
-          true);
-
-  if(theBandId=="Multi")
-  {
-    kwl.add(prefix,
-            "B_band_absCalFactor",
-            theAbsCalFactors[0],
-            true);
-    kwl.add(prefix,
-            "G_band_absCalFactor",
-            theAbsCalFactors[1],
-            true);
-    kwl.add(prefix,
-            "R_band_absCalFactor",
-            theAbsCalFactors[2],
-            true);                        
-    kwl.add(prefix,
-            "N_band_absCalFactor",
-            theAbsCalFactors[3],
-            true);  
-  }
-  else
-  {
-    kwl.add(prefix,
-            "absCalFactor",
-            theAbsCalFactors[0],
-            true);  	
-  }
-
-  return true;
+   kwl.add(prefix,
+           "TDI_level",
+           theTDILevel,
+           true);
+
+   if(theBandId=="Multi")
+   {
+      kwl.add(prefix,
+              "B_band_absCalFactor",
+              theAbsCalFactors[0],
+              true);
+      kwl.add(prefix,
+              "G_band_absCalFactor",
+              theAbsCalFactors[1],
+              true);
+      kwl.add(prefix,
+              "R_band_absCalFactor",
+              theAbsCalFactors[2],
+              true);                        
+      kwl.add(prefix,
+              "N_band_absCalFactor",
+              theAbsCalFactors[3],
+              true);  
+   }
+   else
+   {
+      kwl.add(prefix,
+              "absCalFactor",
+              theAbsCalFactors[0],
+              true);  	
+   }
+
+   return true;
 }
 
 bool ossimQuickbirdMetaData::loadState(const ossimKeywordlist& kwl,
 				       const char* prefix)
 {
-  clearFields();
+   clearFields();
 
-  const char* lookup = 0;
-  ossimString s;
+   const char* lookup = 0;
+   ossimString s;
   
-  lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   if (lookup)
+   {
       s = lookup;
       if(s != "ossimQuickbirdMetaData")
-	{
-	  return false;
-	}
-    }
-
-  lookup = kwl.find(prefix, "generation_date");
-  if (lookup)
-    {
+      {
+         return false;
+      }
+   }
+
+   lookup = kwl.find(prefix, "generation_date");
+   if (lookup)
+   {
       theGenerationDate = lookup;
-    }
+   }
 
-  lookup = kwl.find(prefix, "band_id");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "band_id");
+   if (lookup)
+   {
       theBandId = lookup;
-    }
+   }
   
-  lookup = kwl.find(prefix, "bits_per_pixel");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "bits_per_pixel");
+   if (lookup)
+   {
       s = lookup;
       theBitsPerPixel = s.toInt();;
-    }
+   }
     
-  lookup = kwl.find(prefix, "sat_id");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "sat_id");
+   if (lookup)
+   {
       theSatID = lookup;
-    }
+   }
 
-  lookup = kwl.find(prefix, "tlc_date");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "tlc_date");
+   if (lookup)
+   {
       theTLCDate= lookup;
-    }
+   }
 
-  lookup = kwl.find(prefix, "TDI_level");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "TDI_level");
+   if (lookup)
+   {
       s = lookup;
       theTDILevel = s.toInt();
-    }
+   }
 
-  lookup = kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW);
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW);
+   if (lookup)
+   {
       s = lookup;
       theSunAzimuth = s.toFloat64();
-    }
+   }
 
-  lookup = kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW);
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW);
+   if (lookup)
+   {
       s = lookup;
       theSunElevation = s.toFloat64();
-    }
+   }
 
-  lookup = kwl.find(prefix, "sat_azimuth_angle");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "sat_azimuth_angle");
+   if (lookup)
+   {
       s = lookup;
       theSatAzimuth = s.toFloat64();
-    }
+   }
 
-  lookup = kwl.find(prefix, "sat_elevation_angle");
-  if (lookup)
-    {
+   lookup = kwl.find(prefix, "sat_elevation_angle");
+   if (lookup)
+   {
       s = lookup;
       theSatElevation = s.toFloat64();
-    }
+   }
     
-  if(theBandId=="Multi")
-  {
-    theAbsCalFactors = std::vector<double>(4, 1.);
-    lookup = kwl.find(prefix, "B_band_absCalFactor");
-    if (lookup)
-    {
-      s = lookup;
-      theAbsCalFactors[0] = s.toDouble();
-    }
-    lookup = kwl.find(prefix, "G_band_absCalFactor");
-    if (lookup)
-    {
-      s = lookup;
-      theAbsCalFactors[1] = s.toDouble();
-    }
-    lookup = kwl.find(prefix, "R_band_absCalFactor");
-    if (lookup)
-    {
-      s = lookup;
-      theAbsCalFactors[2] = s.toDouble();
-    }
-    lookup = kwl.find(prefix, "N_band_absCalFactor");
-    if (lookup)
-    {
-      s = lookup;
-      theAbsCalFactors[3] = s.toDouble();
-    }
-  }
-  else if (theBandId=="P")
-  {
-    theAbsCalFactors = std::vector<double>(1, 1.);
-    lookup = kwl.find(prefix, "absCalFactor");
-    if (lookup)
-    {
-      s = lookup;
-      theAbsCalFactors[0] = s.toDouble();
-    }	
-  }
+   if(theBandId=="Multi")
+   {
+      theAbsCalFactors = std::vector<double>(4, 1.);
+      lookup = kwl.find(prefix, "B_band_absCalFactor");
+      if (lookup)
+      {
+         s = lookup;
+         theAbsCalFactors[0] = s.toDouble();
+      }
+      lookup = kwl.find(prefix, "G_band_absCalFactor");
+      if (lookup)
+      {
+         s = lookup;
+         theAbsCalFactors[1] = s.toDouble();
+      }
+      lookup = kwl.find(prefix, "R_band_absCalFactor");
+      if (lookup)
+      {
+         s = lookup;
+         theAbsCalFactors[2] = s.toDouble();
+      }
+      lookup = kwl.find(prefix, "N_band_absCalFactor");
+      if (lookup)
+      {
+         s = lookup;
+         theAbsCalFactors[3] = s.toDouble();
+      }
+   }
+   else if (theBandId=="P")
+   {
+      theAbsCalFactors = std::vector<double>(1, 1.);
+      lookup = kwl.find(prefix, "absCalFactor");
+      if (lookup)
+      {
+         s = lookup;
+         theAbsCalFactors[0] = s.toDouble();
+      }	
+   }
 
 
-  return true;
+   return true;
 }
 
 //*****************************************************************************
@@ -344,107 +344,105 @@ bool ossimQuickbirdMetaData::loadState(const ossimKeywordlist& kwl,
 //*****************************************************************************
 bool ossimQuickbirdMetaData::parseMetaData(const ossimFilename& data_file)
 {
-  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimQuickbirdMetaData::parseMetaData(data_file): entering..." << std::endl;
+   if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimQuickbirdMetaData::parseMetaData(data_file): entering..." << std::endl;
    
-  if( !data_file.exists() )
-    {
-     if (traceExec()) ossimNotify(ossimNotifyLevel_WARN) << "ossimQuickbirdMetaData::parseMetaData(data_file) WARN:" << "\nmetadate data file <" << data_file << ">. " << "doesn't exist..." << std::endl;
-     return false;
-    }
+   if( !data_file.exists() )
+   {
+      if (traceExec()) ossimNotify(ossimNotifyLevel_WARN) << "ossimQuickbirdMetaData::parseMetaData(data_file) WARN:" << "\nmetadate data file <" << data_file << ">. " << "doesn't exist..." << std::endl;
+      return false;
+   }
   
 
-  FILE* fptr = fopen (data_file, "r");
-  if (!fptr)
-    {
+   FILE* fptr = fopen (data_file, "r");
+   if (!fptr)
+   {
       if (traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_DEBUG)
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)
 	    << "ossimQuickbirdRpcModel::parseMetaData(data_file) DEBUG:"
 	    << "\nCould not open Meta data file:  " << data_file
 	    << "\nreturning with error..." << std::endl;
-	}
+      }
       return false;
-    }
-
-  char* strptr(NULL);
-  char dummy[80], name[80];
-  double value(0.);
-
-  //---
-  // Read the file into a buffer:
-  //---
-  ossim_int32 fileSize = static_cast<ossim_int32>(data_file.fileSize());
-  char* filebuf = new char[fileSize];
-  fread(filebuf, 1, fileSize, fptr);
-  strptr = filebuf;
-  fclose(fptr);
-  ossimString temp;
-
-  //---
-  // Generation time:
-  //---
+   }
+
+   char* strptr(NULL);
+
+   //---
+   // Read the file into a buffer:
+   //---
+   ossim_int32 fileSize = static_cast<ossim_int32>(data_file.fileSize());
+   char* filebuf = new char[fileSize];
+   fread(filebuf, 1, fileSize, fptr);
+   strptr = filebuf;
+   fclose(fptr);
+   ossimString temp;
+
+   //---
+   // Generation time:
+   //---
   
-  if(getEndOfLine( strptr, ossimString("\ngenerationTime ="), "%17c %s", temp))
-    theGenerationDate = ossimString(temp).before(";");
-  else
-    {
+   if(getEndOfLine( strptr, ossimString("\ngenerationTime ="), "%17c %s", temp))
+      theGenerationDate = ossimString(temp).before(";");
+   else
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_FATAL)
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
 	    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
 	    << "\n\tAborting construction. Error encountered parsing "
 	    << "presumed meta-data file." << std::endl;
 
-	  delete [] filebuf;
-	  return false;
-	}
-    }
-
-  //---
-  // BandId:
-  //---
-  if(getEndOfLine( strptr, ossimString("\nbandId ="), "%9c %s", temp))
-    theBandId = ossimString(temp).after("\"").before("\";");
-  else
-    {
+         delete [] filebuf;
+         return false;
+      }
+   }
+
+   //---
+   // BandId:
+   //---
+   if(getEndOfLine( strptr, ossimString("\nbandId ="), "%9c %s", temp))
+      theBandId = ossimString(temp).after("\"").before("\";");
+   else
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_FATAL)
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
 	    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
 	    << "\n\tAborting construction. Error encountered parsing "
 	    << "presumed meta-data file." << std::endl;
 
-	  delete [] filebuf;
-	  return false;
-	}
-    }
+         delete [] filebuf;
+         return false;
+      }
+   }
     
   
-  //---
-  // BitsPerPixel:
-  //---
-  if(getEndOfLine( strptr, ossimString("\nbitsPerPixel = "), "%16c %s", temp))
-    theBitsPerPixel = ossimString(temp).before(";").toInt();
-  else
-    {
+   //---
+   // BitsPerPixel:
+   //---
+   if(getEndOfLine( strptr, ossimString("\nbitsPerPixel = "), "%16c %s", temp))
+      theBitsPerPixel = ossimString(temp).before(";").toInt();
+   else
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_FATAL)
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
 	    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
 	    << "\n\tAborting construction. Error encountered parsing "
 	    << "presumed meta-data file." << std::endl;
 
-	  delete [] filebuf;
-	  return false;
-	}
-    }
+         delete [] filebuf;
+         return false;
+      }
+   }
      
-  //---
-  // absCalFactors:
-  //---
-  //--- Multispectral
-  if(theBandId=="Multi")
-    {
+   //---
+   // absCalFactors:
+   //---
+   //--- Multispectral
+   if(theBandId=="Multi")
+   {
       theAbsCalFactors = std::vector<double>(4, 1.);
       std::vector<ossimString> bandList(4, "B");
       bandList[1] = "G";
@@ -452,281 +450,281 @@ bool ossimQuickbirdMetaData::parseMetaData(const ossimFilename& data_file)
       bandList[3] = "N";
       for(unsigned int j=0; j<bandList.size(); j++)
       {
-      	ossimString begin_group = "BEGIN_GROUP = BAND_" + bandList[j];
-      	strptr = strstr(filebuf, begin_group.c_str());
-      	if(!strptr && traceDebug())
-	    {	  				
-			ossimNotify(ossimNotifyLevel_FATAL)
-	    				<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-	    				<< "\n\tAborting construction. Error encountered parsing "
-	     				<< "presumed meta-data file." << std::endl;
-		  	delete [] filebuf;
-  			return false;
-		}
-      	else
-      	{
-          char dummy[80], nameChar[80];
-          sscanf(strptr, "%19c %s", dummy, nameChar);
-          ossimString bandCur = ossimString(nameChar).before("\n");
-          if(!strptr && traceDebug())
-	      {	  				
-	    	ossimNotify(ossimNotifyLevel_FATAL)
-	    				<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-	    				<< "\n\tAborting construction. Error encountered parsing "
-	     				<< "presumed meta-data file." << std::endl;
-		  	delete [] filebuf;
-  			return false;
-		  }
-          else
-	  		{
-	  			if(bandList[j] == bandCur)
-	  			{
-	  			strptr = strstr(strptr, "\tabsCalFactor = ");
-	  			sscanf(strptr, "%16c %s", dummy, nameChar);
-	  			theAbsCalFactors[j] = ossimString(nameChar).before(";").toDouble();
-	  			}
+         ossimString begin_group = "BEGIN_GROUP = BAND_" + bandList[j];
+         strptr = strstr(filebuf, begin_group.c_str());
+         if(!strptr && traceDebug())
+         {	  				
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+            delete [] filebuf;
+            return false;
+         }
+         else
+         {
+            char dummy[80], nameChar[80];
+            sscanf(strptr, "%19c %s", dummy, nameChar);
+            ossimString bandCur = ossimString(nameChar).before("\n");
+            if(!strptr && traceDebug())
+            {	  				
+               ossimNotify(ossimNotifyLevel_FATAL)
+                  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+                  << "\n\tAborting construction. Error encountered parsing "
+                  << "presumed meta-data file." << std::endl;
+               delete [] filebuf;
+               return false;
             }
-      	}
-     }
-     }
-  //--- Panchromatic
-  else
-    {
+            else
+            {
+               if(bandList[j] == bandCur)
+               {
+                  strptr = strstr(strptr, "\tabsCalFactor = ");
+                  sscanf(strptr, "%16c %s", dummy, nameChar);
+                  theAbsCalFactors[j] = ossimString(nameChar).before(";").toDouble();
+               }
+            }
+         }
+      }
+   }
+   //--- Panchromatic
+   else
+   {
       theAbsCalFactors = std::vector<double>(1, 1.);
       if(getEndOfLine( strptr, ossimString("\tabsCalFactor = "), "%16c %s", temp))
-        theAbsCalFactors[0] = ossimString(temp).before(";").toDouble();
+         theAbsCalFactors[0] = ossimString(temp).before(";").toDouble();
       else
-    	{
-      		if(traceDebug())
-			{
-	  			ossimNotify(ossimNotifyLevel_FATAL)
-				    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-				    << "\n\tAborting construction. Error encountered parsing "
-				    << "presumed meta-data file." << std::endl;
-
-			  delete [] filebuf;
-			  return false;
-			}
-	    }
-    }
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
     
-  //---
-  // SatID:
-  //---
-  if(getEndOfLine( strptr, ossimString("\n\tsatId ="), "%9c %s", temp))
-    theSatID = ossimString(temp).after("\"").before("\";");
-  else
-    {
+   //---
+   // SatID:
+   //---
+   if(getEndOfLine( strptr, ossimString("\n\tsatId ="), "%9c %s", temp))
+      theSatID = ossimString(temp).after("\"").before("\";");
+   else
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_FATAL)
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
 	    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
 	    << "\n\tAborting construction. Error encountered parsing "
 	    << "presumed meta-data file." << std::endl;
 
-	  delete [] filebuf;
-	  return false;
-	}
-    }
+         delete [] filebuf;
+         return false;
+      }
+   }
 
 
-  //---
-  // TLCTime:
-  //---
-  if(getEndOfLine( strptr, ossimString("\n\tTLCTime ="), "%11c %s", temp))
-    theTLCDate = ossimString(temp).before("\";");
-  else
-    {
+   //---
+   // TLCTime:
+   //---
+   if(getEndOfLine( strptr, ossimString("\n\tTLCTime ="), "%11c %s", temp))
+      theTLCDate = ossimString(temp).before("\";");
+   else
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_FATAL)
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
 	    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
 	    << "\n\tAborting construction. Error encountered parsing "
 	    << "presumed meta-data file." << std::endl;
 
-	  delete [] filebuf;
-	  return false;
-	}
-    }
+         delete [] filebuf;
+         return false;
+      }
+   }
 
 
-  //***
-  // Sun Azimuth:
-  //***
-  if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp))
-    theSunAzimuth = ossimString(temp).before(";").toFloat64();
-  else
-    {
+   //***
+   // Sun Azimuth:
+   //***
+   if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp))
+        theSunAzimuth = ossimString(temp).before(";").toFloat64();
+   else
+   {
       if(getEndOfLine( strptr, ossimString("\n\tmeanSunAz ="), "%13c %s", temp))
-	theSunAzimuth = ossimString(temp).before(";").toFloat64();
+         theSunAzimuth = ossimString(temp).before(";").toFloat64();
       else
-	{
-	  if(traceDebug())
-	    {
-	      ossimNotify(ossimNotifyLevel_FATAL)
-		<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-		<< "\n\tAborting construction. Error encountered parsing "
-		<< "presumed meta-data file." << std::endl;
-
-	      delete [] filebuf;
-	      return false;
-	    }
-	}
-    }
-
-  //***
-  // Sun Elevation:
-  //***
-  if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp))
-    theSunElevation = ossimString(temp).before(";").toFloat64();
-  else
-    {
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
+
+   //***
+   // Sun Elevation:
+   //***
+   if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp))
+        theSunElevation = ossimString(temp).before(";").toFloat64();
+   else
+   {
       if(getEndOfLine( filebuf, ossimString("\n\tmeanSunEl ="), "%13c %s", temp))
-	theSunElevation = ossimString(temp).before(";").toFloat64();
+         theSunElevation = ossimString(temp).before(";").toFloat64();
       else
-	{
-	  if(traceDebug())
-	    {
-	      ossimNotify(ossimNotifyLevel_FATAL)
-		<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-		<< "\n\tAborting construction. Error encountered parsing "
-		<< "presumed meta-data file." << std::endl;
-
-	      delete [] filebuf;
-	      return false;
-	    }
-	}
-    }
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
 
    //***
-  // Sun Azimuth:
-  //***
-  if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp))
-    theSunAzimuth = ossimString(temp).before(";").toFloat64();
-  else
-    {
+        // Sun Azimuth:
+        //***
+             if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp))
+             theSunAzimuth = ossimString(temp).before(";").toFloat64();
+   else
+   {
       if(getEndOfLine( strptr, ossimString("\n\tmeanSunAz ="), "%13c %s", temp))
-	theSunAzimuth = ossimString(temp).before(";").toFloat64();
+         theSunAzimuth = ossimString(temp).before(";").toFloat64();
       else
-	{
-	  if(traceDebug())
-	    {
-	      ossimNotify(ossimNotifyLevel_FATAL)
-		<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-		<< "\n\tAborting construction. Error encountered parsing "
-		<< "presumed meta-data file." << std::endl;
-
-	      delete [] filebuf;
-	      return false;
-	    }
-	}
-    }
-
-  //***
-  // Sun Elevation:
-  //***
-  if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp))
-    theSunElevation = ossimString(temp).before(";").toFloat64();
-  else
-    {
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
+
+   //***
+   // Sun Elevation:
+   //***
+   if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp))
+        theSunElevation = ossimString(temp).before(";").toFloat64();
+   else
+   {
       if(getEndOfLine( filebuf, ossimString("\n\tmeanSunEl ="), "%13c %s", temp))
-	theSunElevation = ossimString(temp).before(";").toFloat64();
+         theSunElevation = ossimString(temp).before(";").toFloat64();
       else
-	{
-	  if(traceDebug())
-	    {
-	      ossimNotify(ossimNotifyLevel_FATAL)
-		<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-		<< "\n\tAborting construction. Error encountered parsing "
-		<< "presumed meta-data file." << std::endl;
-
-	      delete [] filebuf;
-	      return false;
-	    }
-	}
-    }
-
-
-  //***
-  // Sat Azimuth:
-  //***
-  if(getEndOfLine( strptr, ossimString("\n\tsatAz ="), "%9c %s", temp))
-    theSatAzimuth = ossimString(temp).before(";").toFloat64();
-  else
-    {
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
+
+
+   //***
+   // Sat Azimuth:
+   //***
+   if(getEndOfLine( strptr, ossimString("\n\tsatAz ="), "%9c %s", temp))
+        theSatAzimuth = ossimString(temp).before(";").toFloat64();
+   else
+   {
       if(getEndOfLine( strptr, ossimString("\n\tmeanSatAz ="), "%13c %s", temp))
-	    theSatAzimuth = ossimString(temp).before(";").toFloat64();
+         theSatAzimuth = ossimString(temp).before(";").toFloat64();
       else
-	{
-	  if(traceDebug())
-	    {
-	      ossimNotify(ossimNotifyLevel_FATAL)
-		<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-		<< "\n\tAborting construction. Error encountered parsing "
-		<< "presumed meta-data file." << std::endl;
-
-	      delete [] filebuf;
-	      return false;
-	    }
-	}
-    }
-
-  //***
-  // Sat Elevation:
-  //***
-  if(getEndOfLine( filebuf, ossimString("\n\tsatEl ="), "%9c %s", temp))
-    theSatElevation = ossimString(temp).before(";").toFloat64();
-  else
-    {
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+            
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
+   
+   //***
+   // Sat Elevation:
+   //***
+   if(getEndOfLine( filebuf, ossimString("\n\tsatEl ="), "%9c %s", temp))
+        theSatElevation = ossimString(temp).before(";").toFloat64();
+   else
+   {
       if(getEndOfLine( filebuf, ossimString("\n\tmeanSatEl ="), "%13c %s", temp))
-	theSatElevation = ossimString(temp).before(";").toFloat64();
+         theSatElevation = ossimString(temp).before(";").toFloat64();
       else
-	{
-	  if(traceDebug())
-	    {
-	      ossimNotify(ossimNotifyLevel_FATAL)
-		<< "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
-		<< "\n\tAborting construction. Error encountered parsing "
-		<< "presumed meta-data file." << std::endl;
-
-	      delete [] filebuf;
-	      return false;
-	    }
-	}
-    }
-
-
- //---
-  // TDILevel:
-  //---
-  if(getEndOfLine( strptr, ossimString("\n\tTDILevel = "), "%13c %s", temp))
-    theTDILevel = ossimString(temp).before(";").toInt();
-  else
-    {
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_FATAL)
+               << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
+               << "\n\tAborting construction. Error encountered parsing "
+               << "presumed meta-data file." << std::endl;
+            
+            delete [] filebuf;
+            return false;
+         }
+      }
+   }
+   
+   
+   //---
+   // TDILevel:
+   //---
+   if(getEndOfLine( strptr, ossimString("\n\tTDILevel = "), "%13c %s", temp))
+      theTDILevel = ossimString(temp).before(";").toInt();
+   else
+   {
       if(traceDebug())
-	{
-	  ossimNotify(ossimNotifyLevel_FATAL)
+      {
+         ossimNotify(ossimNotifyLevel_FATAL)
 	    << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
 	    << "\n\tAborting construction. Error encountered parsing "
 	    << "presumed meta-data file." << std::endl;
 
-	  delete [] filebuf;
-	  return false;
-	}
-    }
+         delete [] filebuf;
+         return false;
+      }
+   }
 
 
-  delete [] filebuf;
-  filebuf = 0;
+   delete [] filebuf;
+   filebuf = 0;
 
-  if (traceExec())
-    {
+   if (traceExec())
+   {
       ossimNotify(ossimNotifyLevel_DEBUG)
-        << "DEBUG ossimQuickbirdRpcModel::parseMetaData(data_file): returning..."
-        << std::endl;
-    }
+         << "DEBUG ossimQuickbirdRpcModel::parseMetaData(data_file): returning..."
+         << std::endl;
+   }
 
-  return true;
+   return true;
 }
 
 //*****************************************************************************
@@ -762,35 +760,43 @@ bool ossimQuickbirdMetaData::parseATTData(const ossimFilename& data_file)
   return true;
 }
 
+ossimString ossimQuickbirdMetaData::getSatID() const
+{
+   return theSatID;
+}
+
 //*****************************************************************************
 // PROTECTED METHOD: ossimQuickbirdMetaData::getEndOfLine
 //
 // //  Parse a char * to find another char *. Change the pointer only if the second char * is found.
 //
 //*****************************************************************************
-bool ossimQuickbirdMetaData::getEndOfLine( char * fileBuf, ossimString lineBeginning, char * format, ossimString & name)
-  {
-     //char * res = strstr(fileBuf, lineBeginning.c_str());
-     //if (!res)
-     //{
-     //  return false;
-     // }
-    //// if the lineBeginning is found, update the start pointer adress
-    //fileBuf = res;
-        
-    //char dummy[80], nameChar[80];
-    //sscanf(res, format, dummy, nameChar);    
-    //name = ossimString(nameChar);
+bool ossimQuickbirdMetaData::getEndOfLine( char * fileBuf,
+                                           ossimString lineBeginning,
+                                           const char * format,
+                                           ossimString & name)
+{
+   //char * res = strstr(fileBuf, lineBeginning.c_str());
+   //if (!res)
+   //{
+   //  return false;
+   // }
+   //// if the lineBeginning is found, update the start pointer adress
+   //fileBuf = res;
+   
+   //char dummy[80], nameChar[80];
+   //sscanf(res, format, dummy, nameChar);    
+   //name = ossimString(nameChar);
     
-    char * res = strstr(fileBuf, lineBeginning.c_str());
-    if(!res)
-    {
-    	return false;
-    }
-    fileBuf = strstr(fileBuf, lineBeginning.c_str());
-    char dummy[80], nameChar[80];
-    sscanf(fileBuf, format, dummy, nameChar);  
-    name = ossimString(nameChar);
+   char * res = strstr(fileBuf, lineBeginning.c_str());
+   if(!res)
+   {
+      return false;
+   }
+   fileBuf = strstr(fileBuf, lineBeginning.c_str());
+   char dummy[80], nameChar[80];
+   sscanf(fileBuf, format, dummy, nameChar);  
+   name = ossimString(nameChar);
     
-    return true;
-  }
+   return true;
+}
-- 
GitLab