All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
121 {
122  return m_obst;
123 }
124 
126 {
127  if(m_spExtent.isValid())
128  return m_spExtent;
129 
130  std::auto_ptr<te::gm::Envelope> env(m_ds->getExtent(m_obst.getGeomPropIdx()));
131  m_spExtent = *(env.get());
132  return m_spExtent;
133 }
134 
136 {
137  m_spExtent = ext;
138 }
139 
141 {
142  return m_tpExtent.get();
143 }
144 
146 {
147  m_tpExtent.reset(ext);
148 }
149 
151 {
152  return m_ds->moveNext();
153 }
154 
156 {
157  return m_ds->movePrevious();
158 }
159 
161 {
162  return m_ds->moveFirst();
163 }
164 
166 {
167  return m_ds->moveBeforeFirst();
168 }
169 
171 {
172  return m_ds->moveLast();
173 }
174 
176 {
177  return m_ds->isAtBegin();
178 }
179 
181 {
182  return m_ds->isBeforeBegin();
183 }
184 
186 {
187  return m_ds->isAtEnd();
188 }
189 
191 {
192  return m_ds->isAfterEnd();
193 }
194 
195 std::auto_ptr<te::st::Observation> te::st::ObservationDataSet::getObservation() const
196 {
197  std::auto_ptr<te::dt::DateTime> phTime(m_ds->getDateTime(m_obst.getBeginTimePropIdx()));
198  std::auto_ptr<te::dt::DateTime> vlTime(0);
199  std::auto_ptr<te::dt::DateTime> rsTime(0);
200 
201  if(m_obst.getVlBeginTimePropIdx()>-1)
202  vlTime = m_ds->getDateTime(m_obst.getVlBeginTimePropIdx());
203 
204  if(m_obst.getRsTimePropIdx()>-1)
205  rsTime = m_ds->getDateTime(m_obst.getRsTimePropIdx());
206 
207  boost::ptr_vector<te::dt::AbstractData> obsData;
208  for(std::size_t i = 0; i<m_obst.getObsPropIdxs().size(); ++i)
209  obsData.push_back(m_ds->getValue(m_obst.getObsPropIdxs()[i]));
210 
211  return std::auto_ptr<te::st::Observation>(new
212  Observation(phTime.release(),static_cast<te::dt::DateTimeInstant*>(rsTime.release()),
213  static_cast<te::dt::DateTimePeriod*>(vlTime.release()),obsData));
214 }
215 
217 {
218 }
219 
220 
221 
A class to represent an observation.
Definition: Observation.h:58
std::auto_ptr< Observation > getObservation() const
It returns the observation pointed by the internal cursor.
void setSpatialExtent(const te::gm::Envelope &ext)
It sets the spatial extent of the observations, when there is an observed value of geometry type...
An abstract class to represent a period of date and time.
te::da::DataSet * getData() const
It returns the DataSet that contains the observations.
This file contains a class to represent an observation data set.
void setTemporalExtent(te::dt::DateTimePeriod *ext)
It sets the temporal extent of the observations, when there is an observed value of geometry type...
te::dt::DateTimePeriod * getTemporalExtent()
It returns the temporal extent of the observations.
An abstract class to represent an instant of date and time.
ObservationDataSet(te::da::DataSet *ds, const ObservationDataSetType &obst)
Constructor.
A class that contains complemental DataSetType information about a DataSet that holds observations...
virtual ~ObservationDataSet()
It returns the property of the phenomenon beginning time.
const te::gm::Envelope & getSpatialExtent()
It returns the spatial extent of the observations, when there is an observed value of geometry type...
const ObservationDataSetType & getType() const
It returns a reference to the ObservationDataSetType.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111