All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObservationDataSet.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 ObservationDataSet.h
22 
23  \brief This file contains a class to represent an observation data set.
24 */
25 
26 #ifndef __TERRALIB_ST_INTERNAL_OBSERVATIONDATASET_H
27 #define __TERRALIB_ST_INTERNAL_OBSERVATIONDATASET_H
28 
29 //ST
30 #include "../../Config.h"
31 #include "ObservationDataSetType.h"
32 
33 //TerraLib
34 #include "../../../geometry/Envelope.h"
35 #include "../../../datatype/DateTimePeriod.h"
36 
37 // Boost
38 #include <boost/noncopyable.hpp>
39 
40 //STL
41 #include <memory>
42 
43 // Forward declarations
44 namespace te { namespace da { class DataSet; class DataSetType; } }
45 namespace te { namespace dt { class Property; class DateTime; class DateTimePeriod; } }
46 namespace te { namespace gm { class Envelope; class Geometry; } }
47 
48 namespace te
49 {
50  namespace st
51  {
52 
53  // Forward declarations
54  class ObservationDataSetType;
55  class Observation;
56  class TrajectoryDataSet;
57  class TimeSeriesDataSet;
58 
59  /*!
60  \class ObservationDataSet
61 
62  \brief A class to represent a DataSet that contains observations.
63 
64  This class implements a view on a data set. It encapsulates a DataSet as a
65  ObservationDataSet. An observation data set is composed of a finite number
66  of homogeneous observations, that is,
67  every observation has the same number and type of observed values.
68 
69  \ingroup st
70 
71  \sa DataSet Observation DataSource
72  */
73 
74  /*
75  \\\Nota: Poderíamos ter internamente um ponteiro para o STDataLoader
76  \\\ que o gerou ou para o Info (para obter o STDataLoader)... isso seria útil para:
77  \\\ (1) calcular o temporalExtent.
78  \\\ (2) carregar o dado por partes e não tudo de uma vez
79  \\\ mas por enquanto vamos deixar sem esse ponteiro.
80  \\\ No caso do temporalExtent, a pessoa pode informar no construtor ou não
81  */
82  class TESTEXPORT ObservationDataSet : public boost::noncopyable
83  {
85  friend class TrajectoryDataSet;
86  friend class TimeSeriesDataSet;
87 
88  public:
89 
90  /*! \name Constructors */
91  //@{
92  /*! \brief Constructor.
93 
94  It constructs an observation data set, based on the given
95  DataSet and ObservationDataSetType
96 
97  \param ds the DataSet
98  \param obst extra information about the properies of the DataSet
99 
100  \note It will take the ownership of the DataSet pointer
101  */
103 
104  /*! \brief Constructor.
105 
106  It constructs an observation data set, based on the given
107  DataSet and ObservationDataSetType
108 
109  \param ds The DataSet.
110  \param obst extra information about the properies of the DataSet
111  \param text the temporal extent
112 
113  \note It will take the ownership of the given pointers
114  */
116  te::dt::DateTimePeriod* text);
117 
118  /*! \brief Constructor.
119 
120  It constructs an observation data set, based on the given
121  DataSet and ObservationDataSetType
122 
123  \param ds The DataSet.
124  \param obst extra information about the properies of the DataSet
125  \param text the temporal extent
126  \param sext the spatial extent
127 
128  \note It will take the ownership of the given pointers
129  */
131  te::dt::DateTimePeriod* text, const te::gm::Envelope& sext);
132 
133  /*! \brief Constructor.
134 
135  \param ds The DataSet.
136  \param phTimeIdx The index of the property that contains the phenomenon time.
137  \param obsPropIdx The index of the property that is observed.
138  \param geomPropIdx The index of the observed property that contains the geometry.
139 
140  \note It will take the ownership of the DataSet pointer
141  */
142  ObservationDataSet( te::da::DataSet* ds, int phTimeIdx, int obsPropIdx,
143  int geomPropIdx = -1);
144 
145  /*! \brief Constructor.
146 
147  \param ds the DataSet
148  \param phTimeIdxs The indexes of the property that contains the begin and final phenomenon time.
149  \param obsPropIdx The indexes of the properties that are observed.
150  \param geomPropIdx The index of the observed property that contains the geometry.
151 
152  \note It will take the ownership of the DataSet pointer
153  */
154  ObservationDataSet( te::da::DataSet* ds, const std::vector<int>& phTimeIdxs,
155  const std::vector<int>& obsPropIdxs, int geomPropIdx = -1);
156 
157  /*! \brief Constructor.
158 
159  \param ds The DataSet
160  \param phTimeIdx The index of the property that contains the phenomenon time.
161  \param obsPropIdx The index of the property that is observed.
162  \param geomPropIdx The index of the observed property that contains the geometry.
163  \param text The temporal extent
164  \param sext The spatial extent
165 
166  \note It will take the ownership of the DataSet pointer
167  */
168  ObservationDataSet( te::da::DataSet* ds, int phTimeIdx, int obsPropIdx,
169  int geomPropIdx, te::dt::DateTimePeriod* text);
170 
171 
172  /*! \brief Constructor.
173 
174  \param ds The DataSet
175  \param phTimeIdx The index of the property that contains the phenomenon time.
176  \param obsPropIdx The index of the property that is observed.
177  \param geomPropIdx The index of the observed property that contains the geometry.
178  \param text The temporal extent
179  \param sext The spatial extent
180 
181  \note It will take the ownership of the DataSet pointer
182  */
183  ObservationDataSet( te::da::DataSet* ds, int phTimeIdx, int obsPropIdx,
184  int geomPropIdx, te::dt::DateTimePeriod* text,
185  const te::gm::Envelope& sext);
186 
187  /*! \brief Constructor.
188 
189  \param ds The DataSet
190  \param phTimeIdxs The index of the property that contains the begin and end times.
191  \param obsPropIdxs The indexes of the properties that are observed.
192  \param geomPropIdx The index of the observed property that contains the geometry.
193  \param text The temporal extent
194  \param sext The spatial extent
195 
196  \note It will take the ownership of the DataSet pointer
197  */
198  ObservationDataSet( te::da::DataSet* ds, const std::vector<int>& phTimeIdxs,
199  const std::vector<int>& obsPropIdxs, int geomPropIdx,
200  te::dt::DateTimePeriod* text);
201 
202  /*! \brief Constructor.
203 
204  \param ds The DataSet
205  \param phTimeIdxs The index of the property that contains the begin and end times.
206  \param obsPropIdxs The indexes of the properties that are observed.
207  \param geomPropIdx The index of the observed property that contains the geometry.
208  \param text The temporal extent
209  \param sext The spatial extent
210 
211  \note It will take the ownership of the DataSet pointer
212  */
213  ObservationDataSet( te::da::DataSet* ds, const std::vector<int>& phTimeIdxs,
214  const std::vector<int>& obsPropIdxs, int geomPropIdx,
215  te::dt::DateTimePeriod* text, const te::gm::Envelope& sext);
216  //@}
217 
218  /*!
219  \brief It returns the DataSet that contains the observations.
220 
221  \return A pointer to the internal DataSet that contains the observations.
222 
223  \note The caller will NOT take the ownership of the returned pointer.
224  */
225  te::da::DataSet* getData() const;
226 
227  /*!
228  \brief It returns a reference to the ObservationDataSetType.
229 
230  \return A reference to the internal ObservationDataSetType.
231  */
232  const ObservationDataSetType& getType() const;
233 
234  /*!
235  \brief It returns the spatial extent of the observations,
236  when there is an observed value of geometry type.
237 
238  \return The spatial extent of the observations.
239  */
240  const te::gm::Envelope& getSpatialExtent();
241 
242  /*!
243  \brief It sets the spatial extent of the observations,
244  when there is an observed value of geometry type.
245 
246  \param ext The spatial extent of the observations.
247  */
248  void setSpatialExtent(const te::gm::Envelope& ext);
249 
250  /*!
251  \brief It returns the temporal extent of the observations.
252 
253  \return The temporal extent of the observations.
254 
255  \note The caller will NOT take the ownership of the returned pointer.
256  */
257  te::dt::DateTimePeriod* getTemporalExtent();
258 
259  /*!
260  \brief It sets the temporal extent of the observations,
261  when there is an observed value of geometry type.
262 
263  \param ext The temporal extent of the observations.
264 
265  \note It will take the ownership of the given pointer.
266  */
267  void setTemporalExtent(te::dt::DateTimePeriod* ext);
268 
269  /*! \name Methods to traverse the observation set and to check the
270  internal cursor pointer*/
271  //@{
272  bool moveNext();
273 
274  bool movePrevious();
275 
276  bool moveFirst();
277 
278  bool moveBeforeFirst();
279 
280  bool moveLast();
281 
282  bool isAtBegin() const;
283 
284  bool isBeforeBegin() const;
285 
286  bool isAtEnd() const;
287 
288  bool isAfterEnd() const;
289  //@}
290 
291  /*!
292  \brief It returns the observation pointed by the internal cursor.
293 
294  \return The observation pointed by the internal cursor.
295 
296  \note The caller will take the ownership of the output pointer.
297  */
298  std::auto_ptr<Observation> getObservation() const;
299 
300  /*! \name Methods to return the properties associated to observations. */
301  //@{
302  /*!
303  \brief It returns the property of the phenomenon beginning time.
304 
305  \return The property of the phenomenon beginning time.
306 
307  \note The caller will NOT take the ownership of the returned pointer.
308  */
309  //te::dt::DateTimeProperty* getBeginTimeProperty() const;
310 
311  /*!
312  \brief It returns the property of the phenomenon end time.
313 
314  \return The property of the phenomenon end time.
315 
316  \note The caller will NOT take the ownership of the returned pointer.
317  */
318  //te::dt::DateTimeProperty* getEndTimeProperty() const;
319 
320  /*!
321  \brief It returns the properties of the observed values.
322 
323  \param output the properties of the observed values.
324 
325  \note The caller will NOT take the ownership of the output pointers.
326  */
327  //void getObsProperties(std::vector<te::dt::Property*> output);
328 
329  /*!
330  \brief It returns the property of the valid beginning time.
331 
332  \return The property of the valid beginning time.
333 
334  \note The caller will NOT take the ownership of the returned pointer.
335  */
336  //te::dt::DateTimeProperty* getVlBeginTimeProperty() const;
337 
338  /*!
339  \brief It returns the property of the valid end time.
340 
341  \return The property of the valid end time.
342 
343  \note The caller will NOT take the ownership of the returned pointer.
344  */
345  //te::dt::DateTimeProperty* getVlEndTimeProperty() const;
346 
347  /*!
348  \brief It returns the property of the result time.
349 
350  \return The property of the result time.
351 
352  \note The caller will NOT take the ownership of the returned pointer.
353  */
354  //te::dt::DateTimeProperty* getRsTimeProperty() const;
355  //@}
356 
357  /*! \brief Virtual destructor. */
358  virtual ~ObservationDataSet();
359 
360  protected:
361 
362  /*!
363  \brief It releases all internal pointers, returning its internal DataSet and invalidating itself
364  \return A pointer to the internal DataSet that contains the observations.
365 
366  \note This method is used when the user is interested only in its internal DataSet
367  \note The caller will take the ownership of the returned pointer.
368  */
369  std::auto_ptr<te::da::DataSet> release();
370 
371  private:
372 
373  std::auto_ptr<te::da::DataSet> m_ds; //! A data set that contains observations
374  ObservationDataSetType m_obst; //! An observation data set type that refers to m_ds
375  std::auto_ptr<te::dt::DateTimePeriod> m_tpExtent; //! Its temporal extent
376  te::gm::Envelope m_spExtent; //! Its spatial extent
377  };
378 
379  typedef std::auto_ptr<ObservationDataSet> ObservationDataSetPtr;
380 
381  } // end namespace st
382 } // end namespace te
383 
384 #endif // __TERRALIB_ST_INTERNAL_OBSERVATIONDATASET_H
385 
386 
387 
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:90
std::auto_ptr< ObservationDataSet > ObservationDataSetPtr
A layer with reference to a dataset that contains observations.
A class to represent a time series data set.
A class to represent a DataSet that contains observations.
ObservationDataSetType m_obst
A data set that contains observations.
This file contains a class called ObservationDataSetType.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
std::auto_ptr< te::dt::DateTimePeriod > m_tpExtent
An observation data set type that refers to m_ds.
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
te::gm::Envelope m_spExtent
Its temporal extent.
An abstract class to represent a period of date and time.
std::auto_ptr< te::da::DataSet > m_ds
A class that contains complemental DataSetType information about a DataSet that holds observations...