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  /*! \enum BlendMethod Pixel Blend methods. */
162  {
163  ScanLineIterationT, //!< Scan line iteration type.
164  NDisjointBBOXIterationT, //!< Itaration over pixels whose bounding boxes are not disjoint in relation with the polygon.
165  DisjointBBOXIterationT //!< Itaration over pixels whose bounding boxes are disjoint in relation with the polygon.
166  };
167 
168  PolygonIterator();
169 
170  /*!
171  \brief Constructor.
172 
173  \param b The band to iterate.
174  \param p The polygon from where the iteration will navigate.
175  \param iterationType Iteration type.
176  \note Both raster and polygon must have the same SRID.
177  */
179  const IterationType iterationType );
180 
181  /*!
182  \brief Constructor.
183 
184  \param b The band to iterate.
185  \param p The polygon from where the iteration will navigate.
186  \note Both raster and polygon must have the same SRID.
187  \note Iteration type: ScanLineIterationT.
188  */
189  PolygonIterator(const te::rst::Raster* r, const te::gm::Polygon* p);
190 
191  /*!
192  \brief Copy constructor.
193 
194  \param rhs The right-hand-side copy used to copy from.
195  */
196  PolygonIterator(const PolygonIterator& rhs);
197 
199 
200  const std::vector<T> operator*() const;
201 
202  T operator[](const unsigned int i) const;
203 
204  std::complex< T > operator()(const unsigned int i) const;
205 
206  unsigned int getRow() const;
207 
208  unsigned int getColumn() const;
209 
210  void operator++();
211 
212  void operator--();
213 
215 
217 
218  void setEnd();
219 
220  /*! \brief Returns an iterator referring to the first value of the band.*/
221  static PolygonIterator begin(const te::rst::Raster* r, const te::gm::Polygon* p,
222  const IterationType iterationType );
223 
224  /*! \brief Returns an iterator referring to the first value of the band.*/
225  static PolygonIterator begin(const te::rst::Raster* r, const te::gm::Polygon* p);
226 
227  /*! \brief Returns an iterator referring to after the end of the iterator. */
228  static PolygonIterator end(const te::rst::Raster* r, const te::gm::Polygon* p);
229 
230  /*! \brief Returns an iterator referring to after the end of the iterator. */
231  static PolygonIterator end(const te::rst::Raster* r, const te::gm::Polygon* p,
232  const IterationType iterationType );
233 
234  bool operator!=(const PolygonIterator<T>& rhs) const;
235 
236  bool operator!=(const AbstractPositionIterator<T>& rhs) const;
237 
238  protected:
239 
240  const te::rst::Raster* m_raster; //!< The band from where to get the values (default 0).
241  const te::gm::Polygon* m_polygon; //!< The spatial restriction to be applied in the iterator (default 0).
242  IterationType m_iterationType; //!< Current iteration type (default ScanLineIterationT).
243  int m_totalRasterColumns; //!< The number of columns in band (default: 0).
244  int m_totalRasterRows; //!< The number of rows in band (default: 0).
245  int m_polygonStartingColumn; //!< Polygon first raster column (default: -1).
246  int m_polygonEndingColumn; //!< Polygon last raster column (default: -1).
247  int m_polygonStartingRow; //!< Polygon first raster row (default: -1).
248  int m_polygonEndingRow;//!< Polygon last raster row (default: -1).
249 
250  int m_column; //!< The current column of the iterator (default -1).
251  int m_row; //!< The current row of the iterator (default -1).
252  int m_currentRangeStartingColumn; //!< The current line iteration range starting column (default: -1).
253  int m_currentRangeEndingColumn; //!< The current line iteration range column to finalize the iteration (default: -1).
254  int m_currentLineIntersectionRangesIndex; //!< The actual line of the iterator (default -1).
255  std::unique_ptr<te::rst::TileIndexer> m_tileIndexerPtr; //!< Tile indexer used to optimize the geometric operations
256  std::vector<std::pair<int, int> > m_currentLineIntersectionRanges; //!< Coordinates of the columns to be transversed
257 
258  // Variables used by the operator[] method.
259  mutable double m_operatorBrackets_value;
260  mutable std::complex< double > m_operatorParenthesis_value;
261 
262  /*! \brief Initialize all internal variables to initial states. */
263  void initiateVariables();
264 
265  /*! \brief Clear all internal allocated objects and reset back to the initial state. */
266  void clear();
267 
268  /*!
269  \brief Returns the given line intersection ranges (Coordinates of the columns to be transversed) using the current iteration type.
270  \param lineIndex Line index.
271  \param intersectionRanges Line intersection ranges (first:initial column, second:ending column) or an empty vector if no intersections exist.
272  */
273  void getIntersectionRanges( int lineIndex,
274  std::vector<std::pair<int, int> >& intersectionRanges ) const;
275 
276  /*!
277  \brief Returns the given line intersection ranges (Coordinates of the columns to be transversed) using the ScanLineIterationT mode.
278  \param lineIndex Line index.
279  \param intersectionRanges Line intersection ranges (first:initial column, second:ending column) or an empty vector if no intersections exist.
280  */
281  void getScanLineIntersectionRanges( int lineIndex,
282  std::vector<std::pair<int, int> >& intersectionRanges ) const;
283 
284  /*!
285  \brief Returns the given line intersection ranges using the pixel bounding box as reference.
286  \param lineIndex Line index.
287  \param areDisjoint If true, returns only thos pixels disjoint with the polygon, otherwise returns those pixels not disjoint with the polygon.
288  \param intersectionRanges Line intersection ranges (first:initial column, second:ending column) or an empty vector if no intersections exist.
289  */
290  void getBBOXIntersectionRanges( int lineIndex, const bool areDisjoint,
291  std::vector<std::pair<int, int> >& intersectionRanges ) const;
292 
293 
294  /*!
295  \brief Initialize this instance.
296 
297  \param r The raster to iterate.
298  \param p The polygon from where the iteration will navigate.
299  \param iterationType The iteration type
300  \note Both raster and polygon must have the same SRID.
301  */
302  bool initialize(const te::rst::Raster* r, const te::gm::Polygon* p,
303  const IterationType iterationType );
304 
305  /*!
306  \brief It will get a GeometryCollection and distribute in a vector.
307  \param g Input GeometryCollection.
308  \param geoms Output Geometry Vector.
309  \note If the geomSource is not a te::gm::GeometryCollectionType it will return vector with the input geometry.
310  \note Do not delete de returned pointers since they point to parts of the original input geometry.
311  */
312  void breakIntoSingleGeoms( te::gm::Geometry const * const g,
313  std::vector< te::gm::Geometry const * >& geoms) const;
314 
315  };
316 
317  /*!
318  \class LineIterator
319 
320  \brief This class implements the strategy to iterate with spatial restriction,
321  the iteration occurs inside a line.
322 
323  \ingroup rst
324  */
325  template<typename T> class LineIterator: public AbstractPositionIterator<T>
326  {
327  public:
328 
329  LineIterator();
330 
331  /*!
332  \brief Constructor.
333 
334  \param b The band to iterate.
335  \param l The line from where the iteration will navigate.
336  */
337  LineIterator(const te::rst::Raster* r, const te::gm::Line* l);
338 
339  /*!
340  \brief Copy constructor.
341 
342  \param rhs The right-hand-side copy used to copy from.
343  */
344  LineIterator(const LineIterator& rhs);
345 
346  ~LineIterator();
347 
348  const std::vector<T> operator*() const;
349 
350  T operator[](const unsigned int i) const;
351 
352  std::complex< T > operator()(const unsigned int i) const;
353 
354  unsigned int getRow() const;
355 
356  unsigned int getColumn() const;
357 
358  void operator++();
359 
360  void operator--();
361 
362  LineIterator& operator=(const LineIterator& rhs);
363 
365 
366  void setEnd();
367 
368  /*! \brief Returns an iterator referring to the first value of the band.*/
369  static LineIterator begin(const te::rst::Raster* r, const te::gm::Line* l);
370 
371  /*! \brief Returns an iterator referring to after the end of the iterator. */
372  static LineIterator end(const te::rst::Raster* r, const te::gm::Line* l);
373 
374  bool operator!=(const LineIterator<T>& rhs) const;
375 
376  bool operator!=(const AbstractPositionIterator<T>& rhs) const;
377 
378  protected:
379 
380  const te::rst::Raster* m_raster; //!< The band from where to get the values.
381  const te::gm::Line* m_line; //!< The spatial restriction to be applied in the iterator.
382  int m_currentpixelindex; //!< The index of the current pixel location.
383  std::vector<te::gm::Point*> m_pixelsinline; //!< A vector of pixel locations that intersects the line.
384  mutable double m_operatorBrackets_value; //!< Used by the operator[] method.
385  mutable std::complex< double > m_operatorParenthesis_value; //!< Used by the operator() method.
386 
387 
388  };
389 
390  /*!
391  \class PointSetIterator
392 
393  \brief This class implements the strategy to iterate with spatial restriction,
394  the iteration occurs inside a vector of points.
395 
396  \ingroup rst
397  */
398  template<typename T> class PointSetIterator: public AbstractPositionIterator<T>
399  {
400  public:
401 
403 
404  /*!
405  \brief Constructor.
406 
407  \param b The band to iterate.
408  \param p The vector of points where the iteration will navigate.
409  */
410  PointSetIterator(const te::rst::Raster* r, const std::vector<te::gm::Point*> p);
411 
412  /*!
413  \brief Copy constructor.
414 
415  \param rhs The right-hand-side copy used to copy from.
416  */
418 
420 
421  const std::vector<T> operator*() const;
422 
423  T operator[](const unsigned int i) const;
424 
425  std::complex< T > operator()(const unsigned int i) const;
426 
427  unsigned int getRow() const;
428 
429  unsigned int getColumn() const;
430 
431  void operator++();
432 
433  void operator--();
434 
436 
438 
439  void setEnd();
440 
441  /*! \brief Returns an iterator referring to the first value of the band.*/
442  static PointSetIterator begin(const te::rst::Raster* r, const std::vector<te::gm::Point*> p);
443 
444  /*! \brief Returns an iterator referring to after the end of the iterator. */
445  static PointSetIterator end(const te::rst::Raster* r, const std::vector<te::gm::Point*> p);
446 
447  bool operator!=(const PointSetIterator<T>& rhs) const;
448 
449  bool operator!=(const AbstractPositionIterator<T>& rhs) const;
450 
451  protected:
452 
453  const te::rst::Raster* m_raster; //!< The band from where to get the values.
454  std::vector<te::gm::Point*> m_pixelsinpointset; //!< The spatial restriction to be applied in the iterator.
455  int m_currentpixelindex; //!< The index of the current pixel location.
456  mutable double m_operatorBrackets_value; //!< Used by the operator[] method.
457  mutable std::complex< double > m_operatorParenthesis_value; //!< Used by the operator() method.
458 
459 
460  };
461 
462  // ------------------------------------------------------------------------
463 
464 // implementation of abstract position iterator
465 
467  {
468  }
469 
471  {
472  }
473 
475  {
476  }
477 
478  template<typename T>
481  {
482  return *this;
483  }
484 
485  // ------------------------------------------------------------------------
486 
487 // implementation of iteration strategy bounded by a polygon
489  {
490  initiateVariables();
491  }
492 
494  const te::rst::Raster* r, const te::gm::Polygon* p,
495  const IterationType iterationType)
496  {
497  initiateVariables();
498 
499  if( ! initialize( r, p, iterationType ) )
500  {
501  throw te::rst::Exception( TE_TR("Iterator initialization error") );
502  }
503  }
504 
506  {
507  initiateVariables();
508 
509  if( ! initialize( r, p, ScanLineIterationT ) )
510  {
511  throw te::rst::Exception( TE_TR("Iterator initialization error") );
512  }
513  }
514 
516  {
517  initiateVariables();
518  operator=( rhs );
519  }
520 
522  {
523  clear();
524  }
525 
526  template<typename T> const std::vector<T> te::rst::PolygonIterator<T>::operator*() const
527  {
528  std::vector<T> values( m_raster->getNumberOfBands());
529  double value;
530 
531  for (unsigned int b = 0; b < this->m_raster->getNumberOfBands(); b++)
532  {
533  m_raster->getValue( m_column, m_row, value, b);
534  values[b] = ((T) value);
535  }
536 
537  return values;
538  }
539 
540  template<typename T> T te::rst::PolygonIterator<T>::operator[](const unsigned int i) const
541  {
542  this->m_raster->getValue(m_column, m_row, m_operatorBrackets_value, i);
543 
544  return (T) m_operatorBrackets_value;
545  }
546 
547  template<typename T> std::complex< T > te::rst::PolygonIterator<T>::operator()(const unsigned int i) const
548  {
549  this->m_raster->getValue(m_column, m_row, m_operatorParenthesis_value, i);
550 
551  return (std::complex< T >) m_operatorParenthesis_value;
552  }
553 
554  template<typename T> unsigned int te::rst::PolygonIterator<T>::getRow() const
555  {
556  return m_row;
557  }
558 
559  template<typename T> unsigned int te::rst::PolygonIterator<T>::getColumn() const
560  {
561  return m_column;
562  }
563 
564  template<typename T> void te::rst::PolygonIterator<T>::operator++()
565  {
566  if( m_column < m_currentRangeEndingColumn )
567  {
568  ++m_column;
569  }
570  else
571  {
572  if ( ( m_currentLineIntersectionRangesIndex + 1 ) < (int)( m_currentLineIntersectionRanges.size() ) )
573  {
574  ++m_currentLineIntersectionRangesIndex;
575  m_column = m_currentRangeStartingColumn = m_currentLineIntersectionRanges[ m_currentLineIntersectionRangesIndex ].first;
576  m_currentRangeEndingColumn = m_currentLineIntersectionRanges[ m_currentLineIntersectionRangesIndex ].second;
577  }
578  else
579  {
580  if( m_row < m_polygonEndingRow )
581  {
582  m_currentLineIntersectionRanges.clear();
583 
584  while( m_row <= m_polygonEndingRow )
585  {
586  ++m_row;
587 
588  getIntersectionRanges( m_row, m_currentLineIntersectionRanges );
589 
590  if( ! m_currentLineIntersectionRanges.empty() )
591  {
592  break;
593  }
594  }
595 
596  if( m_currentLineIntersectionRanges.empty() )
597  {
598  setEnd();
599  }
600  else
601  {
602  m_column = m_currentRangeStartingColumn = m_currentLineIntersectionRanges[ 0 ].first;
603  m_currentRangeEndingColumn = m_currentLineIntersectionRanges[ 0 ].second;
604  m_currentLineIntersectionRangesIndex = 0;
605  }
606  }
607  else
608  {
609  setEnd();
610  }
611  }
612  }
613  }
614 
615  template<typename T> void te::rst::PolygonIterator<T>::operator--()
616  {
617  if(m_column > m_currentRangeStartingColumn )
618  {
619  --m_column;
620  }
621  else
622  {
623  if( m_currentLineIntersectionRangesIndex > 0 )
624  {
625  --m_currentLineIntersectionRangesIndex;
626  m_currentRangeStartingColumn = m_currentLineIntersectionRanges[ m_currentLineIntersectionRangesIndex ].first;
627  m_column = m_currentRangeEndingColumn = m_currentLineIntersectionRanges[ m_currentLineIntersectionRangesIndex ].second;
628  }
629  else
630  {
631  if( m_row > m_polygonStartingRow )
632  {
633  m_currentLineIntersectionRanges.clear();
634 
635  while( m_row >= m_polygonStartingRow )
636  {
637  --m_row;
638 
639  getIntersectionRanges( m_row, m_currentLineIntersectionRanges );
640 
641  if( ! m_currentLineIntersectionRanges.empty() )
642  {
643  break;
644  }
645  }
646 
647  if( m_currentLineIntersectionRanges.empty() )
648  {
649  setEnd();
650  }
651  else
652  {
653  m_currentLineIntersectionRangesIndex = static_cast<int>(m_currentLineIntersectionRanges.size()) - 1;
654  m_currentRangeStartingColumn = m_currentLineIntersectionRanges[ m_currentLineIntersectionRangesIndex ].first;
655  m_column = m_currentRangeEndingColumn = m_currentLineIntersectionRanges[ m_currentLineIntersectionRangesIndex ].second;
656  }
657  }
658  else
659  {
660  setEnd();
661  }
662  }
663  }
664  }
665 
666  template<typename T>
668  const te::rst::PolygonIterator<T>& rhs)
669  {
670  clear();
671 
672  if (this != &rhs)
673  {
675 
676  m_raster = rhs.m_raster;
677  m_polygon = rhs.m_polygon;
678  m_iterationType = rhs.m_iterationType;
679  m_totalRasterColumns = rhs.m_totalRasterColumns;
680  m_totalRasterRows = rhs.m_totalRasterRows;
681  m_polygonStartingColumn = rhs.m_polygonStartingColumn;
682  m_polygonEndingColumn = rhs.m_polygonEndingColumn;
683  m_polygonStartingRow = rhs.m_polygonStartingRow;
684  m_polygonEndingRow = rhs.m_polygonEndingRow;
685 
686  m_column = rhs.m_column;
687  m_row = rhs.m_row;
688  m_currentRangeStartingColumn = rhs.m_currentRangeStartingColumn;
689  m_currentRangeEndingColumn = rhs.m_currentRangeEndingColumn;
690  m_currentLineIntersectionRangesIndex = rhs.m_currentLineIntersectionRangesIndex;
691 
692  if( rhs.m_tileIndexerPtr.get() )
693  {
694  m_tileIndexerPtr.reset(rhs.m_tileIndexerPtr->clone());
695  }
696 
697  m_currentLineIntersectionRanges = rhs.m_currentLineIntersectionRanges;
698  }
699 
700  return *this;
701  }
702 
703  template<typename T>
706  {
707  return operator=( *((te::rst::PolygonIterator<T>*)&rhs) );
708  }
709 
710  template<typename T> void te::rst::PolygonIterator<T>::setEnd()
711  {
712  m_column = -1;
713  m_row = -1;
714  }
715 
717  const te::rst::Raster* r, const te::gm::Polygon* p, const IterationType iterationType )
718  {
719  return te::rst::PolygonIterator<T>(r, p, iterationType);
720  }
721 
723  {
724  return te::rst::PolygonIterator<T>(r, p);
725  }
726 
728  const te::rst::Raster* r, const te::gm::Polygon* p, const IterationType iterationType)
729  {
730  te::rst::PolygonIterator<T> it(r, p, iterationType);
731 
732  it.setEnd();
733 
734  return it;
735  }
736 
738  {
740 
741  it.setEnd();
742 
743  return it;
744  }
745 
746  template<typename T> bool te::rst::PolygonIterator<T>::operator!=(const te::rst::PolygonIterator<T>& rhs) const
747  {
748  return ( (this->m_row != rhs.m_row) && (this->m_column != rhs.m_column));
749  }
750 
751  template<typename T>
753  const AbstractPositionIterator<T>& rhs) const
754  {
755  return operator!=( *((te::rst::PolygonIterator<T>*)&rhs) );
756  }
757 
759  {
760  m_raster = 0;
761  m_polygon = 0;
762  m_iterationType = ScanLineIterationT;
763  m_totalRasterColumns = 0;
764  m_totalRasterRows = 0;
765  m_polygonStartingColumn = -1;
766  m_polygonEndingColumn = -1;
767  m_polygonStartingRow = -1;
768  m_polygonEndingRow = -1;
769 
770  m_column = -1;
771  m_row = -1;
772  m_currentRangeStartingColumn = -1;
773  m_currentRangeEndingColumn = -1;
774  m_currentLineIntersectionRangesIndex = -1;
775  }
776 
777  template<typename T> void te::rst::PolygonIterator<T>::clear()
778  {
779  m_tileIndexerPtr.reset();
780  m_currentLineIntersectionRanges.clear();
781 
782  initiateVariables();
783  }
784 
785  template<typename T>
787  std::vector<std::pair<int, int> >& intersectionRanges ) const
788  {
789  switch( m_iterationType )
790  {
791  case ScanLineIterationT :
792  {
793  getScanLineIntersectionRanges( lineIndex, intersectionRanges );
794  break;
795  }
796  case NDisjointBBOXIterationT :
797  {
798  getBBOXIntersectionRanges( lineIndex, false, intersectionRanges );
799  break;
800  }
801  case DisjointBBOXIterationT :
802  {
803  getBBOXIntersectionRanges( lineIndex, true, intersectionRanges );
804  break;
805  }
806  default :
807  {
808  throw te::rst::Exception( TE_TR("Invalid iteration type") );
809  break;
810  }
811  }
812  }
813 
814  template<typename T>
816  std::vector<std::pair<int, int> >& intersectionRanges ) const
817  {
818  intersectionRanges.clear();
819 
820  // Globals
821 
822  const double& rasterEnvelopeLLX =
823  m_raster->getGrid()->getExtent()->m_llx;
824  const double& rasterEnvelopeURX =
825  m_raster->getGrid()->getExtent()->m_urx;
826 
827  // current line
828 
829  const double lineY = this->m_raster->getGrid()->gridToGeo(0, (double)lineIndex).y;
830 
831  te::gm::Line currline( te::gm::Point( m_polygon->getSRID() ),
832  te::gm::Point( m_polygon->getSRID() ), te::gm::LineStringType,
833  m_polygon->getSRID() );
834 
835  currline.setX(0, std::min(
836  rasterEnvelopeLLX,
837  m_polygon->getMBR()->getLowerLeft().x) );
838  currline.setY(0, lineY);
839 
840  currline.setX(1, std::max(
841  rasterEnvelopeURX,
842  m_polygon->getMBR()->getUpperRight().x ) );
843  currline.setY(1, lineY);
844 
845  // Vector to store the points where the current line intersects the current tile of the polygon
846  std::vector<te::gm::Point*> intersectionPoints;
847 
848  // Retrieve the tile corresponding to the current line and store the points where the line
849  // intersects the tile
850 
851  te::rst::TileIndexer::TileSegIndex* currentTilePtr = 0;
852 
853  if(
854  m_tileIndexerPtr->getTile(currline.getY(0), &currentTilePtr)
855  &&
856  ( currentTilePtr != 0 )
857  )
858  {
859  te::gm::LinearRing const* ringTile;
860  std::unique_ptr<te::gm::Line> tileSeg;
861  std::unique_ptr< te::gm::Geometry > interResultPtr;
862  std::vector< te::gm::Geometry const* > singleGeomsPtrs;
863  std::size_t singleGeomsPtrsIdx = 0;
864 
865  try
866  {
867  // in some cases the intersection presents an unhandled exception, in this case we do not paint the current line
868  // Transverse the segments of the tile retrieving the intersection between them and the current line
869 
870  te::gm::LineString* lineStrPtr = 0;
871 
872  for (std::size_t i = 0; i < currentTilePtr->size(); i++)
873  {
874  assert((*currentTilePtr)[i].first < m_polygon->getNumRings());
875 
876  // Retrieve the current ring of the current tile
877  assert(dynamic_cast<te::gm::LinearRing const*>((*m_polygon)[(*currentTilePtr)[i].first]));
878  ringTile = (te::gm::LinearRing const*)(*m_polygon)[(*currentTilePtr)[i].first];
879 
880  assert((*currentTilePtr)[i].second < m_polygon->getNPoints());
881 
882  // Retrieve the current segment of the current tile
883  tileSeg.reset(new te::gm::Line(te::gm::Point(ringTile->getX((*currentTilePtr)[i].second),
884  ringTile->getY((*currentTilePtr)[i].second),
885  ringTile->getSRID()),
886  te::gm::Point(ringTile->getX((*currentTilePtr)[i].second + 1),
887  ringTile->getY((*currentTilePtr)[i].second + 1),
888  ringTile->getSRID()),
889  te::gm::LineStringType, ringTile->getSRID()));
890 
891  // Computes the intersection point between the current segment and the current line
892 
893  interResultPtr.reset( tileSeg->intersection( &currline ) );
894 
895  if( interResultPtr.get() != 0 )
896  {
897  singleGeomsPtrs.clear();
898  breakIntoSingleGeoms( interResultPtr.get(), singleGeomsPtrs );
899 
900  for( singleGeomsPtrsIdx = 0 ; singleGeomsPtrsIdx < singleGeomsPtrs.size() ;
901  ++singleGeomsPtrsIdx )
902  {
903  if( singleGeomsPtrs[ singleGeomsPtrsIdx ]->getGeomTypeId() ==
905  {
906  intersectionPoints.push_back( (te::gm::Point*)(
907  singleGeomsPtrs[ singleGeomsPtrsIdx ]->clone() ) );
908  }
909  else if( singleGeomsPtrs[ singleGeomsPtrsIdx ]->getGeomTypeId() ==
911  {
912  lineStrPtr = ((te::gm::LineString*) singleGeomsPtrs[
913  singleGeomsPtrsIdx ]);
914 
915  if( lineStrPtr->size() > 1 )
916  {
917  intersectionPoints.push_back( lineStrPtr->getStartPoint().release() );
918  intersectionPoints.push_back( lineStrPtr->getEndPoint().release() );
919  }
920  }
921  }
922  }
923  }
924  }
925  catch(const std::exception& e)
926  {
927  TE_LOG_WARN( "Geometry intersection error:" + e.what() );
928 
929  // deleting the intersections points
930 
931  for( std::size_t intersectionPointsIdx = 0; intersectionPointsIdx <
932  intersectionPoints.size() ; ++intersectionPointsIdx )
933  {
934  delete intersectionPoints[intersectionPointsIdx];
935  }
936 
937  intersectionPoints.clear();
938  }
939  catch(...)
940  {
941  TE_LOG_WARN( "Geometry intersection error" );
942 
943  // deleting the intersections points
944 
945  for( std::size_t intersectionPointsIdx = 0; intersectionPointsIdx <
946  intersectionPoints.size() ; ++intersectionPointsIdx )
947  {
948  delete intersectionPoints[intersectionPointsIdx];
949  }
950 
951  intersectionPoints.clear();
952  }
953  }
954 
955  // Removing duplicated points
956 
957  {
958  std::size_t positionBegin = 0;
959  std::size_t positionEnd = 0;
960  std::vector<te::gm::Point*> intersectionPointsAux = intersectionPoints;
961 
962  intersectionPoints.clear();
963 
964  while( positionBegin < intersectionPointsAux.size() )
965  {
966  if( intersectionPointsAux[positionBegin] )
967  {
968  positionEnd = positionBegin + 1;
969 
970  while( positionEnd < intersectionPointsAux.size() )
971  {
972  if(
973  ( intersectionPointsAux[positionEnd] != 0 )
974  &&
975  intersectionPointsAux[positionBegin]->equals(
976  intersectionPointsAux[positionEnd], true)
977  )
978  {
979  delete intersectionPointsAux[positionEnd];
980  intersectionPointsAux[positionEnd] = 0;
981  }
982 
983  positionEnd++;
984  }
985 
986  intersectionPoints.push_back( intersectionPointsAux[positionBegin] );
987  }
988 
989  ++positionBegin;
990  }
991  }
992 
993  // Sort the intersection points through its Y coordinates (column)
994  std::sort(intersectionPoints.begin(), intersectionPoints.end(),
996 
997  // Using the intersection points, build a vector of coordinates (columns) with the start and
998  // end column of the current line for each stretch
999 
1000  std::size_t positionBegin = 0;
1001  std::size_t positionEnd = 0;
1002  int startingCol = 0;
1003  int endingCol = 0;
1004  double startingX = 0;
1005  double startingY = 0;
1006  double endingX = 0;
1007  double endingY = 0;
1008 
1009  while( ( positionBegin + 1 ) < intersectionPoints.size() )
1010  {
1011  positionEnd = positionBegin + 1;
1012 
1013  startingX = intersectionPoints[positionBegin]->getX();
1014  startingX = std::max( startingX, rasterEnvelopeLLX );
1015 
1016  startingY = intersectionPoints[positionBegin]->getY();
1017 
1018  endingX = intersectionPoints[positionEnd]->getX();
1019  endingX = std::min( endingX, rasterEnvelopeURX );
1020 
1021  endingY = intersectionPoints[positionEnd]->getY();
1022 
1023  // Build the vector of coordinates with the folowing structure:
1024  // vector<pair<startcolumn, endcolumn>>;
1025  // where each pair represents a stretch to be transversed
1026 
1027  if(
1028  ( startingX != endingX )
1029  &&
1030  (
1031  m_tileIndexerPtr->withinOrTouches(te::gm::Point(
1032  (startingX + (endingX - startingX) / 2.0 ),
1033  (startingY +(endingY - startingY) / 2.0 ),
1034  m_polygon->getSRID()))
1035  )
1036  )
1037  {
1038  // The middle-point (between the start end end point)
1039  // inside the current polygon
1040 
1041  startingCol = (int)std::ceil( m_raster->getGrid()->geoToGrid(startingX, startingY).x );
1042  startingCol = std::max( 0, startingCol );
1043  startingCol = std::min( m_totalRasterColumns - 1, startingCol );
1044 
1045  endingCol = (int)std::floor( m_raster->getGrid()->geoToGrid(endingX, endingY).x );
1046  endingCol = std::max( 0, endingCol );
1047  endingCol = std::min( m_totalRasterColumns - 1, endingCol );
1048 
1049  if( endingCol >= startingCol )
1050  {
1051  intersectionRanges.push_back(std::pair<int, int>(startingCol, endingCol));
1052  }
1053  }
1054 
1055  positionBegin = positionEnd;
1056  }
1057 
1058  // deleting the intersections points
1059 
1060  positionBegin = 0;
1061 
1062  while ( positionBegin < intersectionPoints.size() )
1063  {
1064  delete intersectionPoints[positionBegin];
1065  ++positionBegin;
1066  }
1067  }
1068 
1069  template<typename T>
1071  const bool areDisjoint, std::vector<std::pair<int, int> >& intersectionRanges ) const
1072  {
1073  intersectionRanges.clear();
1074 
1075  double ulXCoord = 0;
1076  double ulYCoord = 0;
1077  m_raster->getGrid()->gridToGeo( ((double)m_polygonStartingColumn) - 0.5,
1078  ((double)lineIndex) - 0.5, ulXCoord, ulYCoord);
1079 
1080  const double yRes = this->m_raster->getGrid()->getResolutionY();
1081  const double xRes = this->m_raster->getGrid()->getResolutionX();
1082 
1084  m_polygon->getSRID(), 0 );
1085  currBBOX.setNumCoordinates( 5 );
1086  te::gm::Coord2D* currBBOXCoordsPtr = currBBOX.getCoordinates();
1087 
1088  bool rangeStarted = false;
1089  std::pair<int, int> range;
1090 
1091  for( int col = m_polygonStartingColumn ; col <= m_polygonEndingColumn ; ++col )
1092  {
1093  // UL
1094  currBBOXCoordsPtr[ 0 ].x = currBBOXCoordsPtr[ 4 ].x =
1095  ulXCoord + ( xRes * (double)( col - m_polygonStartingColumn ) );
1096  currBBOXCoordsPtr[ 0 ].y = currBBOXCoordsPtr[ 4 ].y = ulYCoord;
1097 
1098  // UR
1099  currBBOXCoordsPtr[ 1 ].x = currBBOXCoordsPtr[ 0 ].x + xRes;
1100  currBBOXCoordsPtr[ 1 ].y = ulYCoord;
1101 
1102  // LR
1103  currBBOXCoordsPtr[ 2 ].x = currBBOXCoordsPtr[ 1 ].x;
1104  currBBOXCoordsPtr[ 2 ].y = ulYCoord - yRes;
1105 
1106  // LL
1107  currBBOXCoordsPtr[ 3 ].x = currBBOXCoordsPtr[ 0 ].x;
1108  currBBOXCoordsPtr[ 3 ].y = ulYCoord - yRes;
1109 
1110  if( areDisjoint == currBBOX.disjoint( m_polygon ) )
1111  { // this pixel must be considered
1112  if( rangeStarted )
1113  {
1114  range.second = col;
1115  }
1116  else
1117  {
1118  rangeStarted = true;
1119  range.first = range.second = col;
1120  }
1121  }
1122  else
1123  { // this pixel must NOT be considered
1124  if( rangeStarted )
1125  {
1126  rangeStarted = false;
1127  intersectionRanges.push_back( range );
1128  }
1129  }
1130  }
1131 
1132  // finalizing the last range
1133  if( rangeStarted )
1134  {
1135  intersectionRanges.push_back( range );
1136  }
1137  }
1138 
1139  template<typename T>
1141  const te::gm::Polygon* p, const IterationType iterationType )
1142  {
1143  clear();
1144 
1145  m_raster = r;
1146  m_polygon = p;
1147  m_totalRasterColumns = r->getNumberOfColumns();
1148  m_totalRasterRows = r->getNumberOfRows();
1149  m_iterationType = iterationType;
1150 
1151  if( r->getSRID() != p->getSRID() )
1152  {
1153  return false;
1154  }
1155 
1156  const te::rst::Grid& rasterGrid = *r->getGrid();
1157  const te::gm::Envelope& rasterEnvelope = *rasterGrid.getExtent();
1158 
1159  te::gm::Coord2D ll = m_polygon->getMBR()->getLowerLeft();
1160  te::gm::Coord2D ur = m_polygon->getMBR()->getUpperRight();
1161 
1162  // Is the polygon extent is outside the current raster area
1163 
1164  if(
1165  ( ll.x > rasterEnvelope.m_urx )
1166  ||
1167  ( ur.x < rasterEnvelope.m_llx )
1168  ||
1169  ( ur.y < rasterEnvelope.m_lly )
1170  ||
1171  ( ll.y > rasterEnvelope.m_ury )
1172  )
1173  {
1174  setEnd();
1175  }
1176  else
1177  {
1178  // defining starting/ending rows
1179 
1180  te::gm::Coord2D llIndexed;
1181  rasterGrid.geoToGrid(ll.x, ll.y, llIndexed.x, llIndexed.y);
1182  te::gm::Coord2D urIndexed;
1183  rasterGrid.geoToGrid(ur.x, ur.y, urIndexed.x, urIndexed.y);
1184 
1185  m_polygonStartingRow = (int)std::floor( urIndexed.y );
1186  m_polygonStartingRow = std::max( 0, m_polygonStartingRow );
1187  m_polygonStartingRow = std::min( m_polygonStartingRow, ((int)rasterGrid.getNumberOfRows()) - 1 );
1188 
1189  m_polygonEndingRow = (int)std::ceil( llIndexed.y );
1190  m_polygonEndingRow = std::max( 0, m_polygonEndingRow );
1191  m_polygonEndingRow = std::min( m_polygonEndingRow, ((int)rasterGrid.getNumberOfRows()) - 1 );
1192 
1193  m_polygonStartingColumn = (int)std::floor( llIndexed.x );
1194  m_polygonStartingColumn = std::max( 0, m_polygonStartingColumn );
1195  m_polygonStartingColumn = std::min( m_polygonStartingColumn, ((int)rasterGrid.getNumberOfColumns()) - 1 );
1196 
1197  m_polygonEndingColumn = (int)std::ceil( urIndexed.x );
1198  m_polygonEndingColumn = std::max( 0, m_polygonEndingColumn );
1199  m_polygonEndingColumn = std::min( m_polygonEndingColumn, ((int)rasterGrid.getNumberOfColumns()) - 1 );
1200 
1201  if(
1202  ( m_polygonEndingRow < m_polygonStartingRow )
1203  ||
1204  ( m_polygonEndingColumn < m_polygonStartingColumn )
1205  )
1206  {
1207  setEnd();
1208  }
1209  else
1210  {
1211  // initialize the TileIndexer
1212 
1213  if( m_iterationType == ScanLineIterationT )
1214  {
1215  m_tileIndexerPtr = std::unique_ptr<te::rst::TileIndexer>(new te::rst::TileIndexer(*m_polygon, rasterGrid.getResolutionY()));
1216  }
1217 
1218  // defining initial state
1219 
1220  m_row = m_polygonStartingRow;
1221 
1222  while( m_row <= m_polygonEndingRow )
1223  {
1224  getIntersectionRanges( m_row, m_currentLineIntersectionRanges );
1225 
1226  if( ! m_currentLineIntersectionRanges.empty() )
1227  {
1228  break;
1229  }
1230 
1231  ++m_row;
1232  }
1233 
1234  if( m_currentLineIntersectionRanges.empty() )
1235  {
1236  setEnd();
1237  }
1238  else
1239  {
1240  m_column = m_currentRangeStartingColumn = m_currentLineIntersectionRanges[ 0 ].first;
1241  m_currentRangeEndingColumn = m_currentLineIntersectionRanges[ 0 ].second;
1242  m_currentLineIntersectionRangesIndex = 0;
1243  }
1244  }
1245  }
1246 
1247  return true;
1248  }
1249 
1250  template<typename T>
1252  te::gm::Geometry const * const g,
1253  std::vector< te::gm::Geometry const * >& geoms) const
1254  {
1255  te::gm::GeometryCollection const * const gc =
1256  dynamic_cast< te::gm::GeometryCollection const * >(g);
1257 
1258  if (gc)
1259  {
1260  te::gm::Geometry const* currentGeom = 0;
1261  const std::size_t nGeoms = gc->getNumGeometries();
1262 
1263  for (std::size_t i = 0; i < nGeoms ; ++i)
1264  {
1265  currentGeom = gc->getGeometryN(i);
1266  breakIntoSingleGeoms(currentGeom, geoms);
1267  }
1268  }
1269  else
1270  {
1271  geoms.push_back( g );
1272  }
1273  }
1274 
1275  // ------------------------------------------------------------------------
1276 
1277 
1278 // implementation of iteration strategy bounded by a line
1280  : m_raster(0),
1281  m_line(0),
1282  m_currentpixelindex(0),
1283  m_pixelsinline(0)
1284  {
1285  }
1286 
1288  : m_raster(r),
1289  m_line(l),
1290  m_currentpixelindex(0),
1291  m_pixelsinline(0)
1292  {
1293  if( r->getSRID() != l->getSRID() )
1294  {
1295  throw te::rst::Exception( TE_TR("Invalid line SRID") );
1296  }
1297 
1298  int srid = this->m_raster->getSRID();
1299 
1300 // make intersection between line and band's envelope
1301  te::gm::Geometry* bandEnvelope = te::gm::GetGeomFromEnvelope(this->m_raster->getExtent(), srid);
1302  te::gm::Geometry* inter = bandEnvelope->intersection(m_line);
1303 
1304  if (inter->isEmpty())
1305  {
1306  setEnd();
1307 
1308  return;
1309  }
1310 
1311 // create line that intersects only band's envelope
1312  te::gm::Line* inrasterline = (te::gm::Line*) inter;
1313 
1314 // find starting and ending points
1315  double startingcolumn;
1316  double startingrow;
1317  std::unique_ptr<te::gm::Point> startpoint = inrasterline->getStartPoint();
1318  this->m_raster->getGrid()->geoToGrid(startpoint->getX(), startpoint->getY(),
1319  startingcolumn, startingrow);
1320 
1321  double endingcolumn;
1322  double endingrow;
1323  std::unique_ptr<te::gm::Point> endpoint = inrasterline->getEndPoint();
1324  this->m_raster->getGrid()->geoToGrid(endpoint->getX(), endpoint->getY(),
1325  endingcolumn, endingrow);
1326 
1327 // creating one envelope per pixel, and intersects with line
1328  const double resXdiv2 = this->m_raster->getResolutionX() / 2;
1329  const double resYdiv2 = this->m_raster->getResolutionY() / 2;
1330  double x1, x2, y1, y2, geoX, geoY;
1331  for(int r = (int)startingrow; r <= (int)endingrow; r++)
1332  for(int c = (int)startingcolumn; c <= (int)endingcolumn; c++)
1333  {
1334 // define envelope of pixel
1335  this->m_raster->getGrid()->gridToGeo(c, r, geoX, geoY);
1336  x1 = geoX - resXdiv2; y1 = geoY - resYdiv2;
1337  x2 = geoX + resXdiv2; y2 = geoY + resYdiv2;
1338 
1339  te::gm::Envelope* pixelbox = new te::gm::Envelope(x1, y1, x2, y2);
1340  te::gm::Geometry* pixelboxgeometry = GetGeomFromEnvelope(pixelbox, srid);
1341 
1342  if (te::gm::SatisfySpatialRelation(inrasterline, pixelboxgeometry, te::gm::INTERSECTS))
1343  m_pixelsinline.push_back(new te::gm::Point(c, r, srid));
1344  }
1345 
1346  if (m_pixelsinline.empty())
1347  setEnd();
1348  }
1349 
1351  : m_raster(rhs.m_raster),
1352  m_currentpixelindex(rhs.m_currentpixelindex),
1353  m_pixelsinline(rhs.m_pixelsinline)
1354  {
1355  }
1356 
1358  {
1359  m_pixelsinline.clear();
1360  }
1361 
1362  template<typename T> const std::vector<T> te::rst::LineIterator<T>::operator*() const
1363  {
1364  std::vector<T> values(this->m_raster->getNumberOfBands());
1365  double value;
1366 
1367  for (unsigned int b = 0; b < this->m_raster->getNumberOfBands(); b++)
1368  {
1369  this->m_raster->getValue(getColumn(), getRow(), value, b);
1370  values[b] = ((T) value);
1371  }
1372 
1373  return values;
1374  }
1375 
1376  template<typename T> T te::rst::LineIterator<T>::operator[](const unsigned int i) const
1377  {
1378  this->m_raster->getValue(getColumn(), getRow(), m_operatorBrackets_value, i);
1379 
1380  return (T) m_operatorBrackets_value;
1381  }
1382 
1383  template<typename T> std::complex< T > te::rst::LineIterator<T>::operator()(const unsigned int i) const
1384  {
1385  this->m_raster->getValue(getColumn(), getRow(), m_operatorParenthesis_value, i);
1386 
1387  return (std::complex< T >) m_operatorParenthesis_value;
1388  }
1389 
1390  template<typename T> unsigned int te::rst::LineIterator<T>::getRow() const
1391  {
1392  return (unsigned int)(m_pixelsinline[m_currentpixelindex]->getY());
1393  }
1394 
1395  template<typename T> unsigned int te::rst::LineIterator<T>::getColumn() const
1396  {
1397  return (unsigned int)(m_pixelsinline[m_currentpixelindex]->getX());
1398  }
1399 
1400  template<typename T> void te::rst::LineIterator<T>::operator++()
1401  {
1402  m_currentpixelindex++;
1403 
1404  if (m_currentpixelindex >= (int)(m_pixelsinline.size()))
1405  setEnd();
1406  }
1407 
1408  template<typename T> void te::rst::LineIterator<T>::operator--()
1409  {
1410  m_currentpixelindex--;
1411 
1412  if (m_currentpixelindex < 0)
1413  setEnd();
1414  }
1415 
1417  {
1418  if (this != &rhs)
1419  {
1421 
1422  m_line = rhs.m_line;
1423  m_currentpixelindex = rhs.m_currentpixelindex;
1424  m_pixelsinline = rhs.m_pixelsinline;
1425  }
1426 
1427  return *this;
1428  }
1429 
1430  template<typename T>
1432  const AbstractPositionIterator<T>& rhs)
1433  {
1434  return operator=( *((LineIterator<T>*)&rhs) );
1435  }
1436 
1437  template<typename T> void te::rst::LineIterator<T>::setEnd()
1438  {
1439  this->m_currentpixelindex = -1;
1440  }
1441 
1443  {
1444  return te::rst::LineIterator<T>(r, l);
1445  }
1446 
1448  {
1449  te::rst::LineIterator<T> it(r, l);
1450 
1451  it.setEnd();
1452 
1453  return it;
1454  }
1455 
1456  template<typename T> bool te::rst::LineIterator<T>::operator!=(const te::rst::LineIterator<T>& rhs) const
1457  {
1458  return ( (this->m_currentpixelindex != rhs.m_currentpixelindex) );
1459  }
1460 
1461  template<typename T>
1463  const AbstractPositionIterator<T>& rhs) const
1464  {
1465  return operator!=( *((te::rst::LineIterator<T>*)&rhs) );
1466  }
1467 
1468 // implementation of iteration strategy bounded by a vector of points
1470  : m_raster(0),
1471  m_pixelsinpointset(0),
1472  m_currentpixelindex(0)
1473  {
1474  }
1475 
1476  template<typename T> te::rst::PointSetIterator<T>::PointSetIterator(const te::rst::Raster* r, const std::vector<te::gm::Point*> p)
1477  : m_raster(r),
1478  m_pixelsinpointset(p),
1479  m_currentpixelindex(0)
1480  {
1481  const int rasterSRID = this->m_raster->getSRID();
1482 
1483  const te::gm::Envelope* rasterbox = r->getExtent();
1484  te::gm::Geometry* rasterboxgeometry = GetGeomFromEnvelope(rasterbox, rasterSRID);
1485 
1486 // remove points that are not inside the band's envelope
1487  std::vector<te::gm::Point*> inside_points;
1488  double column;
1489  double row;
1490  for (unsigned int i = 0; i < m_pixelsinpointset.size(); i++)
1491  {
1492  if( rasterSRID != m_pixelsinpointset[i]->getSRID() )
1493  {
1494  throw te::rst::Exception( TE_TR("Invalid point SRID") );
1495  }
1496 
1498  {
1499  this->m_raster->getGrid()->geoToGrid(m_pixelsinpointset[i]->getX(), m_pixelsinpointset[i]->getY(), column, row);
1500 
1501  inside_points.push_back(new te::gm::Point(column, row));
1502  }
1503  }
1504 
1505  m_pixelsinpointset.clear();
1506  m_pixelsinpointset = inside_points;
1507 
1508  if (m_pixelsinpointset.empty())
1509  setEnd();
1510  }
1511 
1513  : m_raster(rhs.m_raster),
1514  m_pixelsinpointset(rhs.m_pixelsinpointset),
1515  m_currentpixelindex(rhs.m_currentpixelindex)
1516  {
1517  }
1518 
1520  {
1521  m_pixelsinpointset.clear();
1522  }
1523 
1524  template<typename T> const std::vector<T> te::rst::PointSetIterator<T>::operator*() const
1525  {
1526  std::vector<T> values(this->m_raster->getNumberOfBands());
1527  double value;
1528 
1529  for (unsigned int b = 0; b < this->m_raster->getNumberOfBands(); b++)
1530  {
1531  this->m_raster->getValue(getColumn(), getRow(), value, b);
1532  values[b] = ((T) value);
1533  }
1534 
1535  return values;
1536  }
1537 
1538  template<typename T> T te::rst::PointSetIterator<T>::operator[](const unsigned int i) const
1539  {
1540  this->m_raster->getValue(getColumn(), getRow(), m_operatorBrackets_value, i);
1541 
1542  return (T) m_operatorBrackets_value;
1543  }
1544 
1545  template<typename T> std::complex< T > te::rst::PointSetIterator<T>::operator()(const unsigned int i) const
1546  {
1547  this->m_raster->getValue(getColumn(), getRow(), m_operatorParenthesis_value, i);
1548 
1549  return (std::complex< T >) m_operatorParenthesis_value;
1550  }
1551 
1552  template<typename T> unsigned int te::rst::PointSetIterator<T>::getRow() const
1553  {
1554  return (unsigned int)(m_pixelsinpointset[m_currentpixelindex]->getY());
1555  }
1556 
1557  template<typename T> unsigned int te::rst::PointSetIterator<T>::getColumn() const
1558  {
1559  return (unsigned int)(m_pixelsinpointset[m_currentpixelindex]->getX());
1560  }
1561 
1562  template<typename T> void te::rst::PointSetIterator<T>::operator++()
1563  {
1564  m_currentpixelindex++;
1565 
1566  if (m_currentpixelindex >= (int) m_pixelsinpointset.size())
1567  setEnd();
1568  }
1569 
1570  template<typename T> void te::rst::PointSetIterator<T>::operator--()
1571  {
1572  m_currentpixelindex--;
1573 
1574  if (m_currentpixelindex < 0)
1575  setEnd();
1576  }
1577 
1579  {
1580  if (this != &rhs)
1581  {
1583 
1584  m_pixelsinpointset = rhs.m_pixelsinpointset;
1585  m_currentpixelindex = rhs.m_currentpixelindex;
1586  }
1587 
1588  return *this;
1589  }
1590 
1591  template<typename T>
1593  const AbstractPositionIterator<T>& rhs)
1594  {
1595  return operator=( *((te::rst::PointSetIterator<T>*)&rhs) );
1596  }
1597 
1598  template<typename T> void te::rst::PointSetIterator<T>::setEnd()
1599  {
1600  this->m_currentpixelindex = -1;
1601  }
1602 
1603  template<typename T> te::rst::PointSetIterator<T> te::rst::PointSetIterator<T>::begin(const te::rst::Raster* r, const std::vector<te::gm::Point*> p)
1604  {
1605  return te::rst::PointSetIterator<T>(r, p);
1606  }
1607 
1608  template<typename T> te::rst::PointSetIterator<T> te::rst::PointSetIterator<T>::end(const te::rst::Raster* r, const std::vector<te::gm::Point*> p)
1609  {
1611 
1612  it.setEnd();
1613 
1614  return it;
1615  }
1616 
1618  {
1619  return ( (this->m_currentpixelindex != rhs.m_currentpixelindex) );
1620  }
1621 
1622  template<typename T>
1624  const AbstractPositionIterator<T>& rhs) const
1625  {
1626  return operator!=( *((te::rst::PointSetIterator<T>*)&rhs) );
1627  }
1628 
1629  } // end namespace rst
1630 } // end namespace te
1631 
1632 #endif // __TERRALIB_RASTER_INTERNAL_POSITIONITERATOR_H
te::rst::LineIterator::m_operatorBrackets_value
double m_operatorBrackets_value
Used by the operator[] method.
Definition: PositionIterator.h:384
te::gm::LineString::getY
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::rst::PointSetIterator::begin
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.
Definition: PositionIterator.h:1603
te::rst::AbstractPositionIterator::AbstractPositionIterator
AbstractPositionIterator()
Constructor.
Definition: PositionIterator.h:466
te::rst::Grid::getNumberOfRows
unsigned int getNumberOfRows() const
Returns the grid number of rows.
te::rst::Raster::getGrid
Grid * getGrid()
It returns the raster grid.
te::rst::PolygonIterator::operator!=
bool operator!=(const PolygonIterator< T > &rhs) const
Definition: PositionIterator.h:746
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rst::StdSortPointPointerComparison
bool StdSortPointPointerComparison(te::gm::Point *p1, te::gm::Point *p2)
Definition: PositionIterator.h:52
te::rst::PolygonIterator::m_currentRangeEndingColumn
int m_currentRangeEndingColumn
The current line iteration range column to finalize the iteration (default: -1).
Definition: PositionIterator.h:253
te::rst::PolygonIterator::operator=
PolygonIterator & operator=(const PolygonIterator &rhs)
Definition: PositionIterator.h:667
te::rst::LineIterator::operator!=
bool operator!=(const LineIterator< T > &rhs) const
Definition: PositionIterator.h:1456
te::rst::PointSetIterator::m_operatorBrackets_value
double m_operatorBrackets_value
Used by the operator[] method.
Definition: PositionIterator.h:456
te::rst::Raster::getSRID
int getSRID() const
Returns the raster spatial reference system identifier.
te::rst::AbstractPositionIterator::getRow
virtual unsigned int getRow() const =0
Returns the current row in iterator.
te::gm::LineString::size
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
Definition: LineString.h:264
te::rst::PolygonIterator::getBBOXIntersectionRanges
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.
Definition: PositionIterator.h:1070
te::rst::AbstractPositionIterator::operator++
virtual void operator++()=0
Advances to the next position.
te::rst::Grid::getExtent
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
te::rst::LineIterator::end
static LineIterator end(const te::rst::Raster *r, const te::gm::Line *l)
Returns an iterator referring to after the end of the iterator.
Definition: PositionIterator.h:1447
te::rst::LineIterator::getColumn
unsigned int getColumn() const
Returns the current column in iterator.
Definition: PositionIterator.h:1395
te::rst::PolygonIterator::operator++
void operator++()
Advances to the next position.
Definition: PositionIterator.h:564
te::rst::PolygonIterator
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
Definition: PositionIterator.h:157
te::rst::PointSetIterator::m_currentpixelindex
int m_currentpixelindex
The index of the current pixel location.
Definition: PositionIterator.h:455
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rst::AbstractPositionIterator::operator=
virtual AbstractPositionIterator< T > & operator=(const AbstractPositionIterator< T > &rhs)
Assignment operator.
Definition: PositionIterator.h:479
te::rst::PointSetIterator::PointSetIterator
PointSetIterator()
Definition: PositionIterator.h:1469
te::rst::LineIterator::operator*
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
Definition: PositionIterator.h:1362
Grid.h
A rectified grid is the spatial support for raster data.
te::rst::PolygonIterator::clear
void clear()
Clear all internal allocated objects and reset back to the initial state.
Definition: PositionIterator.h:777
te::rst::PointSetIterator::operator!=
bool operator!=(const PointSetIterator< T > &rhs) const
Definition: PositionIterator.h:1617
te::rst::PointSetIterator
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
Definition: PositionIterator.h:399
Band.h
Band implementation for TerraLib 4.x.
te::rst::PolygonIterator::operator*
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
Definition: PositionIterator.h:526
te::rst::Grid::gridToGeo
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
te::rst::PointSetIterator::operator=
PointSetIterator & operator=(const PointSetIterator &rhs)
Definition: PositionIterator.h:1578
te::rst::LineIterator::~LineIterator
~LineIterator()
Definition: PositionIterator.h:1357
te::rst::LineIterator
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
Definition: PositionIterator.h:326
te::gm::GetGeomFromEnvelope
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
te::rst::LineIterator::m_line
const te::gm::Line * m_line
The spatial restriction to be applied in the iterator.
Definition: PositionIterator.h:381
te::rst::PolygonIterator::setEnd
void setEnd()
Sets the iterator position to the end of the current band.
Definition: PositionIterator.h:710
te::rst::PointSetIterator::setEnd
void setEnd()
Sets the iterator position to the end of the current band.
Definition: PositionIterator.h:1598
te::rst::PolygonIterator::operator[]
T operator[](const unsigned int i) const
Returns the real value in current position (column, row, band) from iterator.
Definition: PositionIterator.h:540
te::rst::PointSetIterator::m_raster
const te::rst::Raster * m_raster
The band from where to get the values.
Definition: PositionIterator.h:453
te::rst::PolygonIterator::PolygonIterator
PolygonIterator()
Definition: PositionIterator.h:488
te::rst::PointSetIterator::end
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.
Definition: PositionIterator.h:1608
te::gm::GeometryCollection
It is a collection of other geometric objects.
Definition: GeometryCollection.h:58
TE_LOG_WARN
#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:347
te::gm::Envelope::m_llx
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
te::rst::LineIterator::operator++
void operator++()
Advances to the next position.
Definition: PositionIterator.h:1400
te::rst::AbstractPositionIterator::getColumn
virtual unsigned int getColumn() const =0
Returns the current column in iterator.
te::rst::Grid::getResolutionY
double getResolutionY() const
Returns the grid vertical (y-axis) resolution.
te::gm::Polygon
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
te::gm::LineStringType
@ LineStringType
Definition: Enums.h:54
te::rst::LineIterator::m_currentpixelindex
int m_currentpixelindex
The index of the current pixel location.
Definition: PositionIterator.h:382
te::rst::PolygonIterator::m_operatorBrackets_value
double m_operatorBrackets_value
Definition: PositionIterator.h:259
te::rst::Grid
A rectified grid is the spatial support for raster data.
Definition: Grid.h:69
te::gm::PointType
@ PointType
Definition: Enums.h:48
te::rst::PolygonIterator::getScanLineIntersectionRanges
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 S...
Definition: PositionIterator.h:815
te::rst::PolygonIterator::NDisjointBBOXIterationT
@ NDisjointBBOXIterationT
Itaration over pixels whose bounding boxes are not disjoint in relation with the polygon.
Definition: PositionIterator.h:164
te::rst::AbstractPositionIterator::setEnd
virtual void setEnd()=0
Sets the iterator position to the end of the current band.
te::gm::Geometry::disjoint
virtual bool disjoint(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object is spatially disjoint from rhs geometry.
te::rst::AbstractPositionIterator::operator()
virtual std::complex< T > operator()(const unsigned int i) const =0
Returns the complex value in current position (column, row, band) from iterator.
te::gm::LineString::setY
void setY(std::size_t i, const double &y)
It sets the n-th y coordinate value.
te::gm::Geometry::isEmpty
virtual bool isEmpty() const _NOEXCEPT_OP(false)
It returns true if this geometric object is the empty Geometry.
te::rst::PointSetIterator::getColumn
unsigned int getColumn() const
Returns the current column in iterator.
Definition: PositionIterator.h:1557
te::rst::LineIterator::operator()
std::complex< T > operator()(const unsigned int i) const
Returns the complex value in current position (column, row, band) from iterator.
Definition: PositionIterator.h:1383
te::rst::PolygonIterator::m_currentLineIntersectionRangesIndex
int m_currentLineIntersectionRangesIndex
The actual line of the iterator (default -1).
Definition: PositionIterator.h:254
te::rst::PointSetIterator::~PointSetIterator
~PointSetIterator()
Definition: PositionIterator.h:1519
te::rst::LineIterator::m_pixelsinline
std::vector< te::gm::Point * > m_pixelsinline
A vector of pixel locations that intersects the line.
Definition: PositionIterator.h:383
te::rst::PolygonIterator::end
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
Definition: PositionIterator.h:737
te::rst::PolygonIterator::m_currentRangeStartingColumn
int m_currentRangeStartingColumn
The current line iteration range starting column (default: -1).
Definition: PositionIterator.h:252
te::rst::TileIndexer::TileSegIndex
std::vector< std::pair< unsigned int, unsigned int > > TileSegIndex
Definition: TileIndexer.h:58
te::rst::PolygonIterator::m_polygonEndingColumn
int m_polygonEndingColumn
Polygon last raster column (default: -1).
Definition: PositionIterator.h:246
te::rst::LineIterator::setEnd
void setEnd()
Sets the iterator position to the end of the current band.
Definition: PositionIterator.h:1437
te::gm::Envelope::m_urx
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
te::rst::PolygonIterator::operator--
void operator--()
Returns to the previous position.
Definition: PositionIterator.h:615
te::rst::PolygonIterator::m_polygonStartingRow
int m_polygonStartingRow
Polygon first raster row (default: -1).
Definition: PositionIterator.h:247
te::gm::SatisfySpatialRelation
TEGEOMEXPORT bool SatisfySpatialRelation(const Geometry *g1, const Geometry *g2, SpatialRelation relation)
It returns if two geometries satisfy a given spatial relation.
te::rst::PointSetIterator::m_operatorParenthesis_value
std::complex< double > m_operatorParenthesis_value
Used by the operator() method.
Definition: PositionIterator.h:457
te::rst::PolygonIterator::m_totalRasterRows
int m_totalRasterRows
The number of rows in band (default: 0).
Definition: PositionIterator.h:244
te::rst::AbstractPositionIterator::operator*
virtual const std::vector< T > operator*() const =0
Returns a vector of the values in current position (column, row) from iterator.
te::rst::PolygonIterator::m_totalRasterColumns
int m_totalRasterColumns
The number of columns in band (default: 0).
Definition: PositionIterator.h:243
te::rst::PolygonIterator::m_raster
const te::rst::Raster * m_raster
The band from where to get the values (default 0).
Definition: PositionIterator.h:240
Exception.h
An exception class for the XML module.
te::rst::PolygonIterator::IterationType
IterationType
Definition: PositionIterator.h:162
te::rst::PolygonIterator::getIntersectionRanges
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 c...
Definition: PositionIterator.h:786
te::rst::Grid::getNumberOfColumns
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
te::rst::PointSetIterator::operator[]
T operator[](const unsigned int i) const
Returns the real value in current position (column, row, band) from iterator.
Definition: PositionIterator.h:1538
te::rst::PolygonIterator::begin
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.
Definition: PositionIterator.h:716
te::rst::PolygonIterator::m_iterationType
IterationType m_iterationType
Current iteration type (default ScanLineIterationT).
Definition: PositionIterator.h:242
te::rst::PolygonIterator::m_currentLineIntersectionRanges
std::vector< std::pair< int, int > > m_currentLineIntersectionRanges
Coordinates of the columns to be transversed.
Definition: PositionIterator.h:256
te::rst::AbstractPositionIterator
This class is the base for implementing ways to navigate over the band with spatial restriction,...
Definition: PositionIterator.h:66
te::gm::LineString::setX
void setX(std::size_t i, const double &x)
It sets the n-th x coordinate value.
te::rst::PolygonIterator::m_polygon
const te::gm::Polygon * m_polygon
The spatial restriction to be applied in the iterator (default 0).
Definition: PositionIterator.h:241
te::rst::AbstractPositionIterator::operator--
virtual void operator--()=0
Returns to the previous position.
te::rst::PolygonIterator::m_polygonStartingColumn
int m_polygonStartingColumn
Polygon first raster column (default: -1).
Definition: PositionIterator.h:245
te::rst::AbstractPositionIterator::operator[]
virtual T operator[](const unsigned int i) const =0
Returns the real value in current position (column, row, band) from iterator.
te::gm::Line
A Line is LineString with 2 points.
Definition: Line.h:51
te::gm::LineString
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
te::rst::PolygonIterator::breakIntoSingleGeoms
void breakIntoSingleGeoms(te::gm::Geometry const *const g, std::vector< te::gm::Geometry const * > &geoms) const
It will get a GeometryCollection and distribute in a vector.
Definition: PositionIterator.h:1251
te::rst::LineIterator::LineIterator
LineIterator()
Definition: PositionIterator.h:1279
te::rst::Grid::geoToGrid
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
te::gm::INTERSECTS
@ INTERSECTS
Definition: Enums.h:130
te::rst::PolygonIterator::initialize
bool initialize(const te::rst::Raster *r, const te::gm::Polygon *p, const IterationType iterationType)
Initialize this instance.
Definition: PositionIterator.h:1140
te::gm::Envelope::m_lly
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
te::rst::PolygonIterator::m_operatorParenthesis_value
std::complex< double > m_operatorParenthesis_value
Definition: PositionIterator.h:260
te::rst::PolygonIterator::getRow
unsigned int getRow() const
Returns the current row in iterator.
Definition: PositionIterator.h:554
te::rst::PolygonIterator::ScanLineIterationT
@ ScanLineIterationT
Scan line iteration type.
Definition: PositionIterator.h:163
te::rst::LineIterator::operator=
LineIterator & operator=(const LineIterator &rhs)
Definition: PositionIterator.h:1416
te::rst::PointSetIterator::operator--
void operator--()
Returns to the previous position.
Definition: PositionIterator.h:1570
te::rst::PolygonIterator::initiateVariables
void initiateVariables()
Initialize all internal variables to initial states.
Definition: PositionIterator.h:758
te::gm::Coord2D::x
double x
x-coordinate.
Definition: Coord2D.h:113
te::rst::PointSetIterator::operator++
void operator++()
Advances to the next position.
Definition: PositionIterator.h:1562
te::rst::Raster::getResolutionX
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
te::rst::PolygonIterator::operator()
std::complex< T > operator()(const unsigned int i) const
Returns the complex value in current position (column, row, band) from iterator.
Definition: PositionIterator.h:547
te::gm::Coord2D
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:41
te::rst::LineIterator::operator[]
T operator[](const unsigned int i) const
Returns the real value in current position (column, row, band) from iterator.
Definition: PositionIterator.h:1376
te::rst::LineIterator::getRow
unsigned int getRow() const
Returns the current row in iterator.
Definition: PositionIterator.h:1390
te::rst::PointSetIterator::m_pixelsinpointset
std::vector< te::gm::Point * > m_pixelsinpointset
The spatial restriction to be applied in the iterator.
Definition: PositionIterator.h:454
te::rst::TileIndexer
Polygon tile indexing class for optmized geometrical relational tests.
Definition: TileIndexer.h:55
te::rst::AbstractPositionIterator::~AbstractPositionIterator
virtual ~AbstractPositionIterator()
Destructor.
Definition: PositionIterator.h:474
te::rst::PointSetIterator::operator*
const std::vector< T > operator*() const
Returns a vector of the values in current position (column, row) from iterator.
Definition: PositionIterator.h:1524
operator!=
TEDATAACCESSEXPORT te::da::Expression * operator!=(const te::da::Expression &e1, const te::da::Expression &e2)
te::rst::PolygonIterator::~PolygonIterator
~PolygonIterator()
Definition: PositionIterator.h:521
te::gm::LineString::getX
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
te::rst::PointSetIterator::operator()
std::complex< T > operator()(const unsigned int i) const
Returns the complex value in current position (column, row, band) from iterator.
Definition: PositionIterator.h:1545
te::rst::LineIterator::m_operatorParenthesis_value
std::complex< double > m_operatorParenthesis_value
Used by the operator() method.
Definition: PositionIterator.h:385
te::rst::PolygonIterator::getColumn
unsigned int getColumn() const
Returns the current column in iterator.
Definition: PositionIterator.h:559
te::rst::LineIterator::begin
static LineIterator begin(const te::rst::Raster *r, const te::gm::Line *l)
Returns an iterator referring to the first value of the band.
Definition: PositionIterator.h:1442
BandProperty.h
It describes one band (or dimension) of a raster.
te::rst::PolygonIterator::m_tileIndexerPtr
std::unique_ptr< te::rst::TileIndexer > m_tileIndexerPtr
Tile indexer used to optimize the geometric operations.
Definition: PositionIterator.h:255
te::gm::LinearRing
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:54
te::rst::Raster::getResolutionY
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
te::gm::Envelope::m_ury
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
te::rst::Raster::getExtent
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
te::gm::Coord2D::y
double y
y-coordinate.
Definition: Coord2D.h:114
te::rst::PolygonIterator::m_column
int m_column
The current column of the iterator (default -1).
Definition: PositionIterator.h:250
te::rst::PolygonIterator::DisjointBBOXIterationT
@ DisjointBBOXIterationT
Itaration over pixels whose bounding boxes are disjoint in relation with the polygon.
Definition: PositionIterator.h:165
te::rst::LineIterator::operator--
void operator--()
Returns to the previous position.
Definition: PositionIterator.h:1408
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
TE_TR
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:264
te::rst::PointSetIterator::getRow
unsigned int getRow() const
Returns the current row in iterator.
Definition: PositionIterator.h:1552
te::gm::GeometryCollection::getNumGeometries
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
Definition: GeometryCollection.h:228
te::gm::LineString::getCoordinates
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
Definition: LineString.h:458
te::gm::Geometry::intersection
virtual Geometry * intersection(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns a geometric object that represents the point set intersection with another geometry.
te::gm::GeometryCollection::getGeometryN
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
te::rst::PolygonIterator::m_polygonEndingRow
int m_polygonEndingRow
Polygon last raster row (default: -1).
Definition: PositionIterator.h:248
te::gm::Geometry::getSRID
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:242
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51
te::rst::Raster::getNumberOfRows
unsigned int getNumberOfRows() const
Returns the raster number of rows.
BlockUtils.h
Utility functions for dealing with raster data blocks.
te::rst::Raster::getNumberOfColumns
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
te::rst::AbstractPositionIterator::operator!=
virtual bool operator!=(const AbstractPositionIterator< T > &rhs) const =0
Difference operator.
te::gm::LineString::getStartPoint
std::unique_ptr< Point > getStartPoint() const
The length of this Curve in its associated spatial reference.
te::gm::LineString::getEndPoint
std::unique_ptr< Point > getEndPoint() const
It returns the curve end point.
te::gm::LineString::setNumCoordinates
void setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
te::rst::LineIterator::m_raster
const te::rst::Raster * m_raster
The band from where to get the values.
Definition: PositionIterator.h:380
te::rst::PolygonIterator::m_row
int m_row
The current row of the iterator (default -1).
Definition: PositionIterator.h:251