27 #ifndef __TERRALIB_RASTER_INTERNAL_POSITIONITERATOR_H 28 #define __TERRALIB_RASTER_INTERNAL_POSITIONITERATOR_H 31 #include "../common/STLUtils.h" 32 #include "../geometry.h" 82 virtual const std::vector<T>
operator*()
const = 0;
93 virtual T
operator[](
const unsigned int i)
const = 0;
104 virtual std::complex< T >
operator()(
const unsigned int i)
const = 0;
107 virtual unsigned int getRow()
const = 0;
110 virtual unsigned int getColumn()
const = 0;
141 virtual void setEnd() = 0;
181 void setNextLine(
bool updatecurrline =
true);
187 std::complex< T >
operator()(
const unsigned int i)
const;
189 unsigned int getRow()
const;
237 std::vector<te::gm::LineString*>& decomposedGeoms )
const;
279 std::complex< T >
operator()(
const unsigned int i)
const;
281 unsigned int getRow()
const;
347 std::complex< T >
operator()(
const unsigned int i)
const;
349 unsigned int getRow()
const;
424 m_actualintersection(-1),
446 throw te::rst::Exception(
TE_TR(
"Invalid polygon SRID") );
513 std::vector<te::gm::LineString*>& decomposedGeoms )
const 530 decomposedGeoms.push_back(static_cast<te::gm::LineString*> (
550 lineinter->
setX(0, pointinter->getX());
551 lineinter->
setY(0, pointinter->getY());
552 lineinter->
setX(1, pointinter->getX());
553 lineinter->
setY(1, pointinter->getY());
555 decomposedGeoms.push_back(lineinter);
570 decomposedGeoms.push_back(lineinter);
583 throw te::rst::Exception(
TE_TR(
584 "An exception has occurred in Polygon Iterator, with geometry " +
629 catch(
const std::exception& e)
631 std::cout <<
"Unhandled exception, status:" << std::endl;
634 std::cout <<
" m_column: " <<
m_column <<
" m_row: " <<
m_row << std::endl;
635 std::cout <<
" intersection line: " <<
m_currline->
toString() << std::endl << std::endl;
636 std::cout <<
" current polygon: " <<
m_polygon->
toString() << std::endl << std::endl;
637 std::cout <<
" exception message: " << e.what() << std::endl;
638 std::cout << std::endl;
647 intersections->
add(inter);
654 delete intersections;
689 values[b] = ((T) value);
779 for(
unsigned int intersectionsIdx = 0 ; intersectionsIdx <
836 for(
unsigned int intersectionsIdx = 0 ; intersectionsIdx <
865 m_currentpixelindex(0),
878 throw te::rst::Exception(
TE_TR(
"Invalid line SRID") );
887 if (inter->isEmpty())
898 double startingcolumn;
902 startingcolumn, startingrow);
908 endingcolumn, endingrow);
913 double x1, x2, y1, y2, geoX, geoY;
914 for(
int r = (
int)startingrow; r <= (int)endingrow; r++)
915 for(
int c = (
int)startingcolumn; c <= (int)endingcolumn; c++)
919 x1 = geoX - resXdiv2; y1 = geoY - resYdiv2;
920 x2 = geoX + resXdiv2; y2 = geoY + resYdiv2;
953 values[b] = ((T) value);
1040 m_pixelsinpointset(0),
1056 std::vector<te::gm::Point*> inside_points;
1063 throw te::rst::Exception(
TE_TR(
"Invalid point SRID") );
1101 values[b] = ((T) value);
1186 #endif // __TERRALIB_RASTER_INTERNAL_POSITIONITERATOR_H virtual Geometry * intersection(const Geometry *const rhs) const
It returns a geometric object that represents the point set intersection with another geometry...
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
int m_row
The current row of the iterator.
void setEnd()
Sets the iterator position to the end of the current band.
virtual T operator[](const unsigned int i) const =0
Returns the real value in current position (column, row, band) from iterator.
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Point * getStartPoint() const
The length of this Curve in its associated spatial reference.
int m_startingcolumn
The starting column (in current line) to initialize the iteration.
int m_startingrow
The starting row of the iteration.
A Line is LineString with 2 points.
It describes one band (or dimension) of a raster.
Coord2D getLowerLeft() const
It returns the lower left coordinate of the envelope.
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
void setX(std::size_t i, const double &x)
It sets the n-th x coordinate value.
const te::gm::Line * m_line
The spatial restriction to be applied in the iterator.
int m_nintersections
The number number of intersected lines in current line of the iterator.
void setEnd()
Sets the iterator position to the end of the current band.
void decompose(te::gm::Geometry const *const g, std::vector< te::gm::LineString * > &decomposedGeoms) const
Decomponse one geometry collection in a vector of basic components (line, point). ...
std::complex< double > m_operatorParenthesis_value
Used by the operator() method.
te::gm::Line * m_currline
The current line in the iterator.
double m_operatorBrackets_value
Used by the operator[] method.
virtual void operator--()=0
Returns to the previous position.
int m_maxcolumns
The number of columns in band.
bool operator!=(const PolygonIterator< T > &rhs) const
T operator[](const unsigned int i) const
Returns the real value in current position (column, row, band) from iterator.
unsigned int getColumn() const
Returns the current column in iterator.
int m_currentpixelindex
The index of the current pixel location.
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
double m_operatorBrackets_value
Used by the operator[] method.
static PointSetIterator end(const te::rst::Raster *r, const std::vector< te::gm::Point * > p)
Returns an iterator referring to after the end of the iterator.
This class is the base for implementing ways to navigate over the band with spatial restriction...
unsigned int getRow() const
Returns the current row in iterator.
An utility struct for representing 2D coordinates.
bool operator!=(const PointSetIterator< T > &rhs) const
void operator++()
Advances to the next position.
int m_actualintersection
The actual line of the iterator.
const te::gm::Polygon * m_polygon
The spatial restriction to be applied in the iterator.
bool operator!=(const LineIterator< T > &rhs) const
#define TE_TR(message)
It marks a string in order to get translated.
T operator[](const unsigned int i) const
Returns the real value in current position (column, row, band) from iterator.
virtual std::complex< T > operator()(const unsigned int i) const =0
Returns the complex value in current position (column, row, band) from iterator.
PolygonIterator & operator=(const PolygonIterator &rhs)
PointSetIterator & operator=(const PointSetIterator &rhs)
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
int m_endingrow
The ending row of the iteration.
Grid * getGrid()
It returns the raster grid.
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
int m_endingcolumn
The column (in current line) to finalize the iteration.
AbstractPositionIterator()
Constructor.
Utility functions for dealing with raster data blocks.
void setNextLine(bool updatecurrline=true)
virtual void operator++()=0
Advances to the next position.
void operator++()
Advances to the next position.
std::complex< T > operator()(const unsigned int i) const
Returns the complex value in current position (column, row, band) from iterator.
virtual bool isEmpty() const
It returns true if this geometric object is the empty Geometry.
An exception class for the Raster module.
Coord2D getUpperRight() const
It returns the upper right coordinate of the envelope.
std::vector< te::gm::Point * > m_pixelsinline
A vector of pixel locations that intersects the line.
MultiPoint is a GeometryCollection whose elements are restricted to points.
LineString is a curve with linear interpolation between points.
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
int m_currentpixelindex
The index of the current pixel location.
TEGEOMEXPORT bool SatisfySpatialRelation(const Geometry *g1, const Geometry *g2, SpatialRelation relation)
It returns if two geometries satisfy a given spatial relation.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
std::complex< double > m_operatorParenthesis_value
Used by the operator() method.
int m_maxrows
The number of rows in band.
std::complex< T > operator()(const unsigned int i) const
Returns the complex value in current position (column, row, band) from iterator.
void setEnd()
Sets the iterator position to the end of the current band.
virtual AbstractData * clone() const =0
It returns a clone of this object.
It gives access to values in one band (dimension) of a raster.
void clear()
Clear all internal allocated objects and reset back to the initial state.
virtual void setEnd()=0
Sets the iterator position to the end of the current band.
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
virtual const std::vector< T > operator*() const =0
Returns a vector of the values in current position (column, row) from iterator.
double m_operatorBrackets_value
Used by the operator[] method.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void operator--()
Returns to the previous position.
Point * getEndPoint() const
It returns the curve end point.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
MultiLineString is a MultiCurve whose elements are LineStrings.
te::dt::AbstractData * clone() const
It clones the line.
int getSRID() const
Returns the raster spatial reference system identifier.
std::vector< te::gm::Point * > m_pixelsinpointset
The spatial restriction to be applied in the iterator.
~AbstractPositionIterator()
Destructor.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
void operator--()
Returns to the previous position.
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band.
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
int m_column
The current column of the iterator.
const te::rst::Raster * m_raster
The band from where to get the values.
void add(Geometry *g)
It adds the geometry into the collection.
unsigned int getColumn() const
Returns the current column in iterator.
std::complex< double > m_operatorParenthesis_value
Used by the operator() method.
static LineIterator end(const te::rst::Raster *r, const te::gm::Line *l)
Returns an iterator referring to after the end of the iterator.
std::string toString() const
It returns the data value in a WKT representation.
virtual bool operator!=(const AbstractPositionIterator &rhs) const
Difference operator.
T operator[](const unsigned int i) const
Returns the real value in current position (column, row, band) from iterator.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
A rectified grid is the spatial support for raster data.
unsigned int getRow() const
Returns the current row in iterator.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
virtual unsigned int getRow() const =0
Returns the current row in iterator.
AbstractPositionIterator & operator=(const AbstractPositionIterator &rhs)
Assignment operator.
void setY(std::size_t i, const double &y)
It sets the n-th y coordinate value.
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
std::complex< T > operator()(const unsigned int i) const
Returns the complex value in current position (column, row, band) from iterator.
void operator++()
Advances to the next position.
virtual unsigned int getColumn() const =0
Returns the current column in iterator.
void operator--()
Returns to the previous position.
unsigned int getColumn() const
Returns the current column in iterator.
It is a collection of other geometric objects.
std::vector< te::gm::LineString * > m_intersections
The points or lines of the intersection between the geometry and the current line.
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
LineIterator & operator=(const LineIterator &rhs)
unsigned int getRow() const
Returns the current row in iterator.
const double & getX() const
It returns the Point x-coordinate value.
static PointSetIterator begin(const te::rst::Raster *r, const std::vector< te::gm::Point * > p)
Returns an iterator referring to the first value of the band.
static LineIterator begin(const te::rst::Raster *r, const te::gm::Line *l)
Returns an iterator referring to the first value of the band.