All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObservationDataSetInfo.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 ObservationDataSetInfo.cpp
22 
23  \brief This file contains a class called ObservationDataSetInfo
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 "ObservationDataSetInfo.h"
37 
39  const std::string& dsName)
40  : m_dsInfo(dsInfo),
41  m_dsName(dsName),
42  m_phTimePropInfo(),
43  m_phTime(),
44  m_validTimePropInfo(),
45  m_validTime(),
46  m_resultTimePropInfo(),
47  m_resultTime(),
48  m_observedPropIdx(),
49  m_observedPropName(),
50  m_geomPropInfo(),
51  m_geom(),
52  m_idPropIndex(-1),
53  m_idPropName(""),
54  m_id(""),
55  m_spatialExtent(),
56  m_temporalExtent()
57 {
58 }
59 
61 {
62  *this = obs;
63 }
64 
67 {
68  if(this == &rhs)
69  return *this;
70 
71  m_dsInfo = rhs.m_dsInfo;
72  m_dsName = rhs.m_dsName;
73 
74  m_phTimePropInfo.clear();
75  for(unsigned int i = 0; i<rhs.m_phTimePropInfo.size(); ++i)
76  {
78  m_phTimePropInfo.push_back(prop);
79  }
80 
81  m_phTime.reset();
82  if(rhs.m_phTime.get()!=0)
83  m_phTime.reset(dynamic_cast<te::dt::DateTime*>(rhs.m_phTime->clone()));
84 
85  m_validTimePropInfo.clear();
86  for(unsigned int i = 0; i<rhs.m_validTimePropInfo.size(); ++i)
87  {
89  m_validTimePropInfo.push_back(prop);
90  }
91 
92  m_validTime.reset();
93  if(rhs.m_validTime.get()!=0)
94  m_validTime.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_validTime->clone()));
95 
96  m_resultTimePropInfo.reset();
97  if(rhs.m_resultTimePropInfo.get()!=0)
98  {
100  m_resultTimePropInfo.reset(propAux);
101  }
102 
103  m_resultTime.reset();
104  if(rhs.m_resultTime.get()!=0)
105  m_resultTime.reset(dynamic_cast<te::dt::DateTimeInstant*>(rhs.m_resultTime->clone()));
106 
107  m_observedPropIdx = rhs.m_observedPropIdx;
108  m_observedPropName = rhs.m_observedPropName;
109 
110  m_geomPropInfo.reset();
111  if(rhs.m_geomPropInfo.get()!=0)
112  {
114  m_geomPropInfo.reset(prop);
115  }
116 
117  m_geom.reset();
118  if(rhs.m_geom.get()!=0)
119  m_geom.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_geom.get()->clone()));
120 
121  m_idPropIndex = rhs.m_idPropIndex;
122  m_idPropName = rhs.m_idPropName;
123  m_id = rhs.m_id;
124 
125  m_spatialExtent.reset();
126  if(rhs.m_spatialExtent.get()!=0)
127  m_spatialExtent.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_spatialExtent.get()->clone()));
128 
129  m_temporalExtent.reset();
130  if(rhs.m_temporalExtent.get()!=0)
131  m_temporalExtent.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_temporalExtent.get()->clone()));
132 
133  return *this;
134 }
135 
137  const std::string& dsName)
138 {
139  m_dsInfo = dsInfo;
140  m_dsName = dsName;
141 }
142 
144 {
145  m_phTimePropInfo.clear();
146  m_phTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo));
147 }
148 
150  te::dt::DateTimeProperty* tpInfo2)
151 {
152  m_phTimePropInfo.clear();
153  m_phTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo1));
154  m_phTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo2));
155 }
156 
158 {
159  m_phTime.reset(t);
160 }
161 
163 {
164  m_validTimePropInfo.clear();
165  m_validTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo));
166 }
167 
169  te::dt::DateTimeProperty* tpInfo2)
170 {
171  m_validTimePropInfo.clear();
172  m_validTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo1));
173  m_validTimePropInfo.push_back(std::auto_ptr<te::dt::DateTimeProperty>(tpInfo2));
174 }
175 
177 {
178  m_validTime.reset(t);
179 }
180 
182 {
183  m_resultTimePropInfo.reset(tpInfo);
184 }
185 
187 {
188  m_resultTime.reset(t);
189 }
190 
191 void te::st::ObservationDataSetInfo::setObsPropInfo(const std::vector<int>& props)
192 {
193  m_observedPropIdx = props;
194 }
195 
196 void te::st::ObservationDataSetInfo::setObsPropInfo(const std::vector<std::string>& props)
197 {
198  m_observedPropName = props;
199 }
200 
202 {
203  m_geomPropInfo.reset(prop);
204 }
205 
207 {
208  m_geom.reset(geom);
209 }
210 
212 {
213  m_idPropIndex = idProp;
214 }
215 
216 void te::st::ObservationDataSetInfo::setIdPropInfo(const std::string& idProp)
217 {
218  m_idPropName = idProp;
219 }
220 
221 void te::st::ObservationDataSetInfo::setId(const std::string& id)
222 {
223  m_id = id;
224 }
225 
227 {
228  m_spatialExtent.reset(se);
229 }
230 
232 {
233  m_temporalExtent.reset(te);
234 }
235 
237 {
238  return m_phTimePropInfo.size()>0;
239 }
240 
242 {
243  return m_phTimePropInfo.size()==2;
244 }
245 
247 {
248  return m_phTime.get()!=0;
249 }
250 
252 {
253  return m_validTimePropInfo.size()>0;
254 }
255 
257 {
258  return m_validTimePropInfo.size()==2;
259 }
260 
262 {
263  return m_validTime.get()!=0;
264 }
265 
267 {
268  return m_resultTimePropInfo.get()!=0;
269 }
270 
272 {
273  return m_resultTime.get()!=0;
274 }
275 
277 {
278  return m_geomPropInfo.get()!=0;
279 }
280 
282 {
283  return m_geom.get()!=0;
284 }
285 
287 {
288  if(m_idPropIndex >= 0 || !m_idPropName.empty())
289  return true;
290  return false;
291 }
292 
294 {
295  return !m_id.empty();
296 }
297 
299 {
300  return (m_spatialExtent.get()!=0);
301 }
302 
304 {
305  return (m_temporalExtent.get()!=0);
306 }
307 
310 {
311  return m_dsInfo;
312 }
313 
314 std::string
316 {
317  return m_dsName;
318 }
319 
322 {
323  if(hasTimeProp())
324  return &m_phTimePropInfo[0];
325  return 0;
326 }
327 
330 {
331  if(hasTwoTimeProp())
332  return &m_phTimePropInfo[1];
333  return 0;
334 }
335 
336 const te::dt::DateTime*
338 {
339  return m_phTime.get();
340 }
341 
344 {
345  if(hasVlTimeProp())
346  return &m_validTimePropInfo[0];
347  return 0;
348 }
349 
352 {
353  if(hasTwoVlTimeProp())
354  return &m_validTimePropInfo[1];
355  return 0;
356 }
357 
360 {
361  return m_validTime.get();
362 }
363 
366 {
367  return m_resultTimePropInfo.get();
368 }
369 
372 {
373  return m_resultTime.get();
374 }
375 
376 const std::vector<int>&
378 {
379  return m_observedPropIdx;
380 }
381 
382 const std::vector<std::string>&
384 {
385  return m_observedPropName;
386 }
387 
390 {
391  return m_geomPropInfo.get();
392 }
393 
394 const te::gm::Geometry*
396 {
397  return m_geom.get();
398 }
399 
401 {
402  return m_idPropIndex;
403 }
404 
406 {
407  return m_idPropName;
408 }
409 
411 {
412  return m_id;
413 }
414 
415 /*
416 int te::st::ObservationDataSetInfo::getBeginTimePropIdx() const
417 {
418  if(hasTimeProp())
419  return m_phTimePropInfo[0].getId();
420  return -1;
421 }
422 */
423 
424 std::string
426 {
427  if(hasTimeProp())
428  return m_phTimePropInfo[0].getName();
429  return "";
430 }
431 
432 /*
433 int te::st::ObservationDataSetInfo::getEndTimePropIdx() const
434 {
435  if(hasTwoTimeProp())
436  return m_phTimePropInfo[1].getId();
437  return -1;
438 }
439 */
440 
441 std::string
443 {
444  if(hasTwoTimeProp())
445  return m_phTimePropInfo[1].getName();
446  return "";
447 }
448 
449 /*
450 int te::st::ObservationDataSetInfo::getGeomPropIdx() const
451 {
452  if(hasGeomProp())
453  return m_geomPropInfo->getId();
454  return -1;
455 }
456 */
457 
459 {
460  if(hasGeomProp())
461  return m_geomPropInfo->getName();
462  return "";
463 }
464 
467  {
468  if(hasTemporalExtent())
469  return m_temporalExtent.get();
470  return 0;
471  }
472 
473  const te::gm::Geometry*
475  {
476  if(hasSpatialExtent())
477  return m_spatialExtent.get();
478  return 0;
479  }
480 
482 {
483  return te::common::Convert2UCase(m_dsInfo.getId()+"&"+m_dsName);
484 }
485 
487 {
488 }
void setSpatialExtent(te::gm::Geometry *se)
It sets the spatial extent of all observations.
void setRsTime(te::dt::DateTimeInstant *t)
It sets the result time associated to all observations.
Geometric property.
std::string getBeginTimePropName() const
It returns the name of the DataSet property that contains the phenomenon beginning time...
void setVlTime(te::dt::DateTimePeriod *t)
It sets the valid time associated to all observations.
boost::ptr_vector< te::dt::DateTimeProperty > m_validTimePropInfo
Valid time: information about the DataSet properties that contain the valid time. ...
const te::dt::DateTime * getTime() const
It returns the phenomenon time.
This file contains a class called ObservationDataSetInfo.
std::string getObsId() const
It returns the identifier associated to all observations.
const te::dt::DateTimeInstant * getRsTime() const
It returns the result time.
A class that contains infos about a DataSet that contains observations.
const te::gm::Geometry * getSpatialExtent() const
It returns the spatial extent of the observations.
const std::vector< int > & getObsPropIdxs() const
It returns the indexes of the DataSet properties that are observed over time.
std::string getGeomPropName() const
It returns the name of the property that is a geometry property.
te::da::DataSourceInfo m_dsInfo
Information about the DataSource from which the DataSet come.
std::auto_ptr< te::dt::DateTimeProperty > m_resultTimePropInfo
Result time: information about the DataSet property that contains the result time.
const te::dt::DateTimePeriod * getVlTime() const
It returns the valid time.
std::string m_dsName
The DataSet name.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:163
std::auto_ptr< te::dt::DateTimePeriod > m_validTime
Valid time: the valid time, when the time is not inside a DataSet.
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::gm::Geometry > m_spatialExtent
Spatial extent.
void setDataSourceInfo(const te::da::DataSourceInfo &dsinfo, const std::string &dsName)
It sets the information about the DataSource and the DataSet name that contains the observations...
void setTime(te::dt::DateTime *t)
It sets the phenomenon time associated to all observations.
const te::gm::GeometryProperty * getGeomPropInfo() const
It returns the DataSet property information that contains the geometry.
const te::gm::Geometry * getGeometry() const
It returns the geometry associated to all observations.
void setVlTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the valid time.
std::auto_ptr< te::gm::GeometryProperty > m_geomPropInfo
Geometry: information about the property that has the observation spatial location.
std::vector< std::string > m_observedPropName
Observed properties: the names of DataSet properties that are observed.
const std::vector< std::string > & getObsPropNames() const
It returns the names of the DataSet properties that are observed over time.
void setIdPropInfo(int idProp)
It sets the index of the DataSet property that contains identifiers that groups the observations...
const te::dt::DateTimeProperty * getVlEndTimePropInfo() const
It returns the DataSet property information that contains the valid end time.
void setGeometry(te::gm::Geometry *geom)
It sets the geometry associated to all observations.
const te::dt::DateTimeProperty * getBeginTimePropInfo() const
It returns the DataSet property information that contains the phenomenon beginning time...
const te::da::DataSourceInfo & getDataSourceInfo() const
It returns the information about the DataSource.
void setId(const std::string &id)
It sets the identifier associated to all observations.
void setRsTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the result time.
std::string m_idPropName
Id: the name of DataSet property that contain the id of each group of observation.
const te::dt::DateTimeProperty * getVlBeginTimePropInfo() const
It returns the DataSet property information that contains the valid beginning time.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
std::string getDSId() const
It returns an id (as a string) that identifies the DataSet.
const te::dt::DateTimePeriod * getTemporalExtent() const
It returns the temporal extent of the observations.
void setTemporalExtent(te::dt::DateTimePeriod *te)
It sets the temporal extent of all observations.
std::vector< int > m_observedPropIdx
Observed properties: the indexes of DataSet properties that are observed.
const te::dt::DateTimeProperty * getEndTimePropInfo() const
It returns the DataSet property information that contains the phenomenon end time.
virtual ~ObservationDataSetInfo()
Virtual destructor.
int getIdPropIdx() const
It returns the index of the property that contains identifiers that groups observations.
const te::dt::DateTimeProperty * getRsTimePropInfo() const
It returns the DataSet property information that contains the result time.
void setTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the phenomenon time.
An abstract class to represent a period of date and time.
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.
std::string m_id
Id: the id associated to all observations.
A class that represents a data source component.
std::string getDataSetName() const
It returns the DataSet name.
std::auto_ptr< te::dt::DateTimeInstant > m_resultTime
Result time: the result time, when the time is not inside a DataSet.
std::auto_ptr< te::dt::DateTimePeriod > m_temporalExtent
Temporal extent.
std::string getEndTimePropName() const
It returns the name of the DataSet property that contains the phenomenon end time.
void setGeomPropInfo(te::gm::GeometryProperty *prop)
It sets the info about the property that contains the observation location.
void setObsPropInfo(const std::vector< int > &props)
It sets the indexes of the DataSet properties that are observed over time.
std::string getIdPropName() const
It returns the name of the property that contains identifiers that groups observations.
std::auto_ptr< te::dt::DateTime > m_phTime
Phenomenon time: the phenomenon time, when the time is not inside a DataSet.
int m_idPropIndex
Id: the index of DataSet property that contain the id of each group of observation.
ObservationDataSetInfo(const te::da::DataSourceInfo &dsInfo, const std::string &dsName)
Constructor.
An abstract class to represent an instant of date and time.
boost::ptr_vector< te::dt::DateTimeProperty > m_phTimePropInfo
Phenomenon time: information about the DataSet properties that contain the phenomenon time...
const ObservationDataSetInfo & operator=(const ObservationDataSetInfo &rhs)
Assignment operator.