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 
49  m_timeseries(ts)
50 {
51 }
52 
53 te::st::Object::Object(const std::string& id, Trajectory* tj)
54  : m_id(id), m_trajectory(tj)
55 
56 {
57 }
58 
60  : m_id(obj.m_id)
61 {
62  if(obj.m_timeseries.get())
63  m_timeseries.reset(obj.m_timeseries->clone());
64  if(obj.m_trajectory.get())
65  m_trajectory.reset(obj.m_trajectory->clone());
66 }
67 
69 {
70  if(this != &other)
71  {
72  m_id = other.m_id;
73  if(other.m_timeseries.get())
74  m_timeseries.reset(other.m_timeseries->clone());
75  if(other.m_trajectory.get())
76  m_trajectory.reset(other.m_trajectory->clone());
77  }
78  return *this;
79 }
80 
82 {
83  return new Object(*this);
84 }
85 
86 std::string te::st::Object::getId() const
87 {
88  return m_id;
89 }
90 
91 void te::st::Object::setId(const std::string& id)
92 {
93  m_id = id;
94 }
95 
97 {
98  return m_timeseries.get();
99 }
100 
102 {
103  m_timeseries.reset(ts);
104 }
105 
107 {
108  return m_trajectory.get();
109 }
110 
112 {
113  m_trajectory.reset(tj);
114 }
115 
116 std::pair<te::dt::AbstractData*,te::gm::Geometry*>
118 {
119  std::unique_ptr<te::dt::AbstractData> v;
120  std::unique_ptr<te::gm::Geometry> g;
121 
122  if(m_timeseries.get()!=nullptr)
123  v = m_timeseries->getValue(t);
124 
125  if(m_trajectory.get()!=nullptr)
126  g = m_trajectory->getGeometry(t);
127 
128  std::pair<te::dt::AbstractData*,te::gm::Geometry*> result(v.release(),g.release());
129  return result;
130 }
131 
132 te::st::Object::~Object() = default;
TimeSeries * getTimeSeries() const
It returns the time series associated to the object.
Definition: Object.cpp:96
void setTimeSeries(TimeSeries *ts)
It sets the time series associated to the object.
Definition: Object.cpp:101
std::string m_id
The time series identification.
Definition: Object.h:183
std::unique_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:91
void setTrajectory(Trajectory *tj)
It sets the trajectory associated to the object.
Definition: Object.cpp:111
A class to represent an object.
Definition: Object.h:59
Object * clone() const
It returns a clone of this object.
Definition: Object.cpp:81
std::unique_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:68
A class to represent time series.
Definition: TimeSeries.h:66
This file contains a class to represent an object.
virtual ~Object()
Virtual destructor.
std::string getId() const
It returns the object identification.
Definition: Object.cpp:86
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:117
Trajectory * getTrajectory() const
It returns the trajectory associated to the object.
Definition: Object.cpp:106