All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.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 Utils.h
22 
23  \brief Utility functions for ST module.
24  */
25 
26 //TerraLib
27 #include "../geometry/Geometry.h"
28 #include "../geometry/GeometryProperty.h"
29 #include "../datatype/DateTimeProperty.h"
30 #include "../datatype/DateTime.h"
31 #include "../datatype/DateTimeInstant.h"
32 #include "../datatype/DateTimePeriod.h"
33 
34 //ST
35 #include "Utils.h"
38 
40 {
41 
43 
44  //Phenomenon time
45  if(info.hasTimeProp())
46  {
48 
49  if(info.hasTwoTimeProp())
50  {
52  result.setTimePropInfo(prop1, prop2);
53  }
54  else
55  result.setTimePropInfo(prop1);
56  }
57 
58  if(info.hasTime())
59  {
60  te::dt::DateTime* t = dynamic_cast<te::dt::DateTime*>(info.getTime()->clone());
61  result.setTime(t);
62  }
63 
64  //Valid time
65  if(info.hasVlTimeProp())
66  {
68  if(info.hasTwoVlTimeProp())
69  {
71  result.setVlTimePropInfo(prop1, prop2);
72  }
73  else
74  result.setVlTimePropInfo(prop1);
75  }
76 
77  if(info.hasVlTime())
78  {
79  te::dt::DateTimePeriod* t = dynamic_cast<te::dt::DateTimePeriod*>(info.getVlTime()->clone());
80  result.setVlTime(t);
81  }
82 
83  //Result time
84  if(info.hasRsTimeProp())
85  {
87  result.setRsTimePropInfo(prop);
88  }
89  if(info.hasRsTime())
90  {
91  te::dt::DateTimeInstant* t = dynamic_cast<te::dt::DateTimeInstant*>(info.getRsTime()->clone());
92  result.setRsTime(t);
93  }
94 
95  //observed properties
96  result.setObsPropInfo(info.getObsPropIdxs());
97  result.setObsPropInfo(info.getObsPropNames());
98 
99  //geometry
100  if(info.hasGeomProp())
101  {
103  result.setGeomPropInfo(prop);
104  }
105  if(info.hasGeometry())
106  {
107  te::gm::Geometry* g = dynamic_cast<te::gm::Geometry*>(info.getGeometry()->clone());
108  result.setGeometry(g);
109  }
110 
111  //id properties
112  result.setIdPropInfo(info.getIdPropIdx());
113  result.setIdPropInfo(info.getIdPropName());
114  result.setId(info.getObsId());
115 
116  //spatial extent
117  if(info.hasSpatialExtent())
118  {
119  te::gm::Geometry* g = dynamic_cast<te::gm::Geometry*>(info.getSpatialExtent()->clone());
120  result.setSpatialExtent(g);
121  }
122 
123  //temporal extent
124  if(info.hasTemporalExtent())
125  {
127  result.setTemporalExtent(t);
128  }
129 
130  return result;
131 }
132 
Geometric property.
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.
const te::dt::DateTimePeriod * getVlTime() const
It returns the valid time.
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.
TESTEXPORT ObservationDataSetType GetType(const ObservationDataSetInfo &info)
An auxiliary function that transform ObservationDataSetInfo into ObservationDataSetType.
Definition: Utils.cpp:39
This file contains a class called ObservationDataSetType.
const std::vector< std::string > & getObsPropNames() const
It returns the names of the DataSet properties that are observed over time.
const te::dt::DateTimeProperty * getVlEndTimePropInfo() const
It returns the DataSet property information that contains the valid end time.
const te::dt::DateTimeProperty * getBeginTimePropInfo() const
It returns the DataSet property information that contains the phenomenon beginning time...
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
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.
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.
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.
A class that contains complemental DataSetType information about a DataSet that holds observations...
std::string getDataSetName() const
It returns the DataSet name.
std::string getIdPropName() const
It returns the name of the property that contains identifiers that groups observations.
virtual AbstractData * clone() const =0
It returns a clone of this object.
An abstract class to represent an instant of date and time.