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