OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | List of all members
ossimQuickbirdMetaData Class Reference

#include <ossimQuickbirdMetaData.h>

Inheritance diagram for ossimQuickbirdMetaData:
ossimObject ossimReferenced

Public Member Functions

 ossimQuickbirdMetaData ()
 default constructor More...
 
virtual ~ossimQuickbirdMetaData ()
 virtual destructor More...
 
bool open (const ossimFilename &imageFile)
 Open method that takes the image file, derives the metadata, header and rpc files, then calls parse methods parseMetaData, parseHdrData, and parseRpcData. More...
 
void clearFields ()
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Method to save the state of the object to a keyword list. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of the object from a keyword list. More...
 
bool parseMetaData (const ossimFilename &metadata)
 Method to parse Quickbird metadata file. More...
 
bool parseGEOData (const ossimFilename &data_file)
 Method to parse Quickbird rpc file. More...
 
bool parseATTData (const ossimFilename &data_file)
 
bool parseEPHData (const ossimFilename &data_file)
 
ossimString getSatID () const
 
bool getEndOfLine (char *fileBuf, ossimString lineBeginning, const char *format, ossimString &name)
 
const ossimIptgetImageSize () const
 
bool getMapProjectionKwl (const ossimFilename &imd_file, ossimKeywordlist &kwl)
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Private Attributes

ossimString theGenerationDate
 
ossimString theBandId
 
int theBitsPerPixel
 
ossimString theSatID
 
ossimString theTLCDate
 
ossim_float64 theSunAzimuth
 
ossim_float64 theSunElevation
 
ossim_float64 theSatAzimuth
 
ossim_float64 theSatElevation
 
int theTDILevel
 
std::vector< double > theAbsCalFactors
 
ossimString theBandNameList
 
ossimIpt theImageSize
 

Additional Inherited Members

- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Definition at line 27 of file ossimQuickbirdMetaData.h.

Constructor & Destructor Documentation

◆ ossimQuickbirdMetaData()

ossimQuickbirdMetaData::ossimQuickbirdMetaData ( )

default constructor

Definition at line 32 of file ossimQuickbirdMetaData.cpp.

References ossimIpt::makeNan(), theAbsCalFactors, and theImageSize.

33  :
34  theGenerationDate("Unknown"),
35  theBandId("Unknown"),
36  theBitsPerPixel(0),
37  theSatID("Unknown"),
38  theTLCDate("Unknown"),
39  theSunAzimuth(0.0),
40  theSunElevation(0.0),
41  theSatAzimuth(0.0),
42  theSatElevation(0.0),
43  theTDILevel(0),
45  theBandNameList("Unknown"),
46  theImageSize()
47 {
49  theAbsCalFactors.clear();
50 }
void makeNan()
Definition: ossimIpt.h:56
std::vector< double > theAbsCalFactors

◆ ~ossimQuickbirdMetaData()

ossimQuickbirdMetaData::~ossimQuickbirdMetaData ( )
virtual

virtual destructor

Definition at line 52 of file ossimQuickbirdMetaData.cpp.

53 {
54 }

Member Function Documentation

◆ clearFields()

void ossimQuickbirdMetaData::clearFields ( )

Definition at line 82 of file ossimQuickbirdMetaData.cpp.

References ossimIpt::makeNan(), theAbsCalFactors, theBandId, theBandNameList, theBitsPerPixel, theGenerationDate, theImageSize, theSatAzimuth, theSatElevation, theSatID, theSunAzimuth, theSunElevation, theTDILevel, and theTLCDate.

Referenced by loadState(), and open().

83 {
84  theGenerationDate = "Unknown";
85  theBitsPerPixel = 0;
86  theBandId = "Unknown";
87  theSatID = "Unknown";
88  theTLCDate = "Unknown";
89  theSunAzimuth = 0.0;
90  theSunElevation = 0.0;
91  theSatAzimuth = 0.0;
92  theSatElevation = 0.0;
93  theTDILevel = 0;
94  theAbsCalFactors.clear();
95  theBandNameList = "Unknown";
97 }
void makeNan()
Definition: ossimIpt.h:56
std::vector< double > theAbsCalFactors

◆ getEndOfLine()

bool ossimQuickbirdMetaData::getEndOfLine ( char *  fileBuf,
ossimString  lineBeginning,
const char *  format,
ossimString name 
)

Definition at line 1047 of file ossimQuickbirdMetaData.cpp.

References ossimString::c_str().

1051 {
1052  //char * res = strstr(fileBuf, lineBeginning.c_str());
1053  //if (!res)
1054  //{
1055  // return false;
1056  // }
1058  //fileBuf = res;
1059 
1060  //char dummy[80], nameChar[80];
1061  //sscanf(res, format, dummy, nameChar);
1062  //name = ossimString(nameChar);
1063 
1064  char * res = strstr(fileBuf, lineBeginning.c_str());
1065  if(!res)
1066  {
1067  return false;
1068  }
1069  fileBuf = strstr(fileBuf, lineBeginning.c_str());
1070  char dummy[80], nameChar[80];
1071  sscanf(fileBuf, format, dummy, nameChar);
1072  name = ossimString(nameChar);
1073 
1074  return true;
1075 }
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396

◆ getImageSize()

const ossimIpt & ossimQuickbirdMetaData::getImageSize ( ) const

Definition at line 1077 of file ossimQuickbirdMetaData.cpp.

References theImageSize.

Referenced by ossimQbTileFilesHandler::computeImageRects().

1078 {
1079  return theImageSize;
1080 }

◆ getMapProjectionKwl()

bool ossimQuickbirdMetaData::getMapProjectionKwl ( const ossimFilename imd_file,
ossimKeywordlist kwl 
)

Definition at line 781 of file ossimQuickbirdMetaData.cpp.

Referenced by ossimQbTileFilesHandler::getImageGeometry().

783 {
784  static const char MODULE[] = "ossimQuickbirdMetaData::getMapProjectionKwl";
785  if(traceDebug())
786  {
787  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
788  }
789 
790  bool result = false;
791 
792  if( imd_file.exists() )
793  {
794  FILE* fptr = fopen (imd_file.c_str(), "r");
795  if (fptr)
796  {
797 
798  char* strptr(NULL);
799 
800  //---
801  // Read the file into a buffer:
802  //---
803  ossim_int32 fileSize = static_cast<ossim_int32>(imd_file.fileSize());
804  char* filebuf = new char[fileSize];
805  fread(filebuf, 1, fileSize, fptr);
806  strptr = filebuf;
807  fclose(fptr);
808  ossimString imd_key;
809  ossimString tempStr;
810  std::string key;
811  std::string value;
812 
813 
814  // Loop until we find all our keys or bust out with error.
815  while ( 1 )
816  {
817  // Verify map projected.
818  imd_key = "BEGIN_GROUP = MAP_PROJECTED_PRODUCT";
819  if ( strstr( filebuf, imd_key.c_str() ) == NULL )
820  {
821  break; // Not a map projected product.
822  }
823 
824  // Get datum:
825  if( getEndOfLine( strptr, ossimString("\n\tdatumName = "), "%13c %s", tempStr) )
826  {
827  if ( tempStr.contains("WE") )
828  {
829  key = "dataum";
830  value = "WGE";
831  kwl.addPair(key, value);
832  }
833  else
834  {
835  if(traceDebug())
836  {
838  << "Unhandled datum: " << tempStr << "\n";
839  }
840  }
841  }
842 
843  // Get projection:
844  if( getEndOfLine( strptr, ossimString("\n\tmapProjName = "), "%15c %s", tempStr) )
845  {
846  if ( tempStr.contains("UTM") )
847  {
848  key = "type";
849  value = "ossimUtmProjection";
850  kwl.addPair(key, value);
851  }
852  else
853  {
854  if(traceDebug())
855  {
857  << "Unhandled projection name: " << tempStr << "\n";
858  }
859  }
860  }
861 
862  // Get projection:
863  if( getEndOfLine( strptr, ossimString("\n\tmapProjName = "), "%15c %s", tempStr) )
864  {
865  if ( tempStr.contains("UTM") )
866  {
867  key = "type";
868  value = "ossimUtmProjection";
869  kwl.addPair(key, value);
870 
871  // Get UTM zone:
872  if( getEndOfLine( strptr, ossimString("\n\tmapZone = "), "%11c %s", tempStr) )
873  {
874  key = "zone";
875  value = tempStr.trim(";").string();
876  kwl.addPair(key, value);
877  }
878  else
879  {
880  break;
881  }
882 
883  // Get UTM hemisphere:
884  if( getEndOfLine( strptr, ossimString("\n\tmapHemi = "), "%11c %s", tempStr) )
885  {
886  key = "hemisphere";
887  tempStr = tempStr.trim(";");
888  tempStr = tempStr.trim("\"");
889  value = tempStr.string();
890  kwl.addPair(key, value);
891  }
892  else
893  {
894  break;
895  }
896 
897  } // End UTM:
898  }
899 
900  // Get projection units:
901  std::string units;
902  if( getEndOfLine( strptr, ossimString("\n\tproductUnits = "), "%16c %s", tempStr) )
903  {
904  if ( tempStr == "\"M\";" )
905  {
906  key = "units";
907  units = "meters";
908  kwl.addPair(key, units);
909  }
910  else
911  {
912  if(traceDebug())
913  {
915  << "Unhandled units: " << tempStr << "\n";
916  }
917  }
918  }
919 
920  // Get projection tie point:
921  ossimDpt dpt;
922  dpt.makeNan();
923  if( getEndOfLine( strptr, ossimString("\n\toriginX = "), "%11c %s", tempStr) )
924  {
925  tempStr = tempStr.trim(";");
926  dpt.x = tempStr.toFloat64();
927  }
928  else
929  {
930  break;
931  }
932  if( getEndOfLine( strptr, ossimString("\n\toriginY = "), "%11c %s", tempStr) )
933  {
934  tempStr = tempStr.trim(";");
935  dpt.y = tempStr.toFloat64();
936  }
937  else
938  {
939  break;
940  }
941  if ( dpt.hasNans() == false )
942  {
943  key = "tie_point_units";
944  kwl.addPair(key, units);
945 
946  key = "tie_point_xy";
947  value = dpt.toString().string();
948  kwl.addPair( key, value );
949  }
950  else
951  {
952  if(traceDebug())
953  {
955  << "tie point has nans!";
956  }
957  break;
958  }
959 
960  // Get projection scale:
961  dpt.makeNan();
962  if( getEndOfLine( strptr, ossimString("\n\tcolSpacing = "), "%14c %s", tempStr) )
963  {
964  tempStr = tempStr.trim(";");
965  dpt.x = tempStr.toFloat64();
966  }
967  else
968  {
969  break;
970  }
971  if( getEndOfLine( strptr, ossimString("\n\trowSpacing = "), "%14c %s", tempStr) )
972  {
973  tempStr = tempStr.trim(";");
974  dpt.y = tempStr.toFloat64();
975  }
976  else
977  {
978  break;
979  }
980 
981  if ( dpt.hasNans() == false )
982  {
983  key = "pixel_scale_units";
984  kwl.addPair(key, units);
985 
986  key = "pixel_scale_xy";
987  value = dpt.toString().string();
988  kwl.addPair( key, value );
989  }
990  else
991  {
992  if(traceDebug())
993  {
995  << "scale has nans!";
996  }
997  break;
998  }
999 
1000  //---
1001  // End of key look up. If we get here set the status to true and
1002  // bust out of loop.
1003  //---
1004  result = true;
1005  break;
1006  }
1007 
1008  if ( result == false )
1009  {
1010  if(traceDebug())
1011  {
1013  << "ERROR: Missing or unhandled key in metadat: " << imd_key << "\n";
1014  }
1015  }
1016 
1017  delete [] filebuf;
1018  filebuf = 0;
1019  }
1020  else
1021  {
1022  if (traceDebug())
1023  {
1025  << "ossimQuickbirdRpcModel::parseMetaData(imd_file) DEBUG:"
1026  << "\nCould not open Meta data file: " << imd_file
1027  << "\nreturning with error...\n";
1028  }
1029  }
1030  }
1031 
1032  if(traceDebug())
1033  {
1035  << MODULE << " exit status = " << (result?"true":"false") << "\n";
1036  }
1037 
1038  return result;
1039 }
std::basic_filebuf< char > filebuf
Class for char file buffers.
Definition: ossimIosFwd.h:41
ossim_int64 fileSize() const
double y
Definition: ossimDpt.h:165
bool contains(char aChar) const
Definition: ossimString.h:58
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
bool exists() const
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossim_float64 toFloat64() const
bool hasNans() const
Definition: ossimDpt.h:67
ossimString toString(ossim_uint32 precision=15) const
Definition: ossimDpt.cpp:160
double x
Definition: ossimDpt.h:164
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool getEndOfLine(char *fileBuf, ossimString lineBeginning, const char *format, ossimString &name)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
int ossim_int32
const std::string & string() const
Definition: ossimString.h:414

◆ getSatID()

ossimString ossimQuickbirdMetaData::getSatID ( ) const
Returns
theSatID

Definition at line 776 of file ossimQuickbirdMetaData.cpp.

References theSatID.

Referenced by ossimQuickbirdRpcModel::parseMetaData().

777 {
778  return theSatID;
779 }

◆ loadState()

bool ossimQuickbirdMetaData::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of the object from a keyword list.

Return true if ok or false on error.

Reimplemented from ossimObject.

Definition at line 213 of file ossimQuickbirdMetaData.cpp.

References ossimKeywordNames::AZIMUTH_ANGLE_KW, clearFields(), ossimKeywordNames::ELEVATION_ANGLE_KW, ossimKeywordlist::find(), ossimString::split(), theAbsCalFactors, theBandId, theBandNameList, theBitsPerPixel, theGenerationDate, theSatAzimuth, theSatElevation, theSatID, theSunAzimuth, theSunElevation, theTDILevel, theTLCDate, ossimString::toDouble(), ossimString::toFloat64(), ossimString::toInt(), and ossimKeywordNames::TYPE_KW.

Referenced by ossimQuickbirdRpcModel::loadState().

215 {
216  clearFields();
217 
218  const char* lookup = 0;
219  ossimString s;
220 
221  lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
222  if (lookup)
223  {
224  s = lookup;
225  if(s != "ossimQuickbirdMetaData")
226  {
227  return false;
228  }
229  }
230 
231  lookup = kwl.find(prefix, "generation_date");
232  if (lookup)
233  {
234  theGenerationDate = lookup;
235  }
236 
237  lookup = kwl.find(prefix, "band_id");
238  if (lookup)
239  {
240  theBandId = lookup;
241  }
242 
243  lookup = kwl.find(prefix, "bits_per_pixel");
244  if (lookup)
245  {
246  s = lookup;
247  theBitsPerPixel = s.toInt();;
248  }
249 
250  lookup = kwl.find(prefix, "sat_id");
251  if (lookup)
252  {
253  theSatID = lookup;
254  }
255 
256  lookup = kwl.find(prefix, "tlc_date");
257  if (lookup)
258  {
259  theTLCDate= lookup;
260  }
261 
262  lookup = kwl.find(prefix, "TDI_level");
263  if (lookup)
264  {
265  s = lookup;
266  theTDILevel = s.toInt();
267  }
268 
269  lookup = kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW);
270  if (lookup)
271  {
272  s = lookup;
273  theSunAzimuth = s.toFloat64();
274  }
275 
276  lookup = kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW);
277  if (lookup)
278  {
279  s = lookup;
281  }
282 
283  lookup = kwl.find(prefix, "sat_azimuth_angle");
284  if (lookup)
285  {
286  s = lookup;
287  theSatAzimuth = s.toFloat64();
288  }
289 
290  lookup = kwl.find(prefix, "sat_elevation_angle");
291  if (lookup)
292  {
293  s = lookup;
295  }
296 
297  lookup = kwl.find(prefix, "band_name_list");
298  if (lookup)
299  {
300  theBandNameList= lookup;
301  }
302 
303  if(theBandId=="Multi")
304  {
305  std::vector<ossimString> bandNameList = theBandNameList.split(" ");
306  theAbsCalFactors = std::vector<double>(bandNameList.size(), 1.);
307  for(unsigned int i = 0 ; i < bandNameList.size() ; ++i)
308  {
309  lookup = kwl.find(prefix, bandNameList[i] + "_band_absCalFactor");
310  if (lookup)
311  {
312  s = lookup;
313  theAbsCalFactors[i] = s.toDouble();
314  }
315  }
316  }
317  else if (theBandId=="P")
318  {
319  theAbsCalFactors = std::vector<double>(1, 1.);
320  lookup = kwl.find(prefix, "absCalFactor");
321  if (lookup)
322  {
323  s = lookup;
324  theAbsCalFactors[0] = s.toDouble();
325  }
326  }
327  return true;
328 }
const char * find(const char *key) const
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
std::vector< double > theAbsCalFactors
static const char * TYPE_KW
double toDouble() const
ossim_float64 toFloat64() const
static const char * AZIMUTH_ANGLE_KW
static const char * ELEVATION_ANGLE_KW
int toInt() const

◆ open()

bool ossimQuickbirdMetaData::open ( const ossimFilename imageFile)

Open method that takes the image file, derives the metadata, header and rpc files, then calls parse methods parseMetaData, parseHdrData, and parseRpcData.

Parameters
imageFileUsually in the form of "po_2619900_pan_0000000.tif".
Returns
true on success, false on error.

Definition at line 56 of file ossimQuickbirdMetaData.cpp.

References clearFields(), parseMetaData(), and ossimFilename::setExtension().

Referenced by ossimQbTileFilesHandler::computeImageRects(), and ossimQuickbirdRpcModel::parseMetaData().

57 {
58  static const char MODULE[] = "ossimQuickbirdMetaData::open";
59 
60  clearFields();
61 
62  //retrieve information from the metadata file
63  //if the Quickbird tif is 02APR01105228-M1BS-000000128955_01_P001.TIF
64  //the metadata file will be 02APR01105228-M1BS-000000128955_01_P001.IMD
65 
66  ossimFilename metadatafile = imageFile;
67  metadatafile.setExtension(ossimString("IMD"));
68 
69  if( parseMetaData(metadatafile) == false )
70  {
71  if(traceDebug())
72  {
74  << MODULE << " errors parsing metadata" << std::endl;
75  }
76  return false;
77  }
78 
79  return true;
80 }
bool parseMetaData(const ossimFilename &metadata)
Method to parse Quickbird metadata file.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ parseATTData()

bool ossimQuickbirdMetaData::parseATTData ( const ossimFilename data_file)

Definition at line 771 of file ossimQuickbirdMetaData.cpp.

772 {
773  return true;
774 }

◆ parseEPHData()

bool ossimQuickbirdMetaData::parseEPHData ( const ossimFilename data_file)

Definition at line 760 of file ossimQuickbirdMetaData.cpp.

761 {
762  return true;
763 }

◆ parseGEOData()

bool ossimQuickbirdMetaData::parseGEOData ( const ossimFilename data_file)

Method to parse Quickbird rpc file.

Parameters
metadataFile name usually in the form of ".GEO.txt"
Returns
true on success, false on error.
Note
Currently NOT implemented.

Definition at line 749 of file ossimQuickbirdMetaData.cpp.

750 {
751  return true;
752 }

◆ parseMetaData()

bool ossimQuickbirdMetaData::parseMetaData ( const ossimFilename metadata)

Method to parse Quickbird metadata file.

Parameters
metadataFile name usually in the form of ".IMD."
Returns
true on success, false on error.

Definition at line 336 of file ossimQuickbirdMetaData.cpp.

Referenced by open().

337 {
338  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimQuickbirdMetaData::parseMetaData(data_file): entering..." << std::endl;
339 
340  if( !data_file.exists() )
341  {
342  if (traceExec()) ossimNotify(ossimNotifyLevel_WARN) << "ossimQuickbirdMetaData::parseMetaData(data_file) WARN:" << "\nmetadate data file <" << data_file << ">. " << "doesn't exist..." << std::endl;
343  return false;
344  }
345 
346 
347  FILE* fptr = fopen (data_file, "r");
348  if (!fptr)
349  {
350  if (traceDebug())
351  {
353  << "ossimQuickbirdRpcModel::parseMetaData(data_file) DEBUG:"
354  << "\nCould not open Meta data file: " << data_file
355  << "\nreturning with error..." << std::endl;
356  }
357  return false;
358  }
359 
360  char* strptr(NULL);
361 
362  //---
363  // Read the file into a buffer:
364  //---
365  ossim_int32 fileSize = static_cast<ossim_int32>(data_file.fileSize());
366  char* filebuf = new char[fileSize];
367  fread(filebuf, 1, fileSize, fptr);
368  strptr = filebuf;
369  fclose(fptr);
370  ossimString temp;
371 
372  //---
373  // Generation time:
374  //---
375 
376  if(getEndOfLine( strptr, ossimString("\ngenerationTime ="), "%17c %s", temp))
377  theGenerationDate = ossimString(temp).before(";");
378  else
379  {
380  if(traceDebug())
381  {
383  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
384  << "\n\tAborting construction. Error encountered parsing "
385  << "presumed meta-data file." << std::endl;
386 
387  delete [] filebuf;
388  return false;
389  }
390  }
391 
392  // Number of rows and columns in full image:
393  if(getEndOfLine( strptr, ossimString("\nnumRows ="), "%10c %s", temp))
394  theImageSize.line = ossimString(temp).before("\";").toInt();
395 
396  if(getEndOfLine( strptr, ossimString("\nnumColumns ="), "%13c %s", temp))
397  theImageSize.samp = ossimString(temp).before("\";").toInt();
398 
399  //---
400  // BandId:
401  //---
402  if(getEndOfLine( strptr, ossimString("\nbandId ="), "%9c %s", temp))
403  theBandId = ossimString(temp).after("\"").before("\";");
404  else
405  {
406  if(traceDebug())
407  {
409  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
410  << "\n\tAborting construction. Error encountered parsing "
411  << "presumed meta-data file." << std::endl;
412 
413  delete [] filebuf;
414  return false;
415  }
416  }
417 
418 
419  //---
420  // BitsPerPixel:
421  //---
422  if(getEndOfLine( strptr, ossimString("\nbitsPerPixel = "), "%16c %s", temp))
423  theBitsPerPixel = ossimString(temp).before(";").toInt();
424  else
425  {
426  if(traceDebug())
427  {
429  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
430  << "\n\tAborting construction. Error encountered parsing "
431  << "presumed meta-data file." << std::endl;
432 
433  delete [] filebuf;
434  return false;
435  }
436  }
437 
438  //---
439  // absCalFactors:
440  //---
441 
442  char *iter = (char *)filebuf;
443  unsigned int nbBand = 0;
444  theBandNameList = "";
445  for(iter = strstr(iter, "BEGIN_GROUP = BAND_"); iter ; iter = strstr(iter, "BEGIN_GROUP = BAND_"))
446  {
447  ++nbBand;
448  char dummy[80], nameChar[80];
449  sscanf(iter, "%19c %s", dummy, nameChar);
450  ossimString bandCur = ossimString(nameChar).before("\n");
451  theBandNameList = theBandNameList + bandCur + " ";
452  ++iter;
453  }
455 
456  //--- Multispectral
457  if(theBandId=="Multi")
458  {
459  std::vector<ossimString> bandList;
460  bandList = theBandNameList.split(" ");
461  theAbsCalFactors = std::vector<double>(bandList.size(), 1.);
462  for(unsigned int j=0; j<bandList.size(); j++)
463  {
464  ossimString begin_group = "BEGIN_GROUP = BAND_" + bandList[j];
465  strptr = strstr(filebuf, begin_group.c_str());
466  if(!strptr && traceDebug())
467  {
469  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
470  << "\n\tAborting construction. Error encountered parsing "
471  << "presumed meta-data file." << std::endl;
472  delete [] filebuf;
473  return false;
474  }
475  else
476  {
477  char dummy[80], nameChar[80];
478  sscanf(strptr, "%19c %s", dummy, nameChar);
479  ossimString bandCur = ossimString(nameChar).before("\n");
480  if(!strptr && traceDebug())
481  {
483  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
484  << "\n\tAborting construction. Error encountered parsing "
485  << "presumed meta-data file." << std::endl;
486  delete [] filebuf;
487  return false;
488  }
489  else
490  {
491  if(bandList[j] == bandCur)
492  {
493  strptr = strstr(strptr, "\tabsCalFactor = ");
494  sscanf(strptr, "%16c %s", dummy, nameChar);
495  theAbsCalFactors[j] = ossimString(nameChar).before(";").toDouble();
496  }
497  }
498  }
499  }
500  }
501  //--- Panchromatic
502  else
503  {
504  theAbsCalFactors = std::vector<double>(1, 1.);
505  if(getEndOfLine( strptr, ossimString("\tabsCalFactor = "), "%16c %s", temp))
506  theAbsCalFactors[0] = ossimString(temp).before(";").toDouble();
507  else
508  {
509  if(traceDebug())
510  {
512  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
513  << "\n\tAborting construction. Error encountered parsing "
514  << "presumed meta-data file." << std::endl;
515 
516  delete [] filebuf;
517  return false;
518  }
519  }
520  }
521 
522  //---
523  // SatID:
524  //---
525  if(getEndOfLine( strptr, ossimString("\n\tsatId ="), "%9c %s", temp))
526  theSatID = ossimString(temp).after("\"").before("\";");
527  else
528  {
529  if(traceDebug())
530  {
532  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
533  << "\n\tAborting construction. Error encountered parsing "
534  << "presumed meta-data file." << std::endl;
535 
536  delete [] filebuf;
537  return false;
538  }
539  }
540 
541  //---
542  // TLCTime:
543  //---
544  if(getEndOfLine( strptr, ossimString("\n\tTLCTime ="), "%11c %s", temp))
545  theTLCDate = ossimString(temp).before("\";");
546  else
547  {
548  if(getEndOfLine( strptr, ossimString("\n\tfirstLineTime ="), "%17c %s", temp))
549  theTLCDate = ossimString(temp).before("\";");
550  else
551  {
552  if(traceDebug())
553  {
555  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
556  << "\n\tAborting construction. Error encountered parsing "
557  << "presumed meta-data file." << std::endl;
558  delete [] filebuf;
559  return false;
560  }
561  }
562  }
563 
564  //---
565  // Sun Azimuth:
566  //---
567  if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp))
568  theSunAzimuth = ossimString(temp).before(";").toFloat64();
569  else
570  {
571  if(getEndOfLine( strptr, ossimString("\n\tmeanSunAz ="), "%13c %s", temp))
572  theSunAzimuth = ossimString(temp).before(";").toFloat64();
573  else
574  {
575  if(traceDebug())
576  {
578  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
579  << "\n\tAborting construction. Error encountered parsing "
580  << "presumed meta-data file." << std::endl;
581 
582  delete [] filebuf;
583  return false;
584  }
585  }
586  }
587 
588  //---
589  // Sun Elevation:
590  //---
591  if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp))
593  else
594  {
595  if(getEndOfLine( filebuf, ossimString("\n\tmeanSunEl ="), "%13c %s", temp))
597  else
598  {
599  if(traceDebug())
600  {
602  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
603  << "\n\tAborting construction. Error encountered parsing "
604  << "presumed meta-data file." << std::endl;
605 
606  delete [] filebuf;
607  return false;
608  }
609  }
610  }
611 
612  //---
613  // Sun Azimuth:
614  //---
615  if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp))
616  theSunAzimuth = ossimString(temp).before(";").toFloat64();
617  else
618  {
619  if(getEndOfLine( strptr, ossimString("\n\tmeanSunAz ="), "%13c %s", temp))
620  theSunAzimuth = ossimString(temp).before(";").toFloat64();
621  else
622  {
623  if(traceDebug())
624  {
626  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
627  << "\n\tAborting construction. Error encountered parsing "
628  << "presumed meta-data file." << std::endl;
629 
630  delete [] filebuf;
631  return false;
632  }
633  }
634  }
635 
636  //---
637  // Sun Elevation:
638  //---
639  if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp))
641  else
642  {
643  if(getEndOfLine( filebuf, ossimString("\n\tmeanSunEl ="), "%13c %s", temp))
645  else
646  {
647  if(traceDebug())
648  {
650  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
651  << "\n\tAborting construction. Error encountered parsing "
652  << "presumed meta-data file." << std::endl;
653 
654  delete [] filebuf;
655  return false;
656  }
657  }
658  }
659 
660 
661  //---
662  // Sat Azimuth:
663  //---
664  if(getEndOfLine( strptr, ossimString("\n\tsatAz ="), "%9c %s", temp))
665  theSatAzimuth = ossimString(temp).before(";").toFloat64();
666  else
667  {
668  if(getEndOfLine( strptr, ossimString("\n\tmeanSatAz ="), "%13c %s", temp))
669  theSatAzimuth = ossimString(temp).before(";").toFloat64();
670  else
671  {
672  if(traceDebug())
673  {
675  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
676  << "\n\tAborting construction. Error encountered parsing "
677  << "presumed meta-data file." << std::endl;
678 
679  delete [] filebuf;
680  return false;
681  }
682  }
683  }
684 
685  //---
686  // Sat Elevation:
687  //---
688  if(getEndOfLine( filebuf, ossimString("\n\tsatEl ="), "%9c %s", temp))
690  else
691  {
692  if(getEndOfLine( filebuf, ossimString("\n\tmeanSatEl ="), "%13c %s", temp))
694  else
695  {
696  if(traceDebug())
697  {
699  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
700  << "\n\tAborting construction. Error encountered parsing "
701  << "presumed meta-data file." << std::endl;
702 
703  delete [] filebuf;
704  return false;
705  }
706  }
707  }
708 
709 
710  //---
711  // TDILevel:
712  //---
713  if(getEndOfLine( strptr, ossimString("\n\tTDILevel = "), "%13c %s", temp))
714  theTDILevel = ossimString(temp).before(";").toInt();
715  else
716  {
717  if(traceDebug())
718  {
720  << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): "
721  << "\n\tAborting construction. Error encountered parsing "
722  << "presumed meta-data file." << std::endl;
723 
724  delete [] filebuf;
725  return false;
726  }
727  }
728 
729 
730  delete [] filebuf;
731  filebuf = 0;
732 
733  if (traceExec())
734  {
736  << "DEBUG ossimQuickbirdRpcModel::parseMetaData(data_file): returning..."
737  << std::endl;
738  }
739 
740  return true;
741 }
ossimString before(const ossimString &str, std::string::size_type pos=0) const
METHOD: before(str, pos) Returns string beginning at pos and ending one before the token str If strin...
std::basic_filebuf< char > filebuf
Class for char file buffers.
Definition: ossimIosFwd.h:41
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
std::vector< double > theAbsCalFactors
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
double toDouble() const
ossim_float64 toFloat64() const
ossim_int32 samp
Definition: ossimIpt.h:141
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossim_int32 line
Definition: ossimIpt.h:142
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.
bool getEndOfLine(char *fileBuf, ossimString lineBeginning, const char *format, ossimString &name)
int toInt() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ print()

std::ostream & ossimQuickbirdMetaData::print ( std::ostream &  out) const
virtual

Generic print method.

Derived classes should re-implement as they see fit.

Returns
std::ostream&

Reimplemented from ossimObject.

Definition at line 99 of file ossimQuickbirdMetaData.cpp.

References theAbsCalFactors, theBandId, theBandNameList, theBitsPerPixel, theGenerationDate, theImageSize, theSatAzimuth, theSatElevation, theSatID, theSunAzimuth, theSunElevation, theTDILevel, and theTLCDate.

100 {
101 
102  out << "\n----------------- Info on Quickbird Image -------------------"
103  << "\n "
104  << "\n Generation date: " << theGenerationDate
105  << "\n Band Id: " << theBandId
106  << "\n Bits per pixel: " << theBitsPerPixel
107  << "\n Sat Id: " << theSatID
108  << "\n TLC date: " << theTLCDate
109  << "\n Sun Azimuth: " << theSunAzimuth
110  << "\n Sun Elevation: " << theSunElevation
111  << "\n Sat Azimuth: " << theSatAzimuth
112  << "\n Sat Elevation: " << theSatElevation
113  << "\n Band name list: " << theBandNameList
114  << "\n TDI Level: " << theTDILevel
115  << "\n abs Calibration Factors: "
116  << std::endl;
117  for(unsigned int i=0; i<theAbsCalFactors.size(); i++)
118  {
119  out<<theAbsCalFactors[i] << " ";
120  }
121  out << "\n Image Size: " << theImageSize
122  << "\n"
123  << "\n---------------------------------------------------------"
124  << "\n " << std::endl;
125  return out;
126 }
std::vector< double > theAbsCalFactors

◆ saveState()

bool ossimQuickbirdMetaData::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Method to save the state of the object to a keyword list.

Return true if ok or false on error.

Reimplemented from ossimObject.

Definition at line 128 of file ossimQuickbirdMetaData.cpp.

References ossimKeywordlist::add(), ossimKeywordNames::AZIMUTH_ANGLE_KW, ossimKeywordNames::ELEVATION_ANGLE_KW, ossimString::split(), theAbsCalFactors, theBandId, theBandNameList, theBitsPerPixel, theGenerationDate, theSatAzimuth, theSatElevation, theSatID, theSunAzimuth, theSunElevation, theTDILevel, theTLCDate, and ossimKeywordNames::TYPE_KW.

Referenced by ossimQuickbirdRpcModel::saveState().

130 {
131  kwl.add(prefix,
133  "ossimQuickbirdMetaData",
134  true);
135 
136  kwl.add(prefix,
137  "generation_date",
139  true);
140 
141  kwl.add(prefix,
142  "bits_per_pixel",
144  true);
145 
146  kwl.add(prefix,
147  "band_id",
148  theBandId,
149  true);
150 
151  kwl.add(prefix,
152  "sat_id",
153  theSatID,
154  true);
155 
156  kwl.add(prefix,
157  "tlc_date",
158  theTLCDate,
159  true);
160 
161  kwl.add(prefix,
164  true);
165 
166  kwl.add(prefix,
169  true);
170 
171  kwl.add(prefix,
172  "sat_azimuth_angle",
174  true);
175 
176  kwl.add(prefix,
177  "sat_elevation_angle",
179  true);
180 
181  kwl.add(prefix,
182  "TDI_level",
183  theTDILevel,
184  true);
185  kwl.add(prefix,
186  "band_name_list",
188  true);
189 
190  if( theBandId=="Multi" )
191  {
192  std::vector<ossimString> bandNameList = theBandNameList.split(" ");
193  for(unsigned int i = 0 ; i < bandNameList.size(); ++i)
194  {
195  kwl.add(prefix,
196  bandNameList[i] + "_band_absCalFactor",
197  theAbsCalFactors[i],
198  true);
199 
200  }
201  }
202  else if(!theAbsCalFactors.empty())
203  {
204  kwl.add(prefix,
205  "absCalFactor",
206  theAbsCalFactors[0],
207  true);
208  }
209 
210  return true;
211 }
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
std::vector< double > theAbsCalFactors
static const char * TYPE_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const char * AZIMUTH_ANGLE_KW
static const char * ELEVATION_ANGLE_KW

Member Data Documentation

◆ theAbsCalFactors

std::vector<double> ossimQuickbirdMetaData::theAbsCalFactors
private

◆ theBandId

ossimString ossimQuickbirdMetaData::theBandId
private

Definition at line 116 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theBandNameList

ossimString ossimQuickbirdMetaData::theBandNameList
private

Definition at line 126 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theBitsPerPixel

int ossimQuickbirdMetaData::theBitsPerPixel
private

Definition at line 117 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theGenerationDate

ossimString ossimQuickbirdMetaData::theGenerationDate
private

Definition at line 115 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theImageSize

ossimIpt ossimQuickbirdMetaData::theImageSize
private

Definition at line 127 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), getImageSize(), ossimQuickbirdMetaData(), and print().

◆ theSatAzimuth

ossim_float64 ossimQuickbirdMetaData::theSatAzimuth
private

Definition at line 122 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theSatElevation

ossim_float64 ossimQuickbirdMetaData::theSatElevation
private

Definition at line 123 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theSatID

ossimString ossimQuickbirdMetaData::theSatID
private

Definition at line 118 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), getSatID(), loadState(), print(), and saveState().

◆ theSunAzimuth

ossim_float64 ossimQuickbirdMetaData::theSunAzimuth
private

Definition at line 120 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theSunElevation

ossim_float64 ossimQuickbirdMetaData::theSunElevation
private

Definition at line 121 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theTDILevel

int ossimQuickbirdMetaData::theTDILevel
private

Definition at line 124 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().

◆ theTLCDate

ossimString ossimQuickbirdMetaData::theTLCDate
private

Definition at line 119 of file ossimQuickbirdMetaData.h.

Referenced by clearFields(), loadState(), print(), and saveState().


The documentation for this class was generated from the following files: