All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrajectoryDataSet.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 TrajectoryDataSet.h
22 
23  \brief This file contains a class to represent a trajectory data set.
24  */
25 
26 #ifndef __TERRALIB_ST_INTERNAL_TRAJECTORYDATASET_H
27 #define __TERRALIB_ST_INTERNAL_TRAJECTORYDATASET_H
28 
29 //ST
30 #include "../../Config.h"
31 #include "TrajectoryDataSetType.h"
32 
33 // Boost
34 #include <boost/noncopyable.hpp>
35 
36 //STL
37 #include <vector>
38 #include <memory>
39 
40 // Forward declarations
41 namespace te { namespace dt { class DateTime; class DateTimePeriod; class DateTimeProperty;} }
42 namespace te { namespace gm { class Geometry; class Envelope; class GeometryProperty; } }
43 
44 namespace te
45 {
46  namespace st
47  {
48  // Forward declarations
49  class ObservationDataSet;
50  class Trajectory;
51  class AbstractTrajectoryInterp;
52 
53  /*!
54  \class TrajectoryDataSet
55 
56  \brief A class to represent a trajectory data set.
57 
58  This class represents a view on a DataSet that
59  contains observations of a trajectory.
60 
61  A trajectory represents the variation of spatial locations or boundaries of an
62  object over time. It is composed of an observation data set where one
63  observed property is a geometry.
64  The observations have a fixed object identity and measured geometries at controlled
65  times.
66 
67  \ingroup st
68 
69  \sa ObservationDataSet ObservationDatasSetType TrajectoryDataSetType
70  */
71  class TESTEXPORT TrajectoryDataSet : public boost::noncopyable
72  {
73  public:
74 
75  /*! \name Constructor */
76  //@{
77  /*!
78  \brief Constructor.
79 
80  \param ds The data set that contains the trajectory observations.
81  \param tPropIdx The index of the property that contains the times of a trajectory.
82  \param gPropIdx The index of the property that contains the geometries of a trajectory.
83  \param idPropIdx The index of the property that contains the identity of the trajectory.
84  \param id The trajectory id.
85 
86  \note It will take the ownership of the given pointer.
87  */
88  TrajectoryDataSet(te::da::DataSet* ds, int tPropIdx, int gPropIdx, int idPropIdx,
89  const std::string& id);
90 
91  /*!
92  \brief Constructor.
93 
94  \param ds The data set that contains the trajectory observations.
95  \param tPropIdx The index of the property that contains the times of a trajectory.
96  \param gPropIdx The index of the property that contains the geometries of a trajectory.
97  \param idPropIdx The index of the property that contains the identity of the trajectory.
98  \param id The trajectory id.
99  \param text The temporal extent.
100  \param sext The spatial extent.
101 
102  \note It will take the ownership of the given pointer.
103  */
104  TrajectoryDataSet(te::da::DataSet* ds, int tPropIdx, int gPropIdx, int idPropIdx,
105  const std::string& id, te::dt::DateTimePeriod* text,
106  const te::gm::Envelope& sext);
107 
108  /*!
109  \brief Constructor.
110 
111  \param ds The data set that contains the trajectory observations.
112  \param tPropIdxs The indexes of the properties that contains the begin and end times of a trajectory.
113  \param gPropIdx The index of the property that contains the geometries of a trajectory.
114  \param idPropIdx The index of the property that contains the identity of the trajectory.
115  \param id The trajectory id.
116 
117  \note It will take the ownership of the input pointer.
118  \note This constructor is used when each observation of a trajectory is associated to a period and
119  the DataSet uses two properties to store these periods.
120  */
121  TrajectoryDataSet(te::da::DataSet* ds, const std::vector<int>& tPropIdxs, int gPropIdx,
122  int idPropIdx, const std::string& id);
123 
124  /*!
125  \brief Constructor.
126 
127  \param ds The data set that contains the trajectory observations.
128  \param tPropIdxs The indexes of the properties that contains the begin and end times of a trajectory.
129  \param gPropIdx The index of the property that contains the geometries of a trajectory.
130  \param idPropIdx The index of the property that contains the identity of the trajectory.
131  \param id The trajectory id.
132  \param text The temporal extent.
133  \param sext The spatial extent.
134 
135  \note It will take the ownership of the input pointer.
136  \note This constructor is used when each observation of a trajectory is associated to a period and
137  the DataSet uses two properties to store these periods.
138  */
139  TrajectoryDataSet(te::da::DataSet* ds, const std::vector<int>& tPropIdxs, int gPropIdx,
140  int idPropIdx, const std::string& id, te::dt::DateTimePeriod* text,
141  const te::gm::Envelope& sext);
142 
143  /*!
144  \brief Constructor.
145 
146  \param ds The data set that contains the trajectory observations.
147  \param type The trajectory data set type.
148  \param text The temporal extent.
149  \param sext The spatial extent.
150 
151  \note It will take the ownership of the input pointer.
152  \note This constructor is used when each observation of a trajectory is associated to a period and
153  the DataSet uses two properties to store these periods.
154  */
156  te::dt::DateTimePeriod* text, const te::gm::Envelope& sext);
157 
158  /*!
159  \brief Constructor.
160 
161  \param obs The data set that contains the trajectory observations.
162  \param type The trajectory data set type.
163  \param id The trajectory id
164 
165  \note It will take the ownership of the input pointer.
166  */
167  TrajectoryDataSet(ObservationDataSet* obs, const TrajectoryDataSetType& type, const std::string& id);
168  //@}
169 
170  /*!
171  \brief It returns the data set that contains the trajectory observations.
172 
173  \return A reference to the data set that contains the trajectory observations.
174 
175  \note The caller will NOT take the ownership of the input pointer.
176  */
177  ObservationDataSet* getObservationSet() const;
178 
179  /*!
180  \brief It returns a reference to the internal trajectory data set type.
181 
182  \return A reference to the internal trajectory data set type.
183  */
184  const TrajectoryDataSetType& getType() const;
185 
186  /*!
187  \brief It returns the identifier associated to the trajectory.
188 
189  \return The identifier associated to the trajectory.
190  */
191  std::string getId() const;
192 
193  /*!
194  \brief It sets the identifier associated to the trajectory.
195 
196  \param id The identifier associated to the trajectory.
197  */
198  void setId(const std::string& id);
199 
200  /*!
201  \brief It returns the size of the trajectory observation set.
202 
203  \return The observation set size of the trajectory.
204  */
205  std::size_t size() const;
206 
207  /*! \name Methods to traverse the trajectory observations and to check the
208  internal cursor pointer*/
209  //@{
210  bool moveNext();
211 
212  bool movePrevious();
213 
214  bool moveFirst();
215 
216  bool moveBeforeFirst();
217 
218  bool moveLast();
219 
220  bool isAtBegin() const;
221 
222  bool isBeforeBegin() const;
223 
224  bool isAtEnd() const;
225 
226  bool isAfterEnd() const;
227  //@}
228 
229  /*! \name Methods to get values pointed by the internal cursor.
230  //@{
231  /*!
232  \brief It returns the geometry pointed by the internal cursor.
233 
234  \return A pointer to the geometry pointed by the internal cursor.
235 
236  \note The caller will take the ownership of the returned pointer.
237  */
238  std::auto_ptr<te::gm::Geometry> getGeometry() const;
239 
240  /*!
241  \brief It returns the time pointed by the internal cursor.
242 
243  \return A pointer to the time pointed by the internal cursor.
244 
245  \note The caller will take the ownership of the returned pointer.
246  */
247  std::auto_ptr<te::dt::DateTime> getTime() const;
248  //@}
249 
250  /*!
251  \brief It returns the temporal extent of the trajectory observations.
252 
253  \return The temporal extent of the trajectory observations.
254 
255  \note The caller will NOT take the ownership of the output pointer.
256  */
257  te::dt::DateTimePeriod* getTemporalExtent() const;
258 
259  /*!
260  \brief It returns the spatial extent of the trajectory observations.
261 
262  \return The spatial extent of the trajectory observations.
263  */
264  const te::gm::Envelope& getSpatialExtent() const;
265 
266  /*!
267  \brief It returns the trajectory from the DataSet.
268 
269  This method encapsulates all observations of this DataSet as a
270  Trajectory type associated to a given interpolator.
271 
272  \return The trajectory associated to a given interpolator.
273 
274  \note The caller will take the ownership of the returned pointer.
275  \note It uses the method moveNext() internally. So, after calling this method,
276  the internal cursor will point to the end of the DataSet.
277  */
278  std::auto_ptr<Trajectory> getTrajectory(AbstractTrajectoryInterp* interp);
279 
280  /*!
281  \brief It returns the trajectory from the DataSet.
282 
283  This method encapsulates all observations of this DataSet as a
284  Trajectory type associated to a NearestGeometryAtTimeInterp interpolator.
285 
286  \return The trajectory associated to a NearestGeometryAtTimeInterp interpolator.
287 
288  \note The caller will take the ownership of the returned pointer.
289  \note It uses the method moveNext() internally. So, after calling this method,
290  the internal cursor will point to the end of the DataSet.
291  */
292  std::auto_ptr<Trajectory> getTrajectory();
293 
294  /*!
295  \brief It returns the trajectory geometry property.
296 
297  \return The trajectory geometry property.
298 
299  \note The caller will NOT take the ownership of the returned pointer.
300  */
301  //te::gm::GeometryProperty* getGeometryProperty() const;
302 
303  /*!
304  \brief It returns the trajectory datetime property.
305 
306  \return The trajectory datetime property.
307 
308  \note The caller will NOT take the ownership of the returned pointer.
309  */
310  //te::dt::DateTimeProperty* getTimeProperty() const;
311 
312  /*! \brief Virtual destructor. */
313  virtual ~TrajectoryDataSet();
314 
315  private:
316  std::auto_ptr<ObservationDataSet> m_obsDs; //!< The data set that contains the trajectory observations
317  TrajectoryDataSetType m_type; //!< The trajectory type.
318  std::string m_id; //!< The trajectory identification.
319  };
320  } // end namespace st
321 } // end namespace te
322 
323 #endif // __TERRALIB_ST_INTERNAL_TRAJECTORYDATASET_H
324 
This file contains a class called TrajectoryDataSetType.
A class that contains complemental information about a DataSet that holds observations of a trajector...
A class to represent a DataSet that contains observations.
An abstract class to represent a period of date and time.
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:136
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
A class to represent a trajectory data set.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111