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