te::rp::FeederConstRasterDirectory Class Reference

A feeder from an input directory name. More...

#include <FeedersRaster.h>

Inheritance diagram for te::rp::FeederConstRasterDirectory:
te::rp::FeederConstRaster te::rp::AbstractFeeder< const te::rst::Raster >

Public Member Functions

void applyGeometryRestriction (const te::gm::Geometry &restrictionGeom)
 Apply a new geometry intersect restriction selecting only those rasters intersecting the given geometry. More...
 
 FeederConstRasterDirectory (const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions)
 Constructor from an input directory name. More...
 
 FeederConstRasterDirectory (const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions, te::gm::Geometry const *const restrictionGeomPtr, const bool ignoreInvalidRasterFiles)
 Constructor from an input directory name with a restriction geometry. More...
 
te::rst::Raster const * getCurrentObj () const
 Return the current sequence object. More...
 
unsigned int getCurrentOffset () const
 Return the index of the current object. More...
 
const std::string & getCurrentRasterFileName ()
 Returns the current raster file name. More...
 
unsigned int getObjsCount () const
 Return the total number of feeder objects. More...
 
bool moveNext ()
 Advances to the next sequence obeject. More...
 
bool moveTo (const unsigned int index)
 Jump to the given object index. More...
 
void reset ()
 Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct). More...
 
 ~FeederConstRasterDirectory ()
 

Protected Member Functions

 FeederConstRasterDirectory ()
 
bool initialize (const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions, te::gm::Geometry const *const restrictionGeomPtr, const bool ignoreInvalidRasterFiles)
 Initialize this instance. More...
 

Protected Attributes

std::vector< std::string > m_allRasterFileNames
 
std::vector< te::gm::Polygonm_allRastersBoundingBoxes
 
std::unique_ptr< te::rst::Rasterm_currentRasterPtr
 
bool m_ignoreInvalidRasterFiles
 If true, invalid raster files will be ignored. More...
 
std::unique_ptr< te::gm::Geometrym_restrictionGeomPtr
 
std::string m_rType
 
std::vector< unsigned int >::size_type m_selectedRasterIndexesOffset
 
std::vector< unsigned intm_selectedRastersIndexes
 

Detailed Description

A feeder from an input directory name.

Definition at line 184 of file FeedersRaster.h.

Constructor & Destructor Documentation

te::rp::FeederConstRasterDirectory::FeederConstRasterDirectory ( const std::string &  directoryName,
const bool  recursive,
const std::string &  rType,
const bool  sortFileNames,
const std::vector< std::string > &  fileExtensions 
)

Constructor from an input directory name.

Parameters
directoryNameThe directory full path name.
recursivetrue if a recursive search must be performed.
rTypeThe name of the specific driver to instantiate each raster ( See te::rst::RasterFactory dictionary for valid registered values ).
sortFileNamesIf true, the file names will be sorted.
fileExtensionsThe file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.

Definition at line 315 of file FeedersRaster.cpp.

References TERP_TRUE_OR_THROW.

te::rp::FeederConstRasterDirectory::FeederConstRasterDirectory ( const std::string &  directoryName,
const bool  recursive,
const std::string &  rType,
const bool  sortFileNames,
const std::vector< std::string > &  fileExtensions,
te::gm::Geometry const *const  restrictionGeomPtr,
const bool  ignoreInvalidRasterFiles 
)

Constructor from an input directory name with a restriction geometry.

Parameters
directoryNameThe directory full path name.
recursivetrue if a recursive search must be performed.
rTypeThe name of the specific driver to instantiate each raster.
sortFileNamesIf true, the file names will be sorted.
fileExtensionsThe file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
restrictionGeomPtrA pointer to a restriction geometry (only rasters intercepting this geomtry will be considered) or a null pointer if there is no restriction.
ignoreInvalidRasterFilesIf true, invalid raster files will be ignored.

Definition at line 326 of file FeedersRaster.cpp.

References TERP_TRUE_OR_THROW.

te::rp::FeederConstRasterDirectory::~FeederConstRasterDirectory ( )
default
te::rp::FeederConstRasterDirectory::FeederConstRasterDirectory ( )
protected

Definition at line 340 of file FeedersRaster.cpp.

References ~FeederConstRasterDirectory().

Member Function Documentation

te::rst::Raster const * te::rp::FeederConstRasterDirectory::getCurrentObj ( ) const
virtual

Return the current sequence object.

Returns
A pointer to the current object or a null pointer if there are no object to return.

Implements te::rp::FeederConstRaster.

Definition at line 360 of file FeedersRaster.cpp.

References m_currentRasterPtr.

unsigned int te::rp::FeederConstRasterDirectory::getCurrentOffset ( ) const
virtual

Return the index of the current object.

Returns
The index of the current object.

Implements te::rp::FeederConstRaster.

Definition at line 496 of file FeedersRaster.cpp.

References m_selectedRasterIndexesOffset.

const std::string & te::rp::FeederConstRasterDirectory::getCurrentRasterFileName ( )

Returns the current raster file name.

Returns
Returns the current raster file name.

Definition at line 347 of file FeedersRaster.cpp.

References m_allRasterFileNames, m_selectedRasterIndexesOffset, and m_selectedRastersIndexes.

unsigned int te::rp::FeederConstRasterDirectory::getObjsCount ( ) const
virtual

Return the total number of feeder objects.

Returns
The total number of feeder objects.

Implements te::rp::FeederConstRaster.

Definition at line 491 of file FeedersRaster.cpp.

References m_selectedRastersIndexes.

bool te::rp::FeederConstRasterDirectory::initialize ( const std::string &  directoryName,
const bool  recursive,
const std::string &  rType,
const bool  sortFileNames,
const std::vector< std::string > &  fileExtensions,
te::gm::Geometry const *const  restrictionGeomPtr,
const bool  ignoreInvalidRasterFiles 
)
protected

Initialize this instance.

Parameters
directoryNameThe directory full path name.
recursivetrue if a recursive search must be performed.
rTypeThe name of the specific driver to instantiate each raster.
sortFileNamesIf true, the file names will be sorted.
fileExtensionsThe file extensions filter (example: ".tif"), or an empty vector if all extensions must be accepted.
restrictionGeomPtrA pointer to a restriction geometry (only rasters intercepting this geomtry will be considered) or a null pointer if there is no restriction.
ignoreInvalidRasterFilesIf true, invalid raster files will be ignored.

Definition at line 599 of file FeedersRaster.cpp.

References applyGeometryRestriction(), te::core::FileSystem::isDirectory(), te::core::FileSystem::isRegularFile(), m_allRasterFileNames, m_ignoreInvalidRasterFiles, m_rType, m_selectedRasterIndexesOffset, m_selectedRastersIndexes, and reset().

bool te::rp::FeederConstRasterDirectory::moveNext ( )
virtual

Advances to the next sequence obeject.

Returns
true if the advance was completed or false if the objects sequence end was reached.
Note
This method can invalidate any pointer returned by getCurrentObj.

Implements te::rp::FeederConstRaster.

Definition at line 365 of file FeedersRaster.cpp.

References m_allRasterFileNames, m_currentRasterPtr, m_ignoreInvalidRasterFiles, m_rType, m_selectedRasterIndexesOffset, m_selectedRastersIndexes, te::rst::RasterFactory::open(), te::common::RAccess, TERP_LOG_AND_RETURN_FALSE, and te::common::Exception::what().

bool te::rp::FeederConstRasterDirectory::moveTo ( const unsigned int  index)
virtual

Jump to the given object index.

Returns
true if the jump was completed or false on errors.
Note
This method can invalidate any pointer returned by getCurrentObj.

Implements te::rp::FeederConstRaster.

Definition at line 414 of file FeedersRaster.cpp.

References m_allRasterFileNames, m_currentRasterPtr, m_rType, m_selectedRasterIndexesOffset, m_selectedRastersIndexes, te::rst::RasterFactory::open(), te::common::RAccess, TERP_LOGWARN, and te::common::Exception::what().

void te::rp::FeederConstRasterDirectory::reset ( )
virtual

Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct).

Note
This method can invalidate any pointer returned by getCurrentObj.

Implements te::rp::FeederConstRaster.

Definition at line 452 of file FeedersRaster.cpp.

References m_allRasterFileNames, m_currentRasterPtr, m_ignoreInvalidRasterFiles, m_rType, m_selectedRasterIndexesOffset, m_selectedRastersIndexes, te::rst::RasterFactory::open(), te::common::RAccess, TERP_LOGWARN, and te::common::Exception::what().

Referenced by applyGeometryRestriction(), and initialize().

Member Data Documentation

std::vector< std::string > te::rp::FeederConstRasterDirectory::m_allRasterFileNames
protected
std::vector< te::gm::Polygon > te::rp::FeederConstRasterDirectory::m_allRastersBoundingBoxes
protected

Definition at line 249 of file FeedersRaster.h.

Referenced by applyGeometryRestriction().

std::unique_ptr< te::rst::Raster > te::rp::FeederConstRasterDirectory::m_currentRasterPtr
protected

Definition at line 250 of file FeedersRaster.h.

Referenced by getCurrentObj(), moveNext(), moveTo(), and reset().

bool te::rp::FeederConstRasterDirectory::m_ignoreInvalidRasterFiles
protected

If true, invalid raster files will be ignored.

Definition at line 244 of file FeedersRaster.h.

Referenced by applyGeometryRestriction(), initialize(), moveNext(), and reset().

std::unique_ptr< te::gm::Geometry > te::rp::FeederConstRasterDirectory::m_restrictionGeomPtr
protected

Definition at line 251 of file FeedersRaster.h.

Referenced by applyGeometryRestriction().

std::string te::rp::FeederConstRasterDirectory::m_rType
protected

Definition at line 245 of file FeedersRaster.h.

Referenced by applyGeometryRestriction(), initialize(), moveNext(), moveTo(), and reset().

std::vector< unsigned int >::size_type te::rp::FeederConstRasterDirectory::m_selectedRasterIndexesOffset
protected
std::vector< unsigned int > te::rp::FeederConstRasterDirectory::m_selectedRastersIndexes
protected

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