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

This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a polygon. More...

#include <PositionIterator.h>

Inheritance diagram for te::rst::PolygonIterator< T >:
te::rst::AbstractPositionIterator< T >

Public Types

enum  IterationType { ScanLineIterationT, NDisjointBBOXIterationT, DisjointBBOXIterationT }
 

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...
 
bool operator!= (const PolygonIterator< T > &rhs) const
 
bool operator!= (const AbstractPositionIterator< T > &rhs) const
 Difference operator. More...
 
std::complex< T > operator() (const unsigned int i) const
 Returns the complex value in current position (column, row, band) from iterator. More...
 
const std::vector< T > operator* () const
 Returns a vector of the values in current position (column, row) from iterator. More...
 
void operator++ ()
 Advances to the next position. More...
 
void operator-- ()
 Returns to the previous position. More...
 
PolygonIteratoroperator= (const PolygonIterator &rhs)
 
AbstractPositionIterator< T > & operator= (const AbstractPositionIterator< T > &rhs)
 Assignment operator. More...
 
operator[] (const unsigned int i) const
 Returns the real value in current position (column, row, band) from iterator. More...
 
 PolygonIterator ()
 
 PolygonIterator (const te::rst::Raster *r, const te::gm::Polygon *p, const IterationType iterationType)
 Constructor. More...
 
 PolygonIterator (const te::rst::Raster *r, const te::gm::Polygon *p)
 Constructor. More...
 
 PolygonIterator (const PolygonIterator &rhs)
 Copy constructor. More...
 
void setEnd ()
 Sets the iterator position to the end of the current band. More...
 
 ~PolygonIterator ()
 

Static Public Member Functions

static PolygonIterator begin (const te::rst::Raster *r, const te::gm::Polygon *p, const IterationType iterationType)
 Returns an iterator referring to the first value of the band. More...
 
static PolygonIterator begin (const te::rst::Raster *r, const te::gm::Polygon *p)
 Returns an iterator referring to the first value of the band. More...
 
static PolygonIterator end (const te::rst::Raster *r, const te::gm::Polygon *p)
 Returns an iterator referring to after the end of the iterator. More...
 
static PolygonIterator end (const te::rst::Raster *r, const te::gm::Polygon *p, const IterationType iterationType)
 Returns an iterator referring to after the end of the iterator. More...
 

Protected Member Functions

void clear ()
 Clear all internal allocated objects and reset back to the initial state. More...
 
void getBBOXIntersectionRanges (int lineIndex, const bool areDisjoint, std::vector< std::pair< int, int > > &intersectionRanges) const
 Returns the given line intersection ranges using the pixel bounding box as reference. More...
 
void getIntersectionRanges (int lineIndex, std::vector< std::pair< int, int > > &intersectionRanges) const
 Returns the given line intersection ranges (Coordinates of the columns to be transversed) using the current iteration type. More...
 
void getScanLineIntersectionRanges (int lineIndex, std::vector< std::pair< int, int > > &intersectionRanges) const
 Returns the given line intersection ranges (Coordinates of the columns to be transversed) using the ScanLineIterationT mode. More...
 
bool initialize (const te::rst::Raster *r, const te::gm::Polygon *p, const IterationType iterationType)
 Initialize this instance. More...
 
void initiateVariables ()
 Initialize all internal variables to initial states. More...
 

Protected Attributes

int m_column
 The current column of the iterator (default -1). More...
 
std::vector< std::pair< int, int > > m_currentLineIntersectionRanges
 Coordinates of the columns to be transversed. More...
 
int m_currentLineIntersectionRangesIndex
 The actual line of the iterator (default -1). More...
 
int m_currentRangeEndingColumn
 The current line iteration range column to finalize the iteration (default: -1). More...
 
int m_currentRangeStartingColumn
 The current line iteration range starting column (default: -1). More...
 
IterationType m_iterationType
 Current iteration type (default ScanLineIterationT). More...
 
double m_operatorBrackets_value
 
std::complex< double > m_operatorParenthesis_value
 
const te::gm::Polygonm_polygon
 The spatial restriction to be applied in the iterator (default 0). More...
 
int m_polygonEndingColumn
 Polygon last raster column (default: -1). More...
 
int m_polygonEndingRow
 Polygon last raster row (default: -1). More...
 
int m_polygonStartingColumn
 Polygon first raster column (default: -1). More...
 
int m_polygonStartingRow
 Polygon first raster row (default: -1). More...
 
const te::rst::Rasterm_raster
 The band from where to get the values (default 0). More...
 
int m_row
 The current row of the iterator (default -1). More...
 
std::unique_ptr< te::rst::TileIndexerm_tileIndexerPtr
 Tile indexer used to optimize the geometric operations. More...
 
int m_totalRasterColumns
 The number of columns in band (default: 0). More...
 
int m_totalRasterRows
 The number of rows in band (default: 0). More...
 

Detailed Description

template<typename T>
class te::rst::PolygonIterator< T >

This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a polygon.

Definition at line 156 of file PositionIterator.h.

Member Enumeration Documentation

◆ IterationType

template<typename T>
enum te::rst::PolygonIterator::IterationType
Enumerator
ScanLineIterationT 

Scan line iteration type.

NDisjointBBOXIterationT 

Itaration over pixels whose bounding boxes are not disjoint in relation with the polygon.

DisjointBBOXIterationT 

Itaration over pixels whose bounding boxes are disjoint in relation with the polygon.

Definition at line 161 of file PositionIterator.h.

Constructor & Destructor Documentation

◆ PolygonIterator() [1/4]

template<typename T >
te::rst::PolygonIterator< T >::PolygonIterator ( )

Definition at line 478 of file PositionIterator.h.

◆ PolygonIterator() [2/4]

template<typename T >
te::rst::PolygonIterator< T >::PolygonIterator ( const te::rst::Raster r,
const te::gm::Polygon p,
const IterationType  iterationType 
)

Constructor.

Parameters
bThe band to iterate.
pThe polygon from where the iteration will navigate.
iterationTypeIteration type.
Note
Both raster and polygon must have the same SRID.

Definition at line 483 of file PositionIterator.h.

References TE_TR.

◆ PolygonIterator() [3/4]

template<typename T >
te::rst::PolygonIterator< T >::PolygonIterator ( const te::rst::Raster r,
const te::gm::Polygon p 
)

Constructor.

Parameters
bThe band to iterate.
pThe polygon from where the iteration will navigate.
Note
Both raster and polygon must have the same SRID.
Iteration type: ScanLineIterationT.

Definition at line 495 of file PositionIterator.h.

References TE_TR.

◆ PolygonIterator() [4/4]

template<typename T >
te::rst::PolygonIterator< T >::PolygonIterator ( const PolygonIterator< T > &  rhs)

Copy constructor.

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

Definition at line 505 of file PositionIterator.h.

◆ ~PolygonIterator()

template<typename T >
te::rst::PolygonIterator< T >::~PolygonIterator ( )

Definition at line 511 of file PositionIterator.h.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
te::rst::PolygonIterator< T > te::rst::PolygonIterator< T >::begin ( const te::rst::Raster r,
const te::gm::Polygon p,
const IterationType  iterationType 
)
static

Returns an iterator referring to the first value of the band.

Definition at line 706 of file PositionIterator.h.

◆ begin() [2/2]

template<typename T >
te::rst::PolygonIterator< T > te::rst::PolygonIterator< T >::begin ( const te::rst::Raster r,
const te::gm::Polygon p 
)
static

Returns an iterator referring to the first value of the band.

Definition at line 712 of file PositionIterator.h.

◆ clear()

template<typename T >
void te::rst::PolygonIterator< T >::clear ( )
protected

Clear all internal allocated objects and reset back to the initial state.

Definition at line 767 of file PositionIterator.h.

◆ end() [1/2]

template<typename T >
te::rst::PolygonIterator< T > te::rst::PolygonIterator< T >::end ( const te::rst::Raster r,
const te::gm::Polygon p 
)
static

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

Definition at line 727 of file PositionIterator.h.

References te::rst::PolygonIterator< T >::setEnd().

◆ end() [2/2]

template<typename T >
te::rst::PolygonIterator< T > te::rst::PolygonIterator< T >::end ( const te::rst::Raster r,
const te::gm::Polygon p,
const IterationType  iterationType 
)
static

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

Definition at line 717 of file PositionIterator.h.

References te::rst::PolygonIterator< T >::setEnd().

◆ getBBOXIntersectionRanges()

template<typename T >
void te::rst::PolygonIterator< T >::getBBOXIntersectionRanges ( int  lineIndex,
const bool  areDisjoint,
std::vector< std::pair< int, int > > &  intersectionRanges 
) const
protected

Returns the given line intersection ranges using the pixel bounding box as reference.

Parameters
lineIndexLine index.
areDisjointIf true, returns only thos pixels disjoint with the polygon, otherwise returns those pixels not disjoint with the polygon.
intersectionRangesLine intersection ranges (first:initial column, second:ending column) or an empty vector if no intersections exist.

Definition at line 1062 of file PositionIterator.h.

References te::gm::LineStringType, te::gm::LineString::setNumCoordinates(), te::gm::Coord2D::x, and te::gm::Coord2D::y.

◆ getColumn()

template<typename T >
unsigned int te::rst::PolygonIterator< T >::getColumn ( ) const
virtual

Returns the current column in iterator.

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 549 of file PositionIterator.h.

◆ getIntersectionRanges()

template<typename T >
void te::rst::PolygonIterator< T >::getIntersectionRanges ( int  lineIndex,
std::vector< std::pair< int, int > > &  intersectionRanges 
) const
protected

Returns the given line intersection ranges (Coordinates of the columns to be transversed) using the current iteration type.

Parameters
lineIndexLine index.
intersectionRangesLine intersection ranges (first:initial column, second:ending column) or an empty vector if no intersections exist.

Definition at line 776 of file PositionIterator.h.

References TE_TR.

◆ getRow()

template<typename T >
unsigned int te::rst::PolygonIterator< T >::getRow ( ) const
virtual

Returns the current row in iterator.

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 544 of file PositionIterator.h.

◆ getScanLineIntersectionRanges()

template<typename T >
void te::rst::PolygonIterator< T >::getScanLineIntersectionRanges ( int  lineIndex,
std::vector< std::pair< int, int > > &  intersectionRanges 
) const
protected

Returns the given line intersection ranges (Coordinates of the columns to be transversed) using the ScanLineIterationT mode.

Parameters
lineIndexLine index.
intersectionRangesLine intersection ranges (first:initial column, second:ending column) or an empty vector if no intersections exist.

Definition at line 805 of file PositionIterator.h.

References te::gm::LineString::getEndPoint(), te::gm::Geometry::getSRID(), te::gm::LineString::getStartPoint(), te::gm::LineString::getX(), te::gm::LineString::getY(), te::gm::LineStringType, te::gm::Multi2Single(), te::gm::PointType, te::gm::LineString::setX(), te::rst::StdSortPointPointerComparison(), and TE_LOG_WARN.

◆ initialize()

template<typename T >
bool te::rst::PolygonIterator< T >::initialize ( const te::rst::Raster r,
const te::gm::Polygon p,
const IterationType  iterationType 
)
protected

◆ initiateVariables()

template<typename T >
void te::rst::PolygonIterator< T >::initiateVariables ( )
protected

Initialize all internal variables to initial states.

Definition at line 748 of file PositionIterator.h.

◆ operator!=() [1/2]

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

◆ operator!=() [2/2]

template<typename T >
bool te::rst::PolygonIterator< T >::operator!= ( const AbstractPositionIterator< T > &  rhs) const
virtual

Difference operator.

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

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 742 of file PositionIterator.h.

References operator!=().

◆ operator()()

template<typename T >
std::complex< T > te::rst::PolygonIterator< T >::operator() ( const unsigned int  i) const
virtual

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

Parameters
iThe band index.
Returns
The pixel comples value in current position.
Note
For real values use operator[]

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 537 of file PositionIterator.h.

◆ operator*()

template<typename T >
const std::vector< T > te::rst::PolygonIterator< T >::operator* ( ) const
virtual

Returns a vector of the values in current position (column, row) from iterator.

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 516 of file PositionIterator.h.

◆ operator++()

template<typename T >
void te::rst::PolygonIterator< T >::operator++ ( )
virtual

Advances to the next position.

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 554 of file PositionIterator.h.

◆ operator--()

template<typename T >
void te::rst::PolygonIterator< T >::operator-- ( )
virtual

Returns to the previous position.

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 605 of file PositionIterator.h.

◆ operator=() [1/2]

◆ operator=() [2/2]

template<typename T >
AbstractPositionIterator< T > & te::rst::PolygonIterator< T >::operator= ( const AbstractPositionIterator< T > &  rhs)
virtual

Assignment operator.

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

Reimplemented from te::rst::AbstractPositionIterator< T >.

Definition at line 694 of file PositionIterator.h.

◆ operator[]()

template<typename T >
T te::rst::PolygonIterator< T >::operator[] ( const unsigned int  i) const
virtual

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

Parameters
iThe band index.
Returns
The pixel real value in current position.
Note
For complex values use operator()

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 530 of file PositionIterator.h.

◆ setEnd()

template<typename T >
void te::rst::PolygonIterator< T >::setEnd ( )
virtual

Sets the iterator position to the end of the current band.

Parameters
bThe band to retrieve the end information.

Implements te::rst::AbstractPositionIterator< T >.

Definition at line 700 of file PositionIterator.h.

Referenced by te::rst::PolygonIterator< T >::end().

Member Data Documentation

◆ m_column

template<typename T>
int te::rst::PolygonIterator< T >::m_column
protected

The current column of the iterator (default -1).

Definition at line 250 of file PositionIterator.h.

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

◆ m_currentLineIntersectionRanges

template<typename T>
std::vector<std::pair<int, int> > te::rst::PolygonIterator< T >::m_currentLineIntersectionRanges
protected

Coordinates of the columns to be transversed.

Definition at line 256 of file PositionIterator.h.

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

◆ m_currentLineIntersectionRangesIndex

template<typename T>
int te::rst::PolygonIterator< T >::m_currentLineIntersectionRangesIndex
protected

The actual line of the iterator (default -1).

Definition at line 254 of file PositionIterator.h.

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

◆ m_currentRangeEndingColumn

template<typename T>
int te::rst::PolygonIterator< T >::m_currentRangeEndingColumn
protected

The current line iteration range column to finalize the iteration (default: -1).

Definition at line 253 of file PositionIterator.h.

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

◆ m_currentRangeStartingColumn

template<typename T>
int te::rst::PolygonIterator< T >::m_currentRangeStartingColumn
protected

The current line iteration range starting column (default: -1).

Definition at line 252 of file PositionIterator.h.

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

◆ m_iterationType

template<typename T>
IterationType te::rst::PolygonIterator< T >::m_iterationType
protected

Current iteration type (default ScanLineIterationT).

Definition at line 242 of file PositionIterator.h.

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

◆ m_operatorBrackets_value

template<typename T>
double te::rst::PolygonIterator< T >::m_operatorBrackets_value
mutableprotected

Definition at line 259 of file PositionIterator.h.

◆ m_operatorParenthesis_value

template<typename T>
std::complex< double > te::rst::PolygonIterator< T >::m_operatorParenthesis_value
mutableprotected

Definition at line 260 of file PositionIterator.h.

◆ m_polygon

template<typename T>
const te::gm::Polygon* te::rst::PolygonIterator< T >::m_polygon
protected

The spatial restriction to be applied in the iterator (default 0).

Definition at line 241 of file PositionIterator.h.

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

◆ m_polygonEndingColumn

template<typename T>
int te::rst::PolygonIterator< T >::m_polygonEndingColumn
protected

Polygon last raster column (default: -1).

Definition at line 246 of file PositionIterator.h.

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

◆ m_polygonEndingRow

template<typename T>
int te::rst::PolygonIterator< T >::m_polygonEndingRow
protected

Polygon last raster row (default: -1).

Definition at line 248 of file PositionIterator.h.

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

◆ m_polygonStartingColumn

template<typename T>
int te::rst::PolygonIterator< T >::m_polygonStartingColumn
protected

Polygon first raster column (default: -1).

Definition at line 245 of file PositionIterator.h.

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

◆ m_polygonStartingRow

template<typename T>
int te::rst::PolygonIterator< T >::m_polygonStartingRow
protected

Polygon first raster row (default: -1).

Definition at line 247 of file PositionIterator.h.

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

◆ m_raster

template<typename T>
const te::rst::Raster* te::rst::PolygonIterator< T >::m_raster
protected

The band from where to get the values (default 0).

Definition at line 240 of file PositionIterator.h.

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

◆ m_row

template<typename T>
int te::rst::PolygonIterator< T >::m_row
protected

The current row of the iterator (default -1).

Definition at line 251 of file PositionIterator.h.

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

◆ m_tileIndexerPtr

template<typename T>
std::unique_ptr<te::rst::TileIndexer> te::rst::PolygonIterator< T >::m_tileIndexerPtr
protected

Tile indexer used to optimize the geometric operations.

Definition at line 255 of file PositionIterator.h.

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

◆ m_totalRasterColumns

template<typename T>
int te::rst::PolygonIterator< T >::m_totalRasterColumns
protected

The number of columns in band (default: 0).

Definition at line 243 of file PositionIterator.h.

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

◆ m_totalRasterRows

template<typename T>
int te::rst::PolygonIterator< T >::m_totalRasterRows
protected

The number of rows in band (default: 0).

Definition at line 244 of file PositionIterator.h.

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


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