CalculateGrid.h
Go to the documentation of this file.
1 
2 /*!
3 \file terralib/mnt/core/CalculateGrid.h
4 
5 \brief This file contains a class to calculate retangular grid from Samples.
6 Adapted from SPRING
7 
8 */
9 
10 #ifndef __TERRALIB_MNT_INTERNAL_CALCULATEGRID_H
11 #define __TERRALIB_MNT_INTERNAL_CALCULATEGRID_H
12 
13 // Terralib Includes
14 #include "Config.h"
15 #include "Enums.h"
16 
17 #include "../../dataaccess/dataset/DataSet.h"
18 #include "../../dataaccess/dataset/DataSetType.h"
19 #include "../../dataaccess/datasource/DataSource.h"
20 
21 #include "../../raster/Raster.h"
22 #include "../../sam.h"
23 
24 
27 
28 //MITASOVA PARAMETERS
29 #define mitasovaMINPOINTS 50
30 #define mitasovaTENSION 40.
31 #define mitasovaSMOOTH 0.100000
32 
33 namespace te
34 {
35  namespace mnt
36  {
37 
39  {
40  public:
41  /*! \brief Default constructor. */
42  CalculateGrid();
43 
44  ~CalculateGrid();
45 
46  /*!
47  \brief Calculate GRID
48  \ return true or false.
49  */
50  bool run();
51 
52  /*!
53  \brief It sets the Datasource that is being used to generate TIN.
54  \param inDsrc The datasource being used.
55  \param inDsetName datasource name
56  \param inDsetType input DataSetType
57  \param type Input type: Sample or Isoline
58  */
59  void setInput(te::da::DataSourcePtr inDsrc,
60  std::string inDsetName,
61  std::auto_ptr<te::da::DataSetType> inDsetType,
62  InputType type);
63 
64  /*!
65  \brief It sets the Datasource that is being used to save TIN.
66  */
67  void setOutput(std::map<std::string, std::string> &dsinfo);
68 
69 
70  /*!
71  \brief It sets the parameters that is being used to save TIN.
72  \param resx, resy resolution X and Y.
73  \param gt interpolator
74  */
75  void setParams(const std::string &attriso, const std::string &attrpt, double resx, double resy, Interpolator gt, double rad, int pow);
76 
77  /*! Function used to set the Spatial Reference System ID */
78  void setSRID(int srid);
79 
80  /*! Function used to set the envelope parameter */
81  void setEnvelope(te::gm::Envelope &env);
82 
83  std::auto_ptr<te::rst::Raster> Initialize(bool spline, unsigned int &nro_neighb, double &rx1, double &ry2, unsigned int &outputWidth, unsigned int &outputHeight);
84 
85  /*!
86  \brief Interpolates the z value of the pg point3d.
87  \ This method interpolates the z value of the pg point3d using the
88  \ information on the current partition, the dist double vector and
89  \param pg: points to an point3d whose z value must be calculated
90  \param points: vector that contains points from point pg to the partition points
91  \param distq: points to a double vector that contains distance values from point pg to the partition points.
92  */
93  void Interpolation(te::gm::Point& pg, std::vector<te::gm::Point>& points, std::vector<double>& distq);
94 
95  /*!
96  \brief Interpolates the z value of the pg point3d using an weighted average by quadrant.
97  \ Implements the interpolator that uses the average, weighted by the inverse
98  \ square distance, of the nearest neighbours by quadrant.*/
99  double Interpwq(te::gm::Point& pg, std::vector<te::gm::Point>& points, std::vector<double>& distq);
100 
101  /*!
102  \brief Interpolates the z value of the pg point3d using an weighted average by quadrant and by z values.
103  \ Implements the interpolator tha uses the average, weighted by the inverse
104  \ square distance, of the nearest neighbours by z values and by quadrant.
105  \ This method accepts no repeated z values in the interpolation.*/
106  double Interpwqz(te::gm::Point& pg, std::vector<te::gm::Point>& points, std::vector<double>& distq);
107 
108  /*!
109  \brief Method to calculate a grid from a vector of samples using a Spline (GRASS) fitting algorithm
110  \return true when the z grid value is succesfully evaluated
111  \return false when a z grid value could not be evaluated or some error is encountered
112  */
113  bool GenerateGridSplineGrass();
114 
115  /*!
116  \brief Method to calculate a grid from a vector of samples using a Spline (Mitasova) fitting algorithm
117  \return true when the z grid value is succesfully evaluated
118  \return false when a z grid value could not be evaluated or some error is encountered
119  */
120  bool GenerateGridSplineMitasova();
121 
122  protected:
123 
124  int m_srid; //!< Attribute with spatial reference information
125  te::gm::Envelope m_env; //!< Attribute used to restrict the area to generate the raster.
126 
128  std::string m_inDsetName_sample;
129  std::auto_ptr<te::da::DataSetType> m_inDsetType_sample;
130 
132  std::string m_inDsetName_point;
133  std::auto_ptr<te::da::DataSetType> m_inDsetType_point;
134 
135  std::string m_atrZ_sample; //!< Attribute used to calculate grid
136  std::string m_atrZ_point; //!< Attribute used to calculate grid
137 
138  std::map<std::string, std::string> m_dsinfo; //!<
139 
140  double m_resx, m_resy; //!< grid resolution in X and Y
141  Interpolator m_inter; //!< selected interpolation method
142  double m_radius; //!< radius
143  int m_power; //!< power
144  int m_tension; //!< the tension spline factor considered in the spline fitting process
145  int m_smoothM; //!< smooth factor used
146 
148 
149  double m_tolerance; //!< tolerance used to simplify lines
150  double m_nodatavalue; //!< no data value
151 
153  std::vector<std::pair<te::gm::Coord2D, te::gm::Point> > m_dataset; //!<
154 
155  }; //class CalculateGrid
156 
157  } //mnt
158 } //te
159 
160 #endif
double m_nodatavalue
no data value
std::string m_inDsetName_point
InputType
Input types.
Definition: Enums.h:48
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1438
int m_smoothM
smooth factor used
te::sam::kdtree::AdaptativeNode< te::gm::Coord2D, std::vector< te::gm::Point >, te::gm::Point > KD_ADAPTATIVE_NODE
Definition: CalculateGrid.h:25
#define TEMNTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:41
A class that represents a two dimensional K-d Tree (2-d Tree) that store data-elements into the leafs...
Definition: Index.h:353
te::da::DataSourcePtr m_inDsrc_sample
std::string m_atrZ_sample
Attribute used to calculate grid.
std::string m_inDsetName_sample
std::string m_atrZ_point
Attribute used to calculate grid.
int m_srid
Attribute with spatial reference information.
Interpolator m_inter
selected interpolation method
KD_ADAPTATIVE_TREE * m_adaptativeTree
Interpolator
Definition: Enums.h:54
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
An abstract class for raster data strucutures.
Definition: Raster.h:71
te::sam::kdtree::AdaptativeIndex< KD_ADAPTATIVE_NODE > KD_ADAPTATIVE_TREE
Definition: CalculateGrid.h:26
URI C++ Library.
te::da::DataSourcePtr m_inDsrc_point
double m_radius
radius
te::gm::Envelope m_env
Attribute used to restrict the area to generate the raster.
int m_tension
the tension spline factor considered in the spline fitting process
std::map< std::string, std::string > m_dsinfo
std::vector< std::pair< te::gm::Coord2D, te::gm::Point > > m_dataset
te::rst::Raster * m_rst
std::auto_ptr< te::da::DataSetType > m_inDsetType_sample
A class that represents an Kd-tree node.
Definition: Node.h:206
double m_resy
grid resolution in X and Y
General enumerations.
double m_tolerance
tolerance used to simplify lines
std::auto_ptr< te::da::DataSetType > m_inDsetType_point