Loading...
Searching...
No Matches
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"
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
47namespace 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
This file contains an abstract class to represent a coverage.
This file contains an iterator that is able to traverse all observations of a point coverage.
This file contains a class to represent an observation of a PointCoverage.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
A point with x and y coordinate values.
Definition: Point.h:51
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
An abstract class for interpolation function or interpolator that estimate values at non-observaved l...
An abstract class to represent a coverage.
Definition: Coverage.h:64
A class to traverse the observations of a PointCoverage.
A concrete class to represent a point coverage.
Definition: PointCoverage.h:71
void add(PointCoverageObservation &obs)
It adds an observtion to the PointCoverage.
std::unique_ptr< te::rst::Raster > getRaster(unsigned int p) const
It returns a raster associated to the coverage of the i-th property.
std::unique_ptr< te::gm::Geometry > m_sextent
PointCoverageObservationSet m_observations
te::dt::DateTime * getTime() const
It returns the time associated to the coverage.
std::vector< int > m_ptypes
The number of properties of the point coverage.
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.
void add(const te::gm::Point &l, te::dt::AbstractData *value)
It adds an observtion to the PointCoverage.
std::unique_ptr< te::dt::DateTime > m_textent
AbstractPointCoverageInterp * m_interpolator
unsigned int getNumberOfProperties() const
It returns the number of properties associated to the coverage.
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.
void getInt(const te::gm::Point &l, std::vector< int > &result) const
It returns the values as integers associated to a given location.
PointCoverage()
A constructor.
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...
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.
std::unique_ptr< te::rst::Raster > getRaster() const
It returns a raster associated to the coverage.
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.
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.
PointCoverageIterator begin() const
It returns an iterator that points to the first observation of the point coverage.
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.
PointCvRTreeShrPtr m_rTree
void getDouble(const te::gm::Point &l, std::vector< double > &result) const
It returns the values as doubles associated to a given location.
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::gm::Geometry * getSpatialExtent() const
It returns the spatial extent of a coverage.
virtual ~PointCoverage()
Virtual destructor.
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.
int m_tp
The names of the point coverage properties.
PointCoverageIterator end() const
It returns an iterator that points to the end of the time series.
void getValue(const te::gm::Point &l, boost::ptr_vector< te::dt::AbstractData > &result) const
It returns the values associated to a given location.
void add(const te::gm::Point &l, boost::ptr_vector< te::dt::AbstractData > &value)
It adds an observtion to the 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.
const std::vector< int > & getPropertyTypes() const
It returns the types of the coverage properties.
std::vector< std::string > m_pnames
The types of the point coverage properties.
Coverage * clone() const
It returns a clone of this coverage.
const std::vector< std::string > & getPropertyNames() const
It returns the names of the coverage properties.
CoverageType getType() const
It returns the coverage type.
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...
CoverageType
An enum for the types of coverage.
Definition: Enums.h:44
boost::shared_ptr< te::sam::rtree::Index< std::size_t > > PointCvRTreeShrPtr
Definition: PointCoverage.h:55
boost::shared_ptr< PointCoverageItem > PointCoverageObservation
std::vector< PointCoverageObservation > PointCoverageObservationSet
TerraLib.
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88