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  const std::string& dsName)
40  : m_dsName(dsName),
41 
42  m_idPropIndex(-1),
43  m_idPropName(""),
44  m_id("")
45 
46 {
47 }
48 
50 {
51  *this = obs;
52 }
53 
56 {
57  if(this == &rhs)
58  return *this;
59 
60  m_dsName = rhs.m_dsName;
61 
62  m_phTimePropInfo.clear();
63  for(unsigned int i = 0; i<rhs.m_phTimePropInfo.size(); ++i)
64  {
66  m_phTimePropInfo.push_back(prop);
67  }
68 
69  m_phTime.reset();
70  if(rhs.m_phTime.get()!=nullptr)
71  m_phTime.reset(dynamic_cast<te::dt::DateTime*>(rhs.m_phTime->clone()));
72 
73  m_validTimePropInfo.clear();
74  for(unsigned int i = 0; i<rhs.m_validTimePropInfo.size(); ++i)
75  {
77  m_validTimePropInfo.push_back(prop);
78  }
79 
80  m_validTime.reset();
81  if(rhs.m_validTime.get()!=nullptr)
82  m_validTime.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_validTime->clone()));
83 
84  m_resultTimePropInfo.reset();
85  if(rhs.m_resultTimePropInfo.get()!=nullptr)
86  {
88  m_resultTimePropInfo.reset(propAux);
89  }
90 
91  m_resultTime.reset();
92  if(rhs.m_resultTime.get()!=nullptr)
93  m_resultTime.reset(dynamic_cast<te::dt::DateTimeInstant*>(rhs.m_resultTime->clone()));
94 
97 
98  m_geomPropInfo.reset();
99  if(rhs.m_geomPropInfo.get()!=nullptr)
100  {
102  m_geomPropInfo.reset(prop);
103  }
104 
105  m_geom.reset();
106  if(rhs.m_geom.get()!=nullptr)
107  m_geom.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_geom.get()->clone()));
108 
111  m_id = rhs.m_id;
112 
113  m_spatialExtent.reset();
114  if(rhs.m_spatialExtent.get()!=nullptr)
115  m_spatialExtent.reset(dynamic_cast<te::gm::Geometry*>(rhs.m_spatialExtent.get()->clone()));
116 
117  m_temporalExtent.reset();
118  if(rhs.m_temporalExtent.get()!=nullptr)
119  m_temporalExtent.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_temporalExtent.get()->clone()));
120 
121  return *this;
122 }
123 
124 void te::st::ObservationDataSetType::setDataSetName(const std::string& dsName)
125 {
126  m_dsName = dsName;
127 }
128 
130 {
131  m_phTimePropInfo.clear();
132  m_phTimePropInfo.push_back(tpInfo);
133 }
134 
136  te::dt::DateTimeProperty* tpInfo2)
137 {
138  m_phTimePropInfo.clear();
139  m_phTimePropInfo.push_back(tpInfo1);
140  m_phTimePropInfo.push_back(tpInfo2);
141 }
142 
144 {
145  m_phTime.reset(t);
146 }
147 
149 {
150  m_validTimePropInfo.clear();
151  m_validTimePropInfo.push_back(tpInfo);
152 }
153 
155  te::dt::DateTimeProperty* tpInfo2)
156 {
157  m_validTimePropInfo.clear();
158  m_validTimePropInfo.push_back(tpInfo1);
159  m_validTimePropInfo.push_back(tpInfo2);
160 }
161 
163 {
164  m_validTime.reset(t);
165 }
166 
168 {
169  m_resultTimePropInfo.reset(tpInfo);
170 }
171 
173 {
174  m_resultTime.reset(t);
175 }
176 
177 void te::st::ObservationDataSetType::setObsPropInfo(const std::vector<int>& props)
178 {
179  m_observedPropIdx = props;
180 }
181 
182 void te::st::ObservationDataSetType::setObsPropInfo(const std::vector<std::string>& props)
183 {
184  m_observedPropName = props;
185 }
186 
188 {
189  m_geomPropInfo.reset(prop);
190 }
191 
193 {
194  m_geom.reset(geom);
195 }
196 
198 {
199  m_idPropIndex = idProp;
200 }
201 
202 void te::st::ObservationDataSetType::setIdPropInfo(const std::string& idProp)
203 {
204  m_idPropName = idProp;
205 }
206 
207 void te::st::ObservationDataSetType::setId(const std::string& id)
208 {
209  m_id = id;
210 }
211 
213 {
214  m_spatialExtent.reset(se);
215 }
216 
218 {
219  m_temporalExtent.reset(te);
220 }
221 
223 {
224  return m_phTimePropInfo.size()>0;
225 }
226 
228 {
229  return m_phTimePropInfo.size()==2;
230 }
231 
233 {
234  return m_phTime.get()!=nullptr;
235 }
236 
238 {
239  return m_validTimePropInfo.size()>0;
240 }
241 
243 {
244  return m_validTimePropInfo.size()==2;
245 }
246 
248 {
249  return m_validTime.get()!=nullptr;
250 }
251 
253 {
254  return m_resultTimePropInfo.get()!=nullptr;
255 }
256 
258 {
259  return m_resultTime.get()!=nullptr;
260 }
261 
263 {
264  return m_geomPropInfo.get()!=nullptr;
265 }
266 
268 {
269  return m_geom.get()!=nullptr;
270 }
271 
273 {
274  if(m_idPropIndex >= 0 || !m_idPropName.empty())
275  return true;
276  return false;
277 }
278 
280 {
281  return !m_id.empty();
282 }
283 
285 {
286  return (m_spatialExtent.get()!=nullptr);
287 }
288 
290 {
291  return (m_temporalExtent.get()!=nullptr);
292 }
293 
294 std::string
296 {
297  return m_dsName;
298 }
299 
302 {
303  if(hasTimeProp())
304  return &m_phTimePropInfo[0];
305  return nullptr;
306 }
307 
310 {
311  if(hasTwoTimeProp())
312  return &m_phTimePropInfo[1];
313  return nullptr;
314 }
315 
316 const te::dt::DateTime*
318 {
319  return m_phTime.get();
320 }
321 
324 {
325  if(hasVlTimeProp())
326  return &m_validTimePropInfo[0];
327  return nullptr;
328 }
329 
332 {
333  if(hasTwoVlTimeProp())
334  return &m_validTimePropInfo[1];
335  return nullptr;
336 }
337 
340 {
341  return m_validTime.get();
342 }
343 
346 {
347  return m_resultTimePropInfo.get();
348 }
349 
352 {
353  return m_resultTime.get();
354 }
355 
356 const std::vector<int>&
358 {
359  return m_observedPropIdx;
360 }
361 
362 const std::vector<std::string>&
364 {
365  return m_observedPropName;
366 }
367 
370 {
371  return m_geomPropInfo.get();
372 }
373 
374 const te::gm::Geometry*
376 {
377  return m_geom.get();
378 }
379 
381 {
382  return m_idPropIndex;
383 }
384 
386 {
387  return m_idPropName;
388 }
389 
391 {
392  return m_id;
393 }
394 
395  const te::dt::DateTimePeriod*
397  {
398  if(hasTemporalExtent())
399  return m_temporalExtent.get();
400  return nullptr;
401  }
402 
403  const te::gm::Geometry*
405  {
406  if(hasSpatialExtent())
407  return m_spatialExtent.get();
408  return nullptr;
409  }
410 
411 std::string
413 {
414  if(hasTimeProp())
415  return m_phTimePropInfo[0].getName();
416  return "";
417 }
418 
419 std::string
421 {
422  if(hasTwoTimeProp())
423  return m_phTimePropInfo[1].getName();
424  return "";
425 }
426 
428 {
429  if(hasGeomProp())
430  return m_geomPropInfo->getName();
431  return "";
432 }
433 
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.
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.
std::unique_ptr< te::gm::Geometry > m_geom
Geometry: the geometry, when the spatial location of the observations are not in the DataSet...
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.
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.
void setTimePropInfo(te::dt::DateTimeProperty *tpInfo)
It sets the property info that contains the phenomenon beginning time.
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.
std::unique_ptr< te::gm::Geometry > m_spatialExtent
Spatial extent.
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.
std::unique_ptr< te::dt::DateTimePeriod > m_validTime
Valid time: the valid time, when the time is not inside a DataSet.
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.
URI C++ Library.
Definition: Attributes.h:37
boost::ptr_vector< te::dt::DateTimeProperty > m_phTimePropInfo
Phenomenon time: information about the DataSet properties that contain the phenomenon time...
std::unique_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.
ObservationDataSetType(const std::string &dsName)
Constructor.
std::unique_ptr< te::dt::DateTimePeriod > m_temporalExtent
Temporal extent.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
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::unique_ptr< te::gm::GeometryProperty > m_geomPropInfo
Geometry: information about the property that has the observation spatial location.
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.
std::unique_ptr< te::dt::DateTime > m_phTime
Phenomenon time: the phenomenon time, when the time is not inside a DataSet.
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.
An abstract class to represent an instant of date and time.
std::unique_ptr< te::dt::DateTimeInstant > m_resultTime
Result time: the result time, when the time is not inside a DataSet.
const te::gm::GeometryProperty * getGeomPropInfo() const
It returns the DataSet property information that contains the geometry.