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

for an srtm file. More...

#include <ossimSrtmHandler.h>

Inheritance diagram for ossimSrtmHandler:
ossimElevCellHandler ossimElevSource ossimSource ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Types

enum  { NULL_POST = -32768 }
 
- Public Types inherited from ossimConnectableObject
enum  ossimConnectableObjectDirectionType { CONNECTABLE_DIRECTION_NONE = 0, CONNECTABLE_DIRECTION_INPUT = 1, CONNECTABLE_DIRECTION_OUTPUT = 2 }
 
typedef std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
 

Public Member Functions

 ossimSrtmHandler ()
 Constructor that takes a file name. More...
 
 ossimSrtmHandler (const ossimSrtmHandler &)
 
virtual double getHeightAboveMSL (const ossimGpt &)
 METHOD: getHeightAboveMSL Height access methods. More...
 
virtual ossimIpt getSizeOfElevCell () const
 METHOD: getSizeOfElevCell Returns the number of post in the cell. More...
 
virtual double getPostValue (const ossimIpt &gridPt) const
 METHOD: getPostValue Returns the value at a given grid point as a double. More...
 
virtual bool isOpen () const
 
virtual bool open (const ossimFilename &file, bool memoryMapFlag=false)
 Opens a stream to the srtm cell. More...
 
virtual void close ()
 Closes the stream to the file. More...
 
virtual ossimObjectdup () const
 
- Public Member Functions inherited from ossimElevCellHandler
 ossimElevCellHandler (const char *elev_filename)
 Constructors: More...
 
 ossimElevCellHandler (const ossimElevCellHandler &src)
 
virtual const ossimFilenamegetFilename () const
 
virtual double getMeanSpacingMeters () const
 METHOD: meanSpacingMeters() Implements pure virtual for. More...
 
virtual bool pointHasCoverage (const ossimGpt &) const
 METHOD: pointIsInsideRect() Method to check if the ground point elevation is defined: More...
 
virtual bool getAccuracyInfo (ossimElevationAccuracyInfo &info, const ossimGpt &gpt) const
 
bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 METHODS: accuracyLE90(), accuracyCE90() Returns the vertical and horizontal accuracy (90% confidence): More...
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- Public Member Functions inherited from ossimElevSource
virtual double getHeightAboveEllipsoid (const ossimGpt &)
 
bool intersectRay (const ossimEcefRay &ray, ossimGpt &gpt, double defaultElevValue=0.0)
 METHOD: intersectRay() More...
 
virtual double getMinHeightAboveMSL () const
 Access methods for the bounding elevations: More...
 
virtual double getMaxHeightAboveMSL () const
 
double getNullHeightValue () const
 Special numeric quantities as defined by this source: More...
 
double getSeaLevelValue () const
 
virtual const ossimGrectgetBoundingGndRect () const
 METHODS: accuracyLE90(), accuracyCE90() Returns the vertical and horizontal accuracy (90% confidence) in the region of gpt: More...
 
virtual void initialize ()
 Implement ossimSource base-class pure virtuals: More...
 
virtual bool getComputeStatisticsFlag () const
 Opens a stream to an elevation cell. More...
 
virtual void setComputeStatisticsFlag (bool flag)
 Sets the flag which controls whether or not statistics will be computed upon opening a cell and not finding a corresponding statistics file. More...
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () 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 isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- 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 ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- 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
 

Protected Member Functions

virtual ~ossimSrtmHandler ()
 destructor More...
 
template<class T >
double getHeightAboveMSLFileTemplate (T dummy, const ossimGpt &gpt)
 
template<class T >
double getHeightAboveMSLMemoryTemplate (T dummy, const ossimGpt &gpt)
 
- Protected Member Functions inherited from ossimElevCellHandler
 ossimElevCellHandler ()
 
virtual ~ossimElevCellHandler ()
 
- Protected Member Functions inherited from ossimElevSource
virtual ~ossimElevSource ()
 
 ossimElevSource ()
 Constructors/Destructors: More...
 
 ossimElevSource (const ossimElevSource &src)
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Protected Attributes

ossimSrtmSupportData m_supportData
 
std::mutex m_fileStrMutex
 
std::ifstream m_fileStr
 
bool m_streamOpen
 true if stream is open. More...
 
ossim_int32 m_numberOfLines
 
ossim_int32 m_numberOfSamples
 
ossim_int32 m_srtmRecordSizeInBytes
 
double m_latSpacing
 
double m_lonSpacing
 
ossimDpt m_nwCornerPost
 
ossimEndianm_swapper
 
ossimScalarType m_scalarType
 
std::vector< ossim_int8m_memoryMap
 
- Protected Attributes inherited from ossimElevCellHandler
ossimFilename theFilename
 Virtual method for reading. More...
 
double theMeanSpacing
 
double theAbsLE90
 
double theAbsCE90
 
- Protected Attributes inherited from ossimElevSource
double theMinHeightAboveMSL
 Data members: More...
 
double theMaxHeightAboveMSL
 
double theNullHeightValue
 
double theSeaLevelValue
 
ossimGrect theGroundRect
 
bool theComputeStatsFlag
 
- Protected Attributes inherited from ossimSource
bool theEnableFlag
 
bool theInitializedFlag
 
- Protected Attributes inherited from ossimConnectableObject
ossimId theId
 
ossimString theDescription
 
ossimObjecttheOwner
 
bool theInputListIsFixedFlag
 Indicates whether the theInputObjectList is fixed. More...
 
bool theOutputListIsFixedFlag
 Indicates whether the theOutputObjectList is fixed. More...
 
ConnectableObjectList theInputObjectList
 Holds a list of input objects. More...
 
ConnectableObjectList theOutputObjectList
 Holds a list of output objects. More...
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Detailed Description

for an srtm file.

Definition at line 29 of file ossimSrtmHandler.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NULL_POST 

Definition at line 38 of file ossimSrtmHandler.h.

39  {
40  NULL_POST = -32768 // Fixed by SRTM specification.
41  };

Constructor & Destructor Documentation

◆ ossimSrtmHandler() [1/2]

ossimSrtmHandler::ossimSrtmHandler ( )

Constructor that takes a file name.

Definition at line 30 of file ossimSrtmHandler.cpp.

31  :
33  m_streamOpen(false),
34  m_numberOfLines(0),
37  m_latSpacing(0.0),
38  m_lonSpacing(0.0),
40  m_swapper(0)
41 {
42 }
ossim_int32 m_numberOfLines
bool m_streamOpen
true if stream is open.
ossim_int32 m_srtmRecordSizeInBytes
ossim_int32 m_numberOfSamples
ossimEndian * m_swapper

◆ ossimSrtmHandler() [2/2]

ossimSrtmHandler::ossimSrtmHandler ( const ossimSrtmHandler src)

Definition at line 384 of file ossimSrtmHandler.cpp.

References ossimString::c_str(), ossimElevCellHandler::getFilename(), isOpen(), m_fileStr, and m_memoryMap.

394 m_swapper(src.m_swapper?new ossimEndian:0),
397 {
398  if(m_memoryMap.empty()&&src.isOpen())
399  {
400  m_fileStr.open(src.getFilename().c_str(),
401  std::ios::binary|std::ios::in);
402  }
403 }
ossimSrtmSupportData m_supportData
ossim_int32 m_numberOfLines
std::vector< ossim_int8 > m_memoryMap
virtual const ossimFilename & getFilename() const
ossimScalarType m_scalarType
bool m_streamOpen
true if stream is open.
ossim_int32 m_srtmRecordSizeInBytes
ossim_int32 m_numberOfSamples
std::ifstream m_fileStr
ossimEndian * m_swapper
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
virtual bool isOpen() const

◆ ~ossimSrtmHandler()

ossimSrtmHandler::~ossimSrtmHandler ( )
protectedvirtual

destructor

Definition at line 44 of file ossimSrtmHandler.cpp.

References close(), and m_swapper.

45 {
46  if (m_swapper)
47  {
48  delete m_swapper;
49  m_swapper = 0;
50  }
51  close();
52 }
virtual void close()
Closes the stream to the file.
ossimEndian * m_swapper

Member Function Documentation

◆ close()

void ossimSrtmHandler::close ( )
virtual

Closes the stream to the file.

Reimplemented from ossimElevCellHandler.

Definition at line 492 of file ossimSrtmHandler.cpp.

References m_fileStr, m_memoryMap, and m_streamOpen.

Referenced by ~ossimSrtmHandler().

493 {
494  m_fileStr.close();
495  m_memoryMap.clear();
496  m_streamOpen = false;
497 }
std::vector< ossim_int8 > m_memoryMap
bool m_streamOpen
true if stream is open.
std::ifstream m_fileStr

◆ dup()

virtual ossimObject* ossimSrtmHandler::dup ( ) const
inlinevirtual

Implements ossimElevSource.

Definition at line 77 of file ossimSrtmHandler.h.

References open().

78  {
80  obj->open(theFilename, (m_memoryMap.size() != 0));
81  return obj;
82  }
std::vector< ossim_int8 > m_memoryMap
virtual bool open(const ossimFilename &file, bool memoryMapFlag=false)
Opens a stream to the srtm cell.
ossimSrtmHandler()
Constructor that takes a file name.
ossimFilename theFilename
Virtual method for reading.
for an srtm file.

◆ getHeightAboveMSL()

double ossimSrtmHandler::getHeightAboveMSL ( const ossimGpt gpt)
virtual

METHOD: getHeightAboveMSL Height access methods.

Implements ossimElevSource.

Definition at line 54 of file ossimSrtmHandler.cpp.

References getHeightAboveMSLFileTemplate(), getHeightAboveMSLMemoryTemplate(), isOpen(), m_memoryMap, m_scalarType, ossim::nan(), OSSIM_FLOAT32, and OSSIM_SINT16.

55 {
56  if(!isOpen()) return ossim::nan();
57  if(!m_memoryMap.empty())
58  {
59  switch(m_scalarType)
60  {
61  case OSSIM_SINT16:
62  {
64  }
65  case OSSIM_FLOAT32:
66  {
68  }
69  default:
70  {
71  break;
72  }
73  }
74  }
75  else
76  {
77  switch(m_scalarType)
78  {
79  case OSSIM_SINT16:
80  {
82  }
83  case OSSIM_FLOAT32:
84  {
86  }
87  default:
88  {
89  break;
90  }
91  }
92  }
93 
94  return ossim::nan();
95 }
double getHeightAboveMSLFileTemplate(T dummy, const ossimGpt &gpt)
std::vector< ossim_int8 > m_memoryMap
double getHeightAboveMSLMemoryTemplate(T dummy, const ossimGpt &gpt)
float ossim_float32
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
ossimScalarType m_scalarType
16 bit signed integer
32 bit floating point
signed short ossim_sint16
virtual bool isOpen() const

◆ getHeightAboveMSLFileTemplate()

template<class T >
double ossimSrtmHandler::getHeightAboveMSLFileTemplate ( dummy,
const ossimGpt gpt 
)
protected

Definition at line 98 of file ossimSrtmHandler.cpp.

References ossimDpt::lat, ossimGpt::lat, ossimDpt::lon, ossimGpt::lon, m_fileStr, m_fileStrMutex, m_latSpacing, m_lonSpacing, m_numberOfLines, m_numberOfSamples, m_nwCornerPost, m_srtmRecordSizeInBytes, m_swapper, ossim::nan(), ossimEndian::swap(), and ossimElevSource::theNullHeightValue.

Referenced by getHeightAboveMSL().

99 {
100  // Establish the grid indexes:
101  double xi = (gpt.lon - m_nwCornerPost.lon) / m_lonSpacing;
102  double yi = (m_nwCornerPost.lat - gpt.lat) / m_latSpacing;
103 
104  int x0 = static_cast<int>(xi);
105  int y0 = static_cast<int>(yi);
106 
107  if(x0 == (m_numberOfSamples-1))
108  {
109  --x0; // Move over one post.
110  }
111 
112  // Check for top edge.
113  // if (gpt.lat == theGroundRect.ul().lat)
114  if(y0 == (m_numberOfLines-1))
115  {
116  --y0; // Move down one post.
117  }
118 
119 
120  // Do some error checking.
121  if ( xi < 0.0 || yi < 0.0 ||
122  x0 > (m_numberOfSamples - 2.0) ||
123  y0 > (m_numberOfLines - 2.0) )
124  {
125  return ossim::nan();
126  }
127 
128  T p[4];
129 
130  double p00;
131  double p01;
132  double p10;
133  double p11;
134 
135  //---
136  // Grab the four points from the srtm cell needed.
137  //---
138  std::streampos offset = y0 * m_srtmRecordSizeInBytes + x0 * sizeof(T);
139 
140  {
141  std::lock_guard<std::mutex> lock(m_fileStrMutex);
142 
143  // lets a seek cur
144  //
145  // Put the file pointer at the start of the first elevation post.
146  m_fileStr.seekg(offset, std::ios::beg);
147  // Get the first post.
148  m_fileStr.read((char*)p, sizeof(T));
149 
150  // Get the second post.
151  m_fileStr.read((char*)(p+1), sizeof(T));
152 
153  // Move over to the next column.
154  offset += m_srtmRecordSizeInBytes;
155 
156  m_fileStr.seekg(offset, std::ios::beg);
157 
158  // Get the third post.
159  m_fileStr.read((char*)(p+2), sizeof(T));
160 
161  // Get the fourth post.
162  m_fileStr.read((char*)(p+3), sizeof(T));
163 
164  if(m_fileStr.fail())
165  {
166  return ossim::nan();
167  }
168  }
169  if (m_swapper)
170  {
171  m_swapper->swap((T*)p, 4);
172  }
173 
174  p00 = p[0];
175  p01 = p[1];
176  p10 = p[2];
177  p11 = p[3];
178 
179  // Perform bilinear interpolation:
180 
181  double xt0 = xi - x0;
182  double yt0 = yi - y0;
183  double xt1 = 1-xt0;
184  double yt1 = 1-yt0;
185 
186  double w00 = xt1*yt1;
187  double w01 = xt0*yt1;
188  double w10 = xt1*yt0;
189  double w11 = xt0*yt0;
190 
191  //***
192  // Test for null posts and set the corresponding weights to 0:
193  //***
194  if (p00 == theNullHeightValue)
195  w00 = 0.0;
196  if (p01 == theNullHeightValue)
197  w01 = 0.0;
198  if (p10 == theNullHeightValue)
199  w10 = 0.0;
200  if (p11 == theNullHeightValue)
201  w11 = 0.0;
202 
203 #if 0 /* Serious debug only... */
204  cout << "\np00: " << p00
205  << "\np01: " << p01
206  << "\np10: " << p10
207  << "\np11: " << p11
208  << "\nw00: " << w00
209  << "\nw01: " << w01
210  << "\nw10: " << w10
211  << "\nw11: " << w11
212  << endl;
213 #endif
214 
215  double sum_weights = w00 + w01 + w10 + w11;
216 
217  if (sum_weights)
218  {
219  return (p00*w00 + p01*w01 + p10*w10 + p11*w11) / sum_weights;
220  }
221 
222  return ossim::nan();
223 }
ossim_int32 m_numberOfLines
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double lat
Definition: ossimDpt.h:165
ossim_float64 lon
Definition: ossimGpt.h:266
ossim_int32 m_srtmRecordSizeInBytes
std::mutex m_fileStrMutex
double lon
Definition: ossimDpt.h:164
ossim_int32 m_numberOfSamples
std::ifstream m_fileStr
ossimEndian * m_swapper
ossim_float64 lat
Definition: ossimGpt.h:265
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26

◆ getHeightAboveMSLMemoryTemplate()

template<class T >
double ossimSrtmHandler::getHeightAboveMSLMemoryTemplate ( dummy,
const ossimGpt gpt 
)
protected

Definition at line 227 of file ossimSrtmHandler.cpp.

References ossim::almostEqual(), ossimDpt::lat, ossimGpt::lat, ossimDpt::lon, ossimGpt::lon, ossimGrect::lr(), m_latSpacing, m_lonSpacing, m_memoryMap, m_numberOfLines, m_numberOfSamples, m_nwCornerPost, m_srtmRecordSizeInBytes, m_swapper, ossim::nan(), ossimEndian::swap(), ossimElevSource::theGroundRect, and ossimElevSource::theNullHeightValue.

Referenced by getHeightAboveMSL().

229 {
230  // Establish the grid indexes:
231  double xi = (gpt.lon - m_nwCornerPost.lon) / m_lonSpacing;
232  double yi = (m_nwCornerPost.lat - gpt.lat) / m_latSpacing;
233 
234  int x0 = static_cast<int>(xi);
235  int y0 = static_cast<int>(yi);
236 
237  if(x0 == (m_numberOfSamples-1))
238  {
239  --x0; // Move over one post.
240  }
241 
242  // Check for top edge.
243  // if (gpt.lat == theGroundRect.ul().lat)
244  if(y0 == (m_numberOfLines-1))
245  {
246  --y0; // Move down one post.
247  }
248 #if 0
249  // Check for right edge.
251  {
252  --x0; // Move over one post to the left.
253  }
254 
255  // Check for bottom edge.
257  {
258  --y0; // Move up one post.
259  }
260 #endif
261  // Do some error checking.
262  if ( xi < 0.0 || yi < 0.0 ||
263  x0 > (m_numberOfSamples - 2.0) ||
264  y0 > (m_numberOfLines - 2.0) )
265  {
266  // std::cout << "ossimSrtmHandler::getHeightAboveMSLTemplate: leaving 1" << std::endl;
267  return ossim::nan();
268  }
269 
270  // Grab the four points from the srtm cell needed.
271  ossim_uint64 offset = y0 * m_srtmRecordSizeInBytes + x0 * sizeof(T);
272  ossim_uint64 offset2 =offset+m_srtmRecordSizeInBytes;
273  T v00 = *(reinterpret_cast<T*> (&m_memoryMap[offset]));
274  T v01 = *(reinterpret_cast<T*> (&m_memoryMap[offset + sizeof(T)]));
275  T v10 = *(reinterpret_cast<T*> (&m_memoryMap[offset2]));
276  T v11 = *(reinterpret_cast<T*> (&m_memoryMap[offset2 + sizeof(T)]));
277  if (m_swapper)
278  {
279  m_swapper->swap(v00);
280  m_swapper->swap(v01);
281  m_swapper->swap(v10);
282  m_swapper->swap(v11);
283  }
284  double p00 = v00;
285  double p01 = v01;
286  double p10 = v10;
287  double p11 = v11;
288 
289  double xt0 = xi - x0;
290  double yt0 = yi - y0;
291  double xt1 = 1-xt0;
292  double yt1 = 1-yt0;
293 
294  double w00 = xt1*yt1;
295  double w01 = xt0*yt1;
296  double w10 = xt1*yt0;
297  double w11 = xt0*yt0;
298 
299  //***
300  // Test for null posts and set the corresponding weights to 0:
301  //***
302  if (p00 == theNullHeightValue)
303  w00 = 0.0;
304  if (p01 == theNullHeightValue)
305  w01 = 0.0;
306  if (p10 == theNullHeightValue)
307  w10 = 0.0;
308  if (p11 == theNullHeightValue)
309  w11 = 0.0;
310 
311 #if 0 /* Serious debug only... */
312  cout << "\np00: " << p00
313  << "\np01: " << p01
314  << "\np10: " << p10
315  << "\np11: " << p11
316  << "\nw00: " << w00
317  << "\nw01: " << w01
318  << "\nw10: " << w10
319  << "\nw11: " << w11
320  << endl;
321 #endif
322 
323  double sum_weights = w00 + w01 + w10 + w11;
324 
325  if (sum_weights)
326  {
327  return (p00*w00 + p01*w01 + p10*w10 + p11*w11) / sum_weights;
328  }
329 
330  return ossim::nan();
331 }
ossim_int32 m_numberOfLines
std::vector< ossim_int8 > m_memoryMap
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
Definition: ossimCommon.h:53
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
ossimGrect theGroundRect
double lat
Definition: ossimDpt.h:165
ossim_float64 lon
Definition: ossimGpt.h:266
ossim_int32 m_srtmRecordSizeInBytes
unsigned long long ossim_uint64
double lon
Definition: ossimDpt.h:164
ossim_int32 m_numberOfSamples
ossimEndian * m_swapper
ossim_float64 lat
Definition: ossimGpt.h:265
const ossimGpt & lr() const
Definition: ossimGrect.h:269
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26

◆ getPostValue()

double ossimSrtmHandler::getPostValue ( const ossimIpt gridPt) const
virtual

METHOD: getPostValue Returns the value at a given grid point as a double.

Satisfies pure virtual.

Implements ossimElevCellHandler.

Definition at line 333 of file ossimSrtmHandler.cpp.

References ossim::nan(), ossimNotify(), ossimNotifyLevel_WARN, and ossimElevSource::theNullHeightValue.

334 {
336  << "ossimSrtmHandler::getPostValue(const ossimIpt& gridPt): NEED TO IMPLEMENT TO NEW INTERFACE\n";
337 
338  return theNullHeightValue;
339 #if 0
340  static const char MODULE[] = "ossimSrtmHandler::getPostValue";
341 
342  if(!theFileStr.valid()) return ossim::nan();
343 
344  // Do some error checking.
345  if ( gridPt.x < 0.0 || gridPt.y < 0.0 ||
346  gridPt.x > (theNumberOfSamples - 1) ||
347  gridPt.y > (theNumberOfLines - 1) )
348  {
349  if(traceDebug())
350  {
352  << "WARNING " << MODULE << ": No intersection..." << std::endl;
353  }
354  return ossim::nan();
355  }
356 
357  if (!isOpen())
358  {
359  return ossim::nan();
360  }
361 
362  std::streampos offset = gridPt.y * theSrtmRecordSizeInBytes + gridPt.x * 2;
363 
364  // Put the file pointer at the start of the first elevation post.
365  m_fileStr.seekg(offset, std::ios::beg);
366 
367  ossim_sint16 p;
368 
369  // Get the post.
370  m_fileStr.read((char*)&p, 2);
371  if (theSwapper)
372  {
373  theSwapper->swap(p);
374  }
375  return p;
376 #endif
377 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
signed short ossim_sint16
ossim_int32 y
Definition: ossimIpt.h:142
std::ifstream m_fileStr
ossim_int32 x
Definition: ossimIpt.h:141
virtual bool isOpen() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getSizeOfElevCell()

ossimIpt ossimSrtmHandler::getSizeOfElevCell ( ) const
virtual

METHOD: getSizeOfElevCell Returns the number of post in the cell.

Satisfies pure virtual. Note: x = longitude, y = latitude

Implements ossimElevCellHandler.

Definition at line 379 of file ossimSrtmHandler.cpp.

References m_numberOfLines, and m_numberOfSamples.

380 {
382 }
ossim_int32 m_numberOfLines
ossim_int32 m_numberOfSamples

◆ isOpen()

bool ossimSrtmHandler::isOpen ( ) const
virtual

Definition at line 405 of file ossimSrtmHandler.cpp.

References m_fileStrMutex, m_memoryMap, and m_streamOpen.

Referenced by getHeightAboveMSL(), and ossimSrtmHandler().

406 {
407  if(!m_memoryMap.empty()) return true;
408 
409  std::lock_guard<std::mutex> lock(m_fileStrMutex);
410  return m_streamOpen;
411  // return (m_fileStr.is_open());
412 }
std::vector< ossim_int8 > m_memoryMap
bool m_streamOpen
true if stream is open.
std::mutex m_fileStrMutex

◆ open()

bool ossimSrtmHandler::open ( const ossimFilename file,
bool  memoryMapFlag = false 
)
virtual

Opens a stream to the srtm cell.

Returns
Returns true on success, false on error.

Reimplemented from ossimElevCellHandler.

Definition at line 415 of file ossimSrtmHandler.cpp.

References ossim::byteOrder(), ossimString::c_str(), ossimErrorStatusInterface::clearErrorStatus(), ossimFilename::fileSize(), ossimSrtmSupportData::getLatitudeSpacing(), ossimSrtmSupportData::getLongitudeSpacing(), ossimSrtmSupportData::getNumberOfLines(), ossimSrtmSupportData::getNumberOfSamples(), ossimSrtmSupportData::getScalarType(), ossimSrtmSupportData::getSouthwestLatitude(), ossimSrtmSupportData::getSouthwestLongitude(), ossimDpt::lat, ossimDpt::lon, m_fileStr, m_latSpacing, m_lonSpacing, m_memoryMap, m_numberOfLines, m_numberOfSamples, m_nwCornerPost, m_scalarType, m_srtmRecordSizeInBytes, m_streamOpen, m_supportData, m_swapper, ossimGpt::metersPerDegree(), ossimErrorCodes::OSSIM_ERROR, OSSIM_LITTLE_ENDIAN, ossim::scalarSizeInBytes(), ossimSrtmSupportData::setFilename(), ossimErrorStatusInterface::theErrorStatus, ossimElevCellHandler::theFilename, ossimElevSource::theGroundRect, ossimElevCellHandler::theMeanSpacing, ossimElevSource::theNullHeightValue, and ossimDpt::y.

Referenced by ossimSrtmElevationDatabase::createCell(), and dup().

416 {
417  theFilename = file;
419  if (!m_supportData.setFilename(file, false) )
420  {
422  return false;
423  }
424  if(m_swapper) {delete m_swapper;m_swapper=0;}
426  // SRTM is stored in big endian.
428  {
429  m_swapper = new ossimEndian();
430  }
431  m_streamOpen = false;
442  0.0),
444  m_nwCornerPost.lon+1.0,
445  0.0));
447 
448  // Set the base class null height value.
449  theNullHeightValue = -32768.0;
450 
451  m_fileStr.clear();
452  m_fileStr.open(theFilename.c_str(), std::ios::in | std::ios::binary);
453  if(!m_fileStr)
454  {
455  return false;
456  }
457 
458  if(memoryMapFlag)
459  {
460  m_memoryMap.resize(theFilename.fileSize());
461  m_fileStr.read((char*)&m_memoryMap.front(), (streamsize)m_memoryMap.size());
462  m_fileStr.close();
463  }
464  m_streamOpen = true;
465  // Capture the stream state for non-const is_open on old compiler.
466 
467  return m_streamOpen;
468 #if 0
469  // theMinHeightAboveMSL;
470  // theMaxHeightAboveMSL;
471  if(theFileStr.valid())
472  {
473  if(!m_fileStr.fail())
474  {
475  return true;
476  }
477  }
478  theFileStr = 0;
479 
480 
481  theFileStr = ossimStreamFactoryRegistry::instance()->createNewIFStream(theFilename,
482  std::ios::in | std::ios::binary);
483 
484  if(theFileStr.valid())
485  {
486  return (!m_fileStr.fail());
487  }
488  return false;
489 #endif
490 }
ossimSrtmSupportData m_supportData
ossim_int32 m_numberOfLines
std::vector< ossim_int8 > m_memoryMap
ossim_float64 getSouthwestLatitude() const
ossim_float64 getSouthwestLongitude() const
ossim_int64 fileSize() const
double y
Definition: ossimDpt.h:165
ossimScalarType m_scalarType
ossim_uint32 getNumberOfSamples() const
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
static const ossimErrorCode OSSIM_ERROR
bool m_streamOpen
true if stream is open.
ossimGrect theGroundRect
double lat
Definition: ossimDpt.h:165
ossim_int32 m_srtmRecordSizeInBytes
ossimFilename theFilename
Virtual method for reading.
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
double lon
Definition: ossimDpt.h:164
ossim_int32 m_numberOfSamples
ossim_uint32 getNumberOfLines() const
ossim_float64 getLatitudeSpacing() const
std::ifstream m_fileStr
ossimEndian * m_swapper
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
ossimScalarType getScalarType() const
ossimDpt metersPerDegree() const
Definition: ossimGpt.cpp:498
ossim_float64 getLongitudeSpacing() const
bool setFilename(const ossimFilename &srtmFile, bool scanForMinMax=false)
Initializes object from file.

Member Data Documentation

◆ m_fileStr

std::ifstream ossimSrtmHandler::m_fileStr
protected

Definition at line 89 of file ossimSrtmHandler.h.

Referenced by close(), getHeightAboveMSLFileTemplate(), open(), and ossimSrtmHandler().

◆ m_fileStrMutex

std::mutex ossimSrtmHandler::m_fileStrMutex
mutableprotected

Definition at line 88 of file ossimSrtmHandler.h.

Referenced by getHeightAboveMSLFileTemplate(), and isOpen().

◆ m_latSpacing

double ossimSrtmHandler::m_latSpacing
protected

◆ m_lonSpacing

double ossimSrtmHandler::m_lonSpacing
protected

◆ m_memoryMap

std::vector<ossim_int8> ossimSrtmHandler::m_memoryMap
mutableprotected

◆ m_numberOfLines

ossim_int32 ossimSrtmHandler::m_numberOfLines
protected

◆ m_numberOfSamples

ossim_int32 ossimSrtmHandler::m_numberOfSamples
protected

◆ m_nwCornerPost

ossimDpt ossimSrtmHandler::m_nwCornerPost
protected

◆ m_scalarType

ossimScalarType ossimSrtmHandler::m_scalarType
protected

Definition at line 101 of file ossimSrtmHandler.h.

Referenced by getHeightAboveMSL(), and open().

◆ m_srtmRecordSizeInBytes

ossim_int32 ossimSrtmHandler::m_srtmRecordSizeInBytes
protected

◆ m_streamOpen

bool ossimSrtmHandler::m_streamOpen
protected

true if stream is open.

Definition at line 92 of file ossimSrtmHandler.h.

Referenced by close(), isOpen(), and open().

◆ m_supportData

ossimSrtmSupportData ossimSrtmHandler::m_supportData
protected

Definition at line 87 of file ossimSrtmHandler.h.

Referenced by open().

◆ m_swapper

ossimEndian* ossimSrtmHandler::m_swapper
protected

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