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. */
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  */
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  */
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  */
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  */
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  */
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  */
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  */
157 
158  /*! \brief Virtual destructor. */
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 
te
TerraLib.
Definition: AddressGeocodingOp.h:52
TrajectoryObservation.h
This file contains a typedef that defines observations of trajectory.
te::st::TrajectoryPatch::begin
TrajectoryIterator begin() const
Definition: TrajectoryIterator.h:176
te::st::TrajectoryIterator::TrajectoryIterator
TrajectoryIterator()
Empty constructor.
te::st::TrajectoryIterator::~TrajectoryIterator
virtual ~TrajectoryIterator()
Virtual destructor.
te::st::TrajectoryIterator::operator++
TrajectoryIterator & operator++()
Prefix operator ++.
te::st::TrajectoryIterator::operator--
TrajectoryIterator operator--(int aux)
Postfix operator –.
te::st::TrajectoryIterator::getTime
te::dt::DateTime * getTime() const
It returns the datetime pointed by the internal cursor.
te::dt::DateTime
Definition: DateTime.h:56
te::st::TrajectoryIterator::operator!=
bool operator!=(const TrajectoryIterator &rhs)
Operator !=.
te::st::TrajectoryPatch::m_begin
TrajectoryIterator m_begin
Definition: TrajectoryIterator.h:181
te::st::TrajectoryPatch::TrajectoryPatch
TrajectoryPatch(TrajectoryIterator b, TrajectoryIterator e)
Definition: TrajectoryIterator.h:174
te::st::TrajectoryIterator::getGeometry
te::gm::Geometry * getGeometry() const
It returns the geometry pointed by the internal cursor.
te::st::TrajectoryIterator::operator=
const TrajectoryIterator & operator=(const TrajectoryIterator &rhs)
Assignment operator.
te::st::TrajectoryObservation
std::pair< te::dt::DateTimeShrPtr, te::gm::GeometrySharedPtr > TrajectoryObservation
Definition: TrajectoryObservation.h:50
te::st::TrajectoryIterator::operator--
TrajectoryIterator & operator--()
Prefix operator –.
te::st::TrajectoryPatch
A struct to represent a patch or a continuous piece of a trajectory.
Definition: TrajectoryIterator.h:172
te::st::TrajectoryPatch::m_end
TrajectoryIterator m_end
Definition: TrajectoryIterator.h:182
te::st::TrajectoryIterator::operator*
TrajectoryObservation operator*() const
Prefix operator *.
te::st::TrajectoryIterator
A class to traverse the observations of a trajectory.
Definition: TrajectoryIterator.h:69
TESTEXPORT
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88
te::st::TrajectoryIterator::operator++
TrajectoryIterator operator++(int aux)
Postfix operator ++.
te::st::TrajectoryIterator::operator==
bool operator==(const TrajectoryIterator &rhs)
Operator ==.
te::st::TrajectoryIterator::m_it
TrajectoryObservationSet::const_iterator m_it
The internal cursor.
Definition: TrajectoryIterator.h:163
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::st::TrajectoryPatch::end
TrajectoryIterator end() const
Definition: TrajectoryIterator.h:178
te::st::TrajectoryIterator::TrajectoryIterator
TrajectoryIterator(TrajectoryObservationSet::const_iterator &it)
Constructor.