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

#include <ossimGeoidManager.h>

Inheritance diagram for ossimGeoidManager:
ossimGeoid ossimObject ossimErrorStatusInterface ossimReferenced

Public Member Functions

virtual ~ossimGeoidManager ()
 
virtual bool open (const ossimFilename &dir, ossimByteOrder byteOrder)
 Permits initialization of geoids from directory name. More...
 
virtual double offsetFromEllipsoid (const ossimGpt &gpt)
 
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...
 
virtual void addGeoid (ossimRefPtr< ossimGeoid > geoid, bool toFrontFlag=false)
 Permits adding additional geoids to the list: More...
 
ossimGeoidfindGeoidByShortName (const ossimString &shortName, bool caseSensitive=true)
 
virtual void clear ()
 Permits to clear the GeoidList. More...
 
- Public Member Functions inherited from ossimGeoid
 ossimGeoid ()
 
- 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 std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
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
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 

Static Public Member Functions

static ossimGeoidManagerinstance ()
 Implements singelton pattern: More...
 

Private Member Functions

 ossimGeoidManager ()
 Private constructor. More...
 

Private Attributes

std::vector< ossimRefPtr< ossimGeoid > > theGeoidList
 
ossimRefPtr< ossimGeoidtheIdentityGeoid
 

Additional Inherited Members

- Protected Member Functions inherited from ossimGeoid
virtual ~ossimGeoid ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Detailed Description

Definition at line 26 of file ossimGeoidManager.h.

Constructor & Destructor Documentation

◆ ~ossimGeoidManager()

ossimGeoidManager::~ossimGeoidManager ( )
virtual

Definition at line 54 of file ossimGeoidManager.cpp.

References clear().

55 {
56 // vector<ossimGeoid*>::iterator g = theGeoidList.begin();
57 // while (g != theGeoidList.end())
58 // {
59 // delete *g;
60 // ++g;
61 // }
62  clear();
63 }
virtual void clear()
Permits to clear the GeoidList.

◆ ossimGeoidManager()

ossimGeoidManager::ossimGeoidManager ( )
private

Private constructor.

Use "instance" method.

Definition at line 44 of file ossimGeoidManager.cpp.

References theIdentityGeoid.

45 {
46  // theInstance = this;
48 }
ossimRefPtr< ossimGeoid > theIdentityGeoid
Identity geoid.
Definition: ossimGeoid.h:48

Member Function Documentation

◆ addGeoid()

void ossimGeoidManager::addGeoid ( ossimRefPtr< ossimGeoid geoid,
bool  toFrontFlag = false 
)
virtual

Permits adding additional geoids to the list:

Definition at line 94 of file ossimGeoidManager.cpp.

References theGeoidList.

95 {
96  if(!toFrontFlag)
97  {
98  theGeoidList.push_back(geoid);
99  }
100  else
101  {
102  theGeoidList.insert(theGeoidList.begin(), geoid);
103  }
104 }
std::vector< ossimRefPtr< ossimGeoid > > theGeoidList

◆ clear()

void ossimGeoidManager::clear ( )
virtual

Permits to clear the GeoidList.

Definition at line 69 of file ossimGeoidManager.cpp.

References theGeoidList.

Referenced by ~ossimGeoidManager().

70 {
71  theGeoidList.clear();
72 }
std::vector< ossimRefPtr< ossimGeoid > > theGeoidList

◆ findGeoidByShortName()

ossimGeoid * ossimGeoidManager::findGeoidByShortName ( const ossimString shortName,
bool  caseSensitive = true 
)

Definition at line 328 of file ossimGeoidManager.cpp.

References ossimString::downcase(), ossimRefPtr< T >::get(), ossimObject::getShortName(), theGeoidList, and theIdentityGeoid.

Referenced by ossimElevationDatabase::loadState().

329 {
330  ossim_uint32 idx=0;
331  ossimString testString = shortName;
332  if(shortName == "identity")
333  {
334  return theIdentityGeoid.get();
335  }
336  if(!caseSensitive)
337  {
338  testString = testString.downcase();
339  }
340  for(idx = 0; idx < theGeoidList.size(); ++idx)
341  {
342  if(!caseSensitive)
343  {
344  if(theGeoidList[idx]->getShortName().downcase() == testString)
345  {
346  return theGeoidList[idx].get();
347  }
348  }
349  else
350  {
351  if(theGeoidList[idx]->getShortName() == testString)
352  {
353  return theGeoidList[idx].get();
354  }
355  }
356  }
357  return 0;
358 }
ossimRefPtr< ossimGeoid > theIdentityGeoid
virtual ossimString getShortName() const
Definition: ossimObject.cpp:48
unsigned int ossim_uint32
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
std::vector< ossimRefPtr< ossimGeoid > > theGeoidList

◆ instance()

ossimGeoidManager * ossimGeoidManager::instance ( )
static

Implements singelton pattern:

Definition at line 78 of file ossimGeoidManager.cpp.

Referenced by ossimElevRemapper::elevRemap(), ossimElevManager::getHeightAboveEllipsoid(), ossimElevManager::getHeightAboveMSL(), ossimElevationDatabase::getOffsetFromEllipsoid(), ossimGpt::heightMSL(), ossimElevationDatabase::loadState(), ossimIpodSensor::loadState(), ossimSkyBoxLearSensor::loadState(), ossimSonomaSensor::loadState(), and ossimInfo::outputHeight().

79 {
80  static ossimGeoidManager inst;
81 // if (!theInstance)
82 // {
83 // theInstance = new ossimGeoidManager();
84 // }
85 
86  //return theInstance;
87  return &inst;
88 }

◆ loadState()

bool ossimGeoidManager::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 116 of file ossimGeoidManager.cpp.

118 {
119  static const char MODULE[] = "ossimGeoidManager::loadState()";
120 
121  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG)
122  << "DEBUG: " << MODULE << ", entering...\n";
123 
124  //---
125  // Look for geoid sources:
126  // Note: the ossimInit::initializeElevation() does not pass a prefix to us
127  // as it should...
128  //---
129  std::string geoidMgrPrefix = prefix ? prefix : "geoid.manager.";
130 
131  ossimString regExpression = ossimString("^(") + geoidMgrPrefix.c_str() +
132  "geoid_source[0-9]+.)";
133 
134  vector<ossimString> keys = kwl.getSubstringKeyList( regExpression );
135  if ( keys.size() )
136  {
137  for ( ossim_uint32 idx = 0; idx < keys.size(); ++idx )
138  {
139  std::string newPrefix = keys[idx];
140 
141  // See if enable flag is set to false.
142  bool enabled = true;
143  std::string key = ossimKeywordNames::ENABLED_KW;
144  std::string value = kwl.findKey( newPrefix, key );
145  if ( value.size() )
146  {
147  enabled = ossimString( value ).toBool();
148  }
149 
150  if ( enabled )
151  {
152  // Get the type:
154  value = kwl.findKey( newPrefix, key );
155 
156  if ( (value == "geoid_image" ) || ( value == "ossimGeoidImage" ) )
157  {
159  if ( geoid->loadState( kwl, newPrefix.c_str() ) )
160  {
161  if (traceDebug())
162  {
164  << "DEBUG: " << MODULE
165  << "\nAdded geoid: " << geoid->getShortName() << "\n";
166  }
167  addGeoid(geoid.get());
168  }
169  }
170  }
171  }
172  }
173 
174  // End of "geoid_sources" block.
175 
176  // Look for the ngs geoid directories
177  const char* lookup = kwl.find(prefix, "geoid_99_directory");
178  ossimByteOrder geoidNgsByteOrder = OSSIM_LITTLE_ENDIAN;
179  const char* byteOrder = kwl.find(prefix, "geoid_99_directory.byte_order");
180  if (!lookup)
181  {
182  lookup = kwl.find(prefix, "geoid_ngs_directory");
183  byteOrder = kwl.find(prefix, "geoid_ngs_directory.byte_order");
184  }
185  if(byteOrder)
186  {
187  if(ossimString(byteOrder).contains("little"))
188  {
189  geoidNgsByteOrder = OSSIM_LITTLE_ENDIAN;
190  }
191  else
192  {
193  geoidNgsByteOrder = OSSIM_BIG_ENDIAN;
194  }
195  }
196  if(lookup)
197  {
198  ossimFilename f = lookup;
199  if (f.isDir())
200  {
201  ossimRefPtr<ossimGeoid> geoid = new ossimGeoidNgs(f, geoidNgsByteOrder);
202 
204  {
205  if (traceDebug())
206  {
208  << "DEBUG: " << MODULE
209  << "\nAdded geoid dir: " << f.c_str() << "\n";
210  }
211  addGeoid(geoid.get());
212  }
213  else
214  {
215  geoid = 0;
216  }
217  }
218  }
219 
221  geoidGrid1996 = geoidGrid1996.dirCat("geoids");
222  geoidGrid1996 = geoidGrid1996.dirCat("geoid1996");
223  geoidGrid1996 = geoidGrid1996.dirCat("egm96.grd");
224 
225  if(!geoidGrid1996.exists())
226  {
228  geoidGrid1996 = geoidGrid1996.dirCat("geoids");
229  geoidGrid1996 = geoidGrid1996.dirCat("geoid1996");
230  geoidGrid1996 = geoidGrid1996.dirCat("egm96.grd");
231  }
232 
233  if( geoidGrid1996.exists() )
234  {
235  ossimRefPtr<ossimGeoid> geoid = new ossimGeoidEgm96(geoidGrid1996);
237  {
238  if (traceDebug())
239  {
241  << "DEBUG: " << MODULE
242  << "\nAdded geoid egm 96: " << geoidGrid1996.c_str()
243  << "\n";
244  }
245  addGeoid(geoid.get());
246  }
247  else
248  {
249  geoid = 0;
250  }
251  }
252  else
253  {
254  // Look for the geoid Earth Gravity Model (EGM) 96 directory.
255  lookup = kwl.find(prefix, "geoid_egm_96_grid");
256  if (lookup)
257  {
258  ossimFilename f = lookup;
259  if (f.isDir() || f.isFile())
260  {
262 
264  {
265  if (traceDebug())
266  {
268  << "DEBUG: " << MODULE
269  << "\nAdded geoid egm 96: " << f.c_str()
270  << "\n";
271  }
272 
273  addGeoid(geoid.get());
274  }
275  else
276  {
277  geoid = 0;
278  }
279  }
280  }
281  }
282  if (traceExec())
283  {
285  << "DEBUG: " << MODULE << ", returning...\n";
286  }
287 
288  return true;
289 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static const ossimErrorCode OSSIM_OK
ossimFilename getInstalledOssimSupportDir() const
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
bool isDir() const
virtual ossimString getShortName() const
Definition: ossimObject.cpp:48
static const char * TYPE_KW
Generic geoid source which uses a image handler for reading the grid.
bool exists() const
bool toBool() const
String to numeric methods.
unsigned int ossim_uint32
bool isFile() const
ossimByteOrder
virtual void addGeoid(ossimRefPtr< ossimGeoid > geoid, bool toFrontFlag=false)
Permits adding additional geoids to the list:
static const char * ENABLED_KW
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const
static ossimEnvironmentUtility * instance()
virtual ossimErrorCode getErrorStatus() const
ossimFilename dirCat(const ossimFilename &file) const
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
ossimFilename getUserOssimSupportDir() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ offsetFromEllipsoid()

double ossimGeoidManager::offsetFromEllipsoid ( const ossimGpt gpt)
virtual
Returns
The offset from the ellipsoid to the geoid or ossim::nan() if grid does not contain the point.

Implements ossimGeoid.

Definition at line 313 of file ossimGeoidManager.cpp.

References ossim::isnan(), ossim::nan(), and theGeoidList.

Referenced by ossimElevRemapper::elevRemap(), ossimElevManager::getHeightAboveEllipsoid(), ossimElevManager::getHeightAboveMSL(), ossimElevationDatabase::getOffsetFromEllipsoid(), ossimGpt::heightMSL(), ossimIpodSensor::loadState(), ossimSkyBoxLearSensor::loadState(), ossimSonomaSensor::loadState(), and ossimInfo::outputHeight().

314 {
315  double offset = ossim::nan();
316  std::vector<ossimRefPtr<ossimGeoid> >::iterator geoid =
317  theGeoidList.begin();
318 
319  while ( ossim::isnan(offset) && (geoid != theGeoidList.end()))
320  {
321  offset = ((*geoid))->offsetFromEllipsoid(gpt);
322  ++geoid;
323  }
324 
325  return offset;
326 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
std::vector< ossimRefPtr< ossimGeoid > > theGeoidList
virtual double offsetFromEllipsoid(const ossimGpt &gpt)
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ open()

bool ossimGeoidManager::open ( const ossimFilename dir,
ossimByteOrder  byteOrder 
)
virtual

Permits initialization of geoids from directory name.

Should never be called since called on specific geoid types:

Implements ossimGeoid.

Definition at line 296 of file ossimGeoidManager.cpp.

References ossim::byteOrder(), status, and theGeoidList.

297 {
298  std::vector<ossimRefPtr<ossimGeoid> >::iterator g = theGeoidList.begin();
299  bool status = true;
300  while (g != theGeoidList.end())
301  {
302  status &= (*g)->open(dir, byteOrder);
303  ++g;
304  }
305 
306  return status;
307 }
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
return status
std::vector< ossimRefPtr< ossimGeoid > > theGeoidList

◆ saveState()

bool ossimGeoidManager::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. DO NOTHING

Reimplemented from ossimObject.

Definition at line 106 of file ossimGeoidManager.cpp.

108 {
109  return true;
110 }

Member Data Documentation

◆ theGeoidList

std::vector< ossimRefPtr<ossimGeoid> > ossimGeoidManager::theGeoidList
mutableprivate

Definition at line 84 of file ossimGeoidManager.h.

Referenced by addGeoid(), clear(), findGeoidByShortName(), offsetFromEllipsoid(), and open().

◆ theIdentityGeoid

ossimRefPtr<ossimGeoid> ossimGeoidManager::theIdentityGeoid
private

Definition at line 88 of file ossimGeoidManager.h.

Referenced by findGeoidByShortName(), and ossimGeoidManager().


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