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 std::unique_ptr<te::st::ObservationDataSet>
54  te::common::TraverseType travType)
55 {
56  //use the DataSourceManager to get the DataSource
58 
59  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), travType));
60 
61  return buildDataSet(dset.release(), info);
62 }
63 
64 
65 std::unique_ptr<te::st::ObservationDataSet>
68 {
69  //use the DataSourceManager to get the DataSource
71 
72  //get the geometry property name
73  if(!info.hasGeomProp())
74  return std::unique_ptr<te::st::ObservationDataSet>();
75 
76  std::string geomPropName = info.getGeomPropName();
77 
78  //get the data set applying he filter
79  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), geomPropName, &e, r, travType));
80 
81  return buildDataSet(dset.release(), info);
82 }
83 
84 std::unique_ptr<te::st::ObservationDataSet>
87 {
88  //use the DataSourceManager to get the DataSource
90 
91  //get the geometry property name
92  if(!info.hasGeomProp())
93  return std::unique_ptr<te::st::ObservationDataSet>();
94 
95  std::string geomPropName = info.getGeomPropName();
96 
97  //get the data set applying he filter
98  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), geomPropName, &geom, r, travType));
99 
100  return buildDataSet(dset.release(), info);
101 }
102 
103 std::unique_ptr<te::st::ObservationDataSet>
105  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
106  te::common::TraverseType /*travType*/)
107 {
108  //use the DataSourceManager to get the DataSource
109  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
110 
111  //montar uma Query e passar para o data source!
112 
113  //return buildDataSet(dset.release(), info);
114  return std::unique_ptr<te::st::ObservationDataSet>();
115 }
116 
117 std::unique_ptr<te::st::ObservationDataSet>
119  const te::dt::DateTime& /*dt*/,
121  const te::gm::Envelope& /*e*/,
123  te::common::TraverseType /*travType*/)
124 {
125  //use the DataSourceManager to get the DataSource
126  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
127 
128  //montar uma Query e passar para o data source!
129 
130  //return buildDataSet(dset.release(), info);
131  return std::unique_ptr<te::st::ObservationDataSet>();
132 }
133 
134 
135 std::unique_ptr<te::st::ObservationDataSet>
137  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
138  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
139  te::common::TraverseType /*travType*/)
140 {
141  //use the DataSourceManager to get the DataSource
142  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
143 
144  //montar uma Query e passar para o data source!
145 
146  //return buildDataSet(dset.release(), info);
147  return std::unique_ptr<te::st::ObservationDataSet> ();
148 }
149 
150 void
151 te::st::STDataLoaderFromDS::getInfo( const TrajectoryDataSetInfo& /*input*/, std::vector<TrajectoryDataSetInfo>& /*output*/)
152 {
153  return;
154 }
155 
156 std::unique_ptr<te::st::TrajectoryDataSet>
158 {
159  //use the DataSourceManager to get the DataSource
161 
162  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
163 
164  return buildDataSet(dset.release(), info);
165 }
166 
167 std::unique_ptr<te::st::TrajectoryDataSet>
170  te::common::TraverseType travType)
171 {
172  //use the DataSourceManager to get the DataSource
174 
175  //get the geometry property name
177  return std::unique_ptr<te::st::TrajectoryDataSet>();
178 
179  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
180 
181  //get the data set applying he filter
182  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &geom, r, travType));
183 
184  return buildDataSet(dset.release(), info);
185 }
186 
187 std::unique_ptr<te::st::TrajectoryDataSet>
190  te::common::TraverseType travType)
191 {
192  //use the DataSourceManager to get the DataSource
194 
195  //get the geometry property name
197  return std::unique_ptr<te::st::TrajectoryDataSet>();
198 
199  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
200 
201  //get the data set applying he filter
202  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(),
203  geomPropName, &e, r, travType));
204 
205  return buildDataSet(dset.release(), info);
206 }
207 
208 std::unique_ptr<te::st::TrajectoryDataSet>
210  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
211  te::common::TraverseType /*travType*/)
212 {
213  //use the DataSourceManager to get the DataSource
214  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
215 
216  //montar uma Query e passar para o data source!
217 
218  //return buildDataSet(dset.release(), info);
219  return std::unique_ptr<te::st::TrajectoryDataSet>();
220 }
221 
222 std::unique_ptr<te::st::TrajectoryDataSet>
224  const te::dt::DateTime& /*dt*/,
226  const te::gm::Envelope& /*e*/,
228  te::common::TraverseType /*travType*/)
229 {
230  //use the DataSourceManager to get the DataSource
231  //te::da::DataSourcePtr ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
232 
233  //montar uma Query e passar para o data source!
234 
235  //return buildDataSet(dset.release(), info);
236  return std::unique_ptr<te::st::TrajectoryDataSet>();
237 }
238 
239 std::unique_ptr<te::st::TrajectoryDataSet>
241  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
242  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
243  te::common::TraverseType /*travType*/)
244 {
245  //use the DataSourceManager to get the DataSource
246  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
247 
248  //montar uma Query e passar para o data source!
249 
250  //return buildDataSet(dset.release(), info);
251  return std::unique_ptr<te::st::TrajectoryDataSet>();
252 }
253 
255  std::vector<TimeSeriesDataSetInfo>& /*output*/)
256 {
257  return;
258 }
259 
260 std::unique_ptr<te::st::TimeSeriesDataSet>
262  te::common::TraverseType travType)
263 {
264  //use the DataSourceManager to get the DataSource
266 
267  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
268 
269  return buildDataSet(dset.release(), info);
270 }
271 
272 std::unique_ptr<te::st::TimeSeriesDataSet>
274  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
275  te::common::TraverseType /*travType*/)
276 {
277  //use the DataSourceManager to get the DataSource
278  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
279 
280  //montar uma Query e passar para o data source!
281 
282  //return buildDataSet(dset.release(), info);
283  return std::unique_ptr<te::st::TimeSeriesDataSet>();
284 }
285 
286 std::unique_ptr<te::st::TimeSeriesDataSet>
289  te::common::TraverseType travType)
290 {
291  //use the DataSourceManager to get the DataSource
293 
294  //get the geometry property name
296  return std::unique_ptr<te::st::TimeSeriesDataSet>();
297 
298  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
299 
300  //get the data set applying he filter
301  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &geom, r, travType));
302 
303  return buildDataSet(dset.release(), info);
304 }
305 
306 std::unique_ptr<te::st::TimeSeriesDataSet>
309  te::common::TraverseType travType)
310 {
311  //use the DataSourceManager to get the DataSource
313 
314  //get the geometry property name
316  return std::unique_ptr<te::st::TimeSeriesDataSet>();
317 
318  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
319 
320  //get the data set applying he filter
321  std::unique_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(),
322  geomPropName, &e, r, travType));
323 
324  return buildDataSet(dset.release(), info);
325 }
326 
327 std::unique_ptr<te::st::TimeSeriesDataSet>
329  const te::dt::DateTime& /*dt*/,
331  const te::gm::Envelope& /*e*/,
333  te::common::TraverseType /*travType*/)
334 {
335  //use the DataSourceManager to get the DataSource
336  //te::da::DataSourcePtr ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
337 
338  //montar uma Query e passar para o data source!
339 
340  //return buildDataSet(dset.release(), info);
341  return std::unique_ptr<te::st::TimeSeriesDataSet>();
342 }
343 
344 std::unique_ptr<te::st::TimeSeriesDataSet>
346  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
347  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
348  te::common::TraverseType /*travType*/)
349 {
350  //use the DataSourceManager to get the DataSource
351  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
352 
353  //montar uma Query e passar para o data source!
354 
355  //return buildDataSet(dset.release(), info);
356  return std::unique_ptr<te::st::TimeSeriesDataSet>();
357 }
358 
359 
360 std::unique_ptr<te::dt::DateTimePeriod>
362 {
363  //use the DataSourceManager to get the DataSource
364  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
365 
366  //montar uma Query e passar para o data source!
367 
368  //return buildDataSet(dset.release(), info);
369  return std::unique_ptr<te::dt::DateTimePeriod>();
370 }
371 
372 std::unique_ptr<te::dt::DateTimePeriod>
374 {
375  //use the DataSourceManager to get the DataSource
376  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
377 
378  //montar uma Query e passar para o data source!
379 
380  //return buildDataSet(dset.release(), info);
381  return std::unique_ptr<te::dt::DateTimePeriod>();
382 }
383 
384 std::unique_ptr<te::dt::DateTimePeriod>
386 {
387  //use the DataSourceManager to get the DataSource
388  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
389 
390  //montar uma Query e passar para o data source!
391 
392  //return buildDataSet(dset.release(), info);
393  return std::unique_ptr<te::dt::DateTimePeriod>();
394 }
395 
398 {
399  //use the DataSourceManager to get the DataSource
401 
402  //get the geometry property name
403  if(!info.hasGeomProp())
404  return te::gm::Envelope();
405 
406  std::string geomPropName = info.getGeomPropName();
407 
408  std::unique_ptr<te::gm::Envelope> res(ds->getExtent(info.getDataSetName(), geomPropName));
409  return *res.get();
410 }
411 
414 {
415  //use the DataSourceManager to get the DataSource
417 
418  //get the geometry property name
420  return te::gm::Envelope();
421 
422  std::string geomPropName = info.getObservationDataSetInfo().getGeomPropName();
423 
424  std::unique_ptr<te::gm::Envelope> res(ds->getExtent(info.getObservationDataSetInfo().getDataSetName(),
425  geomPropName));
426  return *res.get();
427 }
428 
429 //protected
430 std::unique_ptr<te::st::ObservationDataSet>
432 {
433  return std::unique_ptr<ObservationDataSet> (new ObservationDataSet(ds, te::st::GetType(info)));
434 }
435 
436 std::unique_ptr<te::st::TrajectoryDataSet>
438 {
439  return std::unique_ptr<TrajectoryDataSet> (new TrajectoryDataSet(ds, te::st::GetType(info.getObservationDataSetInfo())));
440 }
441 
442 std::unique_ptr<te::st::TimeSeriesDataSet>
444 {
445  return std::unique_ptr<TimeSeriesDataSet> ( new TimeSeriesDataSet(ds, te::st::GetType(info.getObservationDataSetInfo()),
446  info.getValuePropNames()));
447 }
448 
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
A class to represent a time series data set.
A class to represent a DataSet that contains observations.
boost::shared_ptr< DataSource > DataSourcePtr
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).
const ObservationDataSetInfo & getObservationDataSetInfo() const
It returns information about the DataSet that contains the time series observations.
SpatialRelation
Spatial relations between geometric objects.
std::unique_ptr< ObservationDataSet > getDataSet(const ObservationDataSetInfo &info, te::common::TraverseType travType=te::common::FORWARDONLY)
It returns a ObservationDataSet, that is, a DataSet that contains observations.
static te::dt::Date ds(2010, 01, 01)
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.
TraverseType
A dataset can be traversed in two ways:
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.
std::unique_ptr< te::dt::DateTimePeriod > getTemporalExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations.
std::unique_ptr< ObservationDataSet > buildDataSet(te::da::DataSet *ds, const ObservationDataSetInfo &info)
It builds an ObservationDataSet from a given DataSet.
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.
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.
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.