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
ossimImageElevationDatabase Class Reference

#include <ossimImageElevationDatabase.h>

Inheritance diagram for ossimImageElevationDatabase:
ossimElevationCellDatabase ossimFileProcessorInterface ossimElevationDatabase ossimElevSource ossimSource ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Classes

struct  ossimImageElevationFileEntry
 

Public Member Functions

 ossimImageElevationDatabase ()
 default constructor More...
 
virtual bool open (const ossimString &connectionString)
 Open a connection to a database. More...
 
virtual void close ()
 close method. More...
 
virtual ossimObjectdup () const
 
void mapRegion (const ossimGrect &region)
 Maps elevation data for region to a grid. More...
 
virtual double getHeightAboveMSL (const ossimGpt &gpt)
 Get height above MSL for point. More...
 
virtual double getHeightAboveEllipsoid (const ossimGpt &)
 Get height above ellipsoid for point. More...
 
virtual bool pointHasCoverage (const ossimGpt &gpt) const
 Satisfies pure virtual ossimElevSource::pointHasCoverage. More...
 
virtual bool getAccuracyInfo (ossimElevationAccuracyInfo &info, const ossimGpt &gpt) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Statisfies pure virtual ossimElevSource::getAccuracyLE90. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Save the state to a keyword list. More...
 
void getBoundingRect (ossimGrect &rect) const
 Gets the bounding rectangle/coverage of elevation. More...
 
virtual void processFile (const ossimFilename &file)
 ProcessFile method. More...
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- Public Member Functions inherited from ossimElevationCellDatabase
 ossimElevationCellDatabase ()
 
 ossimElevationCellDatabase (const ossimElevationCellDatabase &src)
 
virtual ossim_uint32 getMinOpenCells () const
 
virtual ossim_uint32 getMaxOpenCells () const
 
virtual void setMinMaxOpenCells (ossim_uint64 minCellCount, ossim_uint64 maxCellCount)
 
virtual bool getMemoryMapCellsFlag () const
 
virtual void setMemoryMapCellsFlag (bool flag)
 
virtual void getOpenCellList (std::vector< ossimFilename > &list) const
 
void getCellsForBounds (const ossim_float64 &minLat, const ossim_float64 &minLon, const ossim_float64 &maxLat, const ossim_float64 &maxLon, std::vector< ossimFilename > &cells, ossim_uint32 maxNumberOfCells=0)
 Gets a list of elevation cells needed to cover bounding box. More...
 
virtual ossim_uint64 createId (const ossimGpt &) const
 
- Public Member Functions inherited from ossimElevationDatabase
 ossimElevationDatabase ()
 
 ossimElevationDatabase (const ossimElevationDatabase &src)
 
virtual double getMeanSpacingMeters () const
 METHOD: meanSpacingMeters() This method returns the post spacing in the region of gpt: More...
 
virtual void setGeoid (ossimGeoid *geoid)
 
ossimGeoidgetGeoid ()
 
const ossimGeoidgetGeoid () const
 
const ossimStringgetConnectionString () const
 
- Public Member Functions inherited from ossimElevSource
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 bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes 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
 
- 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
 
- Public Member Functions inherited from ossimFileProcessorInterface
 ossimFileProcessorInterface ()
 default constructor More...
 
virtual ~ossimFileProcessorInterface ()
 virtual destructor. More...
 

Protected Member Functions

virtual ~ossimImageElevationDatabase ()
 Protected destructor. More...
 
virtual ossimRefPtr< ossimElevCellHandlercreateCell (const ossimGpt &gpt)
 
virtual ossimRefPtr< ossimElevCellHandlergetOrCreateCellHandler (const ossimGpt &gpt)
 Gets cell for point. More...
 
virtual void remove (ossim_uint64 id)
 Removes an entry from the m_cacheMap and m_entryMap maps. More...
 
- Protected Member Functions inherited from ossimElevationCellDatabase
void flushCacheToMinOpenCells ()
 
- Protected Member Functions inherited from ossimElevationDatabase
virtual ~ossimElevationDatabase ()
 
virtual double getOffsetFromEllipsoid (const ossimGpt &gpt)
 
- 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

void loadFileMap ()
 Initializes m_entryMap with all loadable files from m_connectionString. More...
 
 ossimImageElevationDatabase (const ossimImageElevationDatabase &copy_this)
 Hidden from use copy constructor. More...
 

Private Attributes

std::map< ossim_uint64, ossimImageElevationFileEntrym_entryMap
 
ossim_uint64 m_lastMapKey
 
ossim_uint64 m_lastAccessedId
 

Additional Inherited Members

- Public Types inherited from ossimElevationCellDatabase
typedef std::map< ossim_uint64, ossimRefPtr< CellInfo > > CellMap
 
- 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 ossimElevationCellDatabase
ossim_uint32 m_minOpenCells
 
ossim_uint32 m_maxOpenCells
 
std::mutex m_cacheMapMutex
 
CellMap m_cacheMap
 
ossim_uint32 m_memoryMapCellsFlag
 
 TYPE_DATA
 
- Protected Attributes inherited from ossimElevationDatabase
ossimString m_connectionString
 
ossimRefPtr< ossimGeoidm_geoid
 
ossim_float64 m_meanSpacing
 
- 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

Definition at line 37 of file ossimImageElevationDatabase.h.

Constructor & Destructor Documentation

◆ ossimImageElevationDatabase() [1/2]

ossimImageElevationDatabase::ossimImageElevationDatabase ( )

default constructor

Definition at line 28 of file ossimImageElevationDatabase.cpp.

29  :
32  m_entryMap(),
33  m_lastMapKey(0),
35 {
36 }
ossimFileProcessorInterface()
default constructor
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap

◆ ~ossimImageElevationDatabase()

ossimImageElevationDatabase::~ossimImageElevationDatabase ( )
protectedvirtual

Protected destructor.

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

Definition at line 39 of file ossimImageElevationDatabase.cpp.

40 {
41 }

◆ ossimImageElevationDatabase() [2/2]

ossimImageElevationDatabase::ossimImageElevationDatabase ( const ossimImageElevationDatabase copy_this)
private

Hidden from use copy constructor.

Definition at line 431 of file ossimImageElevationDatabase.cpp.

References m_entryMap, m_lastAccessedId, and m_lastMapKey.

433 {
434  m_entryMap = copy.m_entryMap;
435  m_lastMapKey = copy.m_lastMapKey;
436  m_lastAccessedId = copy.m_lastAccessedId;
437 }
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap

Member Function Documentation

◆ close()

void ossimImageElevationDatabase::close ( )
virtual

close method.

Unreferences all data.

Definition at line 83 of file ossimImageElevationDatabase.cpp.

References ossimString::clear(), ossimElevationDatabase::m_connectionString, ossimElevationDatabase::m_geoid, and ossimElevationDatabase::m_meanSpacing.

84 {
85  m_meanSpacing = 0.0;
86  m_geoid = 0;
88 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
ossimRefPtr< ossimGeoid > m_geoid

◆ createCell()

ossimRefPtr< ossimElevCellHandler > ossimImageElevationDatabase::createCell ( const ossimGpt gpt)
protectedvirtual

Reimplemented from ossimElevationCellDatabase.

Definition at line 118 of file ossimImageElevationDatabase.cpp.

References ossimSource::disableSource(), ossimSource::enableSource(), ossimRefPtr< T >::get(), ossimElevSource::getBoundingGndRect(), ossimImageElevationHandler::isOpen(), ossimElevationCellDatabase::m_cacheMapMutex, m_entryMap, m_lastAccessedId, ossimImageElevationHandler::open(), ossimNotify(), ossimNotifyLevel_WARN, and ossimImageElevationHandler::pointHasCoverage().

Referenced by getOrCreateCellHandler().

120 {
122 
123  // Need to disable elevation while loading the DEM image to prevent recursion:
124  disableSource();
125 
126  std::map<ossim_uint64, ossimImageElevationFileEntry>::iterator i = m_entryMap.begin();
127  while ( i != m_entryMap.end() )
128  {
129  if ( (*i).second.m_loadedFlag == false )
130  {
131  // not loaded
133 
134  if ( (*i).second.m_rect.isLonLatNan() )
135  {
136  if ( h->open( (*i).second.m_file ) )
137  {
138  // First time opened. Capture the rectangle. for next time.
139  (*i).second.m_rect = h->getBoundingGndRect();
140  }
141  else
142  {
144  << "ossimImageElevationDatabase::createCell WARN:\nCould not open: "
145  << (*i).second.m_file << "\nRemoving file from map!" << std::endl;
146 
147  // Get a copy of the iterator to delet.
148  std::map<ossim_uint64, ossimImageElevationFileEntry>::iterator badIter = i;
149 
150  ++i; // Go to next image.
151 
152  // Must put lock around erase.
153  m_cacheMapMutex.lock();
154  m_entryMap.erase(badIter);
155  m_cacheMapMutex.unlock();
156 
157  continue; // Skip the rest of this loop.
158  }
159  }
160 
161  // Check the North up bounding rectangle for intersect.
162  if ( (*i).second.m_rect.pointWithin(gpt) )
163  {
164  if ( h->isOpen() == false )
165  {
166  h->open( (*i).second.m_file );
167  }
168 
169  if ( h->isOpen() )
170  {
171  //---
172  // Check point coverage again as image may not be geographic and pointHasCoverage
173  // has a check on worldToLocal point.
174  //---
175  if ( h->pointHasCoverage(gpt) )
176  {
177  m_lastAccessedId = (*i).first;
178  (*i).second.m_loadedFlag = true;
179  result = h.get();
180  break;
181  }
182  else
183  {
184  h = 0;
185  }
186  }
187  }
188  else
189  {
190  h = 0;
191  }
192  }
193 
194  ++i;
195  }
196 
197  enableSource();
198  return result;
199 }
virtual void disableSource()
Definition: ossimSource.cpp:89
virtual const ossimGrect & getBoundingGndRect() const
METHODS: accuracyLE90(), accuracyCE90() Returns the vertical and horizontal accuracy (90% confidence)...
virtual bool pointHasCoverage(const ossimGpt &) const
pointHasCoverage(gpt)
Elevation source for a generic image opened via ossimImageHandler.
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap
virtual void enableSource()
Definition: ossimSource.cpp:84
virtual bool open(const ossimFilename &file)
Opens a stream to the srtm cell.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ dup()

virtual ossimObject* ossimImageElevationDatabase::dup ( ) const
inlinevirtual

Implements ossimElevSource.

Definition at line 59 of file ossimImageElevationDatabase.h.

References open().

60  {
62  duped->open(m_connectionString);
63  return duped;
64  }
virtual bool open(const ossimString &connectionString)
Open a connection to a database.
ossimImageElevationDatabase()
default constructor

◆ getAccuracyInfo()

bool ossimImageElevationDatabase::getAccuracyInfo ( ossimElevationAccuracyInfo info,
const ossimGpt gpt 
) const
virtual

Reimplemented from ossimElevationDatabase.

Definition at line 342 of file ossimImageElevationDatabase.cpp.

References ossimElevationAccuracyInfo::m_surfaceName, and pointHasCoverage().

343 {
344  if(pointHasCoverage(gpt))
345  {
346  info.m_surfaceName = "Image Elevation";
347  }
348 
349  return false;
350 }
virtual bool pointHasCoverage(const ossimGpt &gpt) const
Satisfies pure virtual ossimElevSource::pointHasCoverage.

◆ getBoundingRect()

void ossimImageElevationDatabase::getBoundingRect ( ossimGrect rect) const

Gets the bounding rectangle/coverage of elevation.

Parameters
rectRectangle to initialize.

Definition at line 311 of file ossimImageElevationDatabase.cpp.

References ossimGrect::combine(), ossimElevSource::getBoundingGndRect(), ossimGrect::isLonLatNan(), m_entryMap, ossimGrect::makeNan(), and ossimImageElevationHandler::open().

312 {
313  // The bounding rect is the North up rectangle. So if the underlying image projection is not
314  // a geographic projection and there is a rotation this will include null coverage area.
315  rect.makeNan();
316  std::map<ossim_uint64, ossimImageElevationFileEntry>::const_iterator i = m_entryMap.begin();
317  ossimGrect subRect;
318  while ( i != m_entryMap.end() )
319  {
320  subRect = i->second.m_rect;
321  if (subRect.isLonLatNan())
322  {
323  // The DEM source was not yet initialized:
325  if ( h->open( i->second.m_file ) )
326  subRect = h->getBoundingGndRect();
327  else
328  {
329  ++i;
330  continue;
331  }
332  }
333  if (rect.isLonLatNan())
334  rect = subRect;
335  else
336  rect = rect.combine(subRect);
337  ++i;
338  }
339 }
void makeNan()
Definition: ossimGrect.h:284
virtual const ossimGrect & getBoundingGndRect() const
METHODS: accuracyLE90(), accuracyCE90() Returns the vertical and horizontal accuracy (90% confidence)...
Elevation source for a generic image opened via ossimImageHandler.
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap
ossimGrect combine(const ossimGrect &rect) const
Definition: ossimGrect.h:213
bool isLonLatNan() const
Definition: ossimGrect.h:290
virtual bool open(const ossimFilename &file)
Opens a stream to the srtm cell.

◆ getHeightAboveEllipsoid()

double ossimImageElevationDatabase::getHeightAboveEllipsoid ( const ossimGpt gpt)
virtual

Get height above ellipsoid for point.

Satisfies pure virtual ossimElevSource::getHeightAboveMSL().

Returns
Height above MSL.

Reimplemented from ossimElevSource.

Definition at line 108 of file ossimImageElevationDatabase.cpp.

References getHeightAboveMSL(), ossimElevationDatabase::getOffsetFromEllipsoid(), and ossim::isnan().

109 {
110  double h = getHeightAboveMSL(gpt);
111  if(!ossim::isnan(h))
112  {
113  h += getOffsetFromEllipsoid(gpt);
114  }
115  return h;
116 }
virtual double getOffsetFromEllipsoid(const ossimGpt &gpt)
virtual double getHeightAboveMSL(const ossimGpt &gpt)
Get height above MSL for point.
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ getHeightAboveMSL()

double ossimImageElevationDatabase::getHeightAboveMSL ( const ossimGpt gpt)
virtual

Get height above MSL for point.

Satisfies pure virtual ossimElevSource::getHeightAboveMSL().

Returns
Height above MSL.

Implements ossimElevSource.

Definition at line 90 of file ossimImageElevationDatabase.cpp.

References ossimElevSource::getHeightAboveMSL(), ossimElevCellHandler::getMeanSpacingMeters(), getOrCreateCellHandler(), ossimSource::isSourceEnabled(), ossimElevationDatabase::m_meanSpacing, ossim::nan(), and ossimRefPtr< T >::valid().

Referenced by getHeightAboveEllipsoid().

91 {
92  double h = ossim::nan();
93  if(isSourceEnabled())
94  {
96  if(handler.valid())
97  {
98  h = handler->getHeightAboveMSL(gpt); // still need to shift
99 
100  // Save the elev source's post spacing as the database's mean spacing:
101  m_meanSpacing = handler->getMeanSpacingMeters();
102  }
103  }
104 
105  return h;
106 }
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual double getHeightAboveMSL(const ossimGpt &)=0
Height access methods:
virtual double getMeanSpacingMeters() const
METHOD: meanSpacingMeters() Implements pure virtual for.
virtual ossimRefPtr< ossimElevCellHandler > getOrCreateCellHandler(const ossimGpt &gpt)
Gets cell for point.
bool valid() const
Definition: ossimRefPtr.h:75
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135

◆ getOrCreateCellHandler()

ossimRefPtr< ossimElevCellHandler > ossimImageElevationDatabase::getOrCreateCellHandler ( const ossimGpt gpt)
protectedvirtual

Gets cell for point.

This override ossimElevationCellDatabase::getOrCreateCellHandler as we cannot use the createId as our cells could be of any size.

Reimplemented from ossimElevationCellDatabase.

Definition at line 201 of file ossimImageElevationDatabase.cpp.

References createCell(), ossimElevationCellDatabase::flushCacheToMinOpenCells(), ossimRefPtr< T >::get(), ossimElevationCellDatabase::m_cacheMap, ossimElevationCellDatabase::m_cacheMapMutex, m_lastAccessedId, m_lastMapKey, ossimElevationCellDatabase::m_maxOpenCells, and ossimRefPtr< T >::valid().

Referenced by getHeightAboveMSL().

203 {
205 
206  // Note: Must do mutex lock / unlock around any cach map access.
207  m_cacheMapMutex.lock();
208 
209  if ( m_cacheMap.size() )
210  {
211  //---
212  // Look in existing map for handler.
213  //
214  // Note: Cannot key off of id from gpt as cells can be any arbituary dimensions.
215  //---
216 
217  CellMap::iterator lastAccessedCellIter = m_cacheMap.find(m_lastAccessedId);
218  CellMap::iterator iter = lastAccessedCellIter;
219 
220  // Check from last accessed to end.
221  while ( iter != m_cacheMap.end() )
222  {
223  if ( iter->second->m_handler->pointHasCoverage(gpt) )
224  {
225  result = iter->second->m_handler.get();
226  break;
227  }
228  ++iter;
229  }
230 
231  if ( result.valid() == false )
232  {
233  iter = m_cacheMap.begin();
234 
235  // Beginning to last accessed.
236  while ( iter != lastAccessedCellIter)
237  {
238  if ( iter->second->m_handler->pointHasCoverage(gpt) )
239  {
240  result = iter->second->m_handler.get();
241  break;
242  }
243  ++iter;
244  }
245  }
246 
247  if ( result.valid() )
248  {
249  m_lastAccessedId = iter->second->m_id;
250  iter->second->updateTimestamp();
251  }
252  }
253  m_cacheMapMutex.unlock();
254 
255  if ( result.valid() == false )
256  {
257  // Not in m_cacheMap. Create a new cell for point if we have coverage.
258  result = createCell(gpt);
259 
260  if(result.valid())
261  {
262  std::lock_guard<std::mutex> lock(m_cacheMapMutex);
263 
264  //---
265  // Add the cell to map.
266  // NOTE: ossimImageElevationDatabase::createCell sets m_lastAccessedId to that of
267  // the entries map key.
268  //---
269  m_cacheMap.insert(std::make_pair(m_lastAccessedId,
270  new CellInfo(m_lastAccessedId, result.get())));
271 
272  ++m_lastMapKey;
273 
274  // Check the map size and purge cells if needed.
275  if(m_cacheMap.size() > m_maxOpenCells)
276  {
278  }
279  }
280  }
281 
282  return result;
283 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimRefPtr< ossimElevCellHandler > createCell(const ossimGpt &gpt)

◆ loadFileMap()

void ossimImageElevationDatabase::loadFileMap ( )
private

Initializes m_entryMap with all loadable files from m_connectionString.

Definition at line 408 of file ossimImageElevationDatabase.cpp.

References ossimFileWalker::initializeDefaultFilterList(), ossimElevationDatabase::m_connectionString, ossimFileWalker::setFileProcessor(), ossimString::size(), and ossimFileWalker::walk().

409 {
410  if ( m_connectionString.size() )
411  {
412  // Create a file walker which will find files we can load from the connection string.
413  ossimFileWalker* fw = new ossimFileWalker();
414 
416 
417  // This links the file walker back to our "processFile" method.
418  fw->setFileProcessor( this );
419 
421 
422  // ossimFileWalker::walk will in turn call back to processFile method for each file it finds.
423  fw->walk(f);
424 
425  delete fw;
426  fw = 0;
427  }
428 }
void setFileProcessor(ossimFileProcessorInterface *fpi)
Sets ossimFileProcessorInterfacecallback method to process files.
Utility class to walk through directories and get a list of files to process.
std::string::size_type size() const
Definition: ossimString.h:405
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
void walk(const std::vector< ossimFilename > &files)
Takes an array of files.

◆ loadState()

bool ossimImageElevationDatabase::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Statisfies pure virtual ossimElevSource::getAccuracyLE90.

Returns
The vertical accuracy (90% confidence) in the region of gpt: Statisfies pure virtual ossimElevSource::getAccuracyCE90.
The horizontal accuracy (90% confidence) in the region of gpt.Initialize from keyword list.

Reimplemented from ossimElevationCellDatabase.

Definition at line 352 of file ossimImageElevationDatabase.cpp.

353 {
354  static const char M[] = "ossimImageElevationDatabase::loadState";
355  if(traceDebug())
356  {
358  << M << " entered..." << "\nkwl:\n" << kwl << "\n";
359  }
360  bool result = false;
361  const char* lookup = kwl.find(prefix, "type");
362  if ( lookup )
363  {
364  std::string type = lookup;
365  if ( ( type == "image_directory" ) || ( type == "ossimImageElevationDatabase" ) )
366  {
367  result = ossimElevationCellDatabase::loadState(kwl, prefix);
368 
369  if ( result )
370  {
371  loadFileMap();
372  }
373  }
374  }
375 
376  if(traceDebug())
377  {
378  ossimNotify(ossimNotifyLevel_DEBUG) << M << " result=" << (result?"true\n":"false\n");
379  }
380 
381  return result;
382 }
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
void loadFileMap()
Initializes m_entryMap with all loadable files from m_connectionString.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ mapRegion()

void ossimImageElevationDatabase::mapRegion ( const ossimGrect region)

Maps elevation data for region to a grid.

This uses connectionString passed to open method as starting point.

◆ open()

bool ossimImageElevationDatabase::open ( const ossimString connectionString)
virtual

Open a connection to a database.

Parameters
connectionStringFile or directory to open. In most cases this will point to a directory containing DEMs. Satisfies pure virtual ossimElevationDatabase::open().
Returns
true on success, false on error.

Implements ossimElevationDatabase.

Definition at line 43 of file ossimImageElevationDatabase.cpp.

Referenced by dup(), and ossimPointCloudTool::loadDem().

44 {
45  // return false; // tmp drb...
46 
47  static const char M[] = "ossimImageElevationDatabase::open";
48  if(traceDebug())
49  {
51  << M << " entered...\n"
52  << "\nConnection string: " << connectionString << "\n";
53  }
54 
55  bool result = false;
56 
57  close();
58 
59  if ( connectionString.size() )
60  {
61  m_connectionString = connectionString.c_str();
62 
63  loadFileMap();
64 
65  if ( m_entryMap.size() )
66  {
67  result = true;
68  }
69  else
70  {
72  }
73  }
74 
75  if(traceDebug())
76  {
77  ossimNotify(ossimNotifyLevel_DEBUG) << M << " result=" << (result?"true\n":"false\n");
78  }
79 
80  return result;
81 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
virtual void close()
close method.
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap
std::string::size_type size() const
Definition: ossimString.h:405
void loadFileMap()
Initializes m_entryMap with all loadable files from m_connectionString.
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
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ pointHasCoverage()

bool ossimImageElevationDatabase::pointHasCoverage ( const ossimGpt gpt) const
virtual

Satisfies pure virtual ossimElevSource::pointHasCoverage.

Returns
true if database has coverage for point.

Implements ossimElevSource.

Definition at line 285 of file ossimImageElevationDatabase.cpp.

References m_entryMap.

Referenced by getAccuracyInfo().

286 {
287  //---
288  // NOTE:
289  //
290  // The bounding rect is the North up rectangle. So if the underlying image projection is not
291  // a geographic projection and there is a rotation this could return false positives. Inside
292  // the ossimImageElevationDatabase::createCell there is a call to
293  // ossimImageElevationHandler::pointHasCoverage which does a real check from the
294  // ossimImageGeometry of the image.
295  //---
296  bool result = false;
297  std::map<ossim_uint64, ossimImageElevationFileEntry>::const_iterator i = m_entryMap.begin();
298  while ( i != m_entryMap.end() )
299  {
300  if ( (*i).second.m_rect.pointWithin(gpt) )
301  {
302  result = true;
303  break;
304  }
305  ++i;
306  }
307  return result;
308 }
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap

◆ print()

std::ostream & ossimImageElevationDatabase::print ( std::ostream &  out) const
virtual

Outputs theErrorStatus as an ossimErrorCode and an ossimString.

Returns
std::ostream&
Note
Derived classes should only have to implement a virtual print, not an operator<< funtion as it's implemented here.

Reimplemented from ossimElevationCellDatabase.

Definition at line 466 of file ossimImageElevationDatabase.cpp.

References saveState().

467 {
468  ossimKeywordlist kwl;
469  saveState(kwl);
470  out << "\nossimImageElevationDatabase @ "<< (ossim_uint64) this << "\n"
471  << kwl <<ends;
472  return out;
473 }
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Save the state to a keyword list.
Represents serializable keyword/value map.
unsigned long long ossim_uint64

◆ processFile()

void ossimImageElevationDatabase::processFile ( const ossimFilename file)
virtual

ProcessFile method.

Satisfies pure virtual ossimFileProcessorInterface::processFile.

This method is linked to the ossimFileWalker::walk method via a pointer to this class.

Parameters
fileto process.

Implements ossimFileProcessorInterface.

Definition at line 389 of file ossimImageElevationDatabase.cpp.

390 {
391  static const char M[] = "ossimImageElevationDatabase::processFile";
392  if(traceDebug())
393  {
395  << M << " entered...\n" << "file: " << file << "\n";
396  }
397 
398  // Add the file.
399  m_entryMap.insert( std::make_pair(m_lastMapKey++, ossimImageElevationFileEntry(file)) );
400 
401  if(traceDebug())
402  {
403  // Since ossimFileWalker is threaded output the file so we know which job exited.
404  ossimNotify(ossimNotifyLevel_DEBUG) << M << "\nfile: " << file << "\nexited...\n";
405  }
406 }
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ remove()

void ossimImageElevationDatabase::remove ( ossim_uint64  id)
inlineprotectedvirtual

Removes an entry from the m_cacheMap and m_entryMap maps.

Reimplemented from ossimElevationCellDatabase.

Definition at line 209 of file ossimImageElevationDatabase.h.

References m_entryMap, and ossimElevationCellDatabase::remove().

210 {
211  std::map<ossim_uint64, ossimImageElevationFileEntry>::iterator entryIter = m_entryMap.find(id);
212  if ( entryIter != m_entryMap.end() )
213  {
214  (*entryIter).second.m_loadedFlag = false;
215  }
217 }
virtual void remove(ossim_uint64 id)
std::map< ossim_uint64, ossimImageElevationFileEntry > m_entryMap

◆ saveState()

bool ossimImageElevationDatabase::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Save the state to a keyword list.

Reimplemented from ossimElevationCellDatabase.

Definition at line 384 of file ossimImageElevationDatabase.cpp.

References ossimElevationCellDatabase::saveState().

Referenced by print().

385 {
386  return ossimElevationCellDatabase::saveState(kwl, prefix);
387 }
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const

Member Data Documentation

◆ m_entryMap

std::map<ossim_uint64, ossimImageElevationFileEntry> ossimImageElevationDatabase::m_entryMap
private

◆ m_lastAccessedId

ossim_uint64 ossimImageElevationDatabase::m_lastAccessedId
private

◆ m_lastMapKey

ossim_uint64 ossimImageElevationDatabase::m_lastMapKey
private

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