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

Class for reading and writing an ENVI (The Environment for Visualizing Images) header file. More...

#include <ossimEnviHeader.h>

Inheritance diagram for ossimEnviHeader:
ossimReferenced

Public Member Functions

 ossimEnviHeader ()
 default construtor More...
 
virtual ~ossimEnviHeader ()
 virtual destructor More...
 
virtual void reset ()
 
const ossimKeywordlistgetMap () const
 
ossimKeywordlistgetMap ()
 
bool getValue (const ossimString &key, ossimString &value) const
 Gets value for key. More...
 
bool findCaseInsensitive (const ossimString &key, ossimString &value) const
 Gets value for key. More...
 
bool findSubStringCaseInsensitive (const ossimString &key, ossimString &value) const
 Gets value for key. More...
 
bool open (const ossimFilename &file)
 Opens an envi header. More...
 
bool writeFile (const ossimFilename &file)
 Writes header to file in a standard envi format. More...
 
std::ostream & print (std::ostream &out) const
 Prints header to out in a standard envi format. More...
 
ossimString getDescription () const
 
void setDescription (const ossimString &description)
 
ossim_uint32 getSamples () const
 
void setSamples (ossim_uint32 samples)
 Sets the number of samples. More...
 
ossim_uint32 getLines () const
 
void setLines (ossim_uint32 lines)
 Sets the number of lines. More...
 
ossim_uint32 getBands () const
 
void setBands (ossim_uint32 bands)
 Sets the number of bands. More...
 
bool getDefaultBands (std::vector< ossim_uint32 > &bands) const
 Gets default bands if "default bands" keyword is present. More...
 
bool getRgbBandsFromWaveLength (std::vector< ossim_uint32 > &bands) const
 Gets rgb bands if "wavelength" keyword is present. More...
 
ossim_uint32 getHeaderOffset () const
 
void setHeaderOffset (ossim_uint32 headerOffset)
 Sets the header offset in bytes. More...
 
ossimString getFileType () const
 
void setFileType (const ossimString &fileType)
 Sets the file type. More...
 
ossim_uint32 getDataType () const
 
ossimScalarType getOssimScalarType () const
 
void setDataType (ossimScalarType scalar)
 Sets the envi data type based on the ossimScalarType. More...
 
ossimString getInterleaveType () const
 
ossimInterleaveType getOssimInterleaveType () const
 
void setInterleaveType (ossimInterleaveType interleave)
 Sets the envi interleave type string based on the ossimInterleaveType. More...
 
ossimString getSensorType () const
 
void setSensorType (const ossimString &sensorType)
 Sets the envi sensor type string. More...
 
ossimByteOrder getByteOrder () const
 
void setByteorder (ossimByteOrder byteOrder)
 Sets the envi byte order from the ossimByteOrder. More...
 
ossim_int32 getXStart () const
 
void setXStart (ossim_int32 xstart)
 Sets the x start. More...
 
ossim_int32 getYStart () const
 
void setYStart (ossim_int32 ystart)
 Sets the y start. More...
 
ossimString getMapInfo () const
 
void setMapInfo (const ossimString &mapInfo)
 Sets the envi map info string. More...
 
void setMapInfo (const ossimKeywordlist &kwl, const char *prefix=0)
 Sets the envi map info string from a keyword list containing geometry information. More...
 
ossimString getWavelengthUnits () const
 
void setWavelengthUnits (const ossimString &wavelenghtUnits)
 Sets the envi wavelength units string. More...
 
void getBandNames (std::vector< ossimString > &bandNames) const
 
void setBandNames (const std::vector< ossimString > &bandNames)
 Sets the band name string vector. More...
 
void getWavelengths (std::vector< ossimString > &wavelengths) const
 
void setWavelengths (const std::vector< ossimString > &wavelengths)
 Sets the envi band name string. More...
 
bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of the object from a keyword list. More...
 
const ossimFilenamegetFile () const
 
- 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
 

Static Public Member Functions

static bool isEnviHeader (const ossimFilename &file)
 Global method to test first line of file for "ENVI". More...
 
static bool isEnviHeader (std::istream &in)
 Global method to test first line of stream for "ENVI". More...
 

Private Member Functions

bool rangeCheckBands (const std::vector< ossim_uint32 > &bands) const
 Check band list to see if any are outside of range of bands. More...
 
bool readStream (std::istream &in)
 Parses stream. More...
 

Private Attributes

ossimFilename m_file
 
ossimKeywordlist m_keywords
 

Friends

OSSIM_DLL std::ostream & operator<< (std::ostream &out, const ossimEnviHeader &obj)
 friend operator<< More...
 

Additional Inherited Members

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

Detailed Description

Class for reading and writing an ENVI (The Environment for Visualizing Images) header file.

Definition at line 30 of file ossimEnviHeader.h.

Constructor & Destructor Documentation

◆ ossimEnviHeader()

ossimEnviHeader::ossimEnviHeader ( )

default construtor

Definition at line 66 of file ossimEnviHeader.cpp.

References m_keywords.

67  :
68  m_file(),
69  m_keywords()
70 {
71  // Start the byte order of with the machine byte order.
72  m_keywords[FILE_TYPE_KW] = "ENVI Standard";
74 }
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossimKeywordlist m_keywords
ossimFilename m_file
void setByteorder(ossimByteOrder byteOrder)
Sets the envi byte order from the ossimByteOrder.

◆ ~ossimEnviHeader()

ossimEnviHeader::~ossimEnviHeader ( )
virtual

virtual destructor

Definition at line 76 of file ossimEnviHeader.cpp.

77 {
78 }

Member Function Documentation

◆ findCaseInsensitive()

bool ossimEnviHeader::findCaseInsensitive ( const ossimString key,
ossimString value 
) const

Gets value for key.

Parameters
key
value
Returns
true if key is in map even if value is empty; false, if not.

◆ findSubStringCaseInsensitive()

bool ossimEnviHeader::findSubStringCaseInsensitive ( const ossimString key,
ossimString value 
) const

Gets value for key.

Parameters
key
value
Returns
true if key is in map even if value is empty; false, if not.

Definition at line 113 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findValue(), and m_keywords.

115 {
117  value, KwlKeySubStringCaseInsensitive(key));
118 }
ossimKeywordlist m_keywords
bool findValue(ossimString &value, const CompareType &compare) const
This is a generic find method that takes a comparator type and iterates through the map executing t...

◆ getBandNames()

void ossimEnviHeader::getBandNames ( std::vector< ossimString > &  bandNames) const
Parameters
bandNamesVector of strings to initialize with band names.

Definition at line 690 of file ossimEnviHeader.cpp.

References m_keywords, and ossimString::split().

691 {
692  bandNames.clear();
693  ossimString bandNamesString = m_keywords["band names"];
694  bandNamesString.split(bandNames, ",");
695 }
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.
ossimKeywordlist m_keywords

◆ getBands()

ossim_uint32 ossimEnviHeader::getBands ( ) const
Returns
The number of bands.

Definition at line 271 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), m_keywords, ossimString::size(), and ossimString::toUInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr(), rangeCheckBands(), and ossimAlphaSensorSupportData::readHdrFile().

272 {
273  ossim_uint32 result = 0;
274  ossimString value = m_keywords.findKey( std::string("bands") );
275  if( value.size() )
276  {
277  result = value.toUInt32();
278  }
279  return result;
280 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
ossimKeywordlist m_keywords
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32

◆ getByteOrder()

ossimByteOrder ossimEnviHeader::getByteOrder ( ) const
Returns
If key "byte order" found returns the envi byte order; else, system byte order.
Note
(Same as the ossimByteOrder enumeration): 0 = LITTLE_ENDIAN, 1 = BIG_ENDIAN

Definition at line 510 of file ossimEnviHeader.cpp.

References ossim::byteOrder(), m_keywords, OSSIM_BIG_ENDIAN, OSSIM_LITTLE_ENDIAN, and ossimString::toInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr().

511 {
512  ossimByteOrder result = ossim::byteOrder(); // System byte order.
513  std::string value = m_keywords["byte order"];
514  if ( value.size() )
515  {
516  // 0 = LITTLE_ENDIAN
517  // 1 = BIG_ENDIAN
518  ossim_int32 order = ossimString(value).toInt32();
519  result = order ? OSSIM_BIG_ENDIAN : OSSIM_LITTLE_ENDIAN;
520  }
521  return result;
522 }
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossimKeywordlist m_keywords
ossim_int32 toInt32() const
ossimByteOrder
int ossim_int32

◆ getDataType()

ossim_uint32 ossimEnviHeader::getDataType ( ) const
Returns
The envi data type..

Definition at line 366 of file ossimEnviHeader.cpp.

References m_keywords, and ossimString::toUInt32().

367 {
368  return ossimString(m_keywords["data type"]).toUInt32();
369 }
ossim_uint32 toUInt32() const
ossimKeywordlist m_keywords

◆ getDefaultBands()

bool ossimEnviHeader::getDefaultBands ( std::vector< ossim_uint32 > &  bands) const

Gets default bands if "default bands" keyword is present.

Parameters
bandsInitialized by this.
Returns
true on success, false if keyword not found. "bands" will be zeroed out on failure.

Definition at line 287 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), m_keywords, ossimNotify(), ossimNotifyLevel_WARN, rangeCheckBands(), ossimString::size(), ossimString::split(), and true.

288 {
289  bands.clear();
290 
291  // Note: We could do a "m_map.downcaseKeywords()". (drb)
292  ossimString value = m_keywords.findKey( std::string("default bands") );
293  if ( !value.size() )
294  {
295  value = m_keywords.findKey( std::string("Default bands") );
296  if ( !value.size() )
297  {
298  value = m_keywords.findKey( std::string("DEFAULT BANDS") );
299  }
300  }
301 
302  if ( value.size() )
303  {
304  std::vector<ossimString> strLst;
305  value.split( strLst, ossimString(","));
306  if ( strLst.size() )
307  {
308  std::vector<ossimString>::const_iterator i = strLst.begin();
309  ossim_uint32 band = 0;
310  while ( i != strLst.end() )
311  {
312  band = (*i).toUInt32();
313  if ( band )
314  {
315  // Assuming "default bands" are one based. Totally a hunch... (drb)
316  --band;
317  bands.push_back(band);
318  }
319  else
320  {
322  << "ossimEnviHeader::getDefaultBands WARN!"
323  << "\nDetected zero based bands in \"default bands\" from header!"
324  << std::endl;
325  }
326 
327  ++i;
328  }
329  }
330  }
331 
332  if ( rangeCheckBands( bands ) == false )
333  {
334  bands.clear();
335  }
336 
337  return (bands.size() ? true : false);
338 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
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.
ossimKeywordlist m_keywords
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
bool rangeCheckBands(const std::vector< ossim_uint32 > &bands) const
Check band list to see if any are outside of range of bands.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getDescription()

ossimString ossimEnviHeader::getDescription ( ) const
Returns
The description of the file.

Definition at line 229 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), and m_keywords.

230 {
231  return ossimString( m_keywords.findKey( std::string("description") ) );
232 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimKeywordlist m_keywords

◆ getFile()

const ossimFilename & ossimEnviHeader::getFile ( ) const
Returns
Path to envi header file.

Definition at line 928 of file ossimEnviHeader.cpp.

References m_file.

Referenced by ossimAlphaSensorSupportData::readHdrFile(), and ossimAlphaSensorSupportData::readSupportFiles().

929 {
930  return m_file;
931 }
ossimFilename m_file

◆ getFileType()

ossimString ossimEnviHeader::getFileType ( ) const
Returns
The file type

Definition at line 356 of file ossimEnviHeader.cpp.

References m_keywords.

357 {
358  return m_keywords[FILE_TYPE_KW];
359 }
ossimKeywordlist m_keywords

◆ getHeaderOffset()

ossim_uint32 ossimEnviHeader::getHeaderOffset ( ) const
Returns
The number of header offset in bytes.

Definition at line 340 of file ossimEnviHeader.cpp.

References m_keywords, ossimString::size(), and ossimString::toUInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr().

341 {
342  ossim_uint32 result = 0;
343  ossimString value = m_keywords["header offset"];
344  if( value.size() )
345  {
346  result = value.toUInt32();
347  }
348  return result;
349 }
ossim_uint32 toUInt32() const
ossimKeywordlist m_keywords
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32

◆ getInterleaveType()

ossimString ossimEnviHeader::getInterleaveType ( ) const
Returns
The envi interleave type.

Definition at line 454 of file ossimEnviHeader.cpp.

References m_keywords.

Referenced by getOssimInterleaveType().

455 {
456  return m_keywords["interleave"];
457 }
ossimKeywordlist m_keywords

◆ getLines()

ossim_uint32 ossimEnviHeader::getLines ( ) const
Returns
The number of lines.

Definition at line 255 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), m_keywords, ossimString::size(), and ossimString::toUInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr(), and ossimAlphaSensorSupportData::readHdrFile().

256 {
257  ossim_uint32 result = 0;
258  ossimString value = m_keywords.findKey( std::string("lines") );
259  if( value.size() )
260  {
261  result = value.toUInt32();
262  }
263  return result;
264 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
ossimKeywordlist m_keywords
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32

◆ getMap() [1/2]

const ossimKeywordlist & ossimEnviHeader::getMap ( ) const
Returns
Const reference to map.

Definition at line 88 of file ossimEnviHeader.cpp.

References m_keywords.

Referenced by ossimEnviInfo::print().

89 {
90  return m_keywords;
91 }
ossimKeywordlist m_keywords

◆ getMap() [2/2]

ossimKeywordlist & ossimEnviHeader::getMap ( )
Returns
Reference to map.

Definition at line 93 of file ossimEnviHeader.cpp.

References m_keywords.

94 {
95  return m_keywords;
96 }
ossimKeywordlist m_keywords

◆ getMapInfo()

ossimString ossimEnviHeader::getMapInfo ( ) const
Returns
The envi map info string.

Definition at line 576 of file ossimEnviHeader.cpp.

References m_keywords.

577 {
578  return m_keywords["map info"];
579 }
ossimKeywordlist m_keywords

◆ getOssimInterleaveType()

ossimInterleaveType ossimEnviHeader::getOssimInterleaveType ( ) const
Returns
The ossimInterleaveType from the envi interleave..

Definition at line 458 of file ossimEnviHeader.cpp.

References getInterleaveType(), OSSIM_BIL, OSSIM_BIP, OSSIM_BSQ, and OSSIM_INTERLEAVE_UNKNOWN.

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr().

459 {
460  ossimString interleave = getInterleaveType();
461  if (interleave == "bsq")
462  {
463  return OSSIM_BSQ;
464  }
465  else if (interleave == "bil")
466  {
467  return OSSIM_BIL;
468  }
469  else if (interleave == "bip")
470  {
471  return OSSIM_BIP;
472  }
473  else
474  {
476  }
477 }
ossimString getInterleaveType() const

◆ getOssimScalarType()

ossimScalarType ossimEnviHeader::getOssimScalarType ( ) const
Returns
The ossimScalarType from the envi data type..

Definition at line 371 of file ossimEnviHeader.cpp.

References m_keywords, OSSIM_CFLOAT32, OSSIM_CFLOAT64, OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_SCALAR_UNKNOWN, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, and ossimString::toUInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr().

372 {
373  ossim_uint32 dataTypeInt = ossimString(m_keywords["data type"]).toUInt32();
374 
376 
377  switch( dataTypeInt )
378  {
379  case 1:
380  result = OSSIM_UINT8;
381  break;
382  case 2:
383  result = OSSIM_SINT16;
384  break;
385  case 3:
386  result = OSSIM_SINT32;
387  break;
388  case 4:
389  result = OSSIM_FLOAT32;
390  break;
391  case 5:
392  result = OSSIM_FLOAT64;
393  break;
394  case 6:
395  result = OSSIM_CFLOAT32;
396  break;
397  case 9:
398  result = OSSIM_CFLOAT64;
399  break;
400  case 12:
401  result = OSSIM_UINT16;
402  break;
403  case 13:
404  result = OSSIM_UINT32;
405  break;
406  default:
407  break;
408  }
409 
410  return result;
411 }
32 bit complex floating point
64 bit floating point
16 bit unsigned integer
16 bit signed integer
ossim_uint32 toUInt32() const
32 bit floating point
ossimKeywordlist m_keywords
32 bit unsigned integer
32 bit signed integer
unsigned int ossim_uint32
ossimScalarType
64 bit complex floating point
8 bit unsigned integer

◆ getRgbBandsFromWaveLength()

bool ossimEnviHeader::getRgbBandsFromWaveLength ( std::vector< ossim_uint32 > &  bands) const

Gets rgb bands if "wavelength" keyword is present.

Parameters
bandsInitialized by this.
Returns
true on success, false if keyword not found. "bands" will be zeroed out on failure.

◆ getSamples()

ossim_uint32 ossimEnviHeader::getSamples ( ) const
Returns
The number of samples.

Definition at line 239 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), m_keywords, ossimString::size(), and ossimString::toUInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr(), and ossimAlphaSensorSupportData::readHdrFile().

240 {
241  ossim_uint32 result = 0;
242  ossimString value = m_keywords.findKey( std::string("samples") );
243  if( value.size() )
244  {
245  result = value.toUInt32();
246  }
247  return result;
248 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
ossimKeywordlist m_keywords
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32

◆ getSensorType()

ossimString ossimEnviHeader::getSensorType ( ) const
Returns
The sensor type..

Definition at line 500 of file ossimEnviHeader.cpp.

References m_keywords.

Referenced by ossimAlphaSensorSupportData::readHdrFile().

501 {
502  return m_keywords["sensor type"];
503 }
ossimKeywordlist m_keywords

◆ getValue()

bool ossimEnviHeader::getValue ( const ossimString key,
ossimString value 
) const

Gets value for key.

Parameters
keyTo search for.
valueInitialized by this.
Returns
true on success, false on error. This will return true if key is found, even if value is empty.

Definition at line 98 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), ossimKeywordlist::hasKey(), m_keywords, ossimString::size(), and ossimString::string().

Referenced by ossimWavelength::initialize(), and ossimAlphaSensorSupportData::readHdrFile().

99 {
100  bool result = false;
101  value.string() = m_keywords.findKey( key.string());
102  if( value.size() )
103  {
104  result = true;
105  }
106  else
107  {
108  result = m_keywords.hasKey( key.string() );
109  }
110  return result;
111 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
bool hasKey(const std::string &key) const
Checks for key in map.
ossimKeywordlist m_keywords
std::string::size_type size() const
Definition: ossimString.h:405
const std::string & string() const
Definition: ossimString.h:414

◆ getWavelengths()

void ossimEnviHeader::getWavelengths ( std::vector< ossimString > &  wavelengths) const
Parameters
wavelengthsVector of strings to initialize with wave lengths.

Definition at line 704 of file ossimEnviHeader.cpp.

References m_keywords.

706 {
707  waveLengths.clear();
708  ossimString bandNamesString = m_keywords[WAVELENGTH_KW];
709  bandNamesString.split(waveLengths, ",");
710 }
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.
ossimKeywordlist m_keywords

◆ getWavelengthUnits()

ossimString ossimEnviHeader::getWavelengthUnits ( ) const
Returns
The env wavelength units..

Definition at line 679 of file ossimEnviHeader.cpp.

References m_keywords.

680 {
681  return m_keywords["wavelength units"];
682 }
ossimKeywordlist m_keywords

◆ getXStart()

ossim_int32 ossimEnviHeader::getXStart ( ) const
Returns
The x start.

Definition at line 536 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), m_keywords, and ossimString::toInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr().

537 {
538  ossim_int32 result = 0;
539  std::string s = m_keywords.findKey( std::string("x start") );
540  if ( !s.size() )
541  {
542  s = m_keywords.findKey( std::string("sample start") );
543  }
544  if ( s.size() )
545  {
546  result = ossimString( s ).toInt32();
547  }
548  return result;
549 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimKeywordlist m_keywords
ossim_int32 toInt32() const
int ossim_int32

◆ getYStart()

ossim_int32 ossimEnviHeader::getYStart ( ) const
Returns
The x start.

Definition at line 556 of file ossimEnviHeader.cpp.

References ossimKeywordlist::findKey(), m_keywords, and ossimString::toInt32().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr().

557 {
558  ossim_int32 result = 0;
559  std::string s = m_keywords.findKey( std::string("y start") );
560  if ( !s.size() )
561  {
562  s = m_keywords.findKey( std::string("line start") );
563  }
564  if ( s.size() )
565  {
566  result = ossimString( s ).toInt32();
567  }
568  return result;
569 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimKeywordlist m_keywords
ossim_int32 toInt32() const
int ossim_int32

◆ isEnviHeader() [1/2]

bool ossimEnviHeader::isEnviHeader ( const ossimFilename file)
static

Global method to test first line of file for "ENVI".

Returns
true on success, false on error.

Definition at line 900 of file ossimEnviHeader.cpp.

References ossimString::c_str().

Referenced by ossimEnviInfo::open(), and readStream().

901 {
902  bool result = false;
903  std::ifstream in;
904  in.open(file.c_str(), std::ios::in | std::ios::binary);
905  if ( in.is_open() )
906  {
907  result = isEnviHeader( in );
908  in.close();
909  }
910  return result;
911 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
static bool isEnviHeader(const ossimFilename &file)
Global method to test first line of file for "ENVI".
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

◆ isEnviHeader() [2/2]

bool ossimEnviHeader::isEnviHeader ( std::istream &  in)
static

Global method to test first line of stream for "ENVI".

Returns
true on success, false on error.

Definition at line 913 of file ossimEnviHeader.cpp.

References ossim::skipws().

914 {
915  bool result = false;
916  ossim::skipws(in);
917  char eh[5];
918  in.read(eh, 4);
919  eh[4] = '\0';
920  std::string s(eh);
921  if ( s == "ENVI" )
922  {
923  result = true;
924  }
925  return result;
926 }
OSSIM_DLL std::istream & skipws(std::istream &in)
Definition: ossimCommon.cpp:38

◆ loadState()

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

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

Parameters
kwlKeyword list to initialize from.
prefixUsually something like: "object1."
Returns
This method will alway return true as it is intended to be used in conjuction with the set methods.

Keywords picked up by loadState:

description: My_file

number_samples: 1024

number_lines: 512

number_bands: 3

header_offset: 0

file_type: ENVI Standard

data_type: 1

interleave_type: bil

sensor_type: Unknown

(little_endian or big_endian) byte_order: little_endian

map_info: Unknown

wavelength_units:

band_name0: Red band band_name1: Green band band_name2: Blue band

wavelength0: 620.25 wavelength1: 514.5 wavelength2: 470.0

Definition at line 720 of file ossimEnviHeader.cpp.

References ossimKeywordNames::DESCRIPTION_KW, ossimKeywordNames::FILENAME_KW, ossimKeywordlist::findKey(), m_file, m_keywords, ossimKeywordNames::NUMBER_BANDS_KW, ossimKeywordNames::NUMBER_LINES_KW, ossimKeywordNames::NUMBER_SAMPLES_KW, reset(), setDescription(), and ossimString::string().

Referenced by ossimEnviHeaderFileWriter::loadState().

722 {
723  std::string lookup;
724  std::string pfx = (prefix ? prefix: "" );
725  ossimString s;
726 
727  reset();
728 
729  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::FILENAME_KW));
730  if (lookup.size())
731  {
732  m_file.string() = lookup;
733  }
734 
735  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::DESCRIPTION_KW));
736  if (lookup.size())
737  {
738  setDescription(lookup);
739  }
740 
741  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::NUMBER_SAMPLES_KW));
742  if (lookup.size())
743  {
744  m_keywords["samples"] = lookup;
745  }
746 
747  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::NUMBER_LINES_KW));
748  if (lookup.size())
749  {
750  m_keywords["lines"] = lookup;
751  }
752 
753  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::NUMBER_BANDS_KW));
754  if (lookup.size())
755  {
756  m_keywords["bands"] = lookup;
757  }
758 
759  lookup = kwl.findKey(pfx, std::string(HEADER_OFFSET_KW));
760  if (lookup.size())
761  {
762  m_keywords["header offset"] = lookup;
763  }
764 
765  lookup = kwl.findKey(pfx, std::string(FILE_TYPE_KW));
766  if (lookup.size())
767  {
768  m_keywords["file_type"] = lookup;
769  }
770 
771  lookup = kwl.findKey(pfx, DATA_TYPE_KW);
772  if (lookup.size())
773  {
774  m_keywords["data type"] = lookup;
775  }
776 
777  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::INTERLEAVE_TYPE_KW));
778  if (lookup.size())
779  {
780  m_keywords["interleave"] = lookup;
781  }
782 
783  lookup = kwl.findKey(pfx, std::string(SENSOR_TYPE_KW));
784  if (lookup.size())
785  {
786  m_keywords["sensor type"] = lookup;
787  }
788 
789  lookup = kwl.findKey(pfx, std::string(ossimKeywordNames::BYTE_ORDER_KW));
790  if (lookup.size())
791  {
792  s = lookup;
793  s.downcase();
794  if (s == "little_endian")
795  {
796  m_keywords["byte order"] = "0";
797  }
798  else if (s == "big_endian")
799  {
800  m_keywords["byte order"] = "1";
801  }
802  else
803  {
804  m_keywords["byte order"] = lookup;
805  }
806  }
807 
808  lookup = kwl.findKey(pfx, std::string(X_START_KW));
809  if (lookup.size())
810  {
811  m_keywords["x start"] = lookup;
812  }
813  lookup = kwl.findKey(pfx, std::string(Y_START_KW));
814  if (lookup.size())
815  {
816  m_keywords["y start"] = lookup;
817  }
818 
819  lookup = kwl.findKey(pfx, std::string(MAP_INFO_KW));
820  if (lookup.size())
821  {
822  m_keywords["map info"] = lookup;
823  }
824 
825  lookup = kwl.findKey(pfx, std::string(WAVELENGTH_UNITS_KW));
826  if (lookup.size())
827  {
828  m_keywords["wavelength units"] = lookup;
829  }
830 
831  ossim_uint32 n;
832  ossim_uint32 count;
833  const ossim_uint32 MAX_TRIES = 1024; // Avoid infinate loop.
834 
835  // Get the band names.
836  n = kwl.numberOf(prefix, BAND_NAME_KW);
837  if (n)
838  {
839  ossimString value = "";
840  count = 0;
841  while ( (count < n) || (count > MAX_TRIES) )
842  {
843  s = BAND_NAME_KW;
844  s += ossimString::toString(count);
845  lookup = kwl.findKey(pfx, s.string());
846  if (lookup.size())
847  {
848  if(!value.empty())
849  {
850  value += ossimString(lookup);
851  }
852  else
853  {
854  value += (", " + ossimString(lookup));
855 
856  }
857 
858  }
859  ++count;
860  }
861  m_keywords["band names"] = value.c_str();
862  }
863 
864  // Get the band names.
865  n = kwl.numberOf(prefix, WAVELENGTH_KW);
866  if (n)
867  {
868  ossimString value;
869  count = 0;
870  while ( (count < n) || (count > MAX_TRIES) )
871  {
872  s = WAVELENGTH_KW;
873  s += ossimString::toString(count);
874  lookup = kwl.findKey(pfx, s.string());
875  if (lookup.size())
876  {
877  if(!value.empty())
878  {
879  value += ossimString(lookup);
880  }
881  else
882  {
883  value += (", " + ossimString(lookup));
884  }
885  }
886  ++count;
887  }
888  m_keywords["wavelength"] = value.c_str();
889  }
890  if (traceDebug())
891  {
893  << "ossimEnviHeader::loadState DEUG\n";
895  }
896 
897  return true;
898 }
static const char * BYTE_ORDER_KW
std::ostream & print(std::ostream &out) const
Prints header to out in a standard envi format.
ossim_uint32 numberOf(const char *str) const
void setDescription(const ossimString &description)
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_LINES_KW
ossimKeywordlist m_keywords
virtual void reset()
ossimFilename m_file
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
static const char * NUMBER_BANDS_KW
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
static const char * INTERLEAVE_TYPE_KW
static const char * DESCRIPTION_KW
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 empty() const
Definition: ossimString.h:411
static const char * FILENAME_KW
static const char * NUMBER_SAMPLES_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ open()

bool ossimEnviHeader::open ( const ossimFilename file)

Opens an envi header.

Returns
true on success, false on error.

Definition at line 120 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_file, readStream(), and reset().

Referenced by ossimGeneralRasterInfo::initializeFromEnviHdr(), ossimEnviInfo::print(), ossimAlphaSensorSupportData::readHdrFile(), and ossimAlphaSensorSupportData::readSupportFiles().

121 {
122  bool result = false;
123 
124  reset(); // Clear the map, file name.
125 
126  std::ifstream in;
127  in.open(file.c_str(), std::ios::in | std::ios::binary);
128  if( in.is_open() )
129  {
130  result = readStream( in );
131  if ( result )
132  {
133  m_file = file;
134  }
135  }
136 
137  return result;
138 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
virtual void reset()
ossimFilename m_file
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 readStream(std::istream &in)
Parses stream.

◆ print()

std::ostream & ossimEnviHeader::print ( std::ostream &  out) const

Prints header to out in a standard envi format.

Parameters
outStream to write to.
Returns
Reference to the stream passed.

Definition at line 218 of file ossimEnviHeader.cpp.

References m_keywords.

Referenced by operator<<(), and writeFile().

219 {
220  out << "ENVI" << "\n" << m_keywords << std::endl;
221  return out;
222 }
ossimKeywordlist m_keywords

◆ rangeCheckBands()

bool ossimEnviHeader::rangeCheckBands ( const std::vector< ossim_uint32 > &  bands) const
private

Check band list to see if any are outside of range of bands.

Bands should be zero base.

Returns
true if all bands are less than number of bands; false, if outside range or if "bands" key is not found.

Definition at line 933 of file ossimEnviHeader.cpp.

References getBands().

Referenced by getDefaultBands().

934 {
935  bool result = false;
936  const ossim_uint32 INPUT_BANDS = getBands();
937  if ( INPUT_BANDS )
938  {
939  result = true;
940  std::vector<ossim_uint32>::const_iterator i = bands.begin();
941  while ( i != bands.end() )
942  {
943  if ( (*i) >= INPUT_BANDS )
944  {
945  result = false;
946  break;
947  }
948  ++i;
949  }
950  }
951  return result;
952 }
ossim_uint32 getBands() const
unsigned int ossim_uint32

◆ readStream()

bool ossimEnviHeader::readStream ( std::istream &  in)
private

Parses stream.

Returns
true on success, false on error.

Definition at line 140 of file ossimEnviHeader.cpp.

References ossimKeywordlist::add(), ossimKeywordlist::clear(), ossimKeywordlist::findKey(), isEnviHeader(), m_keywords, reset(), ossim::skipws(), and ossimString::trim().

Referenced by open().

141 {
142  reset();
143  bool result = isEnviHeader( in );
144  if ( result )
145  {
146  m_keywords.clear();
147 
148  while(!in.eof()&&in.good())
149  {
150  // read name
151  ossimString name = "";
152  ossimString value = "";
153  ossim::skipws(in);
154  int c = static_cast<char>(in.get());
155  while((c != '=')&&(in.good())&&!in.eof())
156  {
157  name +=static_cast<char>(c);
158  c = in.get();
159  }
160  ossim::skipws(in);
161  c = in.get();
162 
163  if(in.good()&&!in.eof())
164  {
165  if(c == '{') // continue til '}'
166  {
167  c = in.get();
168  while((c != '}')&&(in.good())&&!in.eof())
169  {
170  value +=static_cast<char>(c);
171  c = in.get();
172  }
173  }
174  else
175  {
176  while(((c != '\n')&&(c!='\r'))&&(in.good())&&!in.eof())
177  {
178  value +=static_cast<char>(c);
179  c = (in.get());
180  }
181 
182  }
183  m_keywords.add(name.trim(), value);
184  }
185  }
186 
187  // Test for minimum set of keywords needed.
188  if ( m_keywords.findKey( std::string("samples") ).empty() ||
189  m_keywords.findKey( std::string("lines") ).empty() ||
190  m_keywords.findKey( std::string("bands") ).empty())
191  {
192  result = false;
193  }
194  }
195 
196  return result;
197 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static bool isEnviHeader(const ossimFilename &file)
Global method to test first line of file for "ENVI".
ossimKeywordlist m_keywords
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void reset()
OSSIM_DLL std::istream & skipws(std::istream &in)
Definition: ossimCommon.cpp:38
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.

◆ reset()

void ossimEnviHeader::reset ( void  )
virtual

Definition at line 80 of file ossimEnviHeader.cpp.

References ossimKeywordlist::clear(), m_file, m_keywords, and ossimString::string().

Referenced by loadState(), open(), and readStream().

81 {
82  m_file.string().clear();
83  m_keywords.clear();
84  m_keywords[FILE_TYPE_KW] = "ENVI Standard";
86 }
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossimKeywordlist m_keywords
ossimFilename m_file
void setByteorder(ossimByteOrder byteOrder)
Sets the envi byte order from the ossimByteOrder.
const std::string & string() const
Definition: ossimString.h:414

◆ setBandNames()

void ossimEnviHeader::setBandNames ( const std::vector< ossimString > &  bandNames)

Sets the band name string vector.

Parameters
bandNamesVector of band name strings.

Definition at line 697 of file ossimEnviHeader.cpp.

References ossimString::c_str(), ossimString::join(), and m_keywords.

698 {
699  ossimString value;
700  value.join(bandNames, ",");
701  m_keywords["band names"] = value.c_str();
702 }
const ossimString & join(const std::vector< ossimString > &stringList, const ossimString &separator)
ossimKeywordlist m_keywords
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

◆ setBands()

void ossimEnviHeader::setBands ( ossim_uint32  bands)

Sets the number of bands.

Parameters
bandsThe number of bands.

Definition at line 282 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_keywords, and ossimString::toString().

Referenced by ossimEnviHeaderFileWriter::writeFile().

283 {
284  m_keywords["bands"] = ossimString::toString(bands).c_str();
285 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist m_keywords
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

◆ setByteorder()

void ossimEnviHeader::setByteorder ( ossimByteOrder  byteOrder)

Sets the envi byte order from the ossimByteOrder.

Parameters
byteorderThe ossimByteOrder of the image.

Definition at line 524 of file ossimEnviHeader.cpp.

References ossim::byteOrder(), m_keywords, and OSSIM_LITTLE_ENDIAN.

525 {
527  {
528  m_keywords["byte order"] = "0";
529  }
530  else
531  {
532  m_keywords["byte order"] = "1";
533  }
534 }
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossimKeywordlist m_keywords

◆ setDataType()

void ossimEnviHeader::setDataType ( ossimScalarType  scalar)

Sets the envi data type based on the ossimScalarType.

Parameters
scalarThe ossimScalarType of the image.

Definition at line 413 of file ossimEnviHeader.cpp.

References ossimString::c_str(), ossimString::empty(), m_keywords, OSSIM_CFLOAT32, OSSIM_CFLOAT64, OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, and OSSIM_UINT8.

414 {
415  ossimString dataTypeString = "";
416  switch( scalar )
417  {
418  case OSSIM_UINT8:
419  dataTypeString = "1";
420  break;
421  case OSSIM_SINT16:
422  dataTypeString = "2";
423  break;
424  case OSSIM_SINT32:
425  dataTypeString = "3";
426  break;
427  case OSSIM_FLOAT32:
428  dataTypeString = "4";
429  break;
430  case OSSIM_FLOAT64:
431  dataTypeString = "5";
432  break;
433  case OSSIM_CFLOAT32:
434  dataTypeString = "6";
435  break;
436  case OSSIM_CFLOAT64:
437  dataTypeString = "9";
438  break;
439  case OSSIM_UINT16:
440  dataTypeString = "12";
441  break;
442  case OSSIM_UINT32:
443  dataTypeString = "13";
444  break;
445  default:
446  break;
447  }
448 
449  if(!dataTypeString.empty())
450  {
451  m_keywords["data type"] = dataTypeString.c_str();
452  }
453 }
32 bit complex floating point
64 bit floating point
16 bit unsigned integer
16 bit signed integer
32 bit floating point
ossimKeywordlist m_keywords
32 bit unsigned integer
32 bit signed integer
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 empty() const
Definition: ossimString.h:411
64 bit complex floating point
8 bit unsigned integer

◆ setDescription()

void ossimEnviHeader::setDescription ( const ossimString description)
Parameters
descriptionThe description of the file.

Definition at line 234 of file ossimEnviHeader.cpp.

References ossimString::c_str(), and m_keywords.

Referenced by loadState().

235 {
236  m_keywords["description"] = description.c_str();
237 }
ossimKeywordlist m_keywords
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

◆ setFileType()

void ossimEnviHeader::setFileType ( const ossimString fileType)

Sets the file type.

Parameters
fileTypeThe sensor type as a string.

Definition at line 361 of file ossimEnviHeader.cpp.

References m_keywords.

362 {
363  m_keywords[FILE_TYPE_KW] = fileType.c_str();
364 }
ossimKeywordlist m_keywords
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

◆ setHeaderOffset()

void ossimEnviHeader::setHeaderOffset ( ossim_uint32  headerOffset)

Sets the header offset in bytes.

Parameters
headerOffsetThe number of header offset in bytes.

Definition at line 351 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_keywords, and ossimString::toString().

352 {
353  m_keywords["header offset"] = ossimString::toString(headerOffset).c_str();
354 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist m_keywords
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

◆ setInterleaveType()

void ossimEnviHeader::setInterleaveType ( ossimInterleaveType  interleave)

Sets the envi interleave type string based on the ossimInterleaveType.

Parameters
interleaveThe ossimInterleaveType of the image.

Definition at line 479 of file ossimEnviHeader.cpp.

References m_keywords, OSSIM_BIL, OSSIM_BIP, and OSSIM_BSQ.

480 {
481  std::string interleaveString = "";
482  switch (interleave)
483  {
484  case OSSIM_BIL:
485  interleaveString = "bil";
486  break;
487  case OSSIM_BSQ:
488  interleaveString = "bsq";
489  break;
490  case OSSIM_BIP:
491  interleaveString = "bip";
492  break;
493  default:
494  interleaveString = "Unknown";
495  break;
496  }
497  m_keywords["interleave"] = interleaveString;
498 }
ossimKeywordlist m_keywords

◆ setLines()

void ossimEnviHeader::setLines ( ossim_uint32  lines)

Sets the number of lines.

Parameters
linesThe number of lines.

Definition at line 266 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_keywords, and ossimString::toString().

Referenced by ossimEnviHeaderFileWriter::writeFile().

267 {
268  m_keywords["lines"] = ossimString::toString(lines).c_str();
269 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist m_keywords
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

◆ setMapInfo() [1/2]

void ossimEnviHeader::setMapInfo ( const ossimString mapInfo)

Sets the envi map info string.

Parameters
mapInfoenvi map info string.

Definition at line 581 of file ossimEnviHeader.cpp.

References ossimString::c_str(), and m_keywords.

Referenced by ossimEnviHeaderFileWriter::writeFile().

582 {
583  m_keywords["map info"] = mapInfo.c_str();
584 }
ossimKeywordlist m_keywords
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

◆ setMapInfo() [2/2]

void ossimEnviHeader::setMapInfo ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)

Sets the envi map info string from a keyword list containing geometry information.

Parameters
kwlKeyword list containing geometry information.

Definition at line 586 of file ossimEnviHeader.cpp.

588 {
589  if (traceDebug())
590  {
592  << "ossimEnviHeader::setMapInfo DEBUG:"
593  << "\nkwl:\n"
594  << kwl
595  << std::endl;
596  }
597  ossimString mapInfoString;
598  const char* lookup;
599 
600  // Get the projection type.
601  ossimString projection;
602  lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
603  if (lookup)
604  {
605  projection = lookup;
606  }
607  else
608  {
610  << "ossimEnviHeader::setMapInfo WARNING:"
611  << "\nNo projection type found!\nReturning..."
612  << std::endl;
613 
614  return; // Have to have the projection type!
615  }
616 
617  // Get the datum.
618  ossimString datum = "WGS-84";
619  lookup = kwl.find(prefix, ossimKeywordNames::DATUM_KW);
620  if (lookup)
621  {
622  ossimString os = lookup;
623  if (os == "WGE")
624  {
625  datum = "WGS-84";
626  }
627  else
628  {
630  << "ossimEnviHeader::setMapInfo WARNING:"
631  << "\nUnhandled ossim -> envi datum: " << datum
632  << "\nAssuming WGS-84!"
633  << std::endl;
634  }
635  }
636 
637  if ( (projection == "ossimEquDistCylProjection") ||
638  (projection == "ossimLlxyProjection") )
639  {
640  const char* tieLat = NULL;
641  const char* tieLon = NULL;
642  const char* degLat = NULL;
643  const char* degLon = NULL;
644  tieLat = kwl.find(prefix, ossimKeywordNames::TIE_POINT_LAT_KW);
645  tieLon = kwl.find(prefix, ossimKeywordNames::TIE_POINT_LON_KW);
646  degLat = kwl.find(prefix,
648  degLon = kwl.find(prefix,
650 
651  if (!tieLat || !tieLon || !degLat || !degLon)
652  {
653  return;
654  }
655 
656  mapInfoString = "{Geographic Lat/Lon, 1.0000, 1.0000, ";
657  mapInfoString += tieLon;
658  mapInfoString += ", ";
659  mapInfoString += tieLat;
660  mapInfoString += ", ";
661  mapInfoString += degLon;
662  mapInfoString += ", ";
663  mapInfoString += degLat;
664  mapInfoString += ", ";
665  mapInfoString += datum;
666  mapInfoString += ", units=degrees}";
667  }
668 
669  m_keywords["map info"] = mapInfoString.c_str();
670  if (traceDebug())
671  {
673  << "ossimEnviHeader::setMapInfo DEBUG:"
674  << "\ntheMapInfo: " << mapInfoString
675  << std::endl;
676  }
677 }
static const char * DECIMAL_DEGREES_PER_PIXEL_LAT
static const char * DATUM_KW
const char * find(const char *key) const
static const char * TIE_POINT_LON_KW
ossimKeywordlist m_keywords
static const char * TYPE_KW
static const char * DECIMAL_DEGREES_PER_PIXEL_LON
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
static const char * TIE_POINT_LAT_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setSamples()

void ossimEnviHeader::setSamples ( ossim_uint32  samples)

Sets the number of samples.

Parameters
samplesThe number of samples.

Definition at line 250 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_keywords, and ossimString::toString().

Referenced by ossimEnviHeaderFileWriter::writeFile().

251 {
252  m_keywords[ std::string("samples") ] = ossimString::toString(samples).c_str();
253 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist m_keywords
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

◆ setSensorType()

void ossimEnviHeader::setSensorType ( const ossimString sensorType)

Sets the envi sensor type string.

Parameters
sensorTypeThe sensor type as a string.

Definition at line 505 of file ossimEnviHeader.cpp.

References ossimString::c_str(), and m_keywords.

506 {
507  m_keywords["sensor type"] = sensorType.c_str();
508 }
ossimKeywordlist m_keywords
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

◆ setWavelengths()

void ossimEnviHeader::setWavelengths ( const std::vector< ossimString > &  wavelengths)

Sets the envi band name string.

Parameters
wavelengthsVector of band name strings.

Definition at line 712 of file ossimEnviHeader.cpp.

References ossimString::join(), and m_keywords.

714 {
715  ossimString value;
716  value.join(wavelengths, ",");
717  m_keywords[WAVELENGTH_KW] = value.c_str();
718 }
const ossimString & join(const std::vector< ossimString > &stringList, const ossimString &separator)
ossimKeywordlist m_keywords
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

◆ setWavelengthUnits()

void ossimEnviHeader::setWavelengthUnits ( const ossimString wavelenghtUnits)

Sets the envi wavelength units string.

Parameters
wavelengthUnitsenvi wavelength units string.

Definition at line 684 of file ossimEnviHeader.cpp.

References ossimString::c_str(), and m_keywords.

685 {
686 
687  m_keywords["wavelength units"] = waveLengthUnits.c_str();
688 }
ossimKeywordlist m_keywords

◆ setXStart()

void ossimEnviHeader::setXStart ( ossim_int32  xstart)

Sets the x start.

Parameters
xStart

Definition at line 551 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_keywords, and ossimString::toString().

552 {
553  m_keywords["x start"] = ossimString::toString(xstart).c_str();
554 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist m_keywords
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

◆ setYStart()

void ossimEnviHeader::setYStart ( ossim_int32  ystart)

Sets the y start.

Parameters
ystart

Definition at line 571 of file ossimEnviHeader.cpp.

References ossimString::c_str(), m_keywords, and ossimString::toString().

572 {
573  m_keywords["y start"] = ossimString::toString(ystart).c_str();
574 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist m_keywords
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

◆ writeFile()

bool ossimEnviHeader::writeFile ( const ossimFilename file)

Writes header to file in a standard envi format.

Parameters
fileFile to write to.
Returns
true on success, false on error.

Definition at line 199 of file ossimEnviHeader.cpp.

References ossimString::c_str(), ossimKeywordlist::findKey(), m_keywords, and print().

Referenced by ossimEnviHeaderFileWriter::writeFile().

200 {
201  if (m_keywords.findKey( std::string("description") ).empty())
202  {
203  m_keywords["description"] = file.c_str();
204  }
205 
206  std::ofstream out(file.c_str(), std::ios_base::out);
207 
208  if (!out)
209  {
210  return false;
211  }
212 
213  print(out);
214  out.close();
215  return true;
216 }
std::ostream & print(std::ostream &out) const
Prints header to out in a standard envi format.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimKeywordlist m_keywords
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
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47

Friends And Related Function Documentation

◆ operator<<

OSSIM_DLL std::ostream& operator<< ( std::ostream &  out,
const ossimEnviHeader obj 
)
friend

friend operator<<

Definition at line 224 of file ossimEnviHeader.cpp.

225 {
226  return obj.print( out );
227 }
std::ostream & print(std::ostream &out) const
Prints header to out in a standard envi format.

Member Data Documentation

◆ m_file

ossimFilename ossimEnviHeader::m_file
private

Definition at line 411 of file ossimEnviHeader.h.

Referenced by getFile(), loadState(), open(), and reset().

◆ m_keywords

ossimKeywordlist ossimEnviHeader::m_keywords
private

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