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
52  class AbstractPointCoverageInterp;
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  */
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  */
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  */
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  */
177  //@}
178 
179  /*! \name Coverage inherited methods */
180  //@{
181  Coverage* clone() const;
182 
184 
186 
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::unique_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::unique_ptr<te::rst::Raster> getRaster() const;
220 
221  std::unique_ptr<te::rst::Raster> getRaster(unsigned int p) const;
222  //@}
223 
224  /*! \brief Virtual destructor. */
225  virtual ~PointCoverage();
226 
227  protected:
228 
229  std::unique_ptr<te::gm::Geometry> m_sextent;
230  std::unique_ptr<te::dt::DateTime> m_textent;
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 
te::st::PointCoverage::~PointCoverage
virtual ~PointCoverage()
Virtual destructor.
te::st::PointCoverage::m_pnames
std::vector< std::string > m_pnames
The types of the point coverage properties.
Definition: PointCoverage.h:236
te::st::PointCoverage::getDouble
void getDouble(const te::gm::Point &l, std::vector< double > &result) const
It returns the values as doubles associated to a given location.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::st::PointCoverage::getValue
void getValue(const te::gm::Polygon &l, boost::ptr_vector< te::dt::AbstractData > &result) const
It returns values associated to the locations inside a given polygon.
te::st::PointCoverage::getInt
void getInt(const te::gm::Point &l, std::vector< int > &result) const
It returns the values as integers associated to a given location.
te::st::PointCoverage::getPropertyTypes
const std::vector< int > & getPropertyTypes() const
It returns the types of the coverage properties.
te::st::PointCoverage::begin
PointCoverageIterator begin() const
It returns an iterator that points to the first observation of the point coverage.
te::st::PointCoverage::getInt
int getInt(const te::gm::Point &l, unsigned int p=0) const
It returns the value as integer of the p-th property associated to a given location.
te::st::PointCoverage::add
void add(const te::gm::Point &l, te::dt::AbstractData *value)
It adds an observtion to the PointCoverage.
te::st::PointCoverage::getType
CoverageType getType() const
It returns the coverage type.
te::st::PointCoverageObservation
boost::shared_ptr< PointCoverageItem > PointCoverageObservation
Definition: PointCoverageObservation.h:53
te::st::AbstractPointCoverageInterp
An abstract class for interpolation function or interpolator that estimate values at non-observaved l...
Definition: AbstractPointCoverageInterp.h:61
te::dt::DateTime
Definition: DateTime.h:56
te::st::PointCoverage::m_sextent
std::unique_ptr< te::gm::Geometry > m_sextent
Definition: PointCoverage.h:229
te::st::PointCoverage::getDouble
void getDouble(const te::gm::Polygon &l, std::vector< double > &result) const
It returns values as doubles associated to the locations inside a given polygon.
te::st::PointCoverage::PointCoverage
PointCoverage(AbstractPointCoverageInterp *interp, te::gm::Geometry *sextent, te::dt::DateTime *textent, int np, const std::vector< int > &ptypes, const std::vector< std::string > &pnames, int tp)
A constructor.
te::st::PointCoverage::add
void add(PointCoverageObservation &obs)
It adds an observtion to the PointCoverage.
te::st::PointCoverage::m_textent
std::unique_ptr< te::dt::DateTime > m_textent
Definition: PointCoverage.h:230
te::gm::Polygon
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
te::st::PointCoverage::PointCoverage
PointCoverage(AbstractPointCoverageInterp *interp, te::gm::Geometry *sextent, te::dt::DateTime *textent, int np, const std::vector< int > &ptypes, const std::vector< std::string > &pnames)
A constructor.
te::st::PointCvRTreeShrPtr
boost::shared_ptr< te::sam::rtree::Index< std::size_t > > PointCvRTreeShrPtr
Definition: PointCoverage.h:52
te::st::PointCoverage::end
PointCoverageIterator end() const
It returns an iterator that points to the end of the time series.
te::st::PointCoverageObservationSet
std::vector< PointCoverageObservation > PointCoverageObservationSet
Definition: PointCoverageObservation.h:54
te::st::PointCoverage::getSpatialExtent
te::gm::Geometry * getSpatialExtent() const
It returns the spatial extent of a coverage.
te::st::PointCoverageIterator
A class to traverse the observations of a PointCoverage.
Definition: PointCoverageIterator.h:69
te::st::PointCoverage::m_tp
int m_tp
The names of the point coverage properties.
Definition: PointCoverage.h:237
te::st::PointCoverage::clone
Coverage * clone() const
It returns a clone of this coverage.
te::st::PointCoverage::m_ptypes
std::vector< int > m_ptypes
The number of properties of the point coverage.
Definition: PointCoverage.h:235
Coverage.h
This file contains an abstract class to represent a coverage.
te::st::PointCoverage::getValue
void getValue(const te::gm::Polygon &l, unsigned int p, boost::ptr_vector< te::dt::AbstractData > &result) const
It returns the values of the p-th property associated to the locations inside a given polygon.
PointCoverageObservation.h
This file contains a class to represent an observation of a PointCoverage.
te::st::PointCoverage::getInt
void getInt(const te::gm::Polygon &l, std::vector< int > &result) const
It returns values as integers associated to the locations inside a given polygon.
te::st::PointCoverage::getValue
void getValue(const te::gm::Point &l, boost::ptr_vector< te::dt::AbstractData > &result) const
It returns the values associated to a given location.
te::st::PointCoverage::m_rTree
PointCvRTreeShrPtr m_rTree
Definition: PointCoverage.h:233
TESTEXPORT
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88
te::st::PointCoverage::getInt
void getInt(const te::gm::Polygon &l, unsigned int p, std::vector< int > &result) const
It returns the values as integers of the p-th property associated to the locations inside a given pol...
te::st::PointCoverage::getValue
std::unique_ptr< te::dt::AbstractData > getValue(const te::gm::Point &l, unsigned int p=0) const
It returns the value of the p-th property associated to a given location.
te::st::CoverageType
CoverageType
An enum for the types of coverage.
Definition: Enums.h:44
te::st::PointCoverage::getDouble
double getDouble(const te::gm::Point &l, unsigned int p=0) const
It returns the value as double of the p-th property associated to a given location.
te::dt::AbstractData
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
te::st::PointCoverage::m_interpolator
AbstractPointCoverageInterp * m_interpolator
Definition: PointCoverage.h:232
PointCoverageIterator.h
This file contains an iterator that is able to traverse all observations of a point coverage.
te::st::PointCoverage::m_np
unsigned int m_np
Definition: PointCoverage.h:234
te::st::PointCoverage
A concrete class to represent a point coverage.
Definition: PointCoverage.h:71
te::st::PointCoverage::getPropertyNames
const std::vector< std::string > & getPropertyNames() const
It returns the names of the coverage properties.
te::st::PointCoverage::getNumberOfProperties
unsigned int getNumberOfProperties() const
It returns the number of properties associated to the coverage.
te::st::Coverage
An abstract class to represent a coverage.
Definition: Coverage.h:64
te::st::PointCoverage::PointCoverage
PointCoverage()
A constructor.
te::st::PointCoverage::add
void add(const te::gm::Point &l, boost::ptr_vector< te::dt::AbstractData > &value)
It adds an observtion to the PointCoverage.
te::st::PointCoverage::getTime
te::dt::DateTime * getTime() const
It returns the time associated to the coverage.
te::st::PointCoverage::getRaster
std::unique_ptr< te::rst::Raster > getRaster() const
It returns a raster associated to the coverage.
te::st::PointCoverage::getDouble
void getDouble(const te::gm::Polygon &l, unsigned int p, std::vector< double > &result) const
It returns the values as doubles of the p-th property associated to the locations inside a given poly...
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::st::PointCoverage::m_observations
PointCoverageObservationSet m_observations
Definition: PointCoverage.h:231
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51
te::st::PointCoverage::getRaster
std::unique_ptr< te::rst::Raster > getRaster(unsigned int p) const
It returns a raster associated to the coverage of the i-th property.