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 
38 {
39 }
40 
42 
43 {
44 }
45 
47  te::dt::AbstractData* obsValue)
48  : m_phTime(phTime)
49 
50 {
51  m_observedValues.push_back(obsValue);
52 }
53 
55  te::dt::DateTime* phTime, te::gm::Geometry* geom,
56  const boost::ptr_vector<te::dt::AbstractData>& obsValues)
57  : m_phTime(phTime),
58 
59  m_observedValues(obsValues),
60  m_geometry(geom)
61 {
62  }
63 
66  const boost::ptr_vector<te::dt::AbstractData>& obsValues)
67  : m_phTime(phTime),
68  m_resultTime(resTime),
69  m_validTime(valTime),
70  m_observedValues(obsValues),
71  m_geometry(geom)
72 {
73 }
74 
76 {
77  *this = obs;
78 }
79 
81 {
82  if(this == &rhs)
83  return *this;
84 
85  m_phTime.reset();
86  m_resultTime.reset();
87  m_validTime.reset();
88  m_geometry.reset();
89  m_observedValues.clear();
90 
91  if(rhs.m_phTime.get())
92  m_phTime.reset(dynamic_cast<te::dt::DateTime*>(rhs.m_phTime->clone()));
93  if(rhs.m_resultTime.get())
94  m_resultTime.reset(dynamic_cast<te::dt::DateTimeInstant*>(rhs.m_resultTime->clone()));
95  if(rhs.m_validTime.get())
96  m_validTime.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_validTime->clone()));
97  if(rhs.m_geometry.get())
98  m_geometry.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_geometry->clone()));
99 
100  m_observedValues = rhs.m_observedValues.clone();
101  return *this;
102 }
103 
105 {
106  return m_phTime.get();
107 }
108 
110 {
111  m_phTime.reset(phTime);
112 }
113 
115 {
116  return m_resultTime.get();
117 }
118 
120 {
121  m_resultTime.reset(resTime);
122 }
123 
125 {
126  return m_validTime.get();
127 }
128 
130 {
131  m_validTime.reset(valTime);
132 }
133 
134 boost::ptr_vector<te::dt::AbstractData>& te::st::Observation::getObservedValues()
135 {
136  return m_observedValues;
137 }
138 
140 {
141  return &m_observedValues[idx];
142 }
143 
145 {
146  m_observedValues.push_back(value);
147 }
148 
149 void te::st::Observation::setValues(const boost::ptr_vector<te::dt::AbstractData>& values)
150 {
151  m_observedValues.clear();
152  m_observedValues = values; //deep copy?
153 }
154 
156 {
157  return m_geometry.get();
158 }
159 
161 {
162  m_geometry.reset(geom);
163 }
164 
166 {
167  return new Observation(*this);
168 }
169 
te::dt::DateTime * getTime() const
It returns the phenomenon time.
const Observation & operator=(const Observation &rhs)
Assignment operator.
Definition: Observation.cpp:80
std::unique_ptr< te::dt::DateTime > m_phTime
The phenomenon time.
Definition: Observation.h:244
A class to represent an observation.
Definition: Observation.h:60
void setValidTime(te::dt::DateTimePeriod *valTime)
It sets the valid time.
std::unique_ptr< te::dt::DateTimeInstant > m_resultTime
The result time.
Definition: Observation.h:245
te::dt::DateTimeInstant * getResultTime() const
It returns the result time.
Observation()
It constructs an empty Observation.
Definition: Observation.cpp:36
void setTime(te::dt::DateTime *phTime)
It sets the phenomenon time.
boost::ptr_vector< te::dt::AbstractData > & getObservedValues()
It returns the observed values.
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::unique_ptr< te::gm::Geometry > m_geometry
The observation location.
Definition: Observation.h:248
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
std::unique_ptr< te::dt::DateTimePeriod > m_validTime
The valid time.
Definition: Observation.h:246
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.
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.