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

the elevation manager, this class returns an ossimSrtmElevSource given a ground point and some directory with srtm files in it. More...

#include <ossimSrtmFactory.h>

Inheritance diagram for ossimSrtmFactory:
ossimElevSourceFactory ossimObject ossimReferenced

Public Member Functions

 ossimSrtmFactory ()
 default constructor More...
 
 ossimSrtmFactory (const ossimFilename &dir)
 Constructor that takes a directory name. More...
 
virtual ~ossimSrtmFactory ()
 destructor More...
 
virtual ossimElevSourcegetNewElevSource (const ossimGpt &gpt) const
 Open the appropriate ossimSrtmElevSource that covers given a ground point. More...
 
- Public Member Functions inherited from ossimElevSourceFactory
 ossimElevSourceFactory ()
 default constructor More...
 
virtual ~ossimElevSourceFactory ()
 virtual destructor More...
 
virtual ossimFilename getDirectory () const
 
virtual void setDirectory (const ossimFilename &directory)
 
- 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 bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
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
 

Additional Inherited Members

- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Attributes inherited from ossimElevSourceFactory
ossimFilename theDirectory
 

Detailed Description

the elevation manager, this class returns an ossimSrtmElevSource given a ground point and some directory with srtm files in it.

Definition at line 27 of file ossimSrtmFactory.h.

Constructor & Destructor Documentation

◆ ossimSrtmFactory() [1/2]

ossimSrtmFactory::ossimSrtmFactory ( )

default constructor

Definition at line 34 of file ossimSrtmFactory.cpp.

36 {}
ossimElevSourceFactory()
default constructor

◆ ossimSrtmFactory() [2/2]

ossimSrtmFactory::ossimSrtmFactory ( const ossimFilename dir)

Constructor that takes a directory name.

Definition at line 38 of file ossimSrtmFactory.cpp.

References ossimElevSourceFactory::theDirectory.

40 {
41  theDirectory = dir;
42 }
ossimElevSourceFactory()
default constructor

◆ ~ossimSrtmFactory()

ossimSrtmFactory::~ossimSrtmFactory ( )
virtual

destructor

Definition at line 44 of file ossimSrtmFactory.cpp.

45 {}

Member Function Documentation

◆ getNewElevSource()

ossimElevSource * ossimSrtmFactory::getNewElevSource ( const ossimGpt gpt) const
virtual

Open the appropriate ossimSrtmElevSource that covers given a ground point.

Parameters
gptGround point that an elevation source is need for.
Returns
Returns a pointer to an ossimElevSource if an srtm file is found that can cover the ground point. Returns NULL if no cell is found for the point.

Implements ossimElevSourceFactory.

Definition at line 47 of file ossimSrtmFactory.cpp.

48 {
49 
50  if (traceDebug())
51  {
53  << "DEBUG ossimSrtmFactory::getNewElevSource: Entered..."
54  << std::endl;
55  }
56 
58 
60  {
62  << "ossimSrtmFactory::getNewElevSource: "
63  << "SRTM directory has not been set!"
64  << "\nReturning null elevation source..."
65  << std::endl;
66 
67  return srtmPtr.release();
68  }
69 
70  //---
71  // Build up a srtm file name.
72  //
73  // Standard for name is upper case 'N' and 'W' lower case "hgt" like:
74  // N27W081.hgt
75  //---
76  ossimFilename srtmFileBasename;
77 
78  int ilat = static_cast<int>(floor(gpt.latd()));
79  if (ilat < 0)
80  {
81  srtmFileBasename = "S";
82  }
83  else
84  {
85  srtmFileBasename = "N";
86  }
87 
88  ilat = abs(ilat);
90 
91  os1 << std::setfill('0') << std::setw(2) <<ilat;
92 
93  srtmFileBasename += os1.str().c_str();
94 
95  int ilon = static_cast<int>(floor(gpt.lond()));
96 
97  if (ilon < 0)
98  {
99  srtmFileBasename += "W";
100  }
101  else
102  {
103  srtmFileBasename += "E";
104  }
105 
106  ilon = abs(ilon);
108  os2 << std::setfill('0') << std::setw(3) << ilon;
109 
110  srtmFileBasename += os2.str().c_str();
111  srtmFileBasename.setExtension(".hgt");
112 
113  ossimFilename srtmFile = theDirectory.dirCat(srtmFileBasename);
114 
115  if (traceDebug())
116  {
118  << "DEBUG ossimSrtmFactory::getNewElevSource:"
119  << "\nSearching for file: " << srtmFile
120  << std::endl;
121  }
122  // ossimRefPtr<ossimIFStream> is = ossimStreamFactoryRegistry::instance()->
123  std::shared_ptr<ossim::istream> is = ossim::StreamFactoryRegistry::instance()->
124  createIstream(srtmFile);
125 
126  // Look for the file mix case, then all lower case, then all upper case.
127  if ( is )
128  {
129  if(is->fail())
130  {
131  // Try down casing the whole thing.
132  srtmFileBasename = srtmFileBasename.downcase();
133  srtmFile = theDirectory.dirCat(srtmFileBasename);
134 
136  createIstream(srtmFile);
137  if ( is )
138  {
139  if(is->fail())
140  {
141  // OK, try upcasing the whole thing.
142  srtmFileBasename = srtmFileBasename.upcase();
143  srtmFile = theDirectory.dirCat(srtmFileBasename);
145  createIstream(srtmFile);
146  }
147  }
148  }
149  }
150 
151  if ( is && (!is->fail()) )
152  {
153  is.reset();
154  srtmPtr = new ossimSrtmHandler();
155  if(srtmPtr->open(srtmFile)&&srtmPtr->pointHasCoverage(gpt) )
156  {
157  return srtmPtr.release();
158  }
159  else
160  {
161  srtmPtr = 0;
162  }
163  }
164  return srtmPtr.release();
165 }
std::ostringstream os2
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
static StreamFactoryRegistry * instance()
#define abs(a)
Definition: auxiliary.h:74
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
virtual bool pointHasCoverage(const ossimGpt &) const
METHOD: pointIsInsideRect() Method to check if the ground point elevation is defined: ...
virtual bool open(const ossimFilename &, bool=false)
T * release()
Definition: ossimRefPtr.h:93
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
for an srtm file.
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 & setExtension(const ossimString &e)
Sets the extension of a file name.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

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