OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimEnviInfo.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: ENVI Info object.
10 //
11 //----------------------------------------------------------------------------
12 // $Id$
13 
17 #include <iostream>
18 
20  : ossimInfoBase(),
21  m_file()
22 {
23 }
24 
26 {
27 }
28 
30 {
31  bool result = false;
32 
33  m_file = file;
34 
35  if ( file.ext().downcase() != "hdr" )
36  {
37  // Typical case, we were fed the image file. Look for a header file beside image.
38  m_file.setExtension("hdr"); // image.hdr
39  if ( !m_file.exists() )
40  {
41  m_file.setExtension("HDR"); // image.HDR
42  if ( !m_file.exists() )
43  {
44  m_file = file;
45  m_file.string() += ".hdr"; // image.ras.hdr
46  }
47  }
48  }
49 
50  if ( m_file.exists() )
51  {
53  {
54  result = true;
55  }
56  }
57 
58  if ( !result )
59  {
60  m_file.clear();
61  }
62 
63  return result;
64 }
65 
67 {
68  if ( m_file.size() )
69  {
70  ossimEnviHeader hdr;
71  if ( hdr.open( m_file ) )
72  {
73  hdr.getMap().addPrefixToAll( ossimString( "envi." ) );
74  out << hdr.getMap() << std::endl;
75  }
76  }
77  return out;
78 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
static bool isEnviHeader(const ossimFilename &file)
Global method to test first line of file for "ENVI".
virtual bool open(const ossimFilename &file)
open method.
bool open(const ossimFilename &file)
Opens an envi header.
bool exists() const
std::string::size_type size() const
Definition: ossimString.h:405
Info Base.
Definition: ossimInfoBase.h:32
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual ~ossimEnviInfo()
virtual destructor
const ossimKeywordlist & getMap() const
void addPrefixToAll(const ossimString &prefix)
Class for reading and writing an ENVI (The Environment for Visualizing Images) header file...
ossimString ext() const
ossimFilename m_file
Definition: ossimEnviInfo.h:51
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual std::ostream & print(std::ostream &out) const
Print method.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
ossimEnviInfo()
default constructor
const std::string & string() const
Definition: ossimString.h:414