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