All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Observation.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 Observation.cpp
22 
23  \brief A class to represent an observation.
24  */
25 
26 // TerraLib
27 #include "../../../datatype/AbstractData.h"
28 #include "../../../datatype/DateTime.h"
29 #include "../../../datatype/TimeInstant.h"
30 #include "../../../datatype/TimePeriod.h"
31 #include "../../../geometry/Geometry.h"
32 
33 //ST
34 #include "Observation.h"
35 
37  : m_phTime(),
38  m_resultTime(),
39  m_validTime(),
40  m_geometry()
41 {
42 }
43 
45  : m_phTime(phTime),
46  m_resultTime(),
47  m_validTime(),
48  m_geometry()
49 {
50 }
51 
53  : m_phTime(phTime),
54  m_resultTime(),
55  m_validTime(),
56  m_geometry()
57 {
58  m_observedValues.push_back(obsValue);
59 }
60 
62  const boost::ptr_vector<te::dt::AbstractData>& obsValues)
63  : m_phTime(phTime),
64  m_resultTime(),
65  m_validTime(),
66  m_observedValues(obsValues),
67  m_geometry(geom)
68  {
69  }
70 
73  const boost::ptr_vector<te::dt::AbstractData>& obsValues)
74  : m_phTime(phTime),
75  m_resultTime(resTime),
76  m_validTime(valTime),
77  m_observedValues(obsValues),
78  m_geometry(geom)
79 {
80 }
81 
83 {
84  *this = obs;
85 }
86 
88 {
89  if(this == &rhs)
90  return *this;
91 
92  m_phTime.reset();
93  m_resultTime.reset();
94  m_validTime.reset();
95  m_geometry.reset();
96  m_observedValues.clear();
97 
98  if(rhs.m_phTime.get())
99  m_phTime.reset(dynamic_cast<te::dt::DateTime*>(rhs.m_phTime->clone()));
100  if(rhs.m_resultTime.get())
101  m_resultTime.reset(dynamic_cast<te::dt::DateTimeInstant*>(rhs.m_resultTime->clone()));
102  if(rhs.m_validTime.get())
103  m_validTime.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_validTime->clone()));
104  if(rhs.m_geometry.get())
105  m_geometry.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_geometry->clone()));
106 
107  m_observedValues = rhs.m_observedValues.clone();
108  return *this;
109 }
110 
112 {
113  return m_phTime.get();
114 }
115 
117 {
118  m_phTime.reset(phTime);
119 }
120 
122 {
123  return m_resultTime.get();
124 }
125 
127 {
128  m_resultTime.reset(resTime);
129 }
130 
132 {
133  return m_validTime.get();
134 }
135 
137 {
138  m_validTime.reset(valTime);
139 }
140 
141 boost::ptr_vector<te::dt::AbstractData>& te::st::Observation::getObservedValues()
142 {
143  return m_observedValues;
144 }
145 
147 {
148  return &m_observedValues[idx];
149 }
150 
152 {
153  m_observedValues.push_back(value);
154 }
155 
156 void te::st::Observation::setValues(const boost::ptr_vector<te::dt::AbstractData>& values)
157 {
158  m_observedValues.clear();
159  m_observedValues = values; //deep copy?
160 }
161 
163 {
164  return m_geometry.get();
165 }
166 
168 {
169  m_geometry.reset(geom);
170 }
171 
173 {
174  return new Observation(*this);
175 }
176 
178 {
179 }
180 
181 
te::dt::DateTime * getTime() const
It returns the phenomenon time.
const Observation & operator=(const Observation &rhs)
Assignment operator.
Definition: Observation.cpp:87
A class to represent an observation.
Definition: Observation.h:60
void setValidTime(te::dt::DateTimePeriod *valTime)
It sets the valid time.
te::dt::DateTimeInstant * getResultTime() const
It returns the result time.
Observation()
It constructs an empty Observation.
Definition: Observation.cpp:36
std::auto_ptr< te::dt::DateTimePeriod > m_validTime
The valid time.
Definition: Observation.h:246
void setTime(te::dt::DateTime *phTime)
It sets the phenomenon time.
boost::ptr_vector< te::dt::AbstractData > & getObservedValues()
It returns the observed values.
std::auto_ptr< te::gm::Geometry > m_geometry
The observation location.
Definition: Observation.h:248
boost::ptr_vector< te::dt::AbstractData > m_observedValues
The observed values.
Definition: Observation.h:247
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
std::auto_ptr< te::dt::DateTime > m_phTime
The phenomenon time.
Definition: Observation.h:244
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
te::gm::Geometry * getGeometry() const
It returns the observation location or region.
te::dt::DateTimePeriod * getValidTime() const
It returns the valid time.
Observation * clone() const
It returns a clone of this object.
An abstract class to represent a period of date and time.
void setValues(const boost::ptr_vector< te::dt::AbstractData > &values)
It sets the observed values.
std::auto_ptr< te::dt::DateTimeInstant > m_resultTime
The result time.
Definition: Observation.h:245
void addValue(te::dt::AbstractData *value)
It adds an observed value.
virtual ~Observation()
Virtual destructor.
void setGeometry(te::gm::Geometry *geom)
It sets the observation location or region.
void setResultTime(te::dt::DateTimeInstant *resTime)
It sets the result time.
const te::dt::AbstractData * getObservedValue(int idx=0) const
It returns the idx-th observed value.
An abstract class to represent an instant of date and time.