te::rst::Vectorizer Class Reference

It implements the vectorizer, based on TerraLib 4 algorithm. More...

#include <Vectorizer.h>

Public Member Functions

Vectorizeroperator= (const Vectorizer &rhs)
 Assignment operator. More...
 
bool run (std::vector< te::gm::Geometry * > &polygons, std::vector< double > *const polygonsValues=0)
 Returns true if current algorithm implementation runs ok, false otherwise. More...
 
 Vectorizer (Raster *r, std::size_t b, unsigned int mp=0, const bool noDataExclusion=true)
 Constructor. More...
 
 Vectorizer (const Vectorizer &rhs)
 Copy constructor. More...
 
 ~Vectorizer ()
 Destructor. More...
 

Protected Member Functions

void clear ()
 Clear all internally allocated resources. More...
 
bool detectEdge (long segmentInitialCol, long segmentInitialRow, te::gm::LinearRing &outputLine)
 Detects an edge of a cell in Raster. More...
 
bool startingEdgeTest (const int &x, const int &y)
 Tests if the current point is a edge start. More...
 

Protected Attributes

te::gm::Coord2D m_directions [8]
 Directions vector. More...
 
unsigned int m_maxPolygons
 The maximum allowed number of polygons to be created. More...
 
unsigned long m_nColumns
 The number of columns. More...
 
unsigned long m_nLines
 The number of lines. More...
 
double m_noDataValue
 The used dummy value. More...
 
unsigned int m_rasterBand
 The raster band to be used. More...
 
Rasterm_rasterPtr
 A pointer to the input image. More...
 
double m_resX
 Resolution X. More...
 
double m_resY
 Resolution Y. More...
 

Detailed Description

It implements the vectorizer, based on TerraLib 4 algorithm.

This algorithm implements a vectorizer, which is an algorithm to convert an image with pixel-labels into a set of polygons. All connected pixels in the image with the same label will define an individual polygon. This algorithm is based on the implementation of the previous version of this library, the TerraLib 4.

See also
Raster, Geometry

Definition at line 64 of file Vectorizer.h.

Constructor & Destructor Documentation

te::rst::Vectorizer::Vectorizer ( Raster r,
std::size_t  b,
unsigned int  mp = 0,
const bool  noDataExclusion = true 
)

Constructor.

Parameters
rThe input raster.
bThe selected band of the raster to be vectorized.
mpThe maximum allowed number of polygons to be created (default = 0, unlimited).
noDataExclusionIf true, regions with no-data pixels will not generate geometries.

Definition at line 68 of file Vectorizer.cpp.

References EAST, te::rst::Raster::getBand(), te::rst::Raster::getGrid(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Band::getProperty(), te::rst::Grid::getResolutionX(), te::rst::Grid::getResolutionY(), m_directions, m_nColumns, m_nLines, te::rst::BandProperty::m_noDataValue, m_noDataValue, m_rasterBand, m_rasterPtr, m_resX, m_resY, NORTH, NORTHEAST, NORTHWEST, SOUTH, SOUTHEAST, SOUTHWEST, and WEST.

te::rst::Vectorizer::Vectorizer ( const Vectorizer rhs)

Copy constructor.

Parameters
rhsThe right-hand-side copy that would be used to copy from.

Definition at line 99 of file Vectorizer.cpp.

te::rst::Vectorizer::~Vectorizer ( )

Destructor.

Definition at line 103 of file Vectorizer.cpp.

References clear().

Member Function Documentation

void te::rst::Vectorizer::clear ( )
protected

Clear all internally allocated resources.

Definition at line 720 of file Vectorizer.cpp.

Referenced by run(), and ~Vectorizer().

bool te::rst::Vectorizer::detectEdge ( long  segmentInitialCol,
long  segmentInitialRow,
te::gm::LinearRing outputLine 
)
protected

Detects an edge of a cell in Raster.

Parameters
segmentInitialColabscissa (column) of the upper-left point of the shape
segmentInitialRowordinate (line) of the upper-left point of the shape
line2D Line.
Returns
true if ok, otherwise false

Definition at line 359 of file Vectorizer.cpp.

References APPENDPOINTINLINE, col, te::gm::LineString::computeMBR(), EAST, te::rst::Raster::getGrid(), te::rst::Raster::getSRID(), te::rst::Raster::getValue(), te::rst::Grid::gridToGeo(), m_directions, m_nColumns, m_nLines, m_rasterBand, m_rasterPtr, te::gm::LineString::makeEmpty(), NORTH, NORTHEAST, NORTHWEST, te::gm::LineString::setNumCoordinates(), te::gm::LineString::setPoint(), te::gm::LineString::setSRID(), SOUTH, SOUTHEAST, SOUTHWEST, startingEdgeTest(), TE_TR, and WEST.

Referenced by run().

te::rst::Vectorizer & te::rst::Vectorizer::operator= ( const Vectorizer rhs)

Assignment operator.

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

Definition at line 108 of file Vectorizer.cpp.

bool te::rst::Vectorizer::run ( std::vector< te::gm::Geometry * > &  polygons,
std::vector< double > *const  polygonsValues = 0 
)

Returns true if current algorithm implementation runs ok, false otherwise.

Parameters
polygonsThe vector of polygons (will be cleared) to get the result of the vectorization.
polygonsValuesA pointer to a valid vector where the raster pixel values related to each polygon will be stored, or a NULL pointer.
Note
The caller of this method must take the ownership of the returned geometries and must delete them when necessary.

Definition at line 117 of file Vectorizer.cpp.

References te::rst::VectorizerPolygonStructure::clear(), clear(), detectEdge(), te::gm::FixGeometryTopology::fixTopology(), te::rst::Grid::geoToGrid(), te::rst::Raster::getExtent(), te::rst::Raster::getGrid(), te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::rst::Raster::getResolutionY(), te::rst::Raster::getSRID(), te::rst::Raster::getValue(), te::gm::Coord2D::getX(), te::gm::Coord2D::getY(), te::rst::Grid::gridToGeo(), te::gm::LineStringType, te::gm::TopologyValidationError::m_coordinate, te::rst::VectorizerPolygonStructure::m_indexerPtr, m_maxPolygons, te::gm::TopologyValidationError::m_message, m_nColumns, m_nLines, m_noDataValue, te::rst::VectorizerPolygonStructure::m_polygonPtr, m_rasterBand, m_rasterPtr, te::rst::VectorizerPolygonStructure::m_value, te::gm::PolygonType, te::common::TaskProgress::pulse(), te::rst::VectorizerPolygonStructure::reset(), TE_CORE_LOG_ERROR, TE_TR, te::common::TaskProgress::UNDEFINED, te::gm::Coord2D::x, and te::gm::Coord2D::y.

Referenced by BOOST_AUTO_TEST_SUITE(), and te::rst::Raster::vectorize().

bool te::rst::Vectorizer::startingEdgeTest ( const int x,
const int y 
)
protected

Tests if the current point is a edge start.

Parameters
xX coord.
yY coord.
Returns
true if the current point is a edge start, false if not.

Definition at line 699 of file Vectorizer.cpp.

References te::rst::Raster::getValue(), m_rasterBand, and m_rasterPtr.

Referenced by detectEdge().

Member Data Documentation

te::gm::Coord2D te::rst::Vectorizer::m_directions[8]
protected

Directions vector.

Definition at line 140 of file Vectorizer.h.

Referenced by detectEdge(), and Vectorizer().

unsigned int te::rst::Vectorizer::m_maxPolygons
protected

The maximum allowed number of polygons to be created.

Definition at line 146 of file Vectorizer.h.

Referenced by run().

unsigned long te::rst::Vectorizer::m_nColumns
protected

The number of columns.

Definition at line 144 of file Vectorizer.h.

Referenced by detectEdge(), run(), and Vectorizer().

unsigned long te::rst::Vectorizer::m_nLines
protected

The number of lines.

Definition at line 143 of file Vectorizer.h.

Referenced by detectEdge(), run(), and Vectorizer().

double te::rst::Vectorizer::m_noDataValue
protected

The used dummy value.

Definition at line 138 of file Vectorizer.h.

Referenced by run(), and Vectorizer().

unsigned int te::rst::Vectorizer::m_rasterBand
protected

The raster band to be used.

Definition at line 145 of file Vectorizer.h.

Referenced by detectEdge(), run(), startingEdgeTest(), and Vectorizer().

Raster* te::rst::Vectorizer::m_rasterPtr
protected

A pointer to the input image.

Definition at line 139 of file Vectorizer.h.

Referenced by detectEdge(), run(), startingEdgeTest(), and Vectorizer().

double te::rst::Vectorizer::m_resX
protected

Resolution X.

Definition at line 141 of file Vectorizer.h.

Referenced by Vectorizer().

double te::rst::Vectorizer::m_resY
protected

Resolution Y.

Definition at line 142 of file Vectorizer.h.

Referenced by Vectorizer().


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