OTB  9.0.0
Orfeo Toolbox
Public Types | Public Member Functions | Static Public Member Functions | List of all members
otb::DEMHandler Class Reference

#include <otbDEMHandler.h>

+ Inheritance diagram for otb::DEMHandler:
+ Collaboration diagram for otb::DEMHandler:

Public Types

using PointType = itk::Point< double, 2 >
 
using Self = DEMHandler
 

Public Member Functions

double GetHeightAboveEllipsoid (const PointType &geoPoint) const
 
double GetHeightAboveEllipsoid (double lon, double lat) const
 
bool IsValidDEMDirectory (const std::string &DEMDirectory) const
 
void OpenDEMDirectory (std::string DEMDirectory)
 
void OpenDEMFile (std::string path)
 
bool OpenGeoidFile (std::string geoidFile)
 

Static Public Member Functions

static DEMHandlerGetInstance ()
 
static constexpr char const * DEM_DATASET_PATH = "/vsimem/otb_dem_dataset.vrt"
 
static constexpr char const * DEM_WARPED_DATASET_PATH = "/vsimem/otb_dem_warped_dataset.vrt"
 
static constexpr char const * DEM_SHIFTED_DATASET_PATH = "/vsimem/otb_dem_shifted_dataset.vrt"
 
double m_DefaultHeightAboveEllipsoid
 
std::vector< std::string > m_DEMDirectories
 
std::vector< otb::GDALDatasetWrapper::Pointerm_DatasetList
 
std::string m_GeoidFilename
 
std::list< DEMObserverInterface * > m_ObserverList
 
std::vector< std::shared_ptr< DEMHandlerTLS > > m_tlses
 
double GetHeightAboveMSL (double lon, double lat) const
 
double GetHeightAboveMSL (const PointType &geoPoint) const
 
double GetGeoidHeight (double lon, double lat) const
 
double GetGeoidHeight (const PointType &geoPoint) const
 
std::vcl_size_t GetDEMCount () const noexcept
 
double GetDefaultHeightAboveEllipsoid () const noexcept
 
void SetDefaultHeightAboveEllipsoid (double height)
 
std::string const & GetDEMDirectory (std::vcl_size_t idx=0) const
 
std::vcl_size_t GetNumberOfDEMDirectories () const noexcept
 
std::string const & GetGeoidFile () const noexcept
 
void ClearElevationParameters ()
 
void AttachObserver (DEMObserverInterface *observer) override
 
void DetachObserver (DEMObserverInterface *observer) override
 
void Notify () const override
 
DEMHandlerTLS const & GetHandlerForCurrentThread () const
 
 DEMHandler ()
 
 ~DEMHandler ()
 
std::shared_ptr< DEMHandlerTLS > DoFetchOrCreateHandler () const
 
void RegisterConfigurationInHandler (DEMHandlerTLS &handler) const
 
 DEMHandler (const Self &)=delete
 
void operator= (const Self &)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from otb::DEMSubjectInterface
 DEMSubjectInterface ()=default
 
 DEMSubjectInterface (DEMSubjectInterface const &)=delete
 
DEMSubjectInterfaceoperator= (DEMSubjectInterface const &)=delete
 
 ~DEMSubjectInterface ()=default
 

Detailed Description

Single access point for DEM data retrieval.

This class is the single configuration and access point for elevation handling in images projections and localization functions. Since this class is a singleton, there is no New() function. The DEMHandler::GetInstance() function should be used instead.

Please be aware that a proper instantiation and parameter setting of this class is advised before any call to geometric filters or functionalities.

The class allows configuring a directory containing DEM tiles (raster tiles will be opened by GDAL drivers) using the OpenDEMDirectory() function. The OpenGeoidFile() function allows inputting a geoid file as well. Last, a default height above ellipsoid can be set using the SetDefaultHeightAboveEllipsoid() function.

The class allows retrieving either height above ellipsoid or height above Mean Sea Level (MSL).

Here is the complete description of both functions output depending on the class configuration for the SRTM DEM (in the following, no SRTM means DEMDirectory not set, or no coverage for point, or srtm_value is no_data).

GetHeightAboveEllipsoid():

GetHeightAboveMSL():

Definition at line 113 of file otbDEMHandler.h.

Member Typedef Documentation

◆ PointType

using otb::DEMHandler::PointType = itk::Point<double, 2>

Definition at line 117 of file otbDEMHandler.h.

◆ Self

Definition at line 116 of file otbDEMHandler.h.

Constructor & Destructor Documentation

◆ DEMHandler() [1/2]

otb::DEMHandler::DEMHandler ( )
protected

Default constructor. Takes care of calling GDALAllRegister().

◆ ~DEMHandler()

otb::DEMHandler::~DEMHandler ( )
protected

Destructor.

Postcondition
DEM_DATASET_PATH, DEM_WARPED_DATASET_PATH and DEM_SHIFTED_DATASET_PATH files are deleted.
release shared ownership of the DEMHandlerTLS instances.

◆ DEMHandler() [2/2]

otb::DEMHandler::DEMHandler ( const Self )
privatedelete

Path to the in-memory vrt

Member Function Documentation

◆ AttachObserver()

void otb::DEMHandler::AttachObserver ( DEMObserverInterface observer)
inlineoverridevirtual

Add an element to the current list of observers. The obsever will be updated whenever the DEM configuration is modified.

Implements otb::DEMSubjectInterface.

Definition at line 206 of file otbDEMHandler.h.

References m_ObserverList.

◆ ClearElevationParameters()

void otb::DEMHandler::ClearElevationParameters ( )

Clear the DEM list and geoid filename, close all elevation datasets and reset the default height above ellipsoid.

◆ DetachObserver()

void otb::DEMHandler::DetachObserver ( DEMObserverInterface observer)
inlineoverridevirtual

Remove an element of the current list of observers.

Implements otb::DEMSubjectInterface.

Definition at line 209 of file otbDEMHandler.h.

References m_ObserverList.

◆ DoFetchOrCreateHandler()

std::shared_ptr<DEMHandlerTLS> otb::DEMHandler::DoFetchOrCreateHandler ( ) const
private

Internal function to fetch from the pool or create a new `DEMHandlerTLS.

◆ GetDefaultHeightAboveEllipsoid()

double otb::DEMHandler::GetDefaultHeightAboveEllipsoid ( ) const
noexcept

Path to the in-memory vrt

◆ GetDEMCount()

std::vcl_size_t otb::DEMHandler::GetDEMCount ( ) const
noexcept

Return the number of DEM opened

◆ GetDEMDirectory()

std::string const& otb::DEMHandler::GetDEMDirectory ( std::vcl_size_t  idx = 0) const

Get n-th DEM directory name.

Parameters
[in]idxdirectory index
Returns
the DEM directory corresponding to index idx
Exceptions
std::out_of_rangeif idx >= GetNumberOfDEMDirectories()

◆ GetGeoidFile()

std::string const& otb::DEMHandler::GetGeoidFile ( ) const
noexcept

Get Geoid file

◆ GetGeoidHeight() [1/2]

double otb::DEMHandler::GetGeoidHeight ( const PointType geoPoint) const

Path to the in-memory vrt

◆ GetGeoidHeight() [2/2]

double otb::DEMHandler::GetGeoidHeight ( double  lon,
double  lat 
) const

Return the offset information from the Geoid.

Parameters
[in]loninput longitude
[in]latinput latitude
Returns
Geoid offset

◆ GetHandlerForCurrentThread()

DEMHandlerTLS const& otb::DEMHandler::GetHandlerForCurrentThread ( ) const

Accessor to the current (thread-wise) DEM handler.

Returns the instance of DEMHandlerTLS that is meant to be used exclusively from the current thread.

As a microoptimisation, this function is public and can be used from places like ThreadedGenerateData() to extract a local reference to the instance of the handler, which could then be used with GetHeightAboveEllipsoid(DEMHandlerTLS const&, double lon, double lat) and so on.

◆ GetHeightAboveEllipsoid() [1/2]

double otb::DEMHandler::GetHeightAboveEllipsoid ( const PointType geoPoint) const

◆ GetHeightAboveEllipsoid() [2/2]

double otb::DEMHandler::GetHeightAboveEllipsoid ( double  lon,
double  lat 
) const

Return the height above the ellipsoid.

  • SRTM and geoid both available: srtm_value + geoid_offset
  • No SRTM but geoid available: geoid_offset
  • SRTM available, but no geoid: srtm_value
  • No SRTM and no geoid available: default height above ellipsoid
    Parameters
    [in]loninput longitude
    [in]latinput latitude
    Returns
    height above ellipsoid

Referenced by otb::GCPsToRPCSensorModelImageFilter< TImage >::AddGCP(), otb::DEMToImageGenerator< TDEMImage >::ThreadedGenerateData(), and otb::SarInverseTransform< TScalarType, NInputDimensions, NOutputDimensions >::TransformPoint().

◆ GetHeightAboveMSL() [1/2]

double otb::DEMHandler::GetHeightAboveMSL ( const PointType geoPoint) const

Path to the in-memory vrt

◆ GetHeightAboveMSL() [2/2]

double otb::DEMHandler::GetHeightAboveMSL ( double  lon,
double  lat 
) const

Return the height above the mean sea level.

  • SRTM and geoid both available: srtm_value
  • No SRTM but geoid available: 0
  • SRTM available, but no geoid: srtm_value
  • No SRTM and no geoid available: 0
    Parameters
    [in]loninput longitude
    [in]latinput latitude
    Returns
    height above mean sea level

Referenced by otb::DEMToImageGenerator< TDEMImage >::ThreadedGenerateData().

◆ GetInstance()

static DEMHandler& otb::DEMHandler::GetInstance ( )
static

◆ GetNumberOfDEMDirectories()

std::vcl_size_t otb::DEMHandler::GetNumberOfDEMDirectories ( ) const
inlinenoexcept

Path to the in-memory vrt

Definition at line 191 of file otbDEMHandler.h.

References m_DEMDirectories.

◆ IsValidDEMDirectory()

bool otb::DEMHandler::IsValidDEMDirectory ( const std::string &  DEMDirectory) const

Tells whether the directory contains a raster

Parameters
[in]DEMDirectoryinput directory

◆ Notify()

void otb::DEMHandler::Notify ( ) const
overridevirtual

Update all observers

Implements otb::DEMSubjectInterface.

◆ OpenDEMDirectory()

void otb::DEMHandler::OpenDEMDirectory ( std::string  DEMDirectory)

Open all raster in the directory.

Parameters
[in]DEMDirectoryinput directory
Examples
BasicFilters/DEMToRainbowExample.cxx, BasicFilters/HillShadingExample.cxx, and IO/DEMToImageGenerator.cxx.

◆ OpenDEMFile()

void otb::DEMHandler::OpenDEMFile ( std::string  path)

Try to open the DEM directory.

Parameters
[in]pathinput path

◆ OpenGeoidFile()

bool otb::DEMHandler::OpenGeoidFile ( std::string  geoidFile)

Try to open a geoid file

Parameters
[in]geoidFileinput geoid path

◆ operator=()

void otb::DEMHandler::operator= ( const Self )
privatedelete

Path to the in-memory vrt

◆ RegisterConfigurationInHandler()

void otb::DEMHandler::RegisterConfigurationInHandler ( DEMHandlerTLS &  handler) const
private

(Re)sets GEOID and DEM directory information in the handler. This function is meant to be called from DoFetchOrCreateHandler only: when a thread needs a new DEMHandlerTLS which is created on the fly. It's not thread safe!

Warning
DO NOT change the GEOID filename or the list of DEM directories while this function is being executed. These information should only be changed from a main thread, not from processing threads!

◆ SetDefaultHeightAboveEllipsoid()

void otb::DEMHandler::SetDefaultHeightAboveEllipsoid ( double  height)

Path to the in-memory vrt

Member Data Documentation

◆ DEM_DATASET_PATH

constexpr char const* otb::DEMHandler::DEM_DATASET_PATH = "/vsimem/otb_dem_dataset.vrt"
staticconstexpr

Path to the in-memory vrt

Definition at line 215 of file otbDEMHandler.h.

◆ DEM_SHIFTED_DATASET_PATH

constexpr char const* otb::DEMHandler::DEM_SHIFTED_DATASET_PATH = "/vsimem/otb_dem_shifted_dataset.vrt"
staticconstexpr

Path to the in-memory vrt

Definition at line 217 of file otbDEMHandler.h.

◆ DEM_WARPED_DATASET_PATH

constexpr char const* otb::DEMHandler::DEM_WARPED_DATASET_PATH = "/vsimem/otb_dem_warped_dataset.vrt"
staticconstexpr

Path to the in-memory vrt

Definition at line 216 of file otbDEMHandler.h.

◆ m_DatasetList

std::vector<otb::GDALDatasetWrapper::Pointer> otb::DEMHandler::m_DatasetList
private

List of RAII capsules on all opened DEM datasets for memory management

Definition at line 282 of file otbDEMHandler.h.

◆ m_DefaultHeightAboveEllipsoid

double otb::DEMHandler::m_DefaultHeightAboveEllipsoid
private

Default height above elliposid, used when no DEM or geoid height is available.

Definition at line 276 of file otbDEMHandler.h.

◆ m_DEMDirectories

std::vector<std::string> otb::DEMHandler::m_DEMDirectories
private

List of the DEM directories currently opened

Definition at line 279 of file otbDEMHandler.h.

Referenced by GetNumberOfDEMDirectories().

◆ m_GeoidFilename

std::string otb::DEMHandler::m_GeoidFilename
private

Filename of the current geoid

Definition at line 285 of file otbDEMHandler.h.

◆ m_ObserverList

std::list<DEMObserverInterface *> otb::DEMHandler::m_ObserverList
private

Observers on the DEM

Definition at line 288 of file otbDEMHandler.h.

Referenced by AttachObserver(), and DetachObserver().

◆ m_tlses

std::vector<std::shared_ptr<DEMHandlerTLS> > otb::DEMHandler::m_tlses
mutableprivate

Pool of actual thread local DEM handlers.

Definition at line 291 of file otbDEMHandler.h.


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