All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TimeSeriesDataSet.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 TimeSeriesDataSet.h
22 
23  \brief This file contains a class to represent a time series data set.
24  */
25 
26 #ifndef __TERRALIB_ST_INTERNAL_TIMESERIESDATASET_H
27 #define __TERRALIB_ST_INTERNAL_TIMESERIESDATASET_H
28 
29 //ST
30 #include "../../Config.h"
31 #include "TimeSeriesDataSetType.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 AbstractData; class DateTime; class DateTimePeriod; class DateTimeProperty;} }
42 namespace te { namespace gm { class Geometry; class GeometryProperty; } }
43 
44 namespace te
45 {
46  namespace st
47  {
48  // Forward declarations
49  class ObservationDataSet;
50  class TimeSeries;
51  class AbstractTimeSeriesInterp;
52 
53  /*!
54  \class TimeSeriesDataSet
55 
56  \brief A class to represent a time series data set.
57 
58  This class represents a view on a DataSet that
59  contains observations of time series. A time series
60  represents the variation of the values of a property over time.
61 
62  A TimeSeriesDataSet can contain one or more properties observed
63  over time.
64 
65  \ingroup st
66 
67  \sa ObservationDataSet ObservationDatasSetType TimeSeriesDataSetType
68  */
69  class TESTEXPORT TimeSeriesDataSet : public boost::noncopyable
70  {
71  friend class TimeSeriesDataSetLayer;
72 
73  public:
74 
75  /*! \name Constructor */
76  //@{
77  /*!
78  \brief Constructor.
79 
80  \param ds The data set that contains the time series observations.
81  \param tPropIdx The index of the property that contains the times of time series.
82  \param vPropIdx The index of the property that contains the values of time series.
83  \param gPropIdx The index of the property that contains the location of time series.
84  \param idPropIdx The index of the property that contains the identity of the time series.
85  \param id The time series id.
86 
87  \note It will take the ownership of the input pointer.
88  */
89  TimeSeriesDataSet(te::da::DataSet* ds, int tPropIdx, int vPropIdx, int gPropIdx,
90  int idPropIdx, const std::string& id);
91 
92  /*!
93  \brief Constructor.
94 
95  \param ds The data set that contains the time series observations.
96  \param tPropIdx The index of the property that contains the times of time series.
97  \param vPropIdx The index of the property that contains the values of time series.
98  \param gPropIdx The index of the property that contains the location of time series.
99  \param idPropIdx The index of the property that contains the identity of the time series.
100  \param id The time series id.
101  \param text The temporal extent.
102 
103  \note It will take the ownership of the input pointers.
104  */
105  TimeSeriesDataSet(te::da::DataSet* ds, int tPropIdx, int vPropIdx, int gPropIdx,
106  int idPropIdx, const std::string& id, te::dt::DateTimePeriod* text);
107 
108  /*!
109  \brief Constructor.
110 
111  \param ds The data set that contains the time series observations.
112  \param tPropIdxs The indexes of the properties that contain the begin and end times of time series.
113  \param vPropIdxs The indexes of the properties that contain the values of time series.
114  \param gPropIdx The index of the property that contains the location of time series.
115  \param idPropIdx The index of the property that contains the identity of the time series.
116  \param id The time series id.
117 
118  \note It will take the ownership of the input pointer.
119  */
120  TimeSeriesDataSet(te::da::DataSet* ds, const std::vector<int>& tPropIdxs, const std::vector<int>& vPropIdxs,
121  int gPropIdx, int idPropIdx, const std::string& id);
122 
123  /*!
124  \brief Constructor.
125 
126  \param ds The data set that contains the time series observations.
127  \param tPropIdxs The indexes of the properties that contain the begin and end times of time series.
128  \param vPropIdxs The indexes of the properties that contain the values of time series.
129  \param gPropIdx The index of the property that contains the location of time series.
130  \param idPropIdx The index of the property that contains the identity of the time series.
131  \param id The time series id.
132  \param text The temporal extent.
133 
134  \note It will take the ownership of the input pointer.
135  */
136  TimeSeriesDataSet(te::da::DataSet* ds, const std::vector<int>& tPropIdxs, const std::vector<int>& vPropIdxs,
137  int gPropIdx, int idPropIdx, const std::string& id, te::dt::DateTimePeriod* text);
138  /*!
139  \brief Constructor.
140 
141  \param ds The data set that contains the time series observations.
142  \param type The time series data set type.
143  \param text The temporal extent.
144 
145  \note It will take the ownership of the input pointer.
146  \note This constructor is used when each observation of a trajectory is associated to a period and
147  the DataSet uses two properties to store these periods.
148  */
150 
151  /*!
152  \brief Constructor.
153 
154  \param obs The data set that contains the time series observations.
155  \param type The time series data set type.
156  \param id The time series id
157 
158  \note It will take the ownership of the given pointer.
159  */
160  TimeSeriesDataSet(ObservationDataSet* obs, const TimeSeriesDataSetType& type, const std::string& id);
161  //@}
162 
163  /*!
164  \brief It returns the data set that contains the time series observations.
165 
166  \return A pointer to the data set that contains the time series observations.
167 
168  \note The caller will NOT take the ownership of the input pointer.
169  */
170  ObservationDataSet* getObservationSet() const;
171 
172  /*!
173  \brief It returns a reference to the internal time series data set type.
174 
175  \return A reference to the internal time series data set type.
176  */
177  const TimeSeriesDataSetType& getType() const;
178 
179  /*!
180  \brief It returns the identifier associated to the time series.
181 
182  \return The identifier associated to the time series.
183  */
184  std::string getId() const;
185 
186  /*!
187  \brief It sets the identifier associated to the time series.
188 
189  \param id The identifier associated to the time series.
190  */
191  void setId(const std::string& id);
192 
193  /*!
194  \brief It returns the size of the time series observation set.
195 
196  \return The observation set size of the time series.
197  */
198  std::size_t size() const;
199 
200  /*! \name Methods to traverse the trajectory observations and to check the
201  internal cursor pointer*/
202  //@{
203  bool moveNext();
204 
205  bool movePrevious();
206 
207  bool moveFirst();
208 
209  bool moveBeforeFirst();
210 
211  bool moveLast();
212 
213  bool isAtBegin() const;
214 
215  bool isBeforeBegin() const;
216 
217  bool isAtEnd() const;
218 
219  bool isAfterEnd() const;
220  //@}
221 
222  /*! \name Methods to get values pointed by the internal cursor.
223  //@{
224 
225  /*!
226  \brief It returns the time pointed by the internal cursor.
227 
228  \return A pointer to the time pointed by the internal cursor.
229 
230  \note The caller will take the ownership of the returned pointer.
231  */
232  std::auto_ptr<te::dt::DateTime> getTime() const;
233 
234  /*!
235  \brief It returns the idx-th observed value pointed by the internal cursor.
236 
237  \return A pointer to the idx-th observed value pointed by the internal cursor.
238 
239  \note The caller will take the ownership of the returned pointer.
240  */
241  std::auto_ptr<te::dt::AbstractData> getValue(std::size_t idx) const;
242 
243  /*!
244  \brief It returns the observed value pointed by the internal cursor.
245 
246  \return A pointer to the observed value 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::AbstractData> getValue() const;
251 
252  /*!
253  \brief It returns the idx-th observed value as double pointed by the internal cursor.
254 
255  \return A pointer to the idx-th observed value as double pointed by the internal cursor.
256  */
257  double getDouble(std::size_t idx) const;
258 
259  /*!
260  \brief It returns the observed value as double pointed by the internal cursor.
261 
262  \return A pointer to the observed value as double pointed by the internal cursor.
263  */
264  double getDouble() const;
265 
266  /*!
267  \brief It returns the idx-th observed value as integer pointed by the internal cursor.
268 
269  \return A pointer to the idx-th observed value as integer pointed by the internal cursor.
270 
271  \note It returns a 32-bit integer.
272  */
273  int getInt(std::size_t idx) const;
274 
275  /*!
276  \brief It returns the observed value as double pointed by the internal cursor.
277 
278  \return A pointer to the observed value as double pointed by the internal cursor.
279 
280  \note It returns a 32-bit integer.
281  */
282  int getInt() const;
283 
284  /*!
285  \brief It returns the geometry pointed by the internal cursor.
286 
287  \return A pointer to the geometry pointed by the internal cursor.
288 
289  \note The caller will take the ownership of the returned pointer.
290  */
291  std::auto_ptr<te::gm::Geometry> getGeometry() const;
292  //@}
293 
294  /*!
295  \brief It returns the temporal extent of the time series observations.
296 
297  \return The temporal extent of the trajectory observations.
298 
299  \note The caller will NOT take the ownership of the output pointer.
300  */
301  te::dt::DateTimePeriod* getTemporalExtent() const;
302 
303  /*!
304  \brief It returns the time series from the DataSet.
305 
306  This method encapsulates all observations of this DataSet as a
307  TimeSeries type associated to a given interpolator.
308 
309  \param interp The time series interpolator.
310 
311  \return The time series associated to a given interpolator.
312 
313  \note The caller will take the ownership of the returned pointer.
314  \note It uses the first observed property to generate the time series.
315  */
316  std::auto_ptr<TimeSeries> getTimeSeries(te::st::AbstractTimeSeriesInterp* interp);
317 
318  /*!
319  \brief It returns the time series from the DataSet.
320 
321  This method encapsulates all observations of this DataSet as a
322  TimeSeries type associated to a given interpolator.
323 
324  \param idx The index of the observed property to be considered
325  \param interp The time series interpolator.
326 
327  \return The time series associated to a given interpolator.
328 
329  \note The caller will take the ownership of the returned pointer.
330  */
331  std::auto_ptr<TimeSeries> getTimeSeries(int idx, te::st::AbstractTimeSeriesInterp* interp);
332 
333  /*!
334  \brief It returns all time series from the DataSet.
335 
336  This method encapsulates all observations of this DataSet as a
337  set of TimeSeries associated to a given interpolator.
338 
339  \param interp The time series interpolator.
340  \param result The returned set of time series.
341 
342  \note The caller will take the ownership of the returned pointers.
343  */
344  void getTimeSeriesSet( te::st::AbstractTimeSeriesInterp* interp,
345  std::vector<te::st::TimeSeries*>& result);
346 
347  /*!
348  \brief It returns the trajectory geometry property.
349 
350  \return The trajectory geometry property.
351 
352  \note The caller will NOT take the ownership of the returned pointer.
353  */
354  //te::gm::GeometryProperty* getGeometryProperty() const;
355 
356  /*!
357  \brief It returns the trajectory datetime property.
358 
359  \return The trajectory datetime property.
360 
361  \note The caller will NOT take the ownership of the returned pointer.
362  */
363  //te::dt::DateTimeProperty* getTimeProperty() const;
364 
365  /*! \brief Virtual destructor. */
366  virtual ~TimeSeriesDataSet();
367 
368  protected:
369 
370  /*!
371  \brief It releases all internal pointers, returning its internal DataSet and invalidating itself
372  \return A pointer to the internal DataSet that contains the observations.
373 
374  \note This method is used when the user is interested only in its internal DataSet
375  \note The caller will take the ownership of the returned pointer.
376  */
377  std::auto_ptr<te::da::DataSet> release();
378 
379  private:
380  std::auto_ptr<ObservationDataSet> m_obsDs; //!< The data set that contains the trajectory observations
381  TimeSeriesDataSetType m_type; //!< The trajectory type.
382  std::string m_id; //!< The trajectory identification.
383  };
384  } // end namespace st
385 } // end namespace te
386 
387 #endif // __TERRALIB_ST_INTERNAL_TIMESERIESDATASET_H
388 
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:90
A layer with reference to a dataset that contains trajectories.
A class to represent a time series data set.
A class to represent a DataSet that contains observations.
A class that contains complemental information about a DataSet that holds observations of a time seri...
This file contains a class called TimeSeriesDataSetType.
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.