All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
STDataLoaderFromDS.cpp
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 STDataLoaderFromDS.cpp
22 
23  \brief This file contains a class responsible for loading spatiotemporal data
24  from a DataSource using query capabilities.
25 */
26 
27 //TerraLib
28 #include "../../dataaccess/datasource/DataSourceInfo.h"
29 #include "../../dataaccess/datasource/DataSource.h"
30 #include "../../dataaccess/dataset/DataSet.h"
31 #include "../../dataaccess/utils/Utils.h"
32 #include "../../datatype/DateTimePeriod.h"
33 #include "../../datatype/DateTimeProperty.h"
34 #include "../../geometry/Utils.h"
35 
36 //ST
37 #include "../Exception.h"
38 #include "../Utils.h"
39 #include "STDataLoaderFromDS.h"
40 #include "../core/observation/ObservationDataSetInfo.h"
41 #include "../core/trajectory/TrajectoryDataSetInfo.h"
42 #include "../core/timeseries/TimeSeriesDataSetInfo.h"
43 #include "../core/observation/ObservationDataSet.h"
44 #include "../core/trajectory/TrajectoryDataSet.h"
45 #include "../core/timeseries/TimeSeriesDataSet.h"
46 
47 //STL
48 #include <vector>
49 
51 {
52 }
53 
54 std::auto_ptr<te::st::ObservationDataSet>
56  te::common::TraverseType travType)
57 {
58  //use the DataSourceManager to get the DataSource
60 
61  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), travType));
62 
63  return buildDataSet(dset.release(), info);
64 }
65 
66 
67 std::auto_ptr<te::st::ObservationDataSet>
70 {
71  //use the DataSourceManager to get the DataSource
73 
74  //get the geometry property name
75  if(!info.hasGeomProp())
76  return std::auto_ptr<te::st::ObservationDataSet>();
77 
78  std::string geomPropName = info.getGeomPropName();
79 
80  //get the data set applying he filter
81  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), geomPropName, &e, r, travType));
82 
83  return buildDataSet(dset.release(), info);
84 }
85 
86 std::auto_ptr<te::st::ObservationDataSet>
89 {
90  //use the DataSourceManager to get the DataSource
92 
93  //get the geometry property name
94  if(!info.hasGeomProp())
95  return std::auto_ptr<te::st::ObservationDataSet>();
96 
97  std::string geomPropName = info.getGeomPropName();
98 
99  //get the data set applying he filter
100  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), geomPropName, &geom, r, travType));
101 
102  return buildDataSet(dset.release(), info);
103 }
104 
105 std::auto_ptr<te::st::ObservationDataSet>
107  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
108  te::common::TraverseType /*travType*/)
109 {
110  //use the DataSourceManager to get the DataSource
111  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
112 
113  //montar uma Query e passar para o data source!
114 
115  //return buildDataSet(dset.release(), info);
116  return std::auto_ptr<te::st::ObservationDataSet>();
117 }
118 
119 std::auto_ptr<te::st::ObservationDataSet>
121  const te::dt::DateTime& /*dt*/,
123  const te::gm::Envelope& /*e*/,
125  te::common::TraverseType /*travType*/)
126 {
127  //use the DataSourceManager to get the DataSource
128  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
129 
130  //montar uma Query e passar para o data source!
131 
132  //return buildDataSet(dset.release(), info);
133  return std::auto_ptr<te::st::ObservationDataSet>();
134 }
135 
136 
137 std::auto_ptr<te::st::ObservationDataSet>
139  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
140  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
141  te::common::TraverseType /*travType*/)
142 {
143  //use the DataSourceManager to get the DataSource
144  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
145 
146  //montar uma Query e passar para o data source!
147 
148  //return buildDataSet(dset.release(), info);
149  return std::auto_ptr<te::st::ObservationDataSet> ();
150 }
151 
152 void
153 te::st::STDataLoaderFromDS::getInfo( const TrajectoryDataSetInfo& /*input*/, std::vector<TrajectoryDataSetInfo>& /*output*/)
154 {
155  return;
156 }
157 
158 std::auto_ptr<te::st::TrajectoryDataSet>
160 {
161  //use the DataSourceManager to get the DataSource
163 
164  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
165 
166  return buildDataSet(dset.release(), info);
167 }
168 
169 std::auto_ptr<te::st::TrajectoryDataSet>
172  te::common::TraverseType travType)
173 {
174  //use the DataSourceManager to get the DataSource
176 
177  //get the geometry property name
179  return std::auto_ptr<te::st::TrajectoryDataSet>();
180 
181  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
182 
183  //get the data set applying he filter
184  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &geom, r, travType));
185 
186  return buildDataSet(dset.release(), info);
187 }
188 
189 std::auto_ptr<te::st::TrajectoryDataSet>
192  te::common::TraverseType travType)
193 {
194  //use the DataSourceManager to get the DataSource
196 
197  //get the geometry property name
199  return std::auto_ptr<te::st::TrajectoryDataSet>();
200 
201  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
202 
203  //get the data set applying he filter
204  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(),
205  geomPropName, &e, r, travType));
206 
207  return buildDataSet(dset.release(), info);
208 }
209 
210 std::auto_ptr<te::st::TrajectoryDataSet>
212  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
213  te::common::TraverseType /*travType*/)
214 {
215  //use the DataSourceManager to get the DataSource
216  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
217 
218  //montar uma Query e passar para o data source!
219 
220  //return buildDataSet(dset.release(), info);
221  return std::auto_ptr<te::st::TrajectoryDataSet>();
222 }
223 
224 std::auto_ptr<te::st::TrajectoryDataSet>
226  const te::dt::DateTime& /*dt*/,
228  const te::gm::Envelope& /*e*/,
230  te::common::TraverseType /*travType*/)
231 {
232  //use the DataSourceManager to get the DataSource
233  //te::da::DataSourcePtr ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
234 
235  //montar uma Query e passar para o data source!
236 
237  //return buildDataSet(dset.release(), info);
238  return std::auto_ptr<te::st::TrajectoryDataSet>();
239 }
240 
241 std::auto_ptr<te::st::TrajectoryDataSet>
243  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
244  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
245  te::common::TraverseType /*travType*/)
246 {
247  //use the DataSourceManager to get the DataSource
248  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
249 
250  //montar uma Query e passar para o data source!
251 
252  //return buildDataSet(dset.release(), info);
253  return std::auto_ptr<te::st::TrajectoryDataSet>();
254 }
255 
257  std::vector<TimeSeriesDataSetInfo>& /*output*/)
258 {
259  return;
260 }
261 
262 std::auto_ptr<te::st::TimeSeriesDataSet>
264  te::common::TraverseType travType)
265 {
266  //use the DataSourceManager to get the DataSource
268 
269  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
270 
271  return buildDataSet(dset.release(), info);
272 }
273 
274 std::auto_ptr<te::st::TimeSeriesDataSet>
276  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
277  te::common::TraverseType /*travType*/)
278 {
279  //use the DataSourceManager to get the DataSource
280  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
281 
282  //montar uma Query e passar para o data source!
283 
284  //return buildDataSet(dset.release(), info);
285  return std::auto_ptr<te::st::TimeSeriesDataSet>();
286 }
287 
288 std::auto_ptr<te::st::TimeSeriesDataSet>
291  te::common::TraverseType travType)
292 {
293  //use the DataSourceManager to get the DataSource
295 
296  //get the geometry property name
298  return std::auto_ptr<te::st::TimeSeriesDataSet>();
299 
300  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
301 
302  //get the data set applying he filter
303  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &geom, r, travType));
304 
305  return buildDataSet(dset.release(), info);
306 }
307 
308 std::auto_ptr<te::st::TimeSeriesDataSet>
311  te::common::TraverseType travType)
312 {
313  //use the DataSourceManager to get the DataSource
315 
316  //get the geometry property name
318  return std::auto_ptr<te::st::TimeSeriesDataSet>();
319 
320  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
321 
322  //get the data set applying he filter
323  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(),
324  geomPropName, &e, r, travType));
325 
326  return buildDataSet(dset.release(), info);
327 }
328 
329 std::auto_ptr<te::st::TimeSeriesDataSet>
331  const te::dt::DateTime& /*dt*/,
333  const te::gm::Envelope& /*e*/,
335  te::common::TraverseType /*travType*/)
336 {
337  //use the DataSourceManager to get the DataSource
338  //te::da::DataSourcePtr ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
339 
340  //montar uma Query e passar para o data source!
341 
342  //return buildDataSet(dset.release(), info);
343  return std::auto_ptr<te::st::TimeSeriesDataSet>();
344 }
345 
346 std::auto_ptr<te::st::TimeSeriesDataSet>
348  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
349  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
350  te::common::TraverseType /*travType*/)
351 {
352  //use the DataSourceManager to get the DataSource
353  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
354 
355  //montar uma Query e passar para o data source!
356 
357  //return buildDataSet(dset.release(), info);
358  return std::auto_ptr<te::st::TimeSeriesDataSet>();
359 }
360 
361 
362 std::auto_ptr<te::dt::DateTimePeriod>
364 {
365  //use the DataSourceManager to get the DataSource
366  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
367 
368  //montar uma Query e passar para o data source!
369 
370  //return buildDataSet(dset.release(), info);
371  return std::auto_ptr<te::dt::DateTimePeriod>();
372 }
373 
374 std::auto_ptr<te::dt::DateTimePeriod>
376 {
377  //use the DataSourceManager to get the DataSource
378  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
379 
380  //montar uma Query e passar para o data source!
381 
382  //return buildDataSet(dset.release(), info);
383  return std::auto_ptr<te::dt::DateTimePeriod>();
384 }
385 
386 std::auto_ptr<te::dt::DateTimePeriod>
388 {
389  //use the DataSourceManager to get the DataSource
390  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
391 
392  //montar uma Query e passar para o data source!
393 
394  //return buildDataSet(dset.release(), info);
395  return std::auto_ptr<te::dt::DateTimePeriod>();
396 }
397 
400 {
401  //use the DataSourceManager to get the DataSource
403 
404  //get the geometry property name
405  if(!info.hasGeomProp())
406  return te::gm::Envelope();
407 
408  std::string geomPropName = info.getGeomPropName();
409 
410  std::auto_ptr<te::gm::Envelope> res(ds->getExtent(info.getDataSetName(), geomPropName));
411  return *res.get();
412 }
413 
416 {
417  //use the DataSourceManager to get the DataSource
419 
420  //get the geometry property name
422  return te::gm::Envelope();
423 
424  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
425 
426  std::auto_ptr<te::gm::Envelope> res(ds->getExtent(info.getObservationDataSetInfo().getDataSetName(),
427  geomPropName));
428  return *res.get();
429 }
430 
431 //protected
432 std::auto_ptr<te::st::ObservationDataSet>
434 {
435  return std::auto_ptr<ObservationDataSet> (new ObservationDataSet(ds, te::st::GetType(info)));
436 }
437 
438 std::auto_ptr<te::st::TrajectoryDataSet>
440 {
441  return std::auto_ptr<TrajectoryDataSet> (new TrajectoryDataSet(ds, te::st::GetType(info.getObservationDataSetInfo())));
442 }
443 
444 std::auto_ptr<te::st::TimeSeriesDataSet>
446 {
447  return std::auto_ptr<TimeSeriesDataSet> ( new TimeSeriesDataSet(ds, te::st::GetType(info.getObservationDataSetInfo()),
448  info.getValuePropNames()));
449 }
450 
452 {
453 }
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
Definition: Utils.cpp:262
A class to represent a time series data set.
A class to represent a DataSet that contains observations.
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
A class that contains infos about a DataSet that contains observations.
std::string getGeomPropName() const
It returns the name of the property that is a geometry property.
te::gm::Envelope getSpatialExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations of a coverage series.
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Definition: Enums.h:140
const ObservationDataSetInfo & getObservationDataSetInfo() const
It returns information about the DataSet that contains the time series observations.
std::auto_ptr< ObservationDataSet > getDataSet(const ObservationDataSetInfo &info, te::common::TraverseType travType=te::common::FORWARDONLY)
It returns a ObservationDataSet, that is, a DataSet that contains observations.
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:122
This file contains a class responsible for loading spatiotemporal data from a DataSource using query ...
const ObservationDataSetInfo & getObservationDataSetInfo() const
It returns information about the DataSet that contains the trajectory observations.
TESTEXPORT ObservationDataSetType GetType(const ObservationDataSetInfo &info)
An auxiliary function that transform ObservationDataSetInfo into ObservationDataSetType.
Definition: Utils.cpp:39
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
const std::vector< std::string > & getValuePropNames() const
It returns the names of the DataSet properties that contains the values associated to the time series...
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns the information about the DataSource.
void getInfo(const TrajectoryDataSetInfo &input, std::vector< TrajectoryDataSetInfo > &output)
It returns the information about all trajectories that exist in a single DataSet. ...
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 to represent a trajectory data set.
const std::string & getId() const
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
A class that contains infos about a DataSet that contains observations of one or more time series...
std::string getDataSetName() const
It returns the DataSet name.
std::auto_ptr< ObservationDataSet > buildDataSet(te::da::DataSet *ds, const ObservationDataSetInfo &info)
It builds an ObservationDataSet from a given DataSet.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations.