All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrajectoryDataSet.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 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 : m_obsDs(new ObservationDataSet(ds, type)),
44  m_id()
45 {
46 }
47 
49  const std::string& id)
50 : m_obsDs(new ObservationDataSet(ds, type)),
51  m_id(id)
52 {
53 }
54 
56  : m_obsDs(obs),
57  m_id(id)
58 {
59 }
60 
62 {
63  return m_obsDs.get();
64 }
65 
67 {
68  return m_id;
69 }
70 
71 void te::st::TrajectoryDataSet::setId(const std::string& id)
72 {
73  m_id = id;
74 }
75 
77 {
78  return m_obsDs->getData()->size();
79 }
80 
82 {
83  return m_obsDs->moveNext();
84 }
85 
87 {
88  return m_obsDs->movePrevious();
89 }
90 
92 {
93  return m_obsDs->moveFirst();
94 }
95 
97 {
98  return m_obsDs->moveBeforeFirst();
99 }
100 
102 {
103  return m_obsDs->moveLast();
104 }
105 
107 {
108  return m_obsDs->isAtBegin();
109 }
110 
112 {
113  return m_obsDs->isBeforeBegin();
114 }
115 
117 {
118  return m_obsDs->isAtEnd();
119 }
120 
122 {
123  return m_obsDs->isAfterEnd();
124 }
125 
126 std::auto_ptr<te::gm::Geometry> te::st::TrajectoryDataSet::getGeometry() const
127 {
128  if(!m_obsDs->getType().hasGeomProp())
129  return std::auto_ptr<te::gm::Geometry>();
130  return std::auto_ptr<te::gm::Geometry>(m_obsDs->getData()->getGeometry(m_obsDs->getType().getGeomPropName()));
131 }
132 
133 std::auto_ptr<te::dt::DateTime> te::st::TrajectoryDataSet::getTime() const
134 {
135  //TO DO: arrumar pro caso quando for period dividido em duas colunas
136  std::string phTimePropName = m_obsDs->getType().getBeginTimePropName();
137  return std::auto_ptr<te::dt::DateTime>(m_obsDs->getData()->getDateTime(phTimePropName));
138 }
139 
141 {
142  return m_obsDs->getType().getTemporalExtent();
143 }
144 
146 {
147  return m_obsDs->getType().getSpatialExtent();
148 }
149 
151 {
152  Trajectory* result = new Trajectory(interp,m_id);
153  te::da::DataSet* ds = m_obsDs->getData();
154  while(ds->moveNext())
155  {
156  std::auto_ptr<te::dt::DateTime> time(ds->getDateTime(m_obsDs->getType().getBeginTimePropName()));
157  std::auto_ptr<te::gm::Geometry> geom(ds->getGeometry(m_obsDs->getType().getGeomPropName()));
158  result->add(time.release(), geom.release());
159  }
160  return std::auto_ptr<te::st::Trajectory>(result);
161 }
162 
163 std::auto_ptr<te::st::Trajectory> te::st::TrajectoryDataSet::getTrajectory()
164 {
165  return getTrajectory(&NearestGeometryAtTimeInterp::getInstance());
166 }
167 
168 std::auto_ptr<te::da::DataSet> te::st::TrajectoryDataSet::release()
169 {
170  std::auto_ptr<te::da::DataSet> result(m_obsDs->release());
171  return result;
172 }
173 
175 {
176 }
177 
178 
179 
180 
This file contains a class to represent a trajectory.
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
const te::dt::DateTimePeriod * getTemporalExtent() const
It returns the temporal extent of the trajectory observations.
A class to represent a DataSet that contains observations.
void setId(const std::string &id)
It sets the identifier associated to the trajectory.
std::auto_ptr< Trajectory > getTrajectory()
It returns the trajectory from the DataSet.
std::auto_ptr< te::da::DataSet > release()
It releases all internal pointers, returning its internal DataSet and invalidating itself...
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
An abstract class for an interpolation function or interpolator that estimates geometries at non-obse...
std::string getId() const
It returns the identifier associated to the trajectory.
static NearestGeometryAtTimeInterp & getInstance()
It returns a reference to the singleton instance.
virtual ~TrajectoryDataSet()
Virtual destructor.
std::auto_ptr< te::dt::DateTime > getTime() const
It returns the time pointed by the internal cursor.
const te::gm::Geometry * getSpatialExtent() const
It returns the spatial extent of the trajectory observations.
TrajectoryDataSet(te::da::DataSet *ds, const ObservationDataSetType &type)
Constructor.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
std::auto_ptr< te::gm::Geometry > getGeometry() const
It returns the geometry pointed by the internal cursor.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
ObservationDataSet * getObservationSet() const
It returns the data set that contains the trajectory observations.
An abstract class to represent a period of date and time.
A class that contains complemental DataSetType information about a DataSet that holds observations...
A class to represent trajectory.
Definition: Trajectory.h:75
void add(te::dt::DateTime *time, te::gm::Geometry *geom)
It adds an observation (time and geometry) into the trajectory.
Definition: Trajectory.cpp:173
std::size_t size() const
It returns the size of the trajectory observation set.
This file contains a class to represent a trajectory data set.