All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObservationDataSetType.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 ObservationDataSetType.cpp
22 
23  \brief This file contains a class called ObservationDataSetType
24 */
25 
26 //TerraLib
27 #include "../../../common/StringUtils.h"
28 #include "../../../geometry/Geometry.h"
29 #include "../../../geometry/GeometryProperty.h"
30 #include "../../../datatype/DateTimeProperty.h"
31 #include "../../../datatype/DateTime.h"
32 #include "../../../datatype/DateTimeInstant.h"
33 #include "../../../datatype/DateTimePeriod.h"
34 
35 //ST
36 #include "ObservationDataSetType.h"
37 
39  : m_dsName(dsName),
40  m_phTimePropInfo(),
41  m_phTime(),
42  m_validTimePropInfo(),
43  m_validTime(),
44  m_resultTimePropInfo(),
45  m_resultTime(),
46  m_observedPropIdx(),
47  m_observedPropName(),
48  m_geomPropInfo(),
49  m_geom(),
50  m_idPropIndex(-1),
51  m_idPropName(""),
52  m_id(""),
53  m_spatialExtent(),
54  m_temporalExtent()
55 {
56 }
57 
59 {
60  *this = obs;
61 }
62 
65 {
66  if(this == &rhs)
67  return *this;
68 
69  m_dsName = rhs.m_dsName;
70 
71  m_phTimePropInfo.clear();
72  for(unsigned int i = 0; i<rhs.m_phTimePropInfo.size(); ++i)
73  {
75  m_phTimePropInfo.push_back(prop);
76  }
77 
78  m_phTime.reset();
79  if(rhs.m_phTime.get()!=0)
80  m_phTime.reset(dynamic_cast<te::dt::DateTime*>(rhs.m_phTime->clone()));
81 
82  m_validTimePropInfo.clear();
83  for(unsigned int i = 0; i<rhs.m_validTimePropInfo.size(); ++i)
84  {
86  m_validTimePropInfo.push_back(prop);
87  }
88 
89  m_validTime.reset();
90  if(rhs.m_validTime.get()!=0)
91  m_validTime.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_validTime->clone()));
92 
93  m_resultTimePropInfo.reset();
94  if(rhs.m_resultTimePropInfo.get()!=0)
95  {
97  m_resultTimePropInfo.reset(propAux);
98  }
99 
100  m_resultTime.reset();
101  if(rhs.m_resultTime.get()!=0)
102  m_resultTime.reset(dynamic_cast<te::dt::DateTimeInstant*>(rhs.m_resultTime->clone()));
103 
104  m_observedPropIdx = rhs.m_observedPropIdx;
105  m_observedPropName = rhs.m_observedPropName;
106 
107  m_geomPropInfo.reset();
108  if(rhs.m_geomPropInfo.get()!=0)
109  {
111  m_geomPropInfo.reset(prop);
112  }
113 
114  m_geom.reset();
115  if(rhs.m_geom.get()!=0)
116  m_geom.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_geom.get()->clone()));
117 
118  m_idPropIndex = rhs.m_idPropIndex;
119  m_idPropName = rhs.m_idPropName;
120  m_id = rhs.m_id;
121 
122  m_spatialExtent.reset();
123  if(rhs.m_spatialExtent.get()!=0)
124  m_spatialExtent.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_spatialExtent.get()->clone()));
125 
126  m_temporalExtent.reset();
127  if(rhs.m_temporalExtent.get()!=0)
128  m_temporalExtent.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_temporalExtent.get()->clone()));
129 
130  return *this;
131 }
132 
133 void te::st::ObservationDataSetType::setDataSetName(const std::string& dsName)
134 {
135  m_dsName = dsName;
136 }
137 
139 {
140  m_phTimePropInfo.clear();
141  m_phTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo));
142 }
143 
145  te::dt::DateTimeProperty* tpInfo2)
146 {
147  m_phTimePropInfo.clear();
148  m_phTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo1));
149  m_phTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo2));
150 }
151 
153 {
154  m_phTime.reset(t);
155 }
156 
158 {
159  m_validTimePropInfo.clear();
160  m_validTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo));
161 }
162 
164  te::dt::DateTimeProperty* tpInfo2)
165 {
166  m_validTimePropInfo.clear();
167  m_validTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo1));
168  m_validTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo2));
169 }
170 
172 {
173  m_validTime.reset(t);
174 }
175 
177 {
178  m_resultTimePropInfo.reset(tpInfo);
179 }
180 
182 {
183  m_resultTime.reset(t);
184 }
185 
186 void te::st::ObservationDataSetType::setObsPropInfo(const std::vector<int>& props)
187 {
188  m_observedPropIdx = props;
189 }
190 
191 void te::st::ObservationDataSetType::setObsPropInfo(const std::vector<std::string>& props)
192 {
193  m_observedPropName = props;
194 }
195 
197 {
198  m_geomPropInfo.reset(prop);
199 }
200 
202 {
203  m_geom.reset(geom);
204 }
205 
207 {
208  m_idPropIndex = idProp;
209 }
210 
211 void te::st::ObservationDataSetType::setIdPropInfo(const std::string& idProp)
212 {
213  m_idPropName = idProp;
214 }
215 
216 void te::st::ObservationDataSetType::setId(const std::string& id)
217 {
218  m_id = id;
219 }
220 
222 {
223  m_spatialExtent.reset(se);
224 }
225 
227 {
228  m_temporalExtent.reset(te);
229 }
230 
232 {
233  return m_phTimePropInfo.size()>0;
234 }
235 
237 {
238  return m_phTimePropInfo.size()==2;
239 }
240 
242 {
243  return m_phTime.get()!=0;
244 }
245 
247 {
248  return m_validTimePropInfo.size()>0;
249 }
250 
252 {
253  return m_validTimePropInfo.size()==2;
254 }
255 
257 {
258  return m_validTime.get()!=0;
259 }
260 
262 {
263  return m_resultTimePropInfo.get()!=0;
264 }
265 
267 {
268  return m_resultTime.get()!=0;
269 }
270 
272 {
273  return m_geomPropInfo.get()!=0;
274 }
275 
277 {
278  return m_geom.get()!=0;
279 }
280 
282 {
283  if(m_idPropIndex >= 0 || !m_idPropName.empty())
284  return true;
285  return false;
286 }
287 
289 {
290  return !m_id.empty();
291 }
292 
294 {
295  return (m_spatialExtent.get()!=0);
296 }
297 
299 {
300  return (m_temporalExtent.get()!=0);
301 }
302 
303 std::string
305 {
306  return m_dsName;
307 }
308 
311 {
312  if(hasTimeProp())
313  return &m_phTimePropInfo[0];
314  return 0;
315 }
316 
319 {
320  if(hasTwoTimeProp())
321  return &m_phTimePropInfo[1];
322  return 0;
323 }
324 
325 const te::dt::DateTime*
327 {
328  return m_phTime.get();
329 }
330 
333 {
334  if(hasVlTimeProp())
335  return &m_validTimePropInfo[0];
336  return 0;
337 }
338 
341 {
342  if(hasTwoVlTimeProp())
343  return &m_validTimePropInfo[1];
344  return 0;
345 }
346 
349 {
350  return m_validTime.get();
351 }
352 
355 {
356  return m_resultTimePropInfo.get();
357 }
358 
361 {
362  return m_resultTime.get();
363 }
364 
365 const std::vector<int>&
367 {
368  return m_observedPropIdx;
369 }
370 
371 const std::vector<std::string>&
373 {
374  return m_observedPropName;
375 }
376 
379 {
380  return m_geomPropInfo.get();
381 }
382 
383 const te::gm::Geometry*
385 {
386  return m_geom.get();
387 }
388 
390 {
391  return m_idPropIndex;
392 }
393 
395 {
396  return m_idPropName;
397 }
398 
400 {
401  return m_id;
402 }
403 
404  const te::dt::DateTimePeriod*
406  {
407  if(hasTemporalExtent())
408  return m_temporalExtent.get();
409  return 0;
410  }
411 
412  const te::gm::Geometry*
414  {
415  if(hasSpatialExtent())
416  return m_spatialExtent.get();
417  return 0;
418  }
419 
420 std::string
422 {
423  if(hasTimeProp())
424  return m_phTimePropInfo[0].getName();
425  return "";
426 }
427 
428 std::string
430 {
431  if(hasTwoTimeProp())
432  return m_phTimePropInfo[1].getName();
433  return "";
434 }
435 
437 {
438  if(hasGeomProp())
439  return m_geomPropInfo->getName();
440  return "";
441 }
442 
443 
445 {
446 }
447 
Geometric property.
boost::ptr_vector< te::dt::DateTimeProperty > m_validTimePropInfo
Valid time: information about the DataSet properties that contain the valid time. ...
std::string m_dsName
The DataSet name.
const te::dt::DateTimePeriod * getTemporalExtent() const
It returns the temporal extent of the observations.
const te::dt::DateTimeProperty * getEndTimePropInfo() const
It returns the DataSet property information that contains the phenomenon end time.
std::string getEndTimePropName() const
It returns the name of the DataSet property that contains the phenomenon end time.
std::auto_ptr< te::gm::GeometryProperty > m_geomPropInfo
Geometry: information about the property that has the observation spatial location.
const ObservationDataSetType & operator=(const ObservationDataSetType &rhs)
Assignment operator.
void setGeometry(te::gm::Geometry *geom)
It sets the geometry associated to all observations.
std::string getBeginTimePropName() const
It returns the name of the DataSet property that contains the phenomenon beginning time...
void setTime(te::dt::DateTime *t)
It sets the phenomenon time associated to all observations.
const te::dt::DateTimeProperty * getVlEndTimePropInfo() const
It returns the DataSet property information that contains the valid end time.
void setVlTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the valid time.
std::string getObsId() const
It returns the identifier associated to all observations.
void setDataSetName(const std::string &dsName)
It sets the DataSet name that contains the observations.
std::auto_ptr< te::gm::Geometry > m_spatialExtent
Spatial extent.
void setObsPropInfo(const std::vector< int > &props)
It sets the indexes of the DataSet properties that are observed over time.
void setGeomPropInfo(te::gm::GeometryProperty *prop)
It sets the info about the property that contains the observation location.
const te::dt::DateTimeProperty * getBeginTimePropInfo() const
It returns the DataSet property information that contains the phenomenon beginning time...
const te::gm::Geometry * getSpatialExtent() const
It returns the spatial extent of the observations.
const te::dt::DateTime * getTime() const
It returns the phenomenon time.
std::auto_ptr< te::dt::DateTimePeriod > m_validTime
Valid time: the valid time, when the time is not inside a DataSet.
void setTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the phenomenon beginning time.
std::auto_ptr< te::dt::DateTimeInstant > m_resultTime
Result time: the result time, when the time is not inside a DataSet.
virtual ~ObservationDataSetType()
Virtual destructor.
const te::gm::Geometry * getGeometry() const
It returns the geometry associated to all observations.
int getIdPropIdx() const
It returns the index of the property that contains identifiers that groups observations.
This file contains a class called ObservationDataSetType.
std::string m_idPropName
Id: the name of DataSet property that contain the id of each group of observation.
void setId(const std::string &id)
It sets the identifier associated to all observations.
void setIdPropInfo(int idProp)
It sets the index of the DataSet property that contains identifiers that groups the observations...
int m_idPropIndex
Id: the index of DataSet property that contain the id of each group of observation.
std::vector< int > m_observedPropIdx
Observed properties: the indexes of DataSet properties that are observed.
void setRsTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the result time.
std::string getGeomPropName() const
It returns the name of the property that is a geometry property.
std::auto_ptr< te::dt::DateTime > m_phTime
Phenomenon time: the phenomenon time, when the time is not inside a DataSet.
boost::ptr_vector< te::dt::DateTimeProperty > m_phTimePropInfo
Phenomenon time: information about the DataSet properties that contain the phenomenon time...
const te::dt::DateTimePeriod * getVlTime() const
It returns the valid time.
ObservationDataSetType(const std::string &dsName)
Constructor.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
std::auto_ptr< te::gm::Geometry > m_geom
Geometry: the geometry, when the spatial location of the observations are not in the DataSet...
std::auto_ptr< te::dt::DateTimePeriod > m_temporalExtent
Temporal extent.
std::string getIdPropName() const
It returns the name of the property that contains identifiers that groups observations.
std::string m_id
Id: the id associated to all observations.
void setSpatialExtent(te::gm::Geometry *se)
It sets the spatial extent of all observations.
std::string getDataSetName() const
It returns the DataSet name.
std::vector< std::string > m_observedPropName
Observed properties: the names of DataSet properties that are observed.
An abstract class to represent a period of date and time.
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 setRsTime(te::dt::DateTimeInstant *t)
It sets the result time associated to all observations.
A class that contains complemental DataSetType information about a DataSet that holds observations...
const te::dt::DateTimeInstant * getRsTime() const
It returns the result time.
const std::vector< int > & getObsPropIdxs() const
It returns the indexes of the DataSet properties that are observed over time.
const te::dt::DateTimeProperty * getVlBeginTimePropInfo() const
It returns the DataSet property information that contains the valid beginning time.
void setVlTime(te::dt::DateTimePeriod *t)
It sets the valid time associated to all observations.
const std::vector< std::string > & getObsPropNames() const
It returns the names of the DataSet properties that are observed over time.
const te::dt::DateTimeProperty * getRsTimePropInfo() const
It returns the DataSet property information that contains the result time.
std::auto_ptr< te::dt::DateTimeProperty > m_resultTimePropInfo
Result time: information about the DataSet property that contains the result time.
An abstract class to represent an instant of date and time.
const te::gm::GeometryProperty * getGeomPropInfo() const
It returns the DataSet property information that contains the geometry.