te::rst::RasterIterator< T > Class Template Reference

This class implements and iterator to "navigate" over a raster, with a predefined number of bands. More...

#include <RasterIterator.h>

Public Member Functions

unsigned int getColumn () const
 Returns the current column in iterator. More...
 
unsigned int getRow () const
 Returns the current row in iterator. More...
 
void getValues (std::vector< T > &v) const
 Gets the values from all bands in current position (column, row) from iterator. More...
 
bool operator!= (const RasterIterator &rhs) const
 Difference operator. More...
 
std::vector< T > operator* () const
 Returns a vector with pixel values from all bands in current position (column, row) from iterator. More...
 
void operator++ ()
 Advances to the next position. More...
 
void operator-- ()
 Returns to the previous position. More...
 
RasterIteratoroperator= (const RasterIterator &rhs)
 Assignment operator. More...
 
operator[] (const unsigned int i) const
 Returns the value in current position (column, row, band) from iterator. More...
 
 RasterIterator ()
 Empty constructor. More...
 
 RasterIterator (const RasterIterator &rhs)
 Copy constructor. More...
 
 RasterIterator (Raster *r, const std::vector< unsigned int > &bands, bool ignoreNoDataValue=false)
 Constructor. More...
 
 ~RasterIterator ()
 Destructor. More...
 

Static Public Member Functions

static RasterIterator begin (Raster *r, const std::vector< unsigned int > &bands, bool ignoreNoDataValue=false)
 Returns an iterator referring to the first value. More...
 
static RasterIterator end (Raster *r, const std::vector< unsigned int > &bands)
 Returns an iterator referring to after the end of the iterator. More...
 

Protected Member Functions

bool isNoDataValue ()
 Check if current position from iterartor represents a pixel with no data value. More...
 

Private Attributes

std::vector< unsigned int > m_b
 The vector of bands to iterate. More...
 
bool m_ignoreNoDataValue
 Flag used to not iterate over pixels with no data value. More...
 
std::vector< BandIterator< T > > m_it
 The vector of band iterators. More...
 
Rasterm_raster
 The raster from where to get the values. More...
 

Detailed Description

template<class T>
class te::rst::RasterIterator< T >

This class implements and iterator to "navigate" over a raster, with a predefined number of bands.

See also
te::rst::Raster

Definition at line 52 of file RasterIterator.h.

Constructor & Destructor Documentation

◆ RasterIterator() [1/3]

template<class T >
te::rst::RasterIterator< T >::RasterIterator

Empty constructor.

Definition at line 161 of file RasterIterator.h.

◆ RasterIterator() [2/3]

template<class T >
te::rst::RasterIterator< T >::RasterIterator ( Raster r,
const std::vector< unsigned int > &  bands,
bool  ignoreNoDataValue = false 
)

Constructor.

Parameters
rThe raster to iterate.
bandsThe vector of band indices that the iterator will use.

Definition at line 168 of file RasterIterator.h.

References te::rst::Raster::getBand(), te::rst::RasterIterator< T >::isNoDataValue(), te::rst::RasterIterator< T >::m_b, te::rst::RasterIterator< T >::m_ignoreNoDataValue, te::rst::RasterIterator< T >::m_it, and te::rst::RasterIterator< T >::operator++().

◆ RasterIterator() [3/3]

template<class T >
te::rst::RasterIterator< T >::RasterIterator ( const RasterIterator< T > &  rhs)

Copy constructor.

Parameters
rhsThe right-hand-side copy used to copy from.

Definition at line 185 of file RasterIterator.h.

◆ ~RasterIterator()

template<class T >
te::rst::RasterIterator< T >::~RasterIterator

Destructor.

Definition at line 190 of file RasterIterator.h.

Member Function Documentation

◆ begin()

template<class T >
te::rst::RasterIterator< T > te::rst::RasterIterator< T >::begin ( Raster r,
const std::vector< unsigned int > &  bands,
bool  ignoreNoDataValue = false 
)
static

Returns an iterator referring to the first value.

Parameters
rThe raster to iterate.
bandsThe vector of band indices that the iterator will use.

Definition at line 297 of file RasterIterator.h.

◆ end()

template<class T >
te::rst::RasterIterator< T > te::rst::RasterIterator< T >::end ( Raster r,
const std::vector< unsigned int > &  bands 
)
static

Returns an iterator referring to after the end of the iterator.

Parameters
rThe raster to iterate.
bandsThe vector of band indices that the iterator will use.

Definition at line 302 of file RasterIterator.h.

References te::rst::Raster::getBand(), and te::rst::RasterIterator< T >::m_it.

◆ getColumn()

template<class T >
unsigned int te::rst::RasterIterator< T >::getColumn

Returns the current column in iterator.

Definition at line 199 of file RasterIterator.h.

◆ getRow()

template<class T >
unsigned int te::rst::RasterIterator< T >::getRow

Returns the current row in iterator.

Definition at line 194 of file RasterIterator.h.

◆ getValues()

template<class T >
void te::rst::RasterIterator< T >::getValues ( std::vector< T > &  v) const

Gets the values from all bands in current position (column, row) from iterator.

Parameters
vA vector previously created to be filled with values.
Warning
The caller is responsible for creating the vector with enough space.

Definition at line 218 of file RasterIterator.h.

◆ isNoDataValue()

template<class T >
bool te::rst::RasterIterator< T >::isNoDataValue
protected

Check if current position from iterartor represents a pixel with no data value.

Returns
Returns true if the all values from vector matchs is no data value

Definition at line 312 of file RasterIterator.h.

Referenced by te::rst::RasterIterator< T >::RasterIterator().

◆ operator!=()

template<class T >
bool te::rst::RasterIterator< T >::operator!= ( const RasterIterator< T > &  rhs) const

Difference operator.

Parameters
rhsThe right-hand side to compare.
Returns
Returns true if the iterators are at different positions, or false otherwise.

Definition at line 292 of file RasterIterator.h.

References te::rst::RasterIterator< T >::m_it.

◆ operator*()

template<class T >
std::vector< T > te::rst::RasterIterator< T >::operator*

Returns a vector with pixel values from all bands in current position (column, row) from iterator.

Definition at line 209 of file RasterIterator.h.

◆ operator++()

template<class T >
void te::rst::RasterIterator< T >::operator++

Advances to the next position.

Definition at line 224 of file RasterIterator.h.

Referenced by te::rst::RasterIterator< T >::RasterIterator().

◆ operator--()

template<class T >
void te::rst::RasterIterator< T >::operator--

Returns to the previous position.

Definition at line 250 of file RasterIterator.h.

◆ operator=()

template<class T >
te::rst::RasterIterator< T > & te::rst::RasterIterator< T >::operator= ( const RasterIterator< T > &  rhs)

Assignment operator.

Parameters
rhsThe right-hand-side copy used to copy from.
Returns
A reference to this object.

Definition at line 276 of file RasterIterator.h.

References te::rst::RasterIterator< T >::m_b, te::rst::RasterIterator< T >::m_ignoreNoDataValue, te::rst::RasterIterator< T >::m_it, and te::rst::RasterIterator< T >::m_raster.

◆ operator[]()

template<class T >
T te::rst::RasterIterator< T >::operator[] ( const unsigned int  i) const

Returns the value in current position (column, row, band) from iterator.

Parameters
iThe band index.
Returns
The pixel value in current position.

Definition at line 204 of file RasterIterator.h.

Member Data Documentation

◆ m_b

template<class T >
std::vector<unsigned int> te::rst::RasterIterator< T >::m_b
private

The vector of bands to iterate.

Definition at line 155 of file RasterIterator.h.

Referenced by te::rst::RasterIterator< T >::operator=(), and te::rst::RasterIterator< T >::RasterIterator().

◆ m_ignoreNoDataValue

template<class T >
bool te::rst::RasterIterator< T >::m_ignoreNoDataValue
private

Flag used to not iterate over pixels with no data value.

Definition at line 158 of file RasterIterator.h.

Referenced by te::rst::RasterIterator< T >::operator=(), and te::rst::RasterIterator< T >::RasterIterator().

◆ m_it

◆ m_raster

template<class T >
Raster* te::rst::RasterIterator< T >::m_raster
private

The raster from where to get the values.

Definition at line 156 of file RasterIterator.h.

Referenced by te::rst::RasterIterator< T >::operator=().


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