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

#include <ossimAuxFileHandler.h>

Public Member Functions

 ossimAuxFileHandler ()
 
virtual ~ossimAuxFileHandler ()
 
bool isAuxFile (const ossimFilename &file)
 .aux file More...
 
bool open (const ossimFilename &file)
 the file for reading More...
 
const ossimStringgetProjectionName () const
 Reads a single record from a aux file. More...
 
const ossimStringgetDatumName () const
 
const ossimStringgetUnitType () const
 

Private Attributes

ossimAuxInfom_auxInfo
 
ossimString m_projName
 
ossimString m_datumName
 
ossimString m_unitsType
 

Detailed Description

Definition at line 195 of file ossimAuxFileHandler.h.

Constructor & Destructor Documentation

◆ ossimAuxFileHandler()

ossimAuxFileHandler::ossimAuxFileHandler ( )

Definition at line 110 of file ossimAuxFileHandler.cpp.

111 {
112  m_auxInfo = NULL;
113 }

◆ ~ossimAuxFileHandler()

ossimAuxFileHandler::~ossimAuxFileHandler ( )
virtual

Definition at line 115 of file ossimAuxFileHandler.cpp.

116 {
117  if (m_auxInfo != NULL)
118  {
119  delete m_auxInfo;
120  m_auxInfo = 0;
121  }
122 }

Member Function Documentation

◆ getDatumName()

const ossimString& ossimAuxFileHandler::getDatumName ( ) const
inline

Definition at line 218 of file ossimAuxFileHandler.h.

Referenced by ossimMrSidReader::getGeoProjection().

218 { return m_datumName; }

◆ getProjectionName()

const ossimString& ossimAuxFileHandler::getProjectionName ( ) const
inline

Reads a single record from a aux file.

Returns true if succesful. Returns false if EOF or error.

Definition at line 216 of file ossimAuxFileHandler.h.

Referenced by ossimMrSidReader::getGeoProjection().

216 { return m_projName; }

◆ getUnitType()

const ossimString& ossimAuxFileHandler::getUnitType ( ) const
inline

Definition at line 220 of file ossimAuxFileHandler.h.

Referenced by ossimMrSidReader::getGeoProjection().

220 { return m_unitsType; }

◆ isAuxFile()

bool ossimAuxFileHandler::isAuxFile ( const ossimFilename file)

.aux file

Definition at line 124 of file ossimAuxFileHandler.cpp.

References ossimString::downcase(), ossimFilename::exists(), and ossimFilename::ext().

125 {
126  bool result = false;
127 
128  if ( file.exists() )
129  {
130  ossimString ext = file.ext();
131  ext.downcase();
132  if (ext == "aux")
133  {
134  result = true;
135  }
136  else
137  {
138  result = false;
139  }
140  }
141 
142  return result;
143 }
bool exists() const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimString ext() const

◆ open()

bool ossimAuxFileHandler::open ( const ossimFilename file)

the file for reading

Definition at line 145 of file ossimAuxFileHandler.cpp.

References ossimString::c_str().

Referenced by ossimMrSidReader::getGeoProjection().

146 {
147  FILE *fp = fopen(file.c_str(), "r");
148  char header[16];
149  ossim_uint32 nHeaderPos;
150 
151  if( fp == NULL )
152  {
153  return false;
154  }
155 
156  fread( header, 16, 1, fp);
157 
158  char* tmpHeader = const_cast<char*>(header);
159  if(strcmp(tmpHeader,"EHFA_HEADER_TAG") != 0)
160  {
161  fclose( fp );
162  return false;
163  }
164 
165  //Create the ossimAuxInfo
166  m_auxInfo = new ossimAuxInfo();
167  m_auxInfo->fp = fp;
168 
169  //Where is the header?
170  fread( &nHeaderPos, sizeof(ossim_int32), 1, fp );
171 
172  fseek( fp, nHeaderPos, SEEK_SET );
173 
174  fread( &(m_auxInfo->nVersion), sizeof(ossim_int32), 1, fp );
175 
176  fread( header, 4, 1, fp ); /* skip freeList */
177 
178  fread( &(m_auxInfo->nRootPos), sizeof(ossim_int32), 1, fp );
179 
180  fread( &(m_auxInfo->nEntryHeaderLength), sizeof(ossim_int16), 1, fp );
181  fread( &(m_auxInfo->nDictionaryPos), sizeof(ossim_int32), 1, fp );
182 
183  fseek( fp, 0, SEEK_END );
184  m_auxInfo->nEndOfFile = (ossim_int32) ftell(fp);
185 
186  m_auxInfo->m_Root = new ossimAuxEntry( m_auxInfo, m_auxInfo->nRootPos, NULL, NULL );
187 
188  m_auxInfo->dictionaryData = ossimAuxGetDictionary(m_auxInfo);
190 
192  while( node != NULL )
193  {
194  std::string typeStr = node->getType();
195  size_t typeLen = typeStr.length();
196  std::string str = "Eimg_Layer";
197  size_t strLen = str.length();
198  if( typeLen == strLen)
199  {
200  ossimAuxEntry* projEntry = node->getNamedChild("Map_Info");
201  if( projEntry == NULL )
202  {
203  ossimAuxEntry* childEntry;
204  for( childEntry = node->getChild(); childEntry != NULL && projEntry == NULL; childEntry = childEntry->getNext() )
205  {
206  if (ossimString(childEntry->getType()) == "Eprj_MapInfo")
207  projEntry = childEntry;
208  }
209  }
210 
211  const char* proj = NULL;
212  const char* units = NULL;
213  if (projEntry)
214  {
215  proj = projEntry->getStringField("proName");
216  units = projEntry->getStringField("units");
217  }
218 
219  if (proj != NULL)
220  {
221  m_projName = ossimString(proj);
222  }
223  if (units != NULL)
224  {
225  m_unitsType = ossimString(proj);
226  }
227 
228  ossimAuxEntry* datumEntry = node->getNamedChild( "Projection.Datum" );
229  const char* datumStr = NULL;
230  if (datumEntry)
231  {
232  datumStr = datumEntry->getStringField("datumname");
233  }
234  if (datumStr != NULL)
235  {
236  m_datumName = ossimString(datumStr);;
237  }
238  break;
239  }
240  node = node->getNext();
241  }
242 
243  fclose(fp);
244  return true;
245 }
const char * getStringField(const char *auxFieldPath)
ossimAuxDictionary * m_Dictionary
ossimAuxEntry * m_Root
ossim_uint32 nRootPos
ossimAuxEntry * getNext()
ossimAuxEntry * getChild()
const char * getType()
unsigned int ossim_uint32
ossim_uint32 nDictionaryPos
short ossim_int16
ossim_uint32 nEndOfFile
ossim_int32 nVersion
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_int16 nEntryHeaderLength
ossimAuxEntry * getNamedChild(const char *name)
int ossim_int32

Member Data Documentation

◆ m_auxInfo

ossimAuxInfo* ossimAuxFileHandler::m_auxInfo
private

Definition at line 224 of file ossimAuxFileHandler.h.

◆ m_datumName

ossimString ossimAuxFileHandler::m_datumName
private

Definition at line 226 of file ossimAuxFileHandler.h.

◆ m_projName

ossimString ossimAuxFileHandler::m_projName
private

Definition at line 225 of file ossimAuxFileHandler.h.

◆ m_unitsType

ossimString ossimAuxFileHandler::m_unitsType
private

Definition at line 227 of file ossimAuxFileHandler.h.


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