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) 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 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 
34 //ST
35 #include "../Exception.h"
36 #include "../Utils.h"
37 #include "STDataLoaderFromDS.h"
38 #include "../core/observation/ObservationDataSetInfo.h"
39 #include "../core/trajectory/TrajectoryDataSetInfo.h"
40 #include "../core/timeseries/TimeSeriesDataSetInfo.h"
41 #include "../core/observation/ObservationDataSet.h"
42 #include "../core/trajectory/TrajectoryDataSet.h"
43 #include "../core/timeseries/TimeSeriesDataSet.h"
44 
45 //STL
46 #include <vector>
47 
49 {
50 }
51 
52 std::auto_ptr<te::st::ObservationDataSet>
54  te::common::TraverseType travType)
55 {
56  //use the DataSourceManager to get the DataSource
58 
59  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), travType));
60 
61  return buildDataSet(dset.release(), info);
62 }
63 
64 
65 std::auto_ptr<te::st::ObservationDataSet>
68 {
69  //use the DataSourceManager to get the DataSource
71 
72  //get the geometry property name
73  std::auto_ptr<te::da::DataSetType> dsettype(ds->getDataSetType(info.getDataSetName()));
74 
75  std::string geomPropName = dsettype->getProperty(info.getGeomPropIdx())->getName();
76 
77  //get the data set applying he filter
78  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), geomPropName, &e, r, travType));
79 
80  return buildDataSet(dset.release(), info);
81 }
82 
83 std::auto_ptr<te::st::ObservationDataSet>
86 {
87  //use the DataSourceManager to get the DataSource
89 
90  //get the geometry property name
91  std::auto_ptr<te::da::DataSetType> dsettype(ds->getDataSetType(info.getDataSetName()));
92 
93  std::string geomPropName = dsettype->getProperty(info.getGeomPropIdx())->getName();
94 
95  //get the data set applying he filter
96  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getDataSetName(), geomPropName, &geom, r, travType));
97 
98  return buildDataSet(dset.release(), info);
99 }
100 
101 std::auto_ptr<te::st::ObservationDataSet>
103  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
104  te::common::TraverseType /*travType*/)
105 {
106  //use the DataSourceManager to get the DataSource
107  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
108 
109  //montar uma Query e passar para o data source!
110 
111  //return buildDataSet(dset.release(), info);
112  return std::auto_ptr<te::st::ObservationDataSet>();
113 }
114 
115 std::auto_ptr<te::st::ObservationDataSet>
117  const te::dt::DateTime& /*dt*/,
119  const te::gm::Envelope& /*e*/,
121  te::common::TraverseType /*travType*/)
122 {
123  //use the DataSourceManager to get the DataSource
124  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
125 
126  //montar uma Query e passar para o data source!
127 
128  //return buildDataSet(dset.release(), info);
129  return std::auto_ptr<te::st::ObservationDataSet>();
130 }
131 
132 
133 std::auto_ptr<te::st::ObservationDataSet>
135  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
136  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
137  te::common::TraverseType /*travType*/)
138 {
139  //use the DataSourceManager to get the DataSource
140  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
141 
142  //montar uma Query e passar para o data source!
143 
144  //return buildDataSet(dset.release(), info);
145  return std::auto_ptr<te::st::ObservationDataSet> ();
146 }
147 
148 void
149 te::st::STDataLoaderFromDS::getInfo( const TrajectoryDataSetInfo& /*input*/, std::vector<TrajectoryDataSetInfo>& /*output*/)
150 {
151  return;
152 }
153 
154 std::auto_ptr<te::st::TrajectoryDataSet>
156 {
157  //use the DataSourceManager to get the DataSource
159 
160  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
161 
162  return buildDataSet(dset.release(), info);
163 }
164 
165 std::auto_ptr<te::st::TrajectoryDataSet>
168  te::common::TraverseType travType)
169 {
170  //use the DataSourceManager to get the DataSource
172 
173  //get the geometry property name
174  std::auto_ptr<te::da::DataSetType> dsettype(ds->getDataSetType(info.getObservationDataSetInfo().getDataSetName()));
175 
176  std::string geomPropName = dsettype->getProperty(info.getGeomPropIdx())->getName();
177 
178  //get the data set applying he filter
179  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &geom, r, travType));
180 
181  return buildDataSet(dset.release(), info);
182 }
183 
184 std::auto_ptr<te::st::TrajectoryDataSet>
187  te::common::TraverseType travType)
188 {
189  //use the DataSourceManager to get the DataSource
191 
192  //get the geometry property name
193  std::auto_ptr<te::da::DataSetType> dsettype(ds->getDataSetType(info.getObservationDataSetInfo().getDataSetName()));
194 
195  std::string geomPropName = dsettype->getProperty(info.getGeomPropIdx())->getName();
196 
197  //get the data set applying he filter
198  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &e, r, travType));
199 
200  return buildDataSet(dset.release(), info);
201 }
202 
203 std::auto_ptr<te::st::TrajectoryDataSet>
205  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
206  te::common::TraverseType /*travType*/)
207 {
208  //use the DataSourceManager to get the DataSource
209  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
210 
211  //montar uma Query e passar para o data source!
212 
213  //return buildDataSet(dset.release(), info);
214  return std::auto_ptr<te::st::TrajectoryDataSet>();
215 }
216 
217 std::auto_ptr<te::st::TrajectoryDataSet>
219  const te::dt::DateTime& /*dt*/,
221  const te::gm::Envelope& /*e*/,
223  te::common::TraverseType /*travType*/)
224 {
225  //use the DataSourceManager to get the DataSource
226  //te::da::DataSourcePtr ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
227 
228  //montar uma Query e passar para o data source!
229 
230  //return buildDataSet(dset.release(), info);
231  return std::auto_ptr<te::st::TrajectoryDataSet>();
232 }
233 
234 std::auto_ptr<te::st::TrajectoryDataSet>
236  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
237  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
238  te::common::TraverseType /*travType*/)
239 {
240  //use the DataSourceManager to get the DataSource
241  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
242 
243  //montar uma Query e passar para o data source!
244 
245  //return buildDataSet(dset.release(), info);
246  return std::auto_ptr<te::st::TrajectoryDataSet>();
247 }
248 
250  std::vector<TimeSeriesDataSetInfo>& /*output*/)
251 {
252  return;
253 }
254 
255 std::auto_ptr<te::st::TimeSeriesDataSet>
257  te::common::TraverseType travType)
258 {
259  //use the DataSourceManager to get the DataSource
261 
262  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
263 
264  return buildDataSet(dset.release(), info);
265 }
266 
267 std::auto_ptr<te::st::TimeSeriesDataSet>
269  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
270  te::common::TraverseType /*travType*/)
271 {
272  //use the DataSourceManager to get the DataSource
273  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
274 
275  //montar uma Query e passar para o data source!
276 
277  //return buildDataSet(dset.release(), info);
278  return std::auto_ptr<te::st::TimeSeriesDataSet>();
279 }
280 
281 std::auto_ptr<te::dt::DateTimePeriod>
283 {
284  //use the DataSourceManager to get the DataSource
285  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
286 
287  //montar uma Query e passar para o data source!
288 
289  //return buildDataSet(dset.release(), info);
290  return std::auto_ptr<te::dt::DateTimePeriod>();
291 }
292 
293 std::auto_ptr<te::dt::DateTimePeriod>
295 {
296  //use the DataSourceManager to get the DataSource
297  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
298 
299  //montar uma Query e passar para o data source!
300 
301  //return buildDataSet(dset.release(), info);
302  return std::auto_ptr<te::dt::DateTimePeriod>();
303 }
304 
305 std::auto_ptr<te::dt::DateTimePeriod>
307 {
308  //use the DataSourceManager to get the DataSource
309  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
310 
311  //montar uma Query e passar para o data source!
312 
313  //return buildDataSet(dset.release(), info);
314  return std::auto_ptr<te::dt::DateTimePeriod>();
315 }
316 
319 {
320  //use the DataSourceManager to get the DataSource
322 
323  std::auto_ptr<te::gm::Envelope> res(ds->getExtent(info.getDataSetName(), info.getGeomPropIdx()));
324  return *res.get();
325 }
326 
329 {
330  //use the DataSourceManager to get the DataSource
332 
333  std::auto_ptr<te::gm::Envelope> res(ds->getExtent(info.getObservationDataSetInfo().getDataSetName(),
335  return *res.get();
336 }
337 
338 //protected
339 std::auto_ptr<te::st::ObservationDataSet>
341 {
342  return std::auto_ptr<ObservationDataSet> (new ObservationDataSet(ds, te::st::GetType(info), 0, te::gm::Envelope()));
343 }
344 
345 std::auto_ptr<te::st::TrajectoryDataSet>
347 {
348  return std::auto_ptr<TrajectoryDataSet> (new TrajectoryDataSet(ds, te::st::GetType(info), 0, te::gm::Envelope()));
349 }
350 
351 std::auto_ptr<te::st::TimeSeriesDataSet>
353 {
354 
355  return std::auto_ptr<TimeSeriesDataSet> (new TimeSeriesDataSet(ds, te::st::GetType(info), 0));
356 }
357 
359 {
360 }
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:259
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.
te::gm::Envelope getSpatialExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations of a coverage series.
int getGeomPropIdx() const
It returns the index of the property that is a geometry property.
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Definition: Enums.h:76
const ObservationDataSetInfo & getObservationDataSetInfo() const
It returns information about the DataSet that contians 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 contians the trajectory observations.
int getGeomPropIdx() const
It returns the indexes of the DataSet properties that contains the geometries associated to the traje...
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns information about the DataSource from which the DataSet comes.
TESTEXPORT ObservationDataSetType GetType(const ObservationDataSetInfo &info)
An auxiliary function that transform ObservationDataSetInfo into ObservationDataSetType.
Definition: Utils.cpp:46
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
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.
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns information about the DataSource from which the DataSet comes.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations.