OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimEnviHeader.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: David Burken
6 //
7 // Description:
8 //
9 // Class for reading and writing an ENVI (The Environment for Visualizing
10 // Images) header file.
11 //
12 //----------------------------------------------------------------------------
13 // $Id: ossimEnviHeader.cpp 22349 2013-08-01 21:38:29Z dburken $
14 
16 #include <ossim/base/ossimCommon.h>
21 #include <ossim/base/ossimString.h>
22 #include <ossim/base/ossimTrace.h>
24 #include <algorithm>
25 #include <fstream>
26 #include <string>
27 
28 typedef std::unary_function<std::pair<ossimString, ossimString>, bool> KwlCompareFunctionType;
29 typedef std::pair<const ossimString, ossimString> KwlComparePairType;
30 
32 {
33 public:
35  virtual bool operator()(const KwlComparePairType& rhs)const
36  {
37  return (m_key == rhs.first.downcase());
38  }
40 };
42 {
43 public:
45  virtual bool operator()(const KwlComparePairType& rhs)const
46  {
47  return (rhs.first.downcase().contains(m_key));
48  }
50 };
51 
52 // Define keywords not already found in ossimKeywordNames.
53 static const char HEADER_OFFSET_KW[] = "header_offset";
54 static const char FILE_TYPE_KW[] = "file_type";
55 static const char DATA_TYPE_KW[] = "data_type";
56 static const char SENSOR_TYPE_KW[] = "sensor_type";
57 static const char X_START_KW[] = "x_start";
58 static const char Y_START_KW[] = "y_start";
59 static const char MAP_INFO_KW[] = "map_info";
60 static const char WAVELENGTH_UNITS_KW[] = "wavelength_units";
61 static const char BAND_NAME_KW[] = "band_name";
62 static const char WAVELENGTH_KW[] = "wavelength";
63 
64 static ossimTrace traceDebug(ossimString("ossimEnviHeader:debug"));
65 
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 }
75 
77 {
78 }
79 
81 {
82  m_file.string().clear();
83  m_keywords.clear();
84  m_keywords[FILE_TYPE_KW] = "ENVI Standard";
86 }
87 
89 {
90  return m_keywords;
91 }
92 
94 {
95  return m_keywords;
96 }
97 
98 bool ossimEnviHeader::getValue( const ossimString& key, ossimString& value ) const
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 }
112 
114  ossimString& value) const
115 {
117  value, KwlKeySubStringCaseInsensitive(key));
118 }
119 
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 }
139 
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 }
198 
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 }
217 
219 {
220  out << "ENVI" << "\n" << m_keywords << std::endl;
221  return out;
222 }
223 
225 {
226  return obj.print( out );
227 }
228 
230 {
231  return ossimString( m_keywords.findKey( std::string("description") ) );
232 }
233 
235 {
236  m_keywords["description"] = description.c_str();
237 }
238 
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 }
249 
251 {
252  m_keywords[ std::string("samples") ] = ossimString::toString(samples).c_str();
253 }
254 
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 }
265 
267 {
268  m_keywords["lines"] = ossimString::toString(lines).c_str();
269 }
270 
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 }
281 
283 {
284  m_keywords["bands"] = ossimString::toString(bands).c_str();
285 }
286 
287 bool ossimEnviHeader::getDefaultBands( std::vector<ossim_uint32>& bands ) const
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 }
339 
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 }
350 
352 {
353  m_keywords["header offset"] = ossimString::toString(headerOffset).c_str();
354 }
355 
357 {
358  return m_keywords[FILE_TYPE_KW];
359 }
360 
362 {
363  m_keywords[FILE_TYPE_KW] = fileType.c_str();
364 }
365 
367 {
368  return ossimString(m_keywords["data type"]).toUInt32();
369 }
370 
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 }
412 
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 }
455 {
456  return m_keywords["interleave"];
457 }
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 }
478 
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 }
499 
501 {
502  return m_keywords["sensor type"];
503 }
504 
506 {
507  m_keywords["sensor type"] = sensorType.c_str();
508 }
509 
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 }
523 
525 {
527  {
528  m_keywords["byte order"] = "0";
529  }
530  else
531  {
532  m_keywords["byte order"] = "1";
533  }
534 }
535 
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 }
550 
552 {
553  m_keywords["x start"] = ossimString::toString(xstart).c_str();
554 }
555 
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 }
570 
572 {
573  m_keywords["y start"] = ossimString::toString(ystart).c_str();
574 }
575 
577 {
578  return m_keywords["map info"];
579 }
580 
582 {
583  m_keywords["map info"] = mapInfo.c_str();
584 }
585 
587  const char* prefix)
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 }
678 
680 {
681  return m_keywords["wavelength units"];
682 }
683 
685 {
686 
687  m_keywords["wavelength units"] = waveLengthUnits.c_str();
688 }
689 
690 void ossimEnviHeader::getBandNames(std::vector<ossimString>& bandNames) const
691 {
692  bandNames.clear();
693  ossimString bandNamesString = m_keywords["band names"];
694  bandNamesString.split(bandNames, ",");
695 }
696 
697 void ossimEnviHeader::setBandNames(const std::vector<ossimString>& bandNames)
698 {
699  ossimString value;
700  value.join(bandNames, ",");
701  m_keywords["band names"] = value.c_str();
702 }
703 
704 void ossimEnviHeader::getWavelengths(std::vector<ossimString>& waveLengths)
705  const
706 {
707  waveLengths.clear();
708  ossimString bandNamesString = m_keywords[WAVELENGTH_KW];
709  bandNamesString.split(waveLengths, ",");
710 }
711 
713  const std::vector<ossimString>& wavelengths)
714 {
715  ossimString value;
716  value.join(wavelengths, ",");
717  m_keywords[WAVELENGTH_KW] = value.c_str();
718 }
719 
721  const char* prefix)
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 }
899 
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 }
912 
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 }
927 
929 {
930  return m_file;
931 }
932 
933 bool ossimEnviHeader::rangeCheckBands( const std::vector<ossim_uint32>& bands ) const
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 }
static const char * BYTE_ORDER_KW
static const char * DECIMAL_DEGREES_PER_PIXEL_LAT
std::ostream & print(std::ostream &out) const
Prints header to out in a standard envi format.
void setMapInfo(const ossimString &mapInfo)
Sets the envi map info string.
ossimScalarType getOssimScalarType() const
void setWavelengths(const std::vector< ossimString > &wavelengths)
Sets the envi band name string.
ossim_uint32 numberOf(const char *str) const
ossimInterleaveType getOssimInterleaveType() const
ossim_uint32 getHeaderOffset() const
32 bit complex floating point
static const char * DATUM_KW
64 bit floating point
const ossimString & join(const std::vector< ossimString > &stringList, const ossimString &separator)
16 bit unsigned integer
void setDescription(const ossimString &description)
void setBands(ossim_uint32 bands)
Sets the number of bands.
Represents serializable keyword/value map.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
const char * find(const char *key) const
ossim_uint32 getDataType() const
static bool isEnviHeader(const ossimFilename &file)
Global method to test first line of file for "ENVI".
bool hasKey(const std::string &key) const
Checks for key in map.
static ossimString toString(bool aValue)
Numeric to string methods.
const ossimFilename & getFile() const
static const char * NUMBER_LINES_KW
static const char * TIE_POINT_LON_KW
16 bit signed integer
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.
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossim_uint32 toUInt32() const
32 bit floating point
ossimKeywordlist m_keywords
void setSamples(ossim_uint32 samples)
Sets the number of samples.
ossimEnviHeader()
default construtor
void setHeaderOffset(ossim_uint32 headerOffset)
Sets the header offset in bytes.
32 bit unsigned integer
virtual ~ossimEnviHeader()
virtual destructor
ossimString getWavelengthUnits() const
std::unary_function< std::pair< ossimString, ossimString >, bool > KwlCompareFunctionType
static const char * TYPE_KW
ossim_int32 toInt32() const
std::pair< const ossimString, ossimString > KwlComparePairType
void setSensorType(const ossimString &sensorType)
Sets the envi sensor type string.
bool open(const ossimFilename &file)
Opens an envi header.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossim_uint32 getLines() const
virtual bool operator()(const KwlComparePairType &rhs) const
ossimString getDescription() const
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of the object from a keyword list.
virtual void reset()
void setYStart(ossim_int32 ystart)
Sets the y start.
ossimString getInterleaveType() const
OSSIM_DLL std::istream & skipws(std::istream &in)
Definition: ossimCommon.cpp:38
ossimFilename m_file
std::string::size_type size() const
Definition: ossimString.h:405
ossimString getMapInfo() const
os2<< "> n<< " > nendobj n
32 bit signed integer
ossim_uint32 getBands() const
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...
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossim_int32 getXStart() const
static const char * DECIMAL_DEGREES_PER_PIXEL_LON
void getWavelengths(std::vector< ossimString > &wavelengths) const
ossimByteOrder
static const char * NUMBER_BANDS_KW
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimInterleaveType
bool getDefaultBands(std::vector< ossim_uint32 > &bands) const
Gets default bands if "default bands" keyword is present.
bool rangeCheckBands(const std::vector< ossim_uint32 > &bands) const
Check band list to see if any are outside of range of bands.
ossim_uint32 getSamples() const
const ossimKeywordlist & getMap() const
ossimScalarType
void setDataType(ossimScalarType scalar)
Sets the envi data type based on the ossimScalarType.
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
static const char * INTERLEAVE_TYPE_KW
void getBandNames(std::vector< ossimString > &bandNames) const
static const char * DESCRIPTION_KW
ossimString getFileType() const
ossimString getSensorType() const
ossim_int32 getYStart() const
Class for reading and writing an ENVI (The Environment for Visualizing Images) header 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 empty() const
Definition: ossimString.h:411
KwlKeyCaseInsensitiveEquals(const ossimString &key)
std::ostream & operator<<(std::ostream &out, const ossimEnviHeader &obj)
bool getValue(const ossimString &key, ossimString &value) const
Gets value for key.
bool readStream(std::istream &in)
Parses stream.
void setFileType(const ossimString &fileType)
Sets the file type.
KwlKeySubStringCaseInsensitive(const ossimString &key)
static const char * TIE_POINT_LAT_KW
64 bit complex floating point
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47
void setInterleaveType(ossimInterleaveType interleave)
Sets the envi interleave type string based on the ossimInterleaveType.
8 bit unsigned integer
bool findSubStringCaseInsensitive(const ossimString &key, ossimString &value) const
Gets value for key.
bool writeFile(const ossimFilename &file)
Writes header to file in a standard envi format.
virtual bool operator()(const KwlComparePairType &rhs) const
ossimByteOrder getByteOrder() const
void setXStart(ossim_int32 xstart)
Sets the x start.
static const char * FILENAME_KW
static const char * NUMBER_SAMPLES_KW
void setByteorder(ossimByteOrder byteOrder)
Sets the envi byte order from the ossimByteOrder.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
void setWavelengthUnits(const ossimString &wavelenghtUnits)
Sets the envi wavelength units string.
void setLines(ossim_uint32 lines)
Sets the number of lines.
int ossim_int32
const std::string & string() const
Definition: ossimString.h:414
void setBandNames(const std::vector< ossimString > &bandNames)
Sets the band name string vector.