All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointCoverage.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 PointCoverage.h
22 
23  \brief This file contains a concrete class to represent a point coverage.
24 */
25 
26 #ifndef __TERRALIB_ST_INTERNAL_POINTCOVERAGE_H
27 #define __TERRALIB_ST_INTERNAL_POINTCOVERAGE_H
28 
29 //TerraLib
30 #include "../../../sam/rtree/Index.h"
31 
32 //ST
33 #include "../../Config.h"
34 #include "Coverage.h"
36 #include "PointCoverageIterator.h"
37 
38 //STL
39 #include <vector>
40 #include <map>
41 
42 // Boost
43 #include <boost/shared_ptr.hpp>
44 #include <boost/ptr_container/ptr_vector.hpp>
45 
46 namespace te
47 {
48  namespace st
49  {
50  // Forward declarations
52 
53  //Typedef
54  typedef boost::shared_ptr<te::sam::rtree::Index<std::size_t> > PointCvRTreeShrPtr;
55 
56  /*!
57  \class PointCoverage
58 
59  \brief A concrete class to represent a point coverage.
60 
61  A point coverage is a coverage composed of a set of observations where
62  each one contains a location (point) and a set properties
63  associated to it.
64 
65  \ingroup st
66 
67  \sa Coverage Point Property
68  */
70  {
71  public:
72 
73  /*!
74  \brief A constructor.
75 
76  It constructs an empty point coverage. The user does not indicate the interpolator
77  associated to it. Internally, it uses a default interpolator
78  that is IDWInterpolator.
79  */
80  PointCoverage();
81 
82  /*!
83  \brief A constructor.
84 
85  It constructs an empty point coverage.
86 
87  \param interp The interpolator associated to the PointCoverage
88  \param sextent The spatial extent
89  \param textent The time associated to the coverage.
90  \param np The number of properties of the point coverage.
91  \param ptypes The types of the properties
92  \param pnames The names of the properties
93 
94  \note It will take the ownership of the given pointers.
95  */
97  te::dt::DateTime* textent, int np, const std::vector<int>& ptypes,
98  const std::vector<std::string>& pnames);
99 
100  /*!
101  \brief A constructor.
102 
103  It constructs an empty point coverage.
104 
105  \param interp The interpolator associated to the PointCoverage
106  \param sextent The spatial extent
107  \param textent The time associated to the coverage.
108  \param np The number of properties of the point coverage.
109  \param ptypes The types of the properties
110  \param pnames The names of the properties
111  \param tp The index of the property that contains time associated to each observation
112 
113  \note It will take the ownership of the given pointers.
114  */
116  te::dt::DateTime* textent, int np, const std::vector<int>& ptypes,
117  const std::vector<std::string>& pnames, int tp);
118 
119  /*! \name PointCoverage Iterator
120 
121  An example of use:
122 
123  PointCoverageIterator it = cv.begin();
124  while(it!=cv.end())
125  {
126  Point& l = it.getLocation();
127  double v = it.getDouble(i); //or getValue() or getInt()...
128  ++it;
129  }
130  */
131  //@{
132  /*!
133  \brief It returns an iterator that points to the first observation of the point coverage
134 
135  \return The point coverage iterator.
136  */
137  PointCoverageIterator begin() const;
138 
139  /*!
140  \brief It returns an iterator that points to the end of the time series.
141 
142  \return The point coverage iterator.
143  */
144  PointCoverageIterator end() const;
145  //@}
146 
147  /*!
148  \brief It adds an observtion to the PointCoverage.
149 
150  \param l The given location.
151  \param value The value associated to the given location.
152 
153  \note It will take the ownwership of the given pointers.
154  \note The caller can use this methos when the number of properties is equal to 1. Otherwise, it must use the other add method.
155  */
156  void add(const te::gm::Point& l, te::dt::AbstractData* value);
157 
158  /*!
159  \brief It adds an observtion to the PointCoverage.
160 
161  \param l The given location.
162  \param value A vector of values associated to the given location.
163 
164  \note It will take the ownwership of the given pointers.
165  */
166  void add(const te::gm::Point& l, boost::ptr_vector<te::dt::AbstractData>& value);
167 
168  /*!
169  \brief It adds an observtion to the PointCoverage.
170 
171  \param obs The observation.
172 
173  \note It will share the same observtion.
174  */
175  void add(PointCoverageObservation& obs);
176  //@}
177 
178  /*! \name Coverage inherited methods */
179  //@{
180  Coverage* clone() const;
181 
182  CoverageType getType() const;
183 
184  te::gm::Geometry* getSpatialExtent() const;
185 
186  te::dt::DateTime* getTime() const;
187 
188  unsigned int getNumberOfProperties() const;
189 
190  const std::vector<int>& getPropertyTypes() const;
191 
192  const std::vector<std::string>& getPropertyNames() const;
193 
194  void getValue(const te::gm::Point& l, boost::ptr_vector<te::dt::AbstractData>& result) const;
195 
196  std::auto_ptr<te::dt::AbstractData> getValue(const te::gm::Point& l, unsigned int p=0) const;
197 
198  void getValue(const te::gm::Polygon& l, unsigned int p, boost::ptr_vector<te::dt::AbstractData>& result) const;
199 
200  void getValue(const te::gm::Polygon& l, boost::ptr_vector<te::dt::AbstractData>& result) const;
201 
202  void getInt(const te::gm::Point& l, std::vector<int>& result) const;
203 
204  int getInt(const te::gm::Point& l, unsigned int p=0) const;
205 
206  void getInt(const te::gm::Polygon& l, unsigned int p, std::vector<int>& result) const;
207 
208  void getInt(const te::gm::Polygon& l, std::vector<int>& result) const;
209 
210  void getDouble(const te::gm::Point& l, std::vector<double>& result) const;
211 
212  double getDouble(const te::gm::Point& l, unsigned int p=0) const;
213 
214  void getDouble(const te::gm::Polygon& l, unsigned int p, std::vector<double>& result) const;
215 
216  void getDouble(const te::gm::Polygon& l, std::vector<double>& result) const;
217 
218  std::auto_ptr<te::rst::Raster> getRaster() const;
219 
220  std::auto_ptr<te::rst::Raster> getRaster(unsigned int p) const;
221  //@}
222 
223  /*! \brief Virtual destructor. */
224  virtual ~PointCoverage();
225 
226  protected:
227 
228  std::auto_ptr<te::gm::Geometry> m_sextent;
229  std::auto_ptr<te::dt::DateTime> m_textent;
233  unsigned int m_np; //! The number of properties of the point coverage
234  std::vector<int> m_ptypes; //! The types of the point coverage properties
235  std::vector<std::string> m_pnames; //! The names of the point coverage properties
236  int m_tp; //! The index of the observed property that has the time of each observation.
237  };
238  } // end namespace st
239 } // end namespace te
240 
241 #endif // __TERRALIB_ST_INTERNAL_POINTCOVERAGE_H
242 
An abstract class for interpolation function or interpolator that estimate values at non-observaved l...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
This file contains an abstract class to represent a coverage.
A concrete class to represent a point coverage.
Definition: PointCoverage.h:69
This file contains a class to represent an observation of a PointCoverage.
std::auto_ptr< te::dt::DateTime > m_textent
PointCoverageObservationSet m_observations
int m_tp
The names of the point coverage properties.
An abstract class to represent a coverage.
Definition: Coverage.h:63
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:136
boost::shared_ptr< te::sam::rtree::Index< std::size_t > > PointCvRTreeShrPtr
Definition: PointCoverage.h:51
std::vector< PointCoverageObservation > PointCoverageObservationSet
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
std::vector< int > m_ptypes
The number of properties of the point coverage.
std::auto_ptr< te::gm::Geometry > m_sextent
A point with x and y coordinate values.
Definition: Point.h:50
A class to traverse the observations of a PointCoverage.
PointCvRTreeShrPtr m_rTree
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
std::vector< std::string > m_pnames
The types of the point coverage properties.
CoverageType
An enum for the types of coverage.
Definition: Enums.h:43
This file contains an iterator that is able to traverse all observations of a point coverage...
boost::shared_ptr< PointCoverageItem > PointCoverageObservation
double getDouble(const std::string &value, std::vector< std::string > &sVector)
Definition: Utils.cpp:54
AbstractPointCoverageInterp * m_interpolator