Loading...
Searching...
No Matches
TimeSeriesDataSet.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 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
32// Boost
33#include <boost/noncopyable.hpp>
34
35//STL
36#include <vector>
37#include <memory>
38
39// Forward declarations
40namespace te { namespace dt { class AbstractData; class DateTime; class DateTimePeriod; class DateTimeProperty;} }
41namespace te { namespace gm { class Geometry; class GeometryProperty; } }
42
43namespace te
44{
45 namespace st
46 {
47 // Forward declarations
48 class ObservationDataSet;
49 class ObservationDataSetType;
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 {
72
73 public:
74 /*!
75 \brief Constructor.
76
77 \param ds The data set that contains the time series observations.
78 \param type The observation data set type.
79 \param propNames The names of the properties that contains the time series values
80
81 \note It will take the ownership of the input pointer.
82 */
84 const std::vector<std::string>& propNames);
85
86 /*!
87 \brief Constructor.
88
89 \param ds The data set that contains the time series observations.
90 \param type The observation data set type.
91 \param propNames The names of the properties that contains the time series values
92 \param id The time series id
93
94 \note It will take the ownership of the input pointer.
95 */
97 const std::vector<std::string>& propNames, const std::string& id);
98
99 /*!
100 \brief Constructor.
101
102 \param obs The data set that contains the time series observations.
103 \param propNames The names of the properties that contains the time series values
104 \param id The time series id
105
106 \note It will take the ownership of the given pointer.
107 */
108 TimeSeriesDataSet(ObservationDataSet* obs, const std::vector<std::string>& propNames,
109 const std::string& id);
110 //@}
111
112 /*!
113 \brief It returns the data set that contains the time series observations.
114
115 \return A pointer to the data set that contains the time series observations.
116
117 \note The caller will NOT take the ownership of the input pointer.
118 */
120
121 /*!
122 \brief It returns the indexes of the DataSet properties that contains the values associated to the time series.
123
124 \return The indexes of the DataSet properties that contains the observed values.
125 */
126 const std::vector<std::string>& getValuePropNames() const;
127
128 /*!
129 \brief It sets the names of the DataSet properties that contains the values associated to the time series.
130
131 \param n The names of the DataSet properties that contains the time series values.
132 */
133 void setValuePropNames(const std::vector<std::string>& n);
134
135 /*!
136 \brief It returns the identifier associated to the time series.
137
138 \return The identifier associated to the time series.
139 */
140 std::string getId() const;
141
142 /*!
143 \brief It sets the identifier associated to the time series.
144
145 \param id The identifier associated to the time series.
146 */
147 void setId(const std::string& id);
148
149 /*!
150 \brief It returns the size of the time series observation set.
151
152 \return The observation set size of the time series.
153 */
154 std::size_t size() const;
155
156 /*! \name Methods to traverse the trajectory observations and to check the
157 internal cursor pointer*/
158 //@{
159 bool moveNext();
160
162
163 bool moveFirst();
164
166
167 bool moveLast();
168
169 bool isAtBegin() const;
170
171 bool isBeforeBegin() const;
172
173 bool isAtEnd() const;
174
175 bool isAfterEnd() const;
176 //@}
177
178 /*! \name Methods to get values pointed by the internal cursor. */
179 //@{
180
181 /*!
182 \brief It returns the time pointed by the internal cursor.
183
184 \return A pointer to the time pointed by the internal cursor.
185
186 \note The caller will take the ownership of the returned pointer.
187 */
188 std::unique_ptr<te::dt::DateTime> getTime() const;
189
190 /*!
191 \brief It returns the idx-th observed value pointed by the internal cursor.
192
193 \return A pointer to the idx-th observed value pointed by the internal cursor.
194
195 \note The caller will take the ownership of the returned pointer.
196 */
197 std::unique_ptr<te::dt::AbstractData> getValue(std::size_t idx) const;
198
199 /*!
200 \brief It returns the observed value pointed by the internal cursor.
201
202 \return A pointer to the observed value pointed by the internal cursor.
203
204 \note The caller will take the ownership of the returned pointer.
205 */
206 std::unique_ptr<te::dt::AbstractData> getValue() const;
207
208 /*!
209 \brief It returns the idx-th observed value as double pointed by the internal cursor.
210
211 \return A pointer to the idx-th observed value as double pointed by the internal cursor.
212 */
213 double getDouble(std::size_t idx) const;
214
215 /*!
216 \brief It returns the observed value as double pointed by the internal cursor.
217
218 \return A pointer to the observed value as double pointed by the internal cursor.
219 */
220 double getDouble() const;
221
222 /*!
223 \brief It returns the idx-th observed value as integer pointed by the internal cursor.
224
225 \return A pointer to the idx-th observed value as integer pointed by the internal cursor.
226
227 \note It returns a 32-bit integer.
228 */
229 int getInt(std::size_t idx) const;
230
231 /*!
232 \brief It returns the observed value as double pointed by the internal cursor.
233
234 \return A pointer to the observed value as double pointed by the internal cursor.
235
236 \note It returns a 32-bit integer.
237 */
238 int getInt() const;
239
240 /*!
241 \brief It returns the geometry pointed by the internal cursor.
242
243 \return A pointer to the geometry pointed by the internal cursor.
244
245 \note The caller will take the ownership of the returned pointer.
246 */
247 std::unique_ptr<te::gm::Geometry> getGeometry() const;
248 //@}
249
250 /*!
251 \brief It returns the temporal extent of the time series 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 */
258
259 /*!
260 \brief It returns the time series from the DataSet.
261
262 This method encapsulates all observations of this DataSet as a
263 TimeSeries type associated to a given interpolator.
264
265 \param interp The time series interpolator.
266
267 \return The time series associated to a given interpolator.
268
269 \note The caller will take the ownership of the returned pointer.
270 \note It uses the first observed property to generate the time series.
271 */
272 std::unique_ptr<TimeSeries> getTimeSeries(te::st::AbstractTimeSeriesInterp* interp);
273
274 /*!
275 \brief It returns the time series from the DataSet.
276
277 This method encapsulates all observations of this DataSet as a
278 TimeSeries type associated to a given interpolator.
279
280 \param propName The name of the observed property to be considered
281 \param interp The time series interpolator.
282
283 \return The time series associated to a given interpolator.
284
285 \note The caller will take the ownership of the returned pointer.
286 */
287 std::unique_ptr<TimeSeries> getTimeSeries(const std::string& propName, te::st::AbstractTimeSeriesInterp* interp);
288
289 /*!
290 \brief It returns all time series from the DataSet.
291
292 This method encapsulates all observations of this DataSet as a
293 set of TimeSeries associated to a given interpolator.
294
295 \param interp The time series interpolator.
296 \param vPropName The property name that contains the attribute values associated to a time series
297 \param result The returned set of time series.
298
299 \note The caller will take the ownership of the returned pointers.
300 */
302 const std::string& vPropName,
303 std::vector<te::st::TimeSeries*>& result);
304
305 /*!
306 \brief It returns the trajectory geometry property.
307
308 \return The trajectory geometry property.
309
310 \note The caller will NOT take the ownership of the returned pointer.
311 */
312 //te::gm::GeometryProperty* getGeometryProperty() const;
313
314 /*!
315 \brief It returns the trajectory datetime property.
316
317 \return The trajectory datetime property.
318
319 \note The caller will NOT take the ownership of the returned pointer.
320 */
321 //te::dt::DateTimeProperty* getTimeProperty() const;
322
323 /*! \brief Virtual destructor. */
325
326 protected:
327
328 /*!
329 \brief It releases all internal pointers, returning its internal DataSet and invalidating itself
330 \return A pointer to the internal DataSet that contains the observations.
331
332 \note This method is used when the user is interested only in its internal DataSet
333 \note The caller will take the ownership of the returned pointer.
334 */
335 std::unique_ptr<te::da::DataSet> release();
336
337 private:
338 std::unique_ptr<ObservationDataSet> m_obsDs; //!< The data set that contains the trajectory observations
339 std::vector<std::string> m_vlPropNames; //!< The names of the properties that contain the time series values.
340 std::string m_id; //!< The time series identification.
341 };
342 } // end namespace st
343} // end namespace te
344
345#endif // __TERRALIB_ST_INTERNAL_TIMESERIESDATASET_H
346
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
An abstract class to represent a period of date and time.
An abstract class for an interpolation function or interpolator that estimate a value at non-observav...
A class that contains complemental DataSetType information about a DataSet that holds observations.
A class to represent a DataSet that contains observations.
A layer with reference to a dataset that contains trajectories.
A class to represent a time series data set.
std::size_t size() const
It returns the size of the time series observation set.
ObservationDataSet * getObservationSet() const
It returns the data set that contains the time series observations.
std::string getId() const
It returns the identifier associated to the time series.
TimeSeriesDataSet(te::da::DataSet *ds, const ObservationDataSetType &type, const std::vector< std::string > &propNames)
Constructor.
void setId(const std::string &id)
It sets the identifier associated to the time series.
int getInt() const
It returns the observed value as double pointed by the internal cursor.
std::unique_ptr< te::dt::AbstractData > getValue() const
It returns the observed value pointed by the internal cursor.
TimeSeriesDataSet(ObservationDataSet *obs, const std::vector< std::string > &propNames, const std::string &id)
Constructor.
std::vector< std::string > m_vlPropNames
The names of the properties that contain the time series values.
std::unique_ptr< te::da::DataSet > release()
It releases all internal pointers, returning its internal DataSet and invalidating itself.
std::unique_ptr< ObservationDataSet > m_obsDs
The data set that contains the trajectory observations.
std::unique_ptr< te::dt::AbstractData > getValue(std::size_t idx) const
It returns the idx-th observed value pointed by the internal cursor.
std::unique_ptr< te::dt::DateTime > getTime() const
It returns the time pointed by the internal cursor.
const std::vector< std::string > & getValuePropNames() const
It returns the indexes of the DataSet properties that contains the values associated to the time seri...
int getInt(std::size_t idx) const
It returns the idx-th observed value as integer pointed by the internal cursor.
const te::dt::DateTimePeriod * getTemporalExtent() const
It returns the temporal extent of the time series observations.
std::unique_ptr< TimeSeries > getTimeSeries(const std::string &propName, te::st::AbstractTimeSeriesInterp *interp)
It returns the time series from the DataSet.
void getTimeSeriesSet(te::st::AbstractTimeSeriesInterp *interp, const std::string &vPropName, std::vector< te::st::TimeSeries * > &result)
It returns all time series from the DataSet.
std::unique_ptr< te::gm::Geometry > getGeometry() const
It returns the geometry pointed by the internal cursor.
double getDouble(std::size_t idx) const
It returns the idx-th observed value as double pointed by the internal cursor.
std::string m_id
The time series identification.
void setValuePropNames(const std::vector< std::string > &n)
It sets the names of the DataSet properties that contains the values associated to the time series.
std::unique_ptr< TimeSeries > getTimeSeries(te::st::AbstractTimeSeriesInterp *interp)
It returns the time series from the DataSet.
TimeSeriesDataSet(te::da::DataSet *ds, const ObservationDataSetType &type, const std::vector< std::string > &propNames, const std::string &id)
Constructor.
double getDouble() const
It returns the observed value as double pointed by the internal cursor.
virtual ~TimeSeriesDataSet()
It returns the trajectory geometry property.
TerraLib.
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88