All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrajectoryDataSet.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 TrajectoryDataSet.cpp
22 
23  \brief This file contains a class to represent a trajectory data set.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSet.h"
28 #include "../../../datatype/DateTime.h"
29 #include "../../../datatype/DateTimePeriod.h"
30 #include "../../../datatype/DateTimeInstant.h"
31 #include "../../../datatype/SimpleData.h"
32 #include "../../../geometry/Geometry.h"
33 #include "../../../geometry/Utils.h"
34 
35 //ST
36 #include "TrajectoryDataSet.h"
37 #include "Trajectory.h"
38 #include "../observation/ObservationDataSet.h"
39 #include "../observation/ObservationDataSetType.h"
40 #include "../interpolator/NearestGeometryAtTimeInterp.h"
41 
43  int idPropIdx, const std::string& id)
44 : m_obsDs(new ObservationDataSet(ds, tPropIdx, gPropIdx, gPropIdx)),
45  m_type(tPropIdx, gPropIdx, idPropIdx, id),
46  m_id(id)
47 {
48 
49 }
50 
52  int idPropIdx, const std::string& id,
53  te::dt::DateTimePeriod* text, const te::gm::Envelope& sext)
54 : m_obsDs(new ObservationDataSet(ds, tPropIdx, gPropIdx, gPropIdx, text, sext)),
55  m_type(tPropIdx, gPropIdx, idPropIdx, id),
56  m_id(id)
57 {
58 
59 }
60 
61 te::st::TrajectoryDataSet::TrajectoryDataSet(te::da::DataSet* ds, const std::vector<int>& tPropIdxs,
62  int gPropIdx, int idPropIdx, const std::string& id)
63 : m_obsDs(new ObservationDataSet(ds, tPropIdxs, std::vector<int>(1,gPropIdx), gPropIdx)),
64  m_type(tPropIdxs, gPropIdx, idPropIdx, id),
65  m_id(id)
66 {
67 
68 }
69 
70 te::st::TrajectoryDataSet::TrajectoryDataSet(te::da::DataSet* ds, const std::vector<int>& tPropIdxs,
71  int gPropIdx, int idPropIdx, const std::string& id, te::dt::DateTimePeriod* text,
72  const te::gm::Envelope& sext)
73 : m_obsDs(new ObservationDataSet(ds, tPropIdxs, std::vector<int>(1,gPropIdx), gPropIdx, text, sext)),
74  m_type(tPropIdxs, gPropIdx, idPropIdx, id),
75  m_id(id)
76 {
77 
78 }
79 
81  te::dt::DateTimePeriod* text, const te::gm::Envelope& sext)
82 : m_obsDs(new ObservationDataSet(ds, type.getType(), text, sext)),
83  m_type(type),
84  m_id(type.getId())
85 {
86 
87 }
88 
90  const TrajectoryDataSetType& type, const std::string& id)
91  : m_obsDs(obs),
92  m_type(type),
93  m_id(id)
94 {
95 }
96 
98 {
99  return m_obsDs.get();
100 }
101 
103 {
104  return m_type;
105 }
106 
108 {
109  return m_id;
110 }
111 
112 void te::st::TrajectoryDataSet::setId(const std::string& id)
113 {
114  m_id = id;
115 }
116 
118 {
119  return m_obsDs->getData()->size();
120 }
121 
123 {
124  return m_obsDs->moveNext();
125 }
126 
128 {
129  return m_obsDs->movePrevious();
130 }
131 
133 {
134  return m_obsDs->moveFirst();
135 }
136 
138 {
139  return m_obsDs->moveBeforeFirst();
140 }
141 
143 {
144  return m_obsDs->moveLast();
145 }
146 
148 {
149  return m_obsDs->isAtBegin();
150 }
151 
153 {
154  return m_obsDs->isBeforeBegin();
155 }
156 
158 {
159  return m_obsDs->isAtEnd();
160 }
161 
163 {
164  return m_obsDs->isAfterEnd();
165 }
166 
167 std::auto_ptr<te::gm::Geometry> te::st::TrajectoryDataSet::getGeometry() const
168 {
169  int geomPropIdx = m_type.getGeomPropIdx();
170  return std::auto_ptr<te::gm::Geometry>(m_obsDs->getData()->getGeometry(geomPropIdx));
171 }
172 
173 std::auto_ptr<te::dt::DateTime> te::st::TrajectoryDataSet::getTime() const
174 {
175  //TO DO: arrumar pro caso quando for period dividido em duas colunas
176  int phTimePropIdx = m_type.getBeginTimePropIdx();
177  return std::auto_ptr<te::dt::DateTime>(m_obsDs->getData()->getDateTime(phTimePropIdx));
178 }
179 
181 {
182  return m_obsDs->getTemporalExtent();
183 }
184 
186 {
187  return m_obsDs->getSpatialExtent();
188 }
189 
191 {
192  Trajectory* result = new Trajectory(interp,m_id);
193  te::da::DataSet* ds = m_obsDs->getData();
194  while(ds->moveNext())
195  {
196  std::auto_ptr<te::dt::DateTime> time(ds->getDateTime(m_type.getBeginTimePropIdx()));
197  std::auto_ptr<te::gm::Geometry> geom(ds->getGeometry(m_type.getGeomPropIdx()));
198  result->add(time.release(), geom.release());
199  }
200  return std::auto_ptr<te::st::Trajectory>(result);
201 }
202 
203 std::auto_ptr<te::st::Trajectory> te::st::TrajectoryDataSet::getTrajectory()
204 {
205  return getTrajectory(&NearestGeometryAtTimeInterp::getInstance());
206 }
207 
209 {
210 }
211 
212 
213 
214 
A class to represent trajectory.
Definition: Trajectory.h:75
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
A class that contains complemental information about a DataSet that holds observations of a trajector...
This file contains a class to represent a trajectory data set.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
void setId(const std::string &id)
It sets the identifier associated to the trajectory.
This file contains a class to represent a trajectory.
ObservationDataSet * getObservationSet() const
It returns the data set that contains the trajectory observations.
A class to represent a DataSet that contains observations.
An abstract class to represent a period of date and time.
TrajectoryDataSet(te::da::DataSet *ds, int tPropIdx, int gPropIdx, int idPropIdx, const std::string &id)
Constructor.
const te::gm::Envelope & getSpatialExtent() const
It returns the spatial extent of the trajectory observations.
std::size_t size() const
It returns the size of the trajectory observation set.
te::dt::DateTimePeriod * getTemporalExtent() const
It returns the temporal extent of the trajectory observations.
virtual ~TrajectoryDataSet()
It returns the trajectory geometry property.
std::string getId() const
It returns the identifier associated to the trajectory.
std::auto_ptr< te::gm::Geometry > getGeometry() const
void add(te::dt::DateTime *time, te::gm::Geometry *geom)
It adds an observation (time and geometry) into the trajectory.
Definition: Trajectory.cpp:173
static NearestGeometryAtTimeInterp & getInstance()
It returns a reference to the singleton instance.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
An abstract class for an interpolation function or interpolator that estimates geometries at non-obse...
std::auto_ptr< Trajectory > getTrajectory()
It returns the trajectory from the DataSet.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111
std::auto_ptr< te::dt::DateTime > getTime() const
It returns the time pointed by the internal cursor.
const TrajectoryDataSetType & getType() const
It returns a reference to the internal trajectory data set type.