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

Elevation source for a generic image opened via ossimImageHandler. More...

#include <ossimImageElevationHandler.h>

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

Classes

class  TileCacheEntry
 

Public Member Functions

 ossimImageElevationHandler ()
 default constructor More...
 
 ossimImageElevationHandler (const ossimFilename &file)
 
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)
 Opens a stream to the srtm cell. More...
 
virtual void close ()
 Closes the stream to the file. More...
 
virtual bool pointHasCoverage (const ossimGpt &) const
 pointHasCoverage(gpt) 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 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 bool open (const ossimFilename &, bool=false)
 
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 ~ossimImageElevationHandler ()
 Protected destructor. More...
 
- 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)
 

Private Member Functions

 ossimImageElevationHandler (const ossimImageElevationHandler &)
 Hidden from use copy constructor. More...
 
const ossimImageElevationHandleroperator= (const ossimImageElevationHandler &rhs)
 Hidden from use assignment operator. More...
 
ossimImageDatagetTile (ossim_uint32 x, ossim_uint32 y) const
 Looks for an elevation tile in the cache first before reading the tile from the input handler. More...
 

Private Attributes

ossimRefPtr< ossimImageHandlerm_ih
 Pointers to links in chain. More...
 
ossimRefPtr< ossimImageGeometrym_geom
 
std::vector< TileCacheEntrym_tileCache
 
ossimDrect m_rect
 Image space rect stored as drect for inlined pointHasCoverage method. More...
 
ossimIpt m_tileSize
 
ossim_uint32 m_numTilesPerRow
 
std::mutex m_mutex
 

Additional Inherited Members

- 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
 
- 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

Elevation source for a generic image opened via ossimImageHandler.

Definition at line 32 of file ossimImageElevationHandler.h.

Constructor & Destructor Documentation

◆ ossimImageElevationHandler() [1/3]

ossimImageElevationHandler::ossimImageElevationHandler ( )

default constructor

Definition at line 36 of file ossimImageElevationHandler.cpp.

References ossim::defaultTileSize(), and m_tileSize.

37  :
39  m_rect(),
40  m_tileSize(256,256),
42  m_mutex()
43 {
45 }
ossimDrect m_rect
Image space rect stored as drect for inlined pointHasCoverage method.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)

◆ ossimImageElevationHandler() [2/3]

ossimImageElevationHandler::ossimImageElevationHandler ( const ossimFilename file)

Definition at line 47 of file ossimImageElevationHandler.cpp.

References ossim::defaultTileSize(), m_tileSize, and open().

48  :
50  m_rect(),
51  m_tileSize(256,256),
53  m_mutex()
54 {
56  open(file);
57 }
ossimDrect m_rect
Image space rect stored as drect for inlined pointHasCoverage method.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
virtual bool open(const ossimFilename &file)
Opens a stream to the srtm cell.

◆ ~ossimImageElevationHandler()

ossimImageElevationHandler::~ossimImageElevationHandler ( )
protectedvirtual

Protected destructor.

This class is derived from ossimReferenced so users should always use ossimRefPtr<ossimImageElevationHandler> to hold instance.

Definition at line 131 of file ossimImageElevationHandler.cpp.

References close().

132 {
133  close();
134 }
virtual void close()
Closes the stream to the file.

◆ ossimImageElevationHandler() [3/3]

ossimImageElevationHandler::ossimImageElevationHandler ( const ossimImageElevationHandler copy)
private

Hidden from use copy constructor.

Definition at line 282 of file ossimImageElevationHandler.cpp.

283 {
284  *this = copy;
285 }

Member Function Documentation

◆ close()

void ossimImageElevationHandler::close ( )
inlinevirtual

Closes the stream to the file.

Reimplemented from ossimElevCellHandler.

Definition at line 137 of file ossimImageElevationHandler.h.

References m_geom, and m_ih.

Referenced by open(), and ~ossimImageElevationHandler().

138 {
139  m_geom = 0;
140  m_ih = 0;
141 }
ossimRefPtr< ossimImageGeometry > m_geom
ossimRefPtr< ossimImageHandler > m_ih
Pointers to links in chain.

◆ dup()

virtual ossimObject* ossimImageElevationHandler::dup ( ) const
inlinevirtual

Implements ossimElevSource.

Definition at line 81 of file ossimImageElevationHandler.h.

References ossimElevCellHandler::getFilename().

81 { return new ossimImageElevationHandler(this->getFilename()); }
virtual const ossimFilename & getFilename() const
ossimImageElevationHandler()
default constructor

◆ getHeightAboveMSL()

double ossimImageElevationHandler::getHeightAboveMSL ( const ossimGpt gpt)
virtual

METHOD: getHeightAboveMSL Height access methods.

Implements ossimElevSource.

Definition at line 136 of file ossimImageElevationHandler.cpp.

References ossimImageData::getImageRectangle(), ossimImageData::getNullPix(), ossimImageData::getPix(), getTile(), ossimIrect::lr(), m_geom, m_rect, ossim::nan(), ossimDrect::pointWithin(), ossimImageGeometry::worldToLocal(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

137 {
138  double height = ossim::nan();
139 
140  // Get the image point for the world point.
141  ossimDpt dpt;
142  m_geom->worldToLocal(gpt, dpt);
143 
144  if ( !m_rect.pointWithin(dpt) )
145  return height;
146 
147  // Cast it to an int which will shift to nearest upper left post.
148  ossim_uint32 x0 = static_cast<ossim_uint32>(dpt.x);
149  ossim_uint32 y0 = static_cast<ossim_uint32>(dpt.y);
150 
151  ossimRefPtr<ossimImageData> data = getTile(x0, y0);
152 
153  // Check if we are at the bottom or right edge of the tile to move in one post:
154  ossimIpt data_lr = data->getImageRectangle().lr();
155  if (x0 == static_cast<ossim_uint32>(data_lr.x))
156  --x0;
157  if (y0 == static_cast<ossim_uint32>(data_lr.y))
158  --y0;
159 
160  double p00 = data->getPix( ossimIpt(x0, y0) );
161  double p01 = data->getPix( ossimIpt(x0+1, y0) );
162  double p10 = data->getPix( ossimIpt(x0, y0+1) );
163  double p11 = data->getPix( ossimIpt(x0+1, y0+1) );
164 
165  double xt0 = dpt.x - x0;
166  double yt0 = dpt.y - y0;
167  double xt1 = 1-xt0;
168  double yt1 = 1-yt0;
169 
170  double w00 = xt1*yt1;
171  double w01 = xt0*yt1;
172  double w10 = xt1*yt0;
173  double w11 = xt0*yt0;
174 
175  // Test for null posts and set the corresponding weights to 0:
176  const double NP = data->getNullPix(0);
177 
178  if (p00 == NP)
179  w00 = 0.0;
180  if (p01 == NP)
181  w01 = 0.0;
182  if (p10 == NP)
183  w10 = 0.0;
184  if (p11 == NP)
185  w11 = 0.0;
186 
187 #if 0 /* Serious debug only... */
188  cout << "\np00: " << p00
189  << "\np01: " << p01
190  << "\np10: " << p10
191  << "\np11: " << p11
192  << "\nw00: " << w00
193  << "\nw01: " << w01
194  << "\nw10: " << w10
195  << "\nw11: " << w11
196  << endl;
197 #endif
198 
199  double sum_weights = w00 + w01 + w10 + w11;
200  if (sum_weights)
201  height = (p00*w00 + p01*w01 + p10*w10 + p11*w11) / sum_weights;
202 
203  return height;
204 }
ossimRefPtr< ossimImageGeometry > m_geom
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
ossimDrect m_rect
Image space rect stored as drect for inlined pointHasCoverage method.
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double y
Definition: ossimDpt.h:165
virtual ossim_float64 getPix(const ossimIpt &position, ossim_uint32 band=0) const
Will return the pixel at location position.
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual ossimIrect getImageRectangle() const
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossim_int32 y
Definition: ossimIpt.h:142
double x
Definition: ossimDpt.h:164
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.
ossim_int32 x
Definition: ossimIpt.h:141
ossimImageData * getTile(ossim_uint32 x, ossim_uint32 y) const
Looks for an elevation tile in the cache first before reading the tile from the input handler...

◆ getPostValue()

double ossimImageElevationHandler::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 266 of file ossimImageElevationHandler.cpp.

References ossimImageData::getNullPix(), ossimImageData::getPix(), getTile(), m_rect, ossim::nan(), ossimDrect::pointWithin(), ossimRefPtr< T >::valid(), ossimIpt::x, and ossimIpt::y.

267 {
268  double height = ossim::nan();
269  if ( m_rect.pointWithin(ossimDpt(gridPt)) )
270  {
271  ossimRefPtr<ossimImageData> data = getTile(gridPt.x, gridPt.y);
272  if ( data.valid() )
273  {
274  height = data->getPix(0, 0);
275  if (height == data->getNullPix(0))
276  height = ossim::nan();
277  }
278  }
279  return height;
280 }
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
ossimDrect m_rect
Image space rect stored as drect for inlined pointHasCoverage method.
bool valid() const
Definition: ossimRefPtr.h:75
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
virtual ossim_float64 getPix(const ossimIpt &position, ossim_uint32 band=0) const
Will return the pixel at location position.
virtual const ossim_float64 * getNullPix() const
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
ossimImageData * getTile(ossim_uint32 x, ossim_uint32 y) const
Looks for an elevation tile in the cache first before reading the tile from the input handler...

◆ getSizeOfElevCell()

ossimIpt ossimImageElevationHandler::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 255 of file ossimImageElevationHandler.cpp.

References ossimImageHandler::getNumberOfLines(), ossimImageHandler::getNumberOfSamples(), m_ih, ossimRefPtr< T >::valid(), ossimIpt::x, and ossimIpt::y.

256 {
257  ossimIpt sz(0,0);
258  if ( m_ih.valid() )
259  {
260  sz.x = static_cast<ossim_int32>(m_ih->getNumberOfSamples(0));
261  sz.y = static_cast<ossim_int32>(m_ih->getNumberOfLines(0));
262  }
263  return sz;
264 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
ossimRefPtr< ossimImageHandler > m_ih
Pointers to links in chain.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
int ossim_int32

◆ getTile()

ossimImageData * ossimImageElevationHandler::getTile ( ossim_uint32  x,
ossim_uint32  y 
) const
private

Looks for an elevation tile in the cache first before reading the tile from the input handler.

Definition at line 206 of file ossimImageElevationHandler.cpp.

References ossimImageData::assign(), ossimImageData::dup(), ossimRefPtr< T >::get(), ossimImageSource::getTile(), m_ih, m_mutex, m_numTilesPerRow, m_tileCache, m_tileSize, ossimRefPtr< T >::valid(), ossimIpt::x, x, ossimIpt::y, and y.

Referenced by getHeightAboveMSL(), and getPostValue().

207 {
208  // Establish the tile ID that this post belongs to:
211  ossim_uint32 tile_id = v*m_numTilesPerRow + u;
212 
214 
215  // Search for this tile in the cache:
216  std::lock_guard<std::mutex> lock(m_mutex);
217  vector<TileCacheEntry>::iterator iter = m_tileCache.begin();
218  while ((iter != m_tileCache.end()) && (iter->id != tile_id))
219  ++iter;
220 
221  if (iter != m_tileCache.end())
222  {
223  // Found an entry in the cache:
224  data = iter->data;
225  if (iter != m_tileCache.begin())
226  {
227  // Need to move the entry to the top of the list (current most popular)
228  TileCacheEntry temp = *iter;
229  m_tileCache.erase(iter);
230  m_tileCache.insert(m_tileCache.begin(), temp);
231  }
232  }
233  else
234  {
235  // Didn't find the tile in the cache, read it from the handler and insert into the cache:
236  ossimIpt ul (u*m_tileSize.x, v*m_tileSize.y);
237  ossimIpt lr (ul.x + m_tileSize.x - 1, ul.y + m_tileSize.y - 1);
238  ossimIrect tileRect (ul, lr);
239  ossimRefPtr<ossimImageData> inData = m_ih->getTile(tileRect, 0 );
240  if (inData.valid())
241  {
242  // Always insert at beginning. Need to check for overflow:
243  data = (ossimImageData*) inData->dup();
244  data->assign(inData.get());
245  TileCacheEntry entry (tile_id, data.get());
246  if (m_tileCache.size() == MAX_TILE_CACHE_SIZE)
247  m_tileCache.pop_back();
248  m_tileCache.insert(m_tileCache.begin(), entry);
249  }
250  }
251 
252  return data.get();
253 }
ossim_uint32 x
ossim_uint32 y
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimObject * dup() const
virtual void assign(const ossimDataObject *data)
unsigned int ossim_uint32
ossimRefPtr< ossimImageHandler > m_ih
Pointers to links in chain.
std::vector< TileCacheEntry > m_tileCache
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)

◆ isOpen()

bool ossimImageElevationHandler::isOpen ( ) const
inlinevirtual
Returns
True if open, false if not.

Definition at line 132 of file ossimImageElevationHandler.h.

References m_ih, and ossimRefPtr< T >::valid().

Referenced by ossimImageElevationDatabase::createCell(), and open().

133 {
134  return m_ih.valid();
135 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageHandler > m_ih
Pointers to links in chain.

◆ open()

bool ossimImageElevationHandler::open ( const ossimFilename file)
virtual

Opens a stream to the srtm cell.

Returns
Returns true on success, false on error.

Definition at line 59 of file ossimImageElevationHandler.cpp.

References close(), ossimImageGeometry::getCornerGpts(), ossimImageHandler::getImageGeometry(), ossimImageGeometry::getMetersPerPixel(), ossimImageHandler::getNumberOfLines(), ossimImageHandler::getNumberOfSamples(), ossimImageHandlerRegistry::instance(), isOpen(), ossimGpt::lat, ossimGpt::lon, m_geom, m_ih, m_numTilesPerRow, m_rect, m_tileSize, ossimGrect::makeNan(), ossimImageHandlerRegistry::open(), ossimString::size(), ossimElevCellHandler::theFilename, ossimElevSource::theGroundRect, ossimElevCellHandler::theMeanSpacing, ossimRefPtr< T >::valid(), ossimDrect::width(), ossimIpt::x, ossimDpt::x, and ossimDpt::y.

Referenced by ossimImageElevationDatabase::createCell(), ossimImageElevationDatabase::getBoundingRect(), operator=(), and ossimImageElevationHandler().

60 {
61  static const char M[] = "ossimImageElevationHandler::open";
62 
63  bool result = false;
64 
65  if ( isOpen() ) close();
66 
67  if ( file.size() )
68  {
69  //---
70  // NOTE: The false passed to open is flag to NOT open overviews. If code is ever changed
71  // to go between reduced resolution levels this should be changed.
72  //---
73  m_ih = ossimImageHandlerRegistry::instance()->open(file, true, false);
74  if ( m_ih.valid() )
75  {
77  if ( m_geom.valid() )
78  {
79  result = true;
80 
81  // Image rect stored as a drect for ossimImageElevationHandler::pointHasCoverage
82  // method.
87 
88  // Initialize base class stuff.
89  theFilename = file;
90 
92 
93  // Set the ossimElevSource::theGroundRect
94  std::vector<ossimGpt> corner(4);
95  if ( m_geom->getCornerGpts(corner[0], corner[1], corner[2], corner[3]) )
96  {
97  ossimGpt ulGpt(corner[0]);
98  ossimGpt lrGpt(corner[0]);
99  for ( ossim_uint32 i = 1; i < 4; ++i )
100  {
101  if ( corner[i].lon < ulGpt.lon ) ulGpt.lon = corner[i].lon;
102  if ( corner[i].lat > ulGpt.lat ) ulGpt.lat = corner[i].lat;
103  if ( corner[i].lon > lrGpt.lon ) lrGpt.lon = corner[i].lon;
104  if ( corner[i].lat < lrGpt.lat ) lrGpt.lat = corner[i].lat;
105  }
106  theGroundRect = ossimGrect(ulGpt, lrGpt);
107  }
108  else
109  {
111  }
112  }
113  // theAbsLE90 ???
114  // theAbsCE90 ???
115  }
116  }
117 
118  if ( traceDebug() )
119  {
121  << M << " DEBUG:"
122  << "\nmean spacing(meters): " << theMeanSpacing
123  << "\nunding rect: " << theGroundRect
124  << "\nreturn status: " << (result?"true\n":"false\n");
125  }
126 
127  return result;
128 }
ossimRefPtr< ossimImageGeometry > m_geom
ossim_float64 width() const
Definition: ossimDrect.h:522
ossimDrect m_rect
Image space rect stored as drect for inlined pointHasCoverage method.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
bool valid() const
Definition: ossimRefPtr.h:75
void makeNan()
Definition: ossimGrect.h:284
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
double y
Definition: ossimDpt.h:165
bool getCornerGpts(ossimGpt &ul, ossimGpt &ur, ossimGpt &lr, ossimGpt &ll) const
Assigns the ossimGpts with the ground coordinates of the four corresponding image corner points...
ossimGrect theGroundRect
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
ossimDpt getMetersPerPixel() const
Returns the GSD associated with this image in the active projection.
ossimFilename theFilename
Virtual method for reading.
virtual void close()
Closes the stream to the file.
ossimRefPtr< ossimImageHandler > m_ih
Pointers to links in chain.
double x
Definition: ossimDpt.h:164
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
static ossimImageHandlerRegistry * instance()
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator=()

const ossimImageElevationHandler & ossimImageElevationHandler::operator= ( const ossimImageElevationHandler rhs)
private

Hidden from use assignment operator.

Definition at line 288 of file ossimImageElevationHandler.cpp.

References open(), and ossimElevCellHandler::theFilename.

289 {
290  open(rhs.theFilename);
291  return *this;
292 }
ossimFilename theFilename
Virtual method for reading.
virtual bool open(const ossimFilename &file)
Opens a stream to the srtm cell.

◆ pointHasCoverage()

bool ossimImageElevationHandler::pointHasCoverage ( const ossimGpt gpt) const
inlinevirtual

pointHasCoverage(gpt)

Overrides ossimElevCellHandler::pointHasCoverage

Returns
TRUE if coverage exists over gpt.

Reimplemented from ossimElevCellHandler.

Definition at line 143 of file ossimImageElevationHandler.h.

References m_geom, m_rect, ossimDrect::pointWithin(), ossimRefPtr< T >::valid(), and ossimImageGeometry::worldToLocal().

Referenced by ossimImageElevationDatabase::createCell().

144 {
145  if ( m_geom.valid() )
146  {
147  ossimDpt dpt;
148  m_geom->worldToLocal(gpt, dpt);
149  return m_rect.pointWithin(dpt);
150  }
151  return false;
152 }
ossimRefPtr< ossimImageGeometry > m_geom
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
ossimDrect m_rect
Image space rect stored as drect for inlined pointHasCoverage method.
bool valid() const
Definition: ossimRefPtr.h:75
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.

Member Data Documentation

◆ m_geom

ossimRefPtr<ossimImageGeometry> ossimImageElevationHandler::m_geom
private

Definition at line 119 of file ossimImageElevationHandler.h.

Referenced by close(), getHeightAboveMSL(), open(), and pointHasCoverage().

◆ m_ih

ossimRefPtr<ossimImageHandler> ossimImageElevationHandler::m_ih
mutableprivate

Pointers to links in chain.

Definition at line 118 of file ossimImageElevationHandler.h.

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

◆ m_mutex

std::mutex ossimImageElevationHandler::m_mutex
mutableprivate

Definition at line 127 of file ossimImageElevationHandler.h.

Referenced by getTile().

◆ m_numTilesPerRow

ossim_uint32 ossimImageElevationHandler::m_numTilesPerRow
private

Definition at line 125 of file ossimImageElevationHandler.h.

Referenced by getTile(), and open().

◆ m_rect

ossimDrect ossimImageElevationHandler::m_rect
private

Image space rect stored as drect for inlined pointHasCoverage method.

Definition at line 123 of file ossimImageElevationHandler.h.

Referenced by getHeightAboveMSL(), getPostValue(), open(), and pointHasCoverage().

◆ m_tileCache

std::vector<TileCacheEntry> ossimImageElevationHandler::m_tileCache
mutableprivate

Definition at line 120 of file ossimImageElevationHandler.h.

Referenced by getTile().

◆ m_tileSize

ossimIpt ossimImageElevationHandler::m_tileSize
private

Definition at line 124 of file ossimImageElevationHandler.h.

Referenced by getTile(), open(), and ossimImageElevationHandler().


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