All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
118  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
119  te::common::TraverseType /*travType*/)
120 {
121  //use the DataSourceManager to get the DataSource
122  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
123 
124  //montar uma Query e passar para o data source!
125 
126  //return buildDataSet(dset.release(), info);
127  return std::auto_ptr<te::st::ObservationDataSet> ();
128 }
129 
130 void
131 te::st::STDataLoaderFromDS::getInfo( const TrajectoryDataSetInfo& /*input*/, std::vector<TrajectoryDataSetInfo>& /*output*/)
132 {
133  return;
134 }
135 
136 std::auto_ptr<te::st::TrajectoryDataSet>
138 {
139  //use the DataSourceManager to get the DataSource
141 
142  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
143 
144  return buildDataSet(dset.release(), info);
145 }
146 
147 std::auto_ptr<te::st::TrajectoryDataSet>
150  te::common::TraverseType travType)
151 {
152  //use the DataSourceManager to get the DataSource
154 
155  //get the geometry property name
156  std::auto_ptr<te::da::DataSetType> dsettype(ds->getDataSetType(info.getObservationDataSetInfo().getDataSetName()));
157 
158  std::string geomPropName = dsettype->getProperty(info.getGeomPropIdx())->getName();
159 
160  //get the data set applying he filter
161  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &geom, r, travType));
162 
163  return buildDataSet(dset.release(), info);
164 }
165 
166 std::auto_ptr<te::st::TrajectoryDataSet>
169  te::common::TraverseType travType)
170 {
171  //use the DataSourceManager to get the DataSource
173 
174  //get the geometry property name
175  std::auto_ptr<te::da::DataSetType> dsettype(ds->getDataSetType(info.getObservationDataSetInfo().getDataSetName()));
176 
177  std::string geomPropName = dsettype->getProperty(info.getGeomPropIdx())->getName();
178 
179  //get the data set applying he filter
180  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), geomPropName, &e, r, travType));
181 
182  return buildDataSet(dset.release(), info);
183 }
184 
185 std::auto_ptr<te::st::TrajectoryDataSet>
187  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
188  te::common::TraverseType /*travType*/)
189 {
190  //use the DataSourceManager to get the DataSource
191  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
192 
193  //montar uma Query e passar para o data source!
194 
195  //return buildDataSet(dset.release(), info);
196  return std::auto_ptr<te::st::TrajectoryDataSet>();
197 }
198 
199 std::auto_ptr<te::st::TrajectoryDataSet>
201  const te::gm::Geometry& /*geom*/, te::gm::SpatialRelation /*sr*/,
202  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*tr*/,
203  te::common::TraverseType /*travType*/)
204 {
205  //use the DataSourceManager to get the DataSource
206  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
207 
208  //montar uma Query e passar para o data source!
209 
210  //return buildDataSet(dset.release(), info);
211  return std::auto_ptr<te::st::TrajectoryDataSet>();
212 }
213 
215  std::vector<TimeSeriesDataSetInfo>& /*output*/)
216 {
217  return;
218 }
219 
220 std::auto_ptr<te::st::TimeSeriesDataSet>
222  te::common::TraverseType travType)
223 {
224  //use the DataSourceManager to get the DataSource
226 
227  std::auto_ptr<te::da::DataSet> dset(ds->getDataSet(info.getObservationDataSetInfo().getDataSetName(), travType));
228 
229  return buildDataSet(dset.release(), info);
230 }
231 
232 std::auto_ptr<te::st::TimeSeriesDataSet>
234  const te::dt::DateTime& /*dt*/, te::dt::TemporalRelation /*r*/,
235  te::common::TraverseType /*travType*/)
236 {
237  //use the DataSourceManager to get the DataSource
238  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
239 
240  //montar uma Query e passar para o data source!
241 
242  //return buildDataSet(dset.release(), info);
243  return std::auto_ptr<te::st::TimeSeriesDataSet>();
244 }
245 
246 std::auto_ptr<te::dt::DateTimePeriod>
248 {
249  //use the DataSourceManager to get the DataSource
250  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
251 
252  //montar uma Query e passar para o data source!
253 
254  //return buildDataSet(dset.release(), info);
255  return std::auto_ptr<te::dt::DateTimePeriod>();
256 }
257 
258 std::auto_ptr<te::dt::DateTimePeriod>
260 {
261  //use the DataSourceManager to get the DataSource
262  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
263 
264  //montar uma Query e passar para o data source!
265 
266  //return buildDataSet(dset.release(), info);
267  return std::auto_ptr<te::dt::DateTimePeriod>();
268 }
269 
270 std::auto_ptr<te::dt::DateTimePeriod>
272 {
273  //use the DataSourceManager to get the DataSource
274  //te::da::DataSource* ds = te::da::GetDataSource(info.getDataSourceInfo().getId(), false);
275 
276  //montar uma Query e passar para o data source!
277 
278  //return buildDataSet(dset.release(), info);
279  return std::auto_ptr<te::dt::DateTimePeriod>();
280 }
281 
284 {
285  //use the DataSourceManager to get the DataSource
287 
288  std::auto_ptr<te::gm::Envelope> res(ds->getExtent(info.getDataSetName(), info.getGeomPropIdx()));
289  return *res.get();
290 }
291 
294 {
295  //use the DataSourceManager to get the DataSource
297 
298  std::auto_ptr<te::gm::Envelope> res(ds->getExtent(info.getObservationDataSetInfo().getDataSetName(),
300  return *res.get();
301 }
302 
303 //protected
304 std::auto_ptr<te::st::ObservationDataSet>
306 {
307  return std::auto_ptr<ObservationDataSet> (new ObservationDataSet(ds, te::st::GetType(info), 0, te::gm::Envelope()));
308 }
309 
310 std::auto_ptr<te::st::TrajectoryDataSet>
312 {
313  return std::auto_ptr<TrajectoryDataSet> (new TrajectoryDataSet(ds, te::st::GetType(info), 0, te::gm::Envelope()));
314 }
315 
316 std::auto_ptr<te::st::TimeSeriesDataSet>
318 {
319 
320  return std::auto_ptr<TimeSeriesDataSet> (new TimeSeriesDataSet(ds, te::st::GetType(info), 0));
321 }
322 
324 {
325 }
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns the information about the DataSource.
A class that contains infos about a DataSet that contains observations of one or more time series...
const std::string & getId() const
A class that contains infos about a DataSet that contains observations.
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:258
std::string getDataSetName() const
It returns the DataSet name.
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.
This file contains a class responsible for loading spatiotemporal data from a DataSource using query ...
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:122
A class to represent a DataSet that contains observations.
TESTEXPORT ObservationDataSetType GetType(const ObservationDataSetInfo &info)
An auxiliary function that transform ObservationDataSetInfo into ObservationDataSetType.
Definition: Utils.cpp:46
void getInfo(const TrajectoryDataSetInfo &input, std::vector< TrajectoryDataSetInfo > &output)
It returns the information about all trajectories that exist in a single DataSet. ...
te::gm::Envelope getSpatialExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations of a coverage series.
A class to represent a time series data set.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent(const ObservationDataSetInfo &info)
It returns the temporal extent of the data set with observations.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Definition: Enums.h:76
A class that contains infos about a DataSet that contains observations of one or more trajectories...
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1395
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
int getGeomPropIdx() const
It returns the index of the property that is a geometry property.
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns information about the DataSource from which the DataSet comes.
std::auto_ptr< ObservationDataSet > buildDataSet(te::da::DataSet *ds, const ObservationDataSetInfo &info)
It builds an ObservationDataSet from a given DataSet.
const ObservationDataSetInfo & getObservationDataSetInfo() const
It returns information about the DataSet that contians the time series observations.
const ObservationDataSetInfo & getObservationDataSetInfo() const
It returns information about the DataSet that contians the trajectory observations.
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns information about the DataSource from which the DataSet comes.
int getGeomPropIdx() const
It returns the indexes of the DataSet properties that contains the geometries associated to the traje...
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
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:111