All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObservationDataSet.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 ObservationDataSet.cpp
22 
23  \brief This file contains a class to represent an observation data set.
24 */
25 
26 //TerraLib
27 #include "../../../dataaccess/dataset/DataSet.h"
28 #include "../../../dataaccess/dataset/DataSetType.h"
29 #include "../../../datatype/DateTime.h"
30 #include "../../../datatype/DateTimePeriod.h"
31 #include "../../../datatype/DateTimeInstant.h"
32 
33 //ST
34 #include "ObservationDataSet.h"
35 #include "Observation.h"
36 
38  : m_ds(ds),
39  m_obst(obst),
40  m_tpExtent(),
41  m_spExtent()
42 {
43 }
44 
47  : m_ds(ds),
48  m_obst(obst),
49  m_tpExtent(text)
50 {
51 }
52 
54  te::dt::DateTimePeriod* text, const te::gm::Envelope& sext)
55  : m_ds(ds),
56  m_obst(obst),
57  m_tpExtent(text),
58  m_spExtent(sext)
59 {
60 }
61 
63  int geomPropIdx)
64  : m_ds(ds),
65  m_obst(phTimeIdx, obsPropIdx, geomPropIdx),
66  m_tpExtent(),
67  m_spExtent()
68 {
69 }
70 
71 te::st::ObservationDataSet::ObservationDataSet( te::da::DataSet* ds, const std::vector<int>& phTimeIdxs,
72  const std::vector<int>& obsPropIdxs, int geomPropIdx)
73  : m_ds(ds),
74  m_obst(phTimeIdxs, obsPropIdxs, geomPropIdx),
75  m_tpExtent(),
76  m_spExtent()
77 {
78 }
79 
81  int geomPropIdx, te::dt::DateTimePeriod* text)
82  : m_ds(ds),
83  m_obst(phTimeIdx, obsPropIdx, geomPropIdx),
84  m_tpExtent(text)
85 {
86 }
87 
89  int geomPropIdx, te::dt::DateTimePeriod* text, const te::gm::Envelope& sext)
90  : m_ds(ds),
91  m_obst(phTimeIdx, obsPropIdx, geomPropIdx),
92  m_tpExtent(text),
93  m_spExtent(sext)
94 {
95 }
96 
97 te::st::ObservationDataSet::ObservationDataSet( te::da::DataSet* ds, const std::vector<int>& phTimeIdxs,
98  const std::vector<int>& obsPropIdxs, int geomPropIdx, te::dt::DateTimePeriod* text)
99  : m_ds(ds),
100  m_obst(phTimeIdxs, obsPropIdxs, geomPropIdx),
101  m_tpExtent(text)
102 {
103 }
104 
105 te::st::ObservationDataSet::ObservationDataSet( te::da::DataSet* ds, const std::vector<int>& phTimeIdxs,
106  const std::vector<int>& obsPropIdxs, int geomPropIdx, te::dt::DateTimePeriod* text,
107  const te::gm::Envelope& sext)
108  : m_ds(ds),
109  m_obst(phTimeIdxs, obsPropIdxs, geomPropIdx),
110  m_tpExtent(text),
111  m_spExtent(sext)
112 {
113 }
114 
116 {
117  return m_ds.get();
118 }
119 
120 std::auto_ptr<te::da::DataSet> te::st::ObservationDataSet::release()
121 {
122  delete m_tpExtent.release();
123  std::auto_ptr<te::da::DataSet> result(m_ds.release());
124  return result;
125 }
126 
128 {
129  return m_obst;
130 }
131 
133 {
134  if(m_spExtent.isValid())
135  return m_spExtent;
136 
137  std::auto_ptr<te::gm::Envelope> env(m_ds->getExtent(m_obst.getGeomPropIdx()));
138  m_spExtent = *(env.get());
139  return m_spExtent;
140 }
141 
143 {
144  m_spExtent = ext;
145 }
146 
148 {
149  return m_tpExtent.get();
150 }
151 
153 {
154  m_tpExtent.reset(ext);
155 }
156 
158 {
159  return m_ds->moveNext();
160 }
161 
163 {
164  return m_ds->movePrevious();
165 }
166 
168 {
169  return m_ds->moveFirst();
170 }
171 
173 {
174  return m_ds->moveBeforeFirst();
175 }
176 
178 {
179  return m_ds->moveLast();
180 }
181 
183 {
184  return m_ds->isAtBegin();
185 }
186 
188 {
189  return m_ds->isBeforeBegin();
190 }
191 
193 {
194  return m_ds->isAtEnd();
195 }
196 
198 {
199  return m_ds->isAfterEnd();
200 }
201 
202 std::auto_ptr<te::st::Observation> te::st::ObservationDataSet::getObservation() const
203 {
204  std::auto_ptr<te::dt::DateTime> phTime(m_ds->getDateTime(m_obst.getBeginTimePropIdx()));
205  std::auto_ptr<te::dt::DateTime> vlTime(0);
206  std::auto_ptr<te::dt::DateTime> rsTime(0);
207 
208  if(m_obst.getVlBeginTimePropIdx()>-1)
209  vlTime = m_ds->getDateTime(m_obst.getVlBeginTimePropIdx());
210 
211  if(m_obst.getRsTimePropIdx()>-1)
212  rsTime = m_ds->getDateTime(m_obst.getRsTimePropIdx());
213 
214  boost::ptr_vector<te::dt::AbstractData> obsData;
215  for(std::size_t i = 0; i<m_obst.getObsPropIdxs().size(); ++i)
216  obsData.push_back(m_ds->getValue(m_obst.getObsPropIdxs()[i]));
217 
218  return std::auto_ptr<te::st::Observation>(new
219  Observation(phTime.release(),static_cast<te::dt::DateTimeInstant*>(rsTime.release()),
220  static_cast<te::dt::DateTimePeriod*>(vlTime.release()),obsData));
221 }
222 
224 {
225 }
226 
227 
228 
std::auto_ptr< Observation > getObservation() const
It returns the observation pointed by the internal cursor.
A class to represent an observation.
Definition: Observation.h:58
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
const te::gm::Envelope & getSpatialExtent()
It returns the spatial extent of the observations, when there is an observed value of geometry type...
void setSpatialExtent(const te::gm::Envelope &ext)
It sets the spatial extent of the observations, when there is an observed value of geometry type...
This file contains a class to represent an observation data set.
std::auto_ptr< te::da::DataSet > release()
It releases all internal pointers, returning its internal DataSet and invalidating itself...
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
const ObservationDataSetType & getType() const
It returns a reference to the ObservationDataSetType.
An abstract class to represent a period of date and time.
void setTemporalExtent(te::dt::DateTimePeriod *ext)
It sets the temporal extent of the observations, when there is an observed value of geometry type...
ObservationDataSet(te::da::DataSet *ds, const ObservationDataSetType &obst)
Constructor.
te::da::DataSet * getData() const
It returns the DataSet that contains the observations.
A class that contains complemental DataSetType information about a DataSet that holds observations...
te::dt::DateTimePeriod * getTemporalExtent()
It returns the temporal extent of the observations.
virtual ~ObservationDataSet()
It returns the property of the phenomenon beginning time.
An abstract class to represent an instant of date and time.