All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Object.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 Object.cpp
22 
23  \brief This file contains a class to represent an object.
24 */
25 
26 // TerraLib
27 #include "../../../datatype/DateTime.h"
28 #include "../../../datatype/DateTimePeriod.h"
29 #include "../../../datatype/DateTimeInstant.h"
30 #include "../../../datatype/AbstractData.h"
31 #include "../../../geometry/Geometry.h"
32 
33 //ST
34 #include "../timeseries/TimeSeries.h"
35 #include "../trajectory/Trajectory.h"
36 #include "Object.h"
37 
38 
39 te::st::Object::Object(const std::string& id, TimeSeries* ts, Trajectory* tj)
40  : m_id(id),
41  m_trajectory(tj),
42  m_timeseries(ts)
43 {
44 }
45 
46 te::st::Object::Object(const std::string& id, TimeSeries* ts)
47  : m_id(id),
48  m_trajectory(),
49  m_timeseries(ts)
50 {
51 }
52 
53 te::st::Object::Object(const std::string& id, Trajectory* tj)
54  : m_id(id),
55  m_trajectory(tj),
56  m_timeseries()
57 {
58 }
59 
61  : m_id(obj.m_id)
62 {
63  if(obj.m_timeseries.get())
64  m_timeseries.reset(obj.m_timeseries->clone());
65  if(obj.m_trajectory.get())
66  m_trajectory.reset(obj.m_trajectory->clone());
67 }
68 
70 {
71  if(this != &other)
72  {
73  m_id = other.m_id;
74  if(other.m_timeseries.get())
75  m_timeseries.reset(other.m_timeseries->clone());
76  if(other.m_trajectory.get())
77  m_trajectory.reset(other.m_trajectory->clone());
78  }
79  return *this;
80 }
81 
83 {
84  return new Object(*this);
85 }
86 
87 std::string te::st::Object::getId() const
88 {
89  return m_id;
90 }
91 
92 void te::st::Object::setId(const std::string& id)
93 {
94  m_id = id;
95 }
96 
98 {
99  return m_timeseries.get();
100 }
101 
103 {
104  m_timeseries.reset(ts);
105 }
106 
108 {
109  return m_trajectory.get();
110 }
111 
113 {
114  m_trajectory.reset(tj);
115 }
116 
117 std::pair<te::dt::AbstractData*,te::gm::Geometry*>
119 {
120  std::auto_ptr<te::dt::AbstractData> v;
121  std::auto_ptr<te::gm::Geometry> g;
122 
123  if(m_timeseries.get()!=0)
124  v = m_timeseries->getValue(t);
125 
126  if(m_trajectory.get()!=0)
127  g = m_trajectory->getGeometry(t);
128 
129  std::pair<te::dt::AbstractData*,te::gm::Geometry*> result(v.release(),g.release());
130  return result;
131 }
132 
134 {
135 }
136 
137 
TimeSeries * getTimeSeries() const
It returns the time series associated to the object.
Definition: Object.cpp:97
void setTimeSeries(TimeSeries *ts)
It sets the time series associated to the object.
Definition: Object.cpp:102
std::string m_id
The time series identification.
Definition: Object.h:183
std::auto_ptr< TimeSeries > m_timeseries
The variation of a property of the object.
Definition: Object.h:185
void setId(const std::string &id)
It sets the object identification.
Definition: Object.cpp:92
void setTrajectory(Trajectory *tj)
It sets the trajectory associated to the object.
Definition: Object.cpp:112
A class to represent an object.
Definition: Object.h:59
Object * clone() const
It returns a clone of this object.
Definition: Object.cpp:82
std::auto_ptr< Trajectory > m_trajectory
The variation of the spatial property of the object.
Definition: Object.h:184
Object(const std::string &id, TimeSeries *ts, Trajectory *tj)
Constructor.
Definition: Object.cpp:39
Object & operator=(const Object &other)
Copy assignment operator.
Definition: Object.cpp:69
A class to represent time series.
Definition: TimeSeries.h:66
This file contains a class to represent an object.
virtual ~Object()
Virtual destructor.
Definition: Object.cpp:133
std::string getId() const
It returns the object identification.
Definition: Object.cpp:87
A class to represent trajectory.
Definition: Trajectory.h:75
std::pair< te::dt::AbstractData *, te::gm::Geometry * > getState(te::dt::DateTime *t) const
It returns the state of the object at a given date and time.
Definition: Object.cpp:118
Trajectory * getTrajectory() const
It returns the trajectory associated to the object.
Definition: Object.cpp:107