All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
STDataLoaderImpl.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 STDataLoaderImpl.h
22 
23  \brief This file contains an abstract class responsible for loading
24  spatiotemporal data from data sources.
25 */
26 
27 #ifndef __TERRALIB_ST_INTERNAL_STDATALOADERIMPL_H
28 #define __TERRALIB_ST_INTERNAL_STDATALOADERIMPL_H
29 
30 //TerraLib
31 #include "../../common/Enums.h"
32 #include "../../geometry/Enums.h"
33 #include "../../geometry/Envelope.h"
34 #include "../../datatype/Enums.h"
35 
36 //ST
37 #include "../Config.h"
38 
39 //STL
40 #include <memory>
41 
42 //Boost
43 #include <boost/ptr_container/ptr_vector.hpp>
44 
45 // Forward declarations
46 namespace te { namespace gm { class Geometry; } }
47 namespace te { namespace dt { class DateTime; class DateTimePeriod; } }
48 
49 namespace te
50 {
51  namespace st
52  {
53  // Forward declarations
54  class ObservationDataSet;
55  class TrajectoryDataSet;
56  class TimeSeriesDataSet;
57  class CoverageSeriesDataSet;
58  class ObservationDataSetInfo;
59  class TrajectoryDataSetInfo;
60  class TimeSeriesDataSetInfo;
61  class CoverageSeriesDataSetInfo;
62  class Trajectory;
63  class TimeSeries;
64  class CoverageSeries;
65 
66  /*!
67  \class STDataLoaderImpl
68 
69  \brief An abstract class responsible for loading spatiotemporal data
70  from data sources.
71 
72  \note The methods of this class can throw an Exception when internal errors occur.
73 
74  \sa ObservationDataSet ObservationDataSetInfo
75  \sa TrajectoryDataSet TrajectoryDataSetInfo
76  \sa CoverageSeriesDataSet CoverageSeriesDataSetInfo
77  */
79  {
80  public:
81 
82  /*! \brief Empty constructor */
84 
85  /*! \name Operations for loading ObservationDataSet */
86  //@{
87 
88  /*!
89  \brief It returns a ObservationDataSet, that is, a DataSet that contains observations.
90 
91  \param info Information about the DataSource which the observation are from and
92  the DataSet which contains the observations.
93  \param travType The traverse type associated to the returned dataset.
94 
95  \return A pointer to a new ObservationDataSet.
96 
97  \note The caller will take the ownership of the returned pointer.
98  \note It can throw an Exception when internal errors occur.
99  */
100  virtual std::auto_ptr<ObservationDataSet> getDataSet(const ObservationDataSetInfo& info,
102 
103  /*!
104  \brief It returns a data set with observations whose observed geometries satisfy a
105  given spatial relation.
106 
107  \param info Information about the DataSource which the observation are from and
108  the DataSet which contains the observations.
109  \param e A given envelope.
110  \param r A given spatial relation.
111  \param travType The traverse type associated to the returned dataset.
112 
113  \return A pointer to a new ObservationDataSet.
114 
115  \note The caller will take the ownership of the returned pointer.
116  \note It can throw an Exception when internal errors occur.
117  */
118  virtual std::auto_ptr<ObservationDataSet> getDataSet(const ObservationDataSetInfo& info, const te::gm::Envelope& e,
121 
122  /*!
123  \brief It returns a data set with observations whose observed geometries satisfy a
124  given spatial relation.
125 
126  The possible spatial relations implemented here are: INTERSECTS
127 
128  \param info Information about the DataSource which the observation are from and
129  the DataSet which contains the observations.
130  \param geom A given geometry.
131  \param r A given spatial relation.
132  \param travType The traverse type associated to the returned dataset.
133 
134  \return A pointer to a new ObservationDataSet.
135 
136  \note The caller will take the ownership of the returned pointer.
137  \note It can throw an Exception when internal errors occur.
138  */
139  virtual std::auto_ptr<ObservationDataSet> getDataSet(const ObservationDataSetInfo& info, const te::gm::Geometry& geom,
142 
143  /*!
144  \brief It returns a data set with observations whose phenomenon times satisfy a
145  given temporal relation.
146 
147  The possible temporal relations are: 1. AFTER;
148  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
149 
150  \param info Information about the DataSource which the observation are from and
151  the DataSet which contains the observations.
152  \param dt A given datetime.
153  \param r A given temporal relation.
154  \param travType The traverse type associated to the returned dataset.
155 
156  \return A pointer to a new ObservationDataSet.
157 
158  \note The caller will take the ownership of the returned pointer.
159  \note When the temporal relation is DURING, dt must be a time period.
160  \note It can throw an Exception when internal errors occur.
161  */
162  virtual std::auto_ptr<ObservationDataSet> getDataSet(const ObservationDataSetInfo& info,
165 
166  /*!
167  \brief It returns a data set with observations whose observed geometries
168  satisfy a given spatial relation and phenomenon times satisfy a given temporal relation.
169 
170  The possible temporal relations are: 1. AFTER;
171  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
172 
173  \param info Information about the DataSource which the observation of trajectpries
174  are from and the DataSet which contains the observations.
175  \param dt A given datetime.
176  \param tr A given temporal relation.
177  \param e A given envelope.
178  \param sr A given spatial relation.
179  \param travType The traverse type associated to the returned dataset.
180 
181  \return A pointer to a new ObservationDataSet.
182 
183  \note Before using this method, certify that the Data Source exists in the DataSourceManager and
184  its "id" is correct in the info parameter
185  \note The caller will take the ownership of the returned pointer.
186  \note When the temporal relation is DURING, dt must be a time period.
187  \note It can throw an Exception when internal errors occur.
188  */
189  virtual std::auto_ptr<ObservationDataSet> getDataSet(const ObservationDataSetInfo& info,
190  const te::dt::DateTime& dt,
192  const te::gm::Envelope& e,
195 
196  /*!
197  \brief It returns a data set with observations whose observed geometries satisfy a
198  given spatial relation and phenomenon times satisfy a given temporal relation.
199 
200  The possible spatial relations are: INTERSECTS
201  The possible temporal relations are: 1. AFTER;
202  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
203 
204  \param info Information about the DataSource which the observation are from and
205  the DataSet which contains the observations.
206  \param geom A given geometry.
207  \param sr A given spatial relation.
208  \param dt A given datetime.
209  \param tr A given temporal relation.
210  \param travType The traverse type associated to the returned dataset.
211 
212  \return A pointer to a new ObservationDataSet.
213 
214  \note The caller will take the ownership of the returned pointer.
215  \note It will NOT take the ownership of the given pointers.
216  \note When the temporal relation is DURING, dt must be a time period.
217  \note It can throw an Exception when internal errors occur.
218  */
219  virtual std::auto_ptr<ObservationDataSet> getDataSet(const ObservationDataSetInfo& info,
223  //@}
224 
225  /*! \name Operations for loading TrajectoryDataSet */
226  //@{
227 
228  /*!
229  \brief It returns the information about all trajectories that exist in a single DataSet.
230 
231  The information about the DataSource and DataSet that contains trajectories is defined
232  as a TrajectoryDataSetInfo (input parameter).
233 
234  The information about each trajectory (its correct id) is returned as a
235  TrajectoryDataSetInfo of the parameter output.
236  These results can be used to create TrajectoryDataSetLayers.
237 
238  \param input The information about the DataSource and DataSet that contains trajectories
239  \param output The information about each trajectory (its correct id).
240 
241  \note It can throw an Exception when internal errors occur.
242  */
243  virtual void getInfo( const TrajectoryDataSetInfo& input,
244  std::vector<TrajectoryDataSetInfo>& output) = 0;
245 
246  /*!
247  \brief It returns a data set with observations of a trajectory.
248 
249  When the DataSet contains more than one trajectory, the info parameter
250  (TrajectoryDataSetInfo) must contain the id of the desire trajectory that
251  must be returned as a TrajectoryDataSet.
252 
253  \param info Information about the DataSource which the observations of a trajectory
254  are from and the DataSet which contains these observations.
255  \param travType The traverse type associated to the returned datasets.
256  \param rwRole The read and write permission associated to the returned datasets.
257  \return The returned TrajectoryDataSet.
258 
259  \note The info must have the id of the desire trajectory
260  \note The caller will take the ownership of the returned pointer.
261  \note It can throw an Exception when internal errors occur.
262  */
263  virtual std::auto_ptr<TrajectoryDataSet> getDataSet(const TrajectoryDataSetInfo& info,
265 
266  /*!
267  \brief It returns patches of a trajectory whose geometries
268  satisfy a given spatial relation.
269 
270  When the DataSet contains more than one trajectory, the info parameter
271  (TrajectoryDataSetInfo) must contain the id of the desire trajectory that
272  must be returned as a TrajectoryDataSet.
273 
274  The possible spatial relations implemented here are: INTERSECTS
275 
276  \param info Information about the DataSource which the observations of a trajectory
277  are from and the DataSet which contains these observations.
278  \param geom A given geometry.
279  \param r A given spatial relation.
280  \param travType The traverse type associated to the returned dataset.
281 
282  \return The returned trajectoy data set.
283 
284  \note The caller will take the ownership of the returned pointer.
285  \note It can throw an Exception when internal errors occur.
286  */
287  virtual std::auto_ptr<TrajectoryDataSet> getDataSet(const TrajectoryDataSetInfo& info,
290 
291  /*!
292  \brief It returns patches of a trajectory whose geometries
293  satisfy a given spatial relation.
294 
295  When the DataSet contains more than one trajectory, the info parameter
296  (TrajectoryDataSetInfo) must contain the id of the desire trajectory that
297  must be returned as a TrajectoryDataSet.
298 
299  \param info Information about the DataSource which the observations of a trajectory are from
300  and the DataSet which contains the observations.
301  \param e A given envelope.
302  \param r A given spatial relation.
303  \param travType The traverse type associated to the returned dataset.
304 
305  \return The returned trajectoy data set.
306 
307  \note The caller will take the ownership of the returned pointer.
308  \note It can throw an Exception when internal errors occur.
309  */
310  virtual std::auto_ptr<TrajectoryDataSet> getDataSet(const TrajectoryDataSetInfo& info,
313 
314  /*!
315  \brief It returns a data set with observations of trajectories whose times
316  satisfy a given temporal relation.
317 
318  When the DataSet contains more than one trajectory, the info parameter
319  (TrajectoryDataSetInfo) must contain the id of the desire trajectory that
320  must be returned as a TrajectoryDataSet.
321 
322  The possible temporal relations are: 1. AFTER;
323  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
324 
325  \param info Information about the DataSource which the observation of trajectpries
326  are from and the DataSet which contains the observations.
327  \param dt A given datetime.
328  \param r A given temporal relation.
329  \param travType The traverse type associated to the returned dataset.
330 
331  \return A pointer to a new TrajectoryDataSet.
332 
333  \note The caller will take the ownership of the returned pointer.
334  \note When the temporal relation is DURING, dt must be a time period.
335  \note It can throw an Exception when internal errors occur.
336  */
337  virtual std::auto_ptr<TrajectoryDataSet> getDataSet(const TrajectoryDataSetInfo& info,
340 
341  /*!
342  \brief It returns patches of a trajectory whose envelope
343  satisfy a given spatial relation and times satisfy a given temporal relation.
344 
345  When the DataSet contains more than one trajectory, the info parameter
346  (TrajectoryDataSetInfo) must contain the id of the desire trajectory that
347  must be returned as a TrajectoryDataSet.
348 
349  The possible temporal relations are: 1. AFTER;
350  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
351 
352  \param info Information about the DataSource which the observation of trajectpries
353  are from and the DataSet which contains the observations.
354  \param dt A given datetime.
355  \param tr A given temporal relation.
356  \param e A given envelope.
357  \param sr A given spatial relation.
358  \param travType The traverse type associated to the returned dataset.
359 
360  \return A pointer to a new TrajectoryDataSet.
361 
362  \note Before using this method, certify that the Data Source exists in the DataSourceManager and
363  its "id" is correct in the info parameter
364  \note The caller will take the ownership of the returned pointer.
365  \note When the temporal relation is DURING, dt must be a time period.
366  \note It can throw an Exception when internal errors occur.
367  */
368  virtual std::auto_ptr<TrajectoryDataSet> getDataSet(const TrajectoryDataSetInfo& info,
369  const te::dt::DateTime& dt,
371  const te::gm::Envelope& e,
374 
375  /*!
376  \brief It returns patches of a trajectory whose geometries
377  satisfy a given spatial relation and times satisfy a given temporal relation.
378 
379  When the DataSet contains more than one trajectory, the info parameter
380  (TrajectoryDataSetInfo) must contain the id of the desire trajectory that
381  must be returned as a TrajectoryDataSet.
382 
383  The possible spatial relations are: INTERSECTS
384  The possible temporal relations are: 1. AFTER;
385  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
386 
387  \param info Information about the DataSource which the observations of trajectories
388  are from and the DataSet which contains these observations.
389  \param geom A given geometry.
390  \param sr A given spatial relation.
391  \param dt A given datetime.
392  \param tr A given temporal relation.
393  \param travType The traverse type associated to the returned dataset.
394 
395  \return The returned trajectoy data set.
396 
397  \note The caller will take the ownership of the returned pointer.
398  \note It will NOT take the ownership of the given pointers.
399  \note When the temporal relation is DURING, dt must be a time period.
400  \note It can throw an Exception when internal errors occur.
401  */
402  virtual std::auto_ptr<TrajectoryDataSet> getDataSet(const TrajectoryDataSetInfo& info,
406  //@}
407 
408  /*! \name Operations for loading TimeSeriesDataSet */
409  //@{
410 
411  /*!
412  \brief It returns the information about all time series that exist in a single DataSet.
413 
414  The information about the DataSource and DataSet that contains time series is defined
415  as a TimeSeriesDataSetInfo (input parameter).
416 
417  The information about each time series (its correct id) is returned as a
418  TimeSeriesDataSetInfo of the parameter output.
419  These results can be used to create TimeSeriesDataSetLayers.
420 
421  \param input The information about the DataSource and DataSet that contains time series
422  \param output The information about each time series (its correct id).
423 
424  \note It can throw an Exception when internal errors occur.
425  */
426  virtual void getInfo( const TimeSeriesDataSetInfo& input,
427  std::vector<TimeSeriesDataSetInfo>& output) = 0;
428 
429  /*!
430  \brief It returns a data set with observations of time series.
431 
432  When the DataSet contains more than one time series, the info parameter
433  (TimeSeriesDataSetInfo) must contain the id of the desire time series that
434  must be returned as a TimeSeriesDataSet.
435 
436  \param info Information about the DataSource which the observations of a time series
437  are from and the DataSet which contains these observations.
438  \param travType The traverse type associated to the returned datasets.
439 
440  \return The returned TrajectoryDataSet.
441 
442  \note The caller will take the ownership of the returned pointer.
443  \note It can throw an Exception when internal errors occur.
444  */
445  virtual std::auto_ptr<TimeSeriesDataSet> getDataSet(const TimeSeriesDataSetInfo& info,
447 
448  /*!
449  \brief It returns a data set with observations of time series whose times
450  satisfy a given temporal relation.
451 
452  When the DataSet contains more than one time series, the info parameter
453  (TimeSeriesDataSetInfo) must contain the id of the desire time series that
454  must be returned as a TimeSeriesDataSet.
455 
456  The possible temporal relations are: 1. AFTER;
457  2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
458 
459  \param info Information about the DataSource which the observation of time series
460  are from and the DataSet which contains the observations.
461  \param dt A given datetime.
462  \param r A given temporal relation.
463  \param travType The traverse type associated to the returned dataset.
464 
465  \return A pointer to a new TimeSeriesDataSet.
466 
467  \note The caller will take the ownership of the returned pointer.
468  \note When the temporal relation is DURING, dt must be a time period.
469  \note It can throw an Exception when internal errors occur.
470  */
471  virtual std::auto_ptr<TimeSeriesDataSet> getDataSet(const TimeSeriesDataSetInfo& info,
474  //@}
475 
476  /*! \name Operations for loading spatiotemporal data types
477  (TimeSeries, Trajetory, CoverageSeries) directly from data sources, without using
478  DataSets. */
479  //@{
480 
481  /*!
482  \brief It returns a coverage series.
483 
484  \param info Information about the DataSource which the observations of a coverage series
485  are from and the data sets which contain these observations.
486 
487  \return The returned CoverageSeries.
488 
489  \note The caller will take the ownership of the returned pointer.
490  \note It can throw an Exception when internal errors occur.
491  */
492  //virtual std::auto_ptr<CoverageSeries> getCoverageSeries(const CoverageSeriesDataSetInfo& info) = 0;
493 
494  /*!
495  \brief It returns a time series associated to a point of a coverage series.
496 
497  If info contains information about raster coverages and its associated data source
498  supports raster data type, this function is executed by the data source.
499  Otherwise, it is executed in two steps: (1) creating a CoverageSeries type
500  and (2) using its method getTimeSeries.
501 
502  \param info Information about the DataSource which the observations of a coverage series
503  are from and the data sets which contain these observations.
504  \param p A given point.
505 
506  \return The returned CoverageSeries.
507 
508  \note The caller will take the ownership of the returned pointer.
509  \note It can throw an Exception when internal errors occur.
510 
511  \\TO DO: (1) vantagem de usar o DataSetCoverageDataSet é ele fica armazenado no driver
512  \\em memória (stmem) ao invés de toda hora gerar o CoverageSeries para cada ponto
513  \\que queremos extrair a time series.
514  */
515  //virtual std::auto_ptr<CoverageSeries> getTimeSeries(const CoverageSeriesDataSetInfo& info,
516  // const te::gm::Point& p) = 0;
517  //@}
518 
519  /*! \name Operations for loading temporal and spatial extent */
520  //@{
521 
522  /*!
523  \brief It returns the temporal extent of the data set with observations.
524 
525  \return The temporal extent of the observations.
526 
527  \note The caller will take the ownership of the returned pointer.
528  \note It will NOT take the ownership of the given pointer "info".
529  \note It can throw an Exception when internal errors occur.
530  */
531  virtual std::auto_ptr<te::dt::DateTimePeriod> getTemporalExtent(const ObservationDataSetInfo& info) = 0;
532 
533  /*!
534  \brief It returns the temporal extent of the data set with observations of a trajectory.
535 
536  \return The temporal extent of the observations of a trajectory.
537 
538  \note The caller will take the ownership of the returned pointer.
539  \note It will NOT take the ownership of the given pointer "info".
540  \note It can throw an Exception when internal errors occur.
541  */
542  virtual std::auto_ptr<te::dt::DateTimePeriod> getTemporalExtent(const TrajectoryDataSetInfo& info) = 0;
543 
544  /*!
545  \brief It returns the temporal extent of the data set with observations of a time series.
546 
547  \return The temporal extent of the observations of a time series.
548 
549  \note The caller will take the ownership of the returned pointer.
550  \note It will NOT take the ownership of the given pointer "info".
551  \note It can throw an Exception when internal errors occur.
552  */
553  virtual std::auto_ptr<te::dt::DateTimePeriod> getTemporalExtent(const TimeSeriesDataSetInfo& info) = 0;
554 
555  /*!
556  \brief It returns the temporal extent of the data set with observations of a coverage series.
557 
558  \return The temporal extent of the observations of a coverage series.
559 
560  \note The caller will take the ownership of the returned pointer.
561  \note It will NOT take the ownership of the given pointer "info".
562  \note It can throw an Exception when internal errors occur.
563  */
564  //virtual std::auto_ptr<te::dt::DateTimePeriod> getTemporalExtent(const CoverageSeriesDataSetInfo& info) = 0;
565 
566  /*!
567  \brief It returns the spatial extent of the observations, when there is an observed value of geometry type.
568 
569  \return The spatial extent of the observations.
570 
571  \note The caller will take the ownership of the returned pointer.
572  \note It can throw an Exception when internal errors occur.
573  */
574  virtual te::gm::Envelope getSpatialExtent(const ObservationDataSetInfo& info) = 0;
575 
576  /*!
577  \brief It returns the spatial extent of the observations of a trajectory.
578 
579  \return The spatial extent of the observations of a trajectory.
580 
581  \note The caller will take the ownership of the returned pointer.
582  \note It can throw an Exception when internal errors occur.
583  */
584  virtual te::gm::Envelope getSpatialExtent(const TrajectoryDataSetInfo& info) = 0;
585 
586  /*!
587  \brief It returns the spatial extent of the observations of a coverage series.
588 
589  \return The spatial extent of the observations of a coverage series.
590 
591  \note The caller will take the ownership of the returned pointer.
592  \note It can throw an Exception when internal errors occur.
593  */
594  //virtual te::gm::Envelope getSpatialExtent(const CoverageSeriesDataSetInfo& info) = 0;
595  //@}
596 
597  /*! \brief Virtual destructor. */
598  virtual ~STDataLoaderImpl();
599  };
600 
601  } // end namespace st
602 } // end namespace te
603 
604 #endif // __TERRALIB_ST_INTERNAL_STDATALOADERIMPL_H
605 
606 
607 
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:90
An abstract class responsible for loading spatiotemporal data from data sources.
A class that contains infos about a DataSet that contains observations.
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Definition: Enums.h:76
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:122
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
A class that contains infos about a DataSet that contains observations of one or more trajectories...
A class that contains infos about a DataSet that contains observations of one or more time series...