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) 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 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 "../../../dataaccess/utils/Utils.h"
30 #include "../../../datatype/DateTime.h"
31 #include "../../../datatype/DateTimePeriod.h"
32 #include "../../../datatype/DateTimeInstant.h"
33 #include "../../../datatype/DateTimeProperty.h"
34 #include "../../../geometry/Utils.h"
35 #include "../../../geometry/GeometryProperty.h"
36 
37 //ST
38 #include "ObservationDataSet.h"
39 #include "Observation.h"
40 
42  : m_ds(ds),
43  m_obst(obst)
44 {
45 }
46 
49  : m_ds(ds),
50  m_obst(obst)
51 {
53 }
54 
57  : m_ds(ds),
58  m_obst(obst)
59 {
62 }
63 
65 {
66  return m_ds.get();
67 }
68 
69 std::auto_ptr<te::da::DataSet> te::st::ObservationDataSet::release()
70 {
71  std::auto_ptr<te::da::DataSet> result(m_ds.release());
72  return result;
73 }
74 
76 {
77  return m_obst;
78 }
79 
81 {
82  if(m_obst.hasSpatialExtent())
83  return m_obst.getSpatialExtent();
84 
85  std::size_t idx = te::da::GetPropertyPos(m_ds.get(), m_obst.getGeomPropName());
86  std::auto_ptr<te::gm::Envelope> env(m_ds->getExtent(idx));
87  m_obst.setSpatialExtent(te::gm::GetGeomFromEnvelope(env.get(), -1));
88  return m_obst.getSpatialExtent();
89 }
90 
92 {
93  m_obst.setSpatialExtent(ext);
94 }
95 
97 {
98  return m_obst.getTemporalExtent();
99 }
100 
102 {
103  m_obst.setTemporalExtent(ext);
104 }
105 
107 {
108  return m_ds->moveNext();
109 }
110 
112 {
113  return m_ds->movePrevious();
114 }
115 
117 {
118  return m_ds->moveFirst();
119 }
120 
122 {
123  return m_ds->moveBeforeFirst();
124 }
125 
127 {
128  return m_ds->moveLast();
129 }
130 
132 {
133  return m_ds->isAtBegin();
134 }
135 
137 {
138  return m_ds->isBeforeBegin();
139 }
140 
142 {
143  return m_ds->isAtEnd();
144 }
145 
147 {
148  return m_ds->isAfterEnd();
149 }
150 
151 std::auto_ptr<te::st::Observation> te::st::ObservationDataSet::getObservation() const
152 {
153  std::auto_ptr<te::dt::DateTime> phTime(m_ds->getDateTime(m_obst.getBeginTimePropName()));
154  std::auto_ptr<te::dt::DateTime> vlTime(0);
155  std::auto_ptr<te::dt::DateTime> rsTime(0);
156 
157  if(m_obst.hasVlTimeProp())
158  vlTime = m_ds->getDateTime(m_obst.getVlBeginTimePropInfo()->getName());
159 
160  if(m_obst.hasRsTimeProp())
161  rsTime = m_ds->getDateTime(m_obst.getRsTimePropInfo()->getName());
162 
163  boost::ptr_vector<te::dt::AbstractData> obsData;
164  for(std::size_t i = 0; i<m_obst.getObsPropNames().size(); ++i)
165  obsData.push_back(m_ds->getValue(m_obst.getObsPropNames()[i]));
166 
167  return std::auto_ptr<te::st::Observation>(new
168  Observation(phTime.release(),
169  static_cast<te::dt::DateTimeInstant*>(rsTime.release()),
170  static_cast<te::dt::DateTimePeriod*>(vlTime.release()),
171  0, obsData));
172 }
173 
176 {
177  return m_obst.getBeginTimePropInfo();
178 }
179 
182 {
183  return m_obst.getEndTimePropInfo();
184 }
185 
188 {
189  return m_obst.getVlBeginTimePropInfo();
190 }
191 
194 {
195  return m_obst.getVlEndTimePropInfo();
196 }
197 
200 {
201  return m_obst.getRsTimePropInfo();
202 }
203 
205 {
206 }
207 
208 
209 
std::auto_ptr< Observation > getObservation() const
It returns the observation pointed by the internal cursor.
const te::dt::DateTimeProperty * getBeginTimeProperty() const
It returns the property of the phenomenon beginning time.
A class to represent an observation.
Definition: Observation.h:60
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
Definition: Utils.cpp:500
ObservationDataSetType m_obst
A data set that contains observations.
const te::dt::DateTimeProperty * getVlEndTimeProperty() const
It returns the property of the valid end time.
const te::dt::DateTimeProperty * getRsTimeProperty() const
It returns the property of the result time.
const te::dt::DateTimeProperty * getVlBeginTimeProperty() const
It returns the property of the valid beginning time.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
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...
void setSpatialExtent(te::gm::Geometry *se)
It sets the spatial extent of all observations.
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.
const te::gm::Geometry * getSpatialExtent()
It returns 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.
void setSpatialExtent(te::gm::Geometry *ext)
It sets the spatial extent of the observations, when there is an observed value of geometry type...
void setTemporalExtent(te::dt::DateTimePeriod *te)
It sets the temporal extent of all observations.
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
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...
const te::dt::DateTimePeriod * getTemporalExtent()
It returns the temporal extent of the observations.
virtual ~ObservationDataSet()
Virtual destructor.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
Definition: Utils.cpp:38
const te::dt::DateTimeProperty * getEndTimeProperty() const
It returns the property of the phenomenon end time.
An abstract class to represent an instant of date and time.