TrajectoryIterator.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 TrajectoryIterator.h
22 
23  \brief This file contains a trajetory iterator.
24  */
25 
26 #ifndef __TERRALIB_ST_INTERNAL_TRAJECTORYITERATOR_H
27 #define __TERRALIB_ST_INTERNAL_TRAJECTORYITERATOR_H
28 
29 // ST
30 #include "../../Config.h"
31 #include "../../Utils.h"
32 #include "TrajectoryObservation.h"
33 
34 // STL
35 #include <map>
36 
37 // Boost
38 #include <boost/shared_ptr.hpp>
39 
40 // Forward declarations
41 namespace te { namespace dt { class DateTime; } }
42 namespace te { namespace gm { class Geometry; } }
43 
44 namespace te
45 {
46  namespace st
47  {
48  /*!
49  \class TrajectoryIterator
50 
51  \brief A class to traverse the observations of a trajectory.
52 
53  This class provides a mechanism to traverse the trajectory
54  observations sequentially, ordered by time.
55 
56  An example of use:
57 
58  TrajectoryIterator it = tj.begin();
59  while(it!=tj.end())
60  {
61  Geometry* g = it.getGeometry();
62  DateTime* t = it.getTime();
63  ++it;
64  }
65 
66  \sa Trajectory
67  */
69  {
70  public:
71 
72  /*! \brief Empty constructor. */
74 
75  /*!
76  \brief Constructor.
77 
78  \param it A iterator that points to the trajectory observations
79  */
80  TrajectoryIterator(TrajectoryObservationSet::const_iterator& it);
81 
82 
83  /*! \brief Assignment operator. */
84  const TrajectoryIterator& operator=(const TrajectoryIterator& rhs);
85 
86  /*! \brief Operator == */
87  bool operator==(const TrajectoryIterator& rhs);
88 
89  /*! \brief Operator != */
90  bool operator!=(const TrajectoryIterator& rhs);
91 
92  /*!
93  \brief Prefix operator ++
94 
95  After using this operator, the internal cursor points
96  to the next trajectory observation.
97 
98  The semantics of prefix is this: Increment the value and then fetch it.
99  */
100  TrajectoryIterator& operator++();
101 
102  /*!
103  \brief Postfix operator ++
104 
105  After using this operator, the internal cursor points
106  to the next trajectory observation.
107 
108  The semantics of postfix is: Fetch the value and then increment the original.
109  */
110  TrajectoryIterator operator++(int aux);
111 
112  /*!
113  \brief Prefix operator --
114 
115  After using this operator, the internal cursor points
116  to the preceding trajectory observation.
117 
118  The semantics of prefix is this: Increment the value and then fetch it.
119  */
120  TrajectoryIterator& operator--();
121 
122  /*!
123  \brief Postfix operator --
124 
125  After using this operator, the internal cursor points
126  to the preceding trajectory observation.
127 
128  The semantics of postfix is: Fetch the value and then increment the original.
129  */
130  TrajectoryIterator operator--(int aux);
131 
132  /*!
133  \brief Prefix operator *
134 
135  It returns the item (a pair of shared pointers to the geometry and time)
136  pointed by the internal cursor.
137  */
138  TrajectoryObservation operator*() const;
139 
140  /*!
141  \brief It returns the geometry pointed by the internal cursor.
142 
143  \return A pointer to the geometry pointed by the internal cursor.
144 
145  \note The caller will NOT take the ownership of the returned pointer.
146  */
147  te::gm::Geometry* getGeometry() const;
148 
149  /*!
150  \brief It returns the datetime pointed by the internal cursor.
151 
152  \return A pointer to the datetime pointed by the internal cursor.
153 
154  \note The caller will NOT take the ownership of the returned pointer.
155  */
156  te::dt::DateTime* getTime() const;
157 
158  /*! \brief Virtual destructor. */
159  virtual ~TrajectoryIterator();
160 
161  private:
162 
163  TrajectoryObservationSet::const_iterator m_it; //!< The internal cursor
164  };
165 
166  /*!
167  \struct TrajectoryPatch
168 
169  \brief A struct to represent a patch or a continuous piece of a trajectory.
170  */
172  {
173  public:
175 
176  TrajectoryIterator begin() const { return m_begin; }
177 
178  TrajectoryIterator end() const { return m_end; }
179 
180  private:
181  TrajectoryIterator m_begin; //a pointer to the first observation
182  TrajectoryIterator m_end; //a pointer to the position after the last observation
183  };
184 
185  } // end namespace st
186 } // end namespace te
187 
188 #endif // __TERRALIB_ST_INTERNAL_TimeSeriesITERATOR_H
189 
This file contains a typedef that defines observations of trajectory.
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88
A struct to represent a patch or a continuous piece of a trajectory.
TrajectoryIterator end() const
TrajectoryPatch(TrajectoryIterator b, TrajectoryIterator e)
TEDATAACCESSEXPORT te::da::Expression * operator==(const te::da::Expression &e1, const te::da::Expression &e2)
TEDATAACCESSEXPORT te::da::Expression * operator!=(const te::da::Expression &e1, const te::da::Expression &e2)
std::pair< te::dt::DateTimeShrPtr, te::gm::GeometryShrPtr > TrajectoryObservation
TrajectoryIterator m_begin
URI C++ Library.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
TrajectoryIterator begin() const
TrajectoryIterator m_end
A class to traverse the observations of a trajectory.
TrajectoryObservationSet::const_iterator m_it
The internal cursor.