PositionIterator.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/rp/PositionIterator.h
22 
23  \brief It implements several ways to retrieve positions inside a band with spatial restriction,
24  e.g. through a line, inside a bounding box or polygon, etc.
25 */
26 
27 #ifndef __TERRALIB_RASTER_INTERNAL_POSITIONITERATOR_H
28 #define __TERRALIB_RASTER_INTERNAL_POSITIONITERATOR_H
29 
30 // Terralib
31 #include "../common/STLUtils.h"
32 #include "../common/MathUtils.h"
33 #include "../core/logger/Logger.h"
34 #include "../geometry.h"
35 #include "Band.h"
36 #include "BandProperty.h"
37 #include "BlockUtils.h"
38 #include "Grid.h"
39 #include "Exception.h"
40 
41 // STL
42 #include <iostream>
43 #include <cmath>
44 
45 namespace te
46 {
47  namespace rst
48  {
49 // Forward declaration.
50  class Band;
51 
53  {
54  return *p1 < *p2;
55  }
56 
57  /*!
58  \class AbstractPositionIterator
59 
60  \brief This class is the base for implementing ways to navigate over the band with spatial restriction,
61  e.g. through a line, inside a bounding box or polygon, etc.
62 
63  \ingroup rst
64  */
65  template<typename T> class AbstractPositionIterator
66  {
67  public:
68 
69  /*! \brief Destructor. */
70  virtual ~AbstractPositionIterator();
71 
72  /*! \brief Returns a vector of the values in current position (column, row) from iterator. */
73  virtual const std::vector<T> operator*() const = 0;
74 
75  /*!
76  \brief Returns the real value in current position (column, row, band) from iterator.
77 
78  \param i The band index.
79 
80  \return The pixel real value in current position.
81 
82  \note For complex values use operator()
83  */
84  virtual T operator[](const unsigned int i) const = 0;
85 
86  /*!
87  \brief Returns the complex value in current position (column, row, band) from iterator.
88 
89  \param i The band index.
90 
91  \return The pixel comples value in current position.
92 
93  \note For real values use operator[]
94  */
95  virtual std::complex< T > operator()(const unsigned int i) const = 0;
96 
97  /*! \brief Returns the current row in iterator. */
98  virtual unsigned int getRow() const = 0;
99 
100  /*! \brief Returns the current column in iterator. */
101  virtual unsigned int getColumn() const = 0;
102 
103  /*! \brief Advances to the next position. */
104  virtual void operator++() = 0;
105 
106  /*! \brief Returns to the previous position. */
107  virtual void operator--() = 0;
108 
109  /*!
110  \brief Assignment operator.
111 
112  \param rhs The right-hand-side copy used to copy from.
113 
114  \return A reference to this object.
115  */
117 
118  /*!
119  \brief Difference operator.
120 
121  \param rhs The right-hand side to compare.
122 
123  \return Returns true if the iterators are at different positions, or false otherwise.
124  */
125  virtual bool operator!=(const AbstractPositionIterator<T>& rhs) const = 0;
126 
127  /*!
128  \brief Sets the iterator position to the end of the current band.
129 
130  \param b The band to retrieve the end information.
131  */
132  virtual void setEnd() = 0;
133 
134  protected:
135 
136  /*! \brief Constructor. */
138 
139  /*!
140  \brief Copy constructor.
141 
142  \param rhs The right-hand-side copy used to copy from.
143  */
145 
146  };
147 
148  /*!
149  \class PolygonIterator
150 
151  \brief This class implements the strategy to iterate with spatial restriction,
152  the iteration occurs inside a polygon.
153 
154  \ingroup rst
155  */
156  template<typename T> class PolygonIterator: public AbstractPositionIterator<T>
157  {
158  public:
159 
160  PolygonIterator();
161 
162  /*!
163  \brief Constructor.
164 
165  \param b The band to iterate.
166  \param p The polygon from where the iteration will navigate.
167  \note Both raster and polygon must have the same SRID.
168  */
169  PolygonIterator(const te::rst::Raster* r, const te::gm::Polygon* p);
170 
171  /*!
172  \brief Copy constructor.
173 
174  \param rhs The right-hand-side copy used to copy from.
175  */
176  PolygonIterator(const PolygonIterator& rhs);
177 
179 
180  void setNextLine(bool updatecurrline = true);
181 
182  const std::vector<T> operator*() const;
183 
184  T operator[](const unsigned int i) const;
185 
186  std::complex< T > operator()(const unsigned int i) const;
187 
188  unsigned int getRow() const;
189 
190  unsigned int getColumn() const;
191 
192  void operator++();
193 
194  void operator--();
195 
197 
199 
200  void setEnd();
201 
202  /*! \brief Returns an iterator referring to the first value of the band.*/
203  static PolygonIterator begin(const te::rst::Raster* r, const te::gm::Polygon* p);
204 
205  /*! \brief Returns an iterator referring to after the end of the iterator. */
206  static PolygonIterator end(const te::rst::Raster* r, const te::gm::Polygon* p);
207 
208  bool operator!=(const PolygonIterator<T>& rhs) const;
209 
210  bool operator!=(const AbstractPositionIterator<T>& rhs) const;
211 
212  protected:
213 
214  const te::rst::Raster* m_raster; //!< The band from where to get the values.
215  const te::gm::Polygon* m_polygon; //!< The spatial restriction to be applied in the iterator.
216  te::gm::Line* m_currline; //!< The current line in the iterator.
217  int m_column; //!< The current column of the iterator.
218  int m_row; //!< The current row of the iterator.
219  int m_startingcolumn; //!< The starting column (in current line) to initialize the iteration.
220  int m_endingcolumn; //!< The column (in current line) to finalize the iteration.
221  int m_startingrow; //!< The starting row of the iteration.
222  int m_endingrow; //!< The ending row of the iteration.
223  int m_maxcolumns; //!< The number of columns in band.
224  int m_maxrows; //!< The number of rows in band.
225  int m_actualintersection; //!< The actual line of the iterator.
226  int m_nintersections; //!< The number number of intersected lines in current line of the iterator.
227  std::unique_ptr<te::rst::TileIndexer> m_tileIndexer; //!< Tile indexer used to optimize the geometric operations
228  std::vector<std::pair<int, int> > m_columns; //!< Coordinates of the columns to be transversed
229 
230  // Variables used by the operator[] method.
231  mutable double m_operatorBrackets_value;
232  mutable std::complex< double > m_operatorParenthesis_value;
233 
234 
235  /*! \brief Clear all internal allocated objects and reset back to the initial state. */
236  void clear();
237 
238  };
239 
240  /*!
241  \class LineIterator
242 
243  \brief This class implements the strategy to iterate with spatial restriction,
244  the iteration occurs inside a line.
245 
246  \ingroup rst
247  */
248  template<typename T> class LineIterator: public AbstractPositionIterator<T>
249  {
250  public:
251 
252  LineIterator();
253 
254  /*!
255  \brief Constructor.
256 
257  \param b The band to iterate.
258  \param l The line from where the iteration will navigate.
259  */
260  LineIterator(const te::rst::Raster* r, const te::gm::Line* l);
261 
262  /*!
263  \brief Copy constructor.
264 
265  \param rhs The right-hand-side copy used to copy from.
266  */
267  LineIterator(const LineIterator& rhs);
268 
269  ~LineIterator();
270 
271  const std::vector<T> operator*() const;
272 
273  T operator[](const unsigned int i) const;
274 
275  std::complex< T > operator()(const unsigned int i) const;
276 
277  unsigned int getRow() const;
278 
279  unsigned int getColumn() const;
280 
281  void operator++();
282 
283  void operator--();
284 
285  LineIterator& operator=(const LineIterator& rhs);
286 
288 
289  void setEnd();
290 
291  /*! \brief Returns an iterator referring to the first value of the band.*/
292  static LineIterator begin(const te::rst::Raster* r, const te::gm::Line* l);
293 
294  /*! \brief Returns an iterator referring to after the end of the iterator. */
295  static LineIterator end(const te::rst::Raster* r, const te::gm::Line* l);
296 
297  bool operator!=(const LineIterator<T>& rhs) const;
298 
299  bool operator!=(const AbstractPositionIterator<T>& rhs) const;
300 
301  protected:
302 
303  const te::rst::Raster* m_raster; //!< The band from where to get the values.
304  const te::gm::Line* m_line; //!< The spatial restriction to be applied in the iterator.
305  int m_currentpixelindex; //!< The index of the current pixel location.
306  std::vector<te::gm::Point*> m_pixelsinline; //!< A vector of pixel locations that intersects the line.
307  mutable double m_operatorBrackets_value; //!< Used by the operator[] method.
308  mutable std::complex< double > m_operatorParenthesis_value; //!< Used by the operator() method.
309 
310 
311  };
312 
313  /*!
314  \class PointSetIterator
315 
316  \brief This class implements the strategy to iterate with spatial restriction,
317  the iteration occurs inside a vector of points.
318 
319  \ingroup rst
320  */
321  template<typename T> class PointSetIterator: public AbstractPositionIterator<T>
322  {
323  public:
324 
326 
327  /*!
328  \brief Constructor.
329 
330  \param b The band to iterate.
331  \param p The vector of points where the iteration will navigate.
332  */
333  PointSetIterator(const te::rst::Raster* r, const std::vector<te::gm::Point*> p);
334 
335  /*!
336  \brief Copy constructor.
337 
338  \param rhs The right-hand-side copy used to copy from.
339  */
341 
343 
344  const std::vector<T> operator*() const;
345 
346  T operator[](const unsigned int i) const;
347 
348  std::complex< T > operator()(const unsigned int i) const;
349 
350  unsigned int getRow() const;
351 
352  unsigned int getColumn() const;
353 
354  void operator++();
355 
356  void operator--();
357 
359 
361 
362  void setEnd();
363 
364  /*! \brief Returns an iterator referring to the first value of the band.*/
365  static PointSetIterator begin(const te::rst::Raster* r, const std::vector<te::gm::Point*> p);
366 
367  /*! \brief Returns an iterator referring to after the end of the iterator. */
368  static PointSetIterator end(const te::rst::Raster* r, const std::vector<te::gm::Point*> p);
369 
370  bool operator!=(const PointSetIterator<T>& rhs) const;
371 
372  bool operator!=(const AbstractPositionIterator<T>& rhs) const;
373 
374  protected:
375 
376  const te::rst::Raster* m_raster; //!< The band from where to get the values.
377  std::vector<te::gm::Point*> m_pixelsinpointset; //!< The spatial restriction to be applied in the iterator.
378  int m_currentpixelindex; //!< The index of the current pixel location.
379  mutable double m_operatorBrackets_value; //!< Used by the operator[] method.
380  mutable std::complex< double > m_operatorParenthesis_value; //!< Used by the operator() method.
381 
382 
383  };
384 
385 // implementation of abstract position iterator
386 
388  {
389  }
390 
392  {
393  }
394 
396  {
397  }
398 
399  template<typename T>
402  {
403  return *this;
404  }
405 
406 // implementation of iteration strategy bounded by a polygon
408  : m_raster(0),
409  m_polygon(0),
410  m_currline(0),
411  m_column(-1),
412  m_row(-1),
413  m_startingcolumn(0),
414  m_endingcolumn(0),
415  m_startingrow(0),
416  m_endingrow(0),
417  m_maxcolumns(0),
418  m_maxrows(0),
419  m_actualintersection(-1),
420  m_nintersections(0)
421  {
422  }
423 
425  : m_raster(r),
426  m_polygon(p),
427  m_currline(0),
428  m_column(-1),
429  m_row(-1),
430  m_startingcolumn(0),
431  m_endingcolumn(0),
432  m_startingrow(0),
433  m_endingrow(0),
434  m_maxcolumns(r->getNumberOfColumns()),
435  m_maxrows(r->getNumberOfRows()),
436  m_actualintersection(-1),
437  m_nintersections(0)
438  {
439  if( r->getSRID() != p->getSRID() )
440  {
441  throw te::rst::Exception( TE_TR("Invalid polygon SRID") );
442  }
443 
444  const te::rst::Grid& rasterGrid = *r->getGrid();
445  const te::gm::Envelope& rasterEnvelope = *rasterGrid.getExtent();
446 
449 
450  // Is the polygon extent is outside the current raster area
451 
452  if(
453  ( ll.x > rasterEnvelope.m_urx )
454  ||
455  ( ur.x < rasterEnvelope.m_llx )
456  ||
457  ( ur.y < rasterEnvelope.m_lly )
458  ||
459  ( ll.y > rasterEnvelope.m_ury )
460  )
461  {
462  setEnd();
463  }
464  else
465  {
466  // defining starting/ending rows
467 
468  te::gm::Coord2D llIndexed;
469  rasterGrid.geoToGrid(ll.x, ll.y, llIndexed.x, llIndexed.y);
470  te::gm::Coord2D urIndexed;
471  rasterGrid.geoToGrid(ur.x, ur.y, urIndexed.x, urIndexed.y);
472 
473  m_startingrow = (int)std::ceil( urIndexed.y );
474  m_startingrow = std::max( 0, m_startingrow );
475  m_startingrow = std::min( m_startingrow, ((int)rasterGrid.getNumberOfRows()) - 1 );
476 
477  m_endingrow = (int)std::floor( llIndexed.y );
478  m_endingrow = std::max( 0, m_endingrow );
479  m_endingrow = std::min( m_endingrow, ((int)rasterGrid.getNumberOfRows()) - 1 );
480 
481  if( m_endingrow < m_startingrow )
482  {
483  setEnd();
484  }
485  else
486  {
487  // initialize the TileIndexer
488 
489  m_tileIndexer = std::unique_ptr<te::rst::TileIndexer>(new te::rst::TileIndexer(*m_polygon, rasterGrid.getResolutionY()));
490 
491  // defining initial state
492 
495  m_polygon->getSRID());
496 
498 
499  setNextLine(true);
500 
502  }
503  }
504  }
505 
507  : m_raster(rhs.m_raster),
508  m_polygon(0),
509  m_currline(0),
510  m_column(-1),
511  m_row(-1),
512  m_startingcolumn(0),
513  m_endingcolumn(0),
514  m_startingrow(0),
515  m_endingrow(0),
516  m_maxcolumns(0),
517  m_maxrows(0),
518  m_actualintersection(-1),
519  m_nintersections(0)
520  {
521  operator=( rhs );
522  }
523 
525  {
526  clear();
527  }
528 
529  template<typename T> void te::rst::PolygonIterator<T>::setNextLine(bool updatecurrline)
530  {
531  if (m_actualintersection == -1 || m_actualintersection >= m_nintersections)
532  {
533  // Globals
534 
535  const double& rasterEnvelopeLLX =
536  m_raster->getGrid()->getExtent()->m_llx;
537  const double& rasterEnvelopeURX =
538  m_raster->getGrid()->getExtent()->m_urx;
539 
540  // Updates the line corresponding to the current line of the iterator
541 
542  if (updatecurrline)
543  {
544  double nexty = this->m_raster->getGrid()->gridToGeo(0, m_row).y;
545 
546  m_currline->setX(0, std::min(
547  rasterEnvelopeLLX,
548  m_polygon->getMBR()->getLowerLeft().x) );
549  m_currline->setY(0, nexty);
550 
551  m_currline->setX(1, std::max(
552  rasterEnvelopeURX,
553  m_polygon->getMBR()->getUpperRight().x ) );
554  m_currline->setY(1, nexty);
555  }
556 
557  // Initialize Tile Indexer and structures used to retrieve the points where the current line
558  // intersects the polygon
559 
560  m_columns.clear();
561 
562 
563  // Vector to store the points where the current line intersects the current tile of the polygon
564  std::vector<te::gm::Point*> intersectionPoints;
565 
566  // Retrieve the tile corresponding to the current line and store the points where the line
567  // intersects the tile
568 
569  te::rst::TileIndexer::TileSegIndex* currentTilePtr = 0;
570 
571  if (m_tileIndexer->getTile(m_currline->getY(0), &currentTilePtr))
572  {
573  assert(currentTilePtr);
574 
575  te::gm::LinearRing const* ringTile;
576  std::unique_ptr<te::gm::Line> tileSeg;
577  std::unique_ptr< te::gm::Geometry > interResultPtr;
578  std::vector< te::gm::Geometry * > singleGeomsPtrs;
579  std::size_t singleGeomsPtrsIdx = 0;
580 
581  try
582  {
583  // in some cases the intersection presents an unhandled exception, in this case we do not paint the current line
584  // Transverse the segments of the tile retrieving the intersection between them and the current line
585 
586  te::gm::LineString* lineStrPtr = 0;
587 
588  for (std::size_t i = 0; i < currentTilePtr->size(); i++)
589  {
590  assert((*currentTilePtr)[i].first < m_polygon->getNumRings());
591 
592  // Retrieve the current ring of the current tile
593  assert(dynamic_cast<te::gm::LinearRing const*>((*m_polygon)[(*currentTilePtr)[i].first]));
594  ringTile = (te::gm::LinearRing const*)(*m_polygon)[(*currentTilePtr)[i].first];
595 
596  assert((*currentTilePtr)[i].second < m_polygon->getNPoints());
597 
598  // Retrieve the current segment of the current tile
599  tileSeg.reset(new te::gm::Line(te::gm::Point(ringTile->getX((*currentTilePtr)[i].second),
600  ringTile->getY((*currentTilePtr)[i].second),
601  ringTile->getSRID()),
602  te::gm::Point(ringTile->getX((*currentTilePtr)[i].second + 1),
603  ringTile->getY((*currentTilePtr)[i].second + 1),
604  ringTile->getSRID()),
605  te::gm::LineStringType, ringTile->getSRID()));
606 
607  // Computes the intersection point between the current segment and the current line
608 
609  interResultPtr.reset( tileSeg->intersection( m_currline ) );
610 
611  if( interResultPtr.get() != 0 )
612  {
613  singleGeomsPtrs.clear();
614  te::gm::Multi2Single( interResultPtr.get(), singleGeomsPtrs );
615 
616  for( singleGeomsPtrsIdx = 0 ; singleGeomsPtrsIdx < singleGeomsPtrs.size() ;
617  ++singleGeomsPtrsIdx )
618  {
619  if( singleGeomsPtrs[ singleGeomsPtrsIdx ]->getGeomTypeId() ==
621  {
622  intersectionPoints.push_back( (te::gm::Point*)(
623  singleGeomsPtrs[ singleGeomsPtrsIdx ]->clone() ) );
624  }
625  else if( singleGeomsPtrs[ singleGeomsPtrsIdx ]->getGeomTypeId() ==
627  {
628  lineStrPtr = ((te::gm::LineString*) singleGeomsPtrs[
629  singleGeomsPtrsIdx ]);
630  intersectionPoints.push_back( lineStrPtr->getStartPoint() );
631  intersectionPoints.push_back( lineStrPtr->getEndPoint() );
632  }
633  }
634  }
635  }
636  }
637  catch(const std::exception& e)
638  {
639  TE_LOG_WARN( "Geometry intersection error:" + e.what() );
640 
641  // deleting the intersections points
642 
643  for( std::size_t intersectionPointsIdx = 0; intersectionPointsIdx <
644  intersectionPoints.size() ; ++intersectionPointsIdx )
645  {
646  delete intersectionPoints[intersectionPointsIdx];
647  }
648 
649  intersectionPoints.clear();
650  }
651  catch(...)
652  {
653  TE_LOG_WARN( "Geometry intersection error" );
654 
655  // deleting the intersections points
656 
657  for( std::size_t intersectionPointsIdx = 0; intersectionPointsIdx <
658  intersectionPoints.size() ; ++intersectionPointsIdx )
659  {
660  delete intersectionPoints[intersectionPointsIdx];
661  }
662 
663  intersectionPoints.clear();
664  }
665  }
666 
667  // Removing duplicated points
668 
669  {
670  std::size_t positionBegin = 0;
671  std::size_t positionEnd = 0;
672  std::vector<te::gm::Point*> intersectionPointsAux = intersectionPoints;
673 
674  intersectionPoints.clear();
675 
676  while( positionBegin < intersectionPointsAux.size() )
677  {
678  if( intersectionPointsAux[positionBegin] )
679  {
680  positionEnd = positionBegin + 1;
681 
682  while( positionEnd < intersectionPointsAux.size() )
683  {
684  if(
685  ( intersectionPointsAux[positionEnd] != 0 )
686  &&
687  intersectionPointsAux[positionBegin]->equals(
688  intersectionPointsAux[positionEnd], true)
689  )
690  {
691  delete intersectionPointsAux[positionEnd];
692  intersectionPointsAux[positionEnd] = 0;
693  }
694 
695  positionEnd++;
696  }
697 
698  intersectionPoints.push_back( intersectionPointsAux[positionBegin] );
699  }
700 
701  ++positionBegin;
702  }
703  }
704 
705  // Sort the intersection points through its Y coordinates (column)
706  std::sort(intersectionPoints.begin(), intersectionPoints.end(),
708 
709  // Using the intersection points, build a vector of coordinates (columns) with the start and
710  // end column of the current line for each stretch
711 
712  std::size_t positionBegin = 0;
713  std::size_t positionEnd = 0;
714  int startingCol = 0;
715  int endingCol = 0;
716  double startingX = 0;
717  double startingY = 0;
718  double endingX = 0;
719  double endingY = 0;
720 
721  while( ( positionBegin + 1 ) < intersectionPoints.size() )
722  {
723  positionEnd = positionBegin + 1;
724 
725  startingX = intersectionPoints[positionBegin]->getX();
726  startingX = std::max( startingX, rasterEnvelopeLLX );
727 
728  startingY = intersectionPoints[positionBegin]->getY();
729 
730  endingX = intersectionPoints[positionEnd]->getX();
731  endingX = std::min( endingX, rasterEnvelopeURX );
732 
733  endingY = intersectionPoints[positionEnd]->getY();
734 
735  // Build the vector of coordinates with the folowing structure:
736  // vector<pair<startcolumn, endcolumn>>;
737  // where each pair represents a stretch to be transversed
738 
739  if(
740  ( startingX != endingX )
741  &&
742  (
743  m_tileIndexer->withinOrTouches(te::gm::Point(
744  (startingX + (endingX - startingX) / 2.0 ),
745  (startingY +(endingY - startingY) / 2.0 ),
746  m_polygon->getSRID()))
747  )
748  )
749  {
750  // The middle-point (between the start end end point)
751  // inside the current polygon
752 
753  startingCol = (int)std::ceil( m_raster->getGrid()->geoToGrid(startingX, startingY).x );
754  startingCol = std::max( 0, startingCol );
755  startingCol = std::min( m_maxcolumns - 1, startingCol );
756 
757  endingCol = (int)std::floor( m_raster->getGrid()->geoToGrid(endingX, endingY).x );
758  endingCol = std::max( 0, endingCol );
759  endingCol = std::min( m_maxcolumns - 1, endingCol );
760 
761  if( endingCol >= startingCol )
762  {
763  m_columns.push_back(std::pair<int, int>(startingCol, endingCol));
764  }
765  }
766 
767  positionBegin = positionEnd;
768  }
769 
770  // deleting the intersections points
771 
772  positionBegin = 0;
773 
774  while ( positionBegin < intersectionPoints.size() )
775  {
776  delete intersectionPoints[positionBegin];
777  ++positionBegin;
778  }
779 
780  if (m_columns.empty())
781  {
782  m_row++;
783  if (m_row > m_endingrow)
784  {
785  setEnd();
786 
787  return;
788  }
789 
790  setNextLine();
791 
792  return;
793  }
794 
795  m_actualintersection = 0;
796 
797  m_nintersections = static_cast<int>(m_columns.size());
798  }
799 
800  m_startingcolumn = this->m_columns[m_actualintersection].first;
801  m_endingcolumn = this->m_columns[m_actualintersection].second;
802 
803  int tmp;
804  if (m_startingcolumn > m_endingcolumn)
805  {
806  tmp = m_startingcolumn;
807  m_startingcolumn = m_endingcolumn;
808  m_endingcolumn = tmp;
809  }
810 
811 // // avoiding bad access
812 // m_startingcolumn = m_startingcolumn < 0? 0: m_startingcolumn;
813 // m_startingcolumn = m_startingcolumn >= m_maxcolumns? m_maxcolumns - 1: m_startingcolumn;
814 //
815 // m_endingcolumn = m_endingcolumn < 0? 0: m_endingcolumn;
816 // m_endingcolumn = m_endingcolumn >= m_maxcolumns? m_maxcolumns - 1: m_endingcolumn;
817  }
818 
819  template<typename T> const std::vector<T> te::rst::PolygonIterator<T>::operator*() const
820  {
821  std::vector<T> values(this->m_raster->getNumberOfBands());
822  double value;
823 
824  for (unsigned int b = 0; b < this->m_raster->getNumberOfBands(); b++)
825  {
826  this->m_raster->getValue(getColumn(), getRow(), value, b);
827  values[b] = ((T) value);
828  }
829 
830  return values;
831  }
832 
833  template<typename T> T te::rst::PolygonIterator<T>::operator[](const unsigned int i) const
834  {
835  this->m_raster->getValue(m_column, m_row, m_operatorBrackets_value, i);
836 
837  return (T) m_operatorBrackets_value;
838  }
839 
840  template<typename T> std::complex< T > te::rst::PolygonIterator<T>::operator()(const unsigned int i) const
841  {
842  this->m_raster->getValue(m_column, m_row, m_operatorParenthesis_value, i);
843 
844  return (std::complex< T >) m_operatorParenthesis_value;
845  }
846 
847  template<typename T> unsigned int te::rst::PolygonIterator<T>::getRow() const
848  {
849  return m_row;
850  }
851 
852  template<typename T> unsigned int te::rst::PolygonIterator<T>::getColumn() const
853  {
854  return m_column;
855  }
856 
857  template<typename T> void te::rst::PolygonIterator<T>::operator++()
858  {
859  m_column++;
860 
861  if (m_column > m_endingcolumn)
862  {
863  m_actualintersection++;
864 
865  if (m_actualintersection >= m_nintersections)
866  m_row++;
867 
868  if (m_row > m_endingrow)
869  {
870  setEnd();
871 
872  return;
873  }
874 
875  setNextLine();
876 
877  m_column = m_startingcolumn;
878  }
879  }
880 
881  template<typename T> void te::rst::PolygonIterator<T>::operator--()
882  {
883  if (m_row == -1)
884  throw te::rst::Exception(TE_TR("This operation is not supported!"));
885  m_column--;
886 
887  if (m_column < m_startingcolumn)
888  {
889  m_actualintersection--;
890 
891  if (m_actualintersection < 0)
892  m_row--;
893 
894  if (m_row < m_startingrow)
895  {
896  setEnd();
897 
898  return;
899  }
900 
901  setNextLine();
902 
903  m_column = m_endingcolumn;
904  }
905  }
906 
907  template<typename T>
909  const te::rst::PolygonIterator<T>& rhs)
910  {
911  clear();
912 
913  if (this != &rhs)
914  {
916 
917  m_polygon = rhs.m_polygon;
918 
919  if( rhs.m_currline )
920  {
921  m_currline = (te::gm::Line*)rhs.m_currline->clone();
922  }
923 
924  m_column = rhs.m_column;
925  m_row = rhs.m_row;
926  m_startingcolumn = rhs.m_startingcolumn;
927  m_endingcolumn = rhs.m_endingcolumn;
928  m_startingrow = rhs.m_startingrow;
929  m_endingrow = rhs.m_endingrow;
930  m_maxcolumns = rhs.m_maxcolumns;
931  m_maxrows = rhs.m_maxrows;
932  m_actualintersection = rhs.m_actualintersection;
933  m_nintersections = rhs.m_nintersections;
934  }
935 
936  return *this;
937  }
938 
939  template<typename T>
942  {
943  return operator=( *((te::rst::PolygonIterator<T>*)&rhs) );
944  }
945 
946  template<typename T> void te::rst::PolygonIterator<T>::setEnd()
947  {
948  m_column = -1;
949  m_row = -1;
950  }
951 
953  {
954  return te::rst::PolygonIterator<T>(r, p);
955  }
956 
958  {
960 
961  it.setEnd();
962 
963  return it;
964  }
965 
966  template<typename T> bool te::rst::PolygonIterator<T>::operator!=(const te::rst::PolygonIterator<T>& rhs) const
967  {
968  return ( (this->m_row != rhs.m_row) && (this->m_column != rhs.m_column));
969  }
970 
971  template<typename T>
973  const AbstractPositionIterator<T>& rhs) const
974  {
975  return operator!=( *((te::rst::PolygonIterator<T>*)&rhs) );
976  }
977 
978  template<typename T> void te::rst::PolygonIterator<T>::clear()
979  {
980  m_polygon = 0;
981 
982  if( m_currline )
983  {
984  delete m_currline;
985  m_currline = 0;
986  }
987 
988  m_column = -1;
989  m_row = -1;
990  m_startingcolumn = 0;
991  m_endingcolumn = 0;
992  m_startingrow = 0;
993  m_endingrow = 0;
994  m_maxcolumns = 0;
995  m_maxrows = 0;
996  m_actualintersection = -1;
997  m_nintersections = 0;
998  }
999 
1000 // implementation of iteration strategy bounded by a line
1002  : m_raster(0),
1003  m_line(0),
1004  m_currentpixelindex(0),
1005  m_pixelsinline(0)
1006  {
1007  }
1008 
1010  : m_raster(r),
1011  m_line(l),
1012  m_currentpixelindex(0),
1013  m_pixelsinline(0)
1014  {
1015  if( r->getSRID() != l->getSRID() )
1016  {
1017  throw te::rst::Exception( TE_TR("Invalid line SRID") );
1018  }
1019 
1020  int srid = this->m_raster->getSRID();
1021 
1022 // make intersection between line and band's envelope
1023  te::gm::Geometry* bandEnvelope = te::gm::GetGeomFromEnvelope(this->m_raster->getExtent(), srid);
1024  te::gm::Geometry* inter = bandEnvelope->intersection(m_line);
1025 
1026  if (inter->isEmpty())
1027  {
1028  setEnd();
1029 
1030  return;
1031  }
1032 
1033 // create line that intersects only band's envelope
1034  te::gm::Line* inrasterline = (te::gm::Line*) inter;
1035 
1036 // find starting and ending points
1037  double startingcolumn;
1038  double startingrow;
1039  te::gm::Point* startpoint = inrasterline->getStartPoint();
1040  this->m_raster->getGrid()->geoToGrid(startpoint->getX(), startpoint->getY(),
1041  startingcolumn, startingrow);
1042 
1043  double endingcolumn;
1044  double endingrow;
1045  te::gm::Point* endpoint = inrasterline->getEndPoint();
1046  this->m_raster->getGrid()->geoToGrid(endpoint->getX(), endpoint->getY(),
1047  endingcolumn, endingrow);
1048 
1049 // creating one envelope per pixel, and intersects with line
1050  const double resXdiv2 = this->m_raster->getResolutionX() / 2;
1051  const double resYdiv2 = this->m_raster->getResolutionY() / 2;
1052  double x1, x2, y1, y2, geoX, geoY;
1053  for(int r = (int)startingrow; r <= (int)endingrow; r++)
1054  for(int c = (int)startingcolumn; c <= (int)endingcolumn; c++)
1055  {
1056 // define envelope of pixel
1057  this->m_raster->getGrid()->gridToGeo(c, r, geoX, geoY);
1058  x1 = geoX - resXdiv2; y1 = geoY - resYdiv2;
1059  x2 = geoX + resXdiv2; y2 = geoY + resYdiv2;
1060 
1061  te::gm::Envelope* pixelbox = new te::gm::Envelope(x1, y1, x2, y2);
1062  te::gm::Geometry* pixelboxgeometry = GetGeomFromEnvelope(pixelbox, srid);
1063 
1064  if (te::gm::SatisfySpatialRelation(inrasterline, pixelboxgeometry, te::gm::INTERSECTS))
1065  m_pixelsinline.push_back(new te::gm::Point(c, r, srid));
1066  }
1067 
1068  if (m_pixelsinline.empty())
1069  setEnd();
1070  }
1071 
1073  : m_raster(rhs.m_raster),
1074  m_currentpixelindex(rhs.m_currentpixelindex),
1075  m_pixelsinline(rhs.m_pixelsinline)
1076  {
1077  }
1078 
1080  {
1081  m_pixelsinline.clear();
1082  }
1083 
1084  template<typename T> const std::vector<T> te::rst::LineIterator<T>::operator*() const
1085  {
1086  std::vector<T> values(this->m_raster->getNumberOfBands());
1087  double value;
1088 
1089  for (unsigned int b = 0; b < this->m_raster->getNumberOfBands(); b++)
1090  {
1091  this->m_raster->getValue(getColumn(), getRow(), value, b);
1092  values[b] = ((T) value);
1093  }
1094 
1095  return values;
1096  }
1097 
1098  template<typename T> T te::rst::LineIterator<T>::operator[](const unsigned int i) const
1099  {
1100  this->m_raster->getValue(getColumn(), getRow(), m_operatorBrackets_value, i);
1101 
1102  return (T) m_operatorBrackets_value;
1103  }
1104 
1105  template<typename T> std::complex< T > te::rst::LineIterator<T>::operator()(const unsigned int i) const
1106  {
1107  this->m_raster->getValue(getColumn(), getRow(), m_operatorParenthesis_value, i);
1108 
1109  return (std::complex< T >) m_operatorParenthesis_value;
1110  }
1111 
1112  template<typename T> unsigned int te::rst::LineIterator<T>::getRow() const
1113  {
1114  return (unsigned int)(m_pixelsinline[m_currentpixelindex]->getY());
1115  }
1116 
1117  template<typename T> unsigned int te::rst::LineIterator<T>::getColumn() const
1118  {
1119  return (unsigned int)(m_pixelsinline[m_currentpixelindex]->getX());
1120  }
1121 
1122  template<typename T> void te::rst::LineIterator<T>::operator++()
1123  {
1124  m_currentpixelindex++;
1125 
1126  if (m_currentpixelindex >= (int)(m_pixelsinline.size()))
1127  setEnd();
1128  }
1129 
1130  template<typename T> void te::rst::LineIterator<T>::operator--()
1131  {
1132  m_currentpixelindex--;
1133 
1134  if (m_currentpixelindex < 0)
1135  setEnd();
1136  }
1137 
1139  {
1140  if (this != &rhs)
1141  {
1143 
1144  m_line = rhs.m_line;
1145  m_currentpixelindex = rhs.m_currentpixelindex;
1146  m_pixelsinline = rhs.m_pixelsinline;
1147  }
1148 
1149  return *this;
1150  }
1151 
1152  template<typename T>
1154  const AbstractPositionIterator<T>& rhs)
1155  {
1156  return operator=( *((LineIterator<T>*)&rhs) );
1157  }
1158 
1159  template<typename T> void te::rst::LineIterator<T>::setEnd()
1160  {
1161  this->m_currentpixelindex = -1;
1162  }
1163 
1165  {
1166  return te::rst::LineIterator<T>(r, l);
1167  }
1168 
1170  {
1171  te::rst::LineIterator<T> it(r, l);
1172 
1173  it.setEnd();
1174 
1175  return it;
1176  }
1177 
1178  template<typename T> bool te::rst::LineIterator<T>::operator!=(const te::rst::LineIterator<T>& rhs) const
1179  {
1180  return ( (this->m_currentpixelindex != rhs.m_currentpixelindex) );
1181  }
1182 
1183  template<typename T>
1185  const AbstractPositionIterator<T>& rhs) const
1186  {
1187  return operator!=( *((te::rst::LineIterator<T>*)&rhs) );
1188  }
1189 
1190 // implementation of iteration strategy bounded by a vector of points
1192  : m_raster(0),
1193  m_pixelsinpointset(0),
1194  m_currentpixelindex(0)
1195  {
1196  }
1197 
1198  template<typename T> te::rst::PointSetIterator<T>::PointSetIterator(const te::rst::Raster* r, const std::vector<te::gm::Point*> p)
1199  : m_raster(r),
1200  m_pixelsinpointset(p),
1201  m_currentpixelindex(0)
1202  {
1203  const int rasterSRID = this->m_raster->getSRID();
1204 
1205  const te::gm::Envelope* rasterbox = r->getExtent();
1206  te::gm::Geometry* rasterboxgeometry = GetGeomFromEnvelope(rasterbox, rasterSRID);
1207 
1208 // remove points that are not inside the band's envelope
1209  std::vector<te::gm::Point*> inside_points;
1210  double column;
1211  double row;
1212  for (unsigned int i = 0; i < m_pixelsinpointset.size(); i++)
1213  {
1214  if( rasterSRID != m_pixelsinpointset[i]->getSRID() )
1215  {
1216  throw te::rst::Exception( TE_TR("Invalid point SRID") );
1217  }
1218 
1220  {
1221  this->m_raster->getGrid()->geoToGrid(m_pixelsinpointset[i]->getX(), m_pixelsinpointset[i]->getY(), column, row);
1222 
1223  inside_points.push_back(new te::gm::Point(column, row));
1224  }
1225  }
1226 
1227  m_pixelsinpointset.clear();
1228  m_pixelsinpointset = inside_points;
1229 
1230  if (m_pixelsinpointset.empty())
1231  setEnd();
1232  }
1233 
1235  : m_raster(rhs.m_raster),
1236  m_pixelsinpointset(rhs.m_pixelsinpointset),
1237  m_currentpixelindex(rhs.m_currentpixelindex)
1238  {
1239  }
1240 
1242  {
1243  m_pixelsinpointset.clear();
1244  }
1245 
1246  template<typename T> const std::vector<T> te::rst::PointSetIterator<T>::operator*() const
1247  {
1248  std::vector<T> values(this->m_raster->getNumberOfBands());
1249  double value;
1250 
1251  for (unsigned int b = 0; b < this->m_raster->getNumberOfBands(); b++)
1252  {
1253  this->m_raster->getValue(getColumn(), getRow(), value, b);
1254  values[b] = ((T) value);
1255  }
1256 
1257  return values;
1258  }
1259 
1260  template<typename T> T te::rst::PointSetIterator<T>::operator[](const unsigned int i) const
1261  {
1262  this->m_raster->getValue(getColumn(), getRow(), m_operatorBrackets_value, i);
1263 
1264  return (T) m_operatorBrackets_value;
1265  }
1266 
1267  template<typename T> std::complex< T > te::rst::PointSetIterator<T>::operator()(const unsigned int i) const
1268  {
1269  this->m_raster->getValue(getColumn(), getRow(), m_operatorParenthesis_value, i);
1270 
1271  return (std::complex< T >) m_operatorParenthesis_value;
1272  }
1273 
1274  template<typename T> unsigned int te::rst::PointSetIterator<T>::getRow() const
1275  {
1276  return (unsigned int)(m_pixelsinpointset[m_currentpixelindex]->getY());
1277  }
1278 
1279  template<typename T> unsigned int te::rst::PointSetIterator<T>::getColumn() const
1280  {
1281  return (unsigned int)(m_pixelsinpointset[m_currentpixelindex]->getX());
1282  }
1283 
1284  template<typename T> void te::rst::PointSetIterator<T>::operator++()
1285  {
1286  m_currentpixelindex++;
1287 
1288  if (m_currentpixelindex >= (int) m_pixelsinpointset.size())
1289  setEnd();
1290  }
1291 
1292  template<typename T> void te::rst::PointSetIterator<T>::operator--()
1293  {
1294  m_currentpixelindex--;
1295 
1296  if (m_currentpixelindex < 0)
1297  setEnd();
1298  }
1299 
1301  {
1302  if (this != &rhs)
1303  {
1305 
1306  m_pixelsinpointset = rhs.m_pixelsinpointset;
1307  m_currentpixelindex = rhs.m_currentpixelindex;
1308  }
1309 
1310  return *this;
1311  }
1312 
1313  template<typename T>
1315  const AbstractPositionIterator<T>& rhs)
1316  {
1317  return operator=( *((te::rst::PointSetIterator<T>*)&rhs) );
1318  }
1319 
1320  template<typename T> void te::rst::PointSetIterator<T>::setEnd()
1321  {
1322  this->m_currentpixelindex = -1;
1323  }
1324 
1325  template<typename T> te::rst::PointSetIterator<T> te::rst::PointSetIterator<T>::begin(const te::rst::Raster* r, const std::vector<te::gm::Point*> p)
1326  {
1327  return te::rst::PointSetIterator<T>(r, p);
1328  }
1329 
1330  template<typename T> te::rst::PointSetIterator<T> te::rst::PointSetIterator<T>::end(const te::rst::Raster* r, const std::vector<te::gm::Point*> p)
1331  {
1333 
1334  it.setEnd();
1335 
1336  return it;
1337  }
1338 
1340  {
1341  return ( (this->m_currentpixelindex != rhs.m_currentpixelindex) );
1342  }
1343 
1344  template<typename T>
1346  const AbstractPositionIterator<T>& rhs) const
1347  {
1348  return operator!=( *((te::rst::PointSetIterator<T>*)&rhs) );
1349  }
1350 
1351  } // end namespace rst
1352 } // end namespace te
1353 
1354 #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...
unsigned int getNumberOfRows() const
Returns the grid number of rows.
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.
Definition: Geometry.h:239
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
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.
Polygon tile indexing class for optmized geometrical relational tests.
Definition: TileIndexer.h:54
A Line is LineString with 2 points.
Definition: Line.h:50
double y
y-coordinate.
Definition: Coord2D.h:114
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.
virtual bool operator!=(const AbstractPositionIterator< T > &rhs) const =0
Difference operator.
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.
double x
x-coordinate.
Definition: Coord2D.h:113
std::complex< double > m_operatorParenthesis_value
Used by the operator() method.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
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...
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
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.
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
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.
bool StdSortPointPointerComparison(te::gm::Point *p1, te::gm::Point *p2)
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.
Definition: Coord2D.h:40
bool operator!=(const PointSetIterator< T > &rhs) const
void operator++()
Advances to the next position.
TEDATAACCESSEXPORT te::da::Expression * operator!=(const te::da::Expression &e1, const te::da::Expression &e2)
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.
Definition: Translator.h:243
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...
double getResolutionY() const
Returns the grid vertical (y-axis) resolution.
int m_endingcolumn
The column (in current line) to finalize the iteration.
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.
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
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.
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
const te::rst::Raster * m_raster
The band from where to get the values.
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 te::rst::Raster * m_raster
The band from where to get the values.
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
An abstract class for raster data strucutures.
Definition: Raster.h:71
const te::rst::Raster * m_raster
The band from where to get the values.
URI C++ Library.
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.
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.
virtual const std::vector< T > operator*() const =0
Returns a vector of the values in current position (column, row) from iterator.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
void operator--()
Returns to the previous position.
Point * getEndPoint() const
It returns the curve end point.
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
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.
virtual ~AbstractPositionIterator()
Destructor.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
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.
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
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.
unsigned int getColumn() const
Returns the current column in iterator.
std::complex< double > m_operatorParenthesis_value
static LineIterator end(const te::rst::Raster *r, const te::gm::Line *l)
Returns an iterator referring to after the end of the iterator.
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.
std::vector< std::pair< int, int > > m_columns
Coordinates of the columns to be transversed.
TEGEOMEXPORT void Multi2Single(te::gm::Geometry *g, std::vector< te::gm::Geometry * > &geoms)
It will get a GeometryCollection and distribute in a vector.
virtual unsigned int getRow() const =0
Returns the current row in iterator.
std::vector< std::pair< unsigned int, unsigned int > > TileSegIndex
Definition: TileIndexer.h:58
#define TE_LOG_WARN(message)
Use this tag in order to log a message to the TerraLib default logger with the WARN level...
Definition: Logger.h:327
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.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
virtual AbstractPositionIterator< T > & operator=(const AbstractPositionIterator< T > &rhs)
Assignment operator.
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.
Definition: Point.h:138
std::unique_ptr< te::rst::TileIndexer > m_tileIndexer
Tile indexer used to optimize the geometric operations.
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.