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 
63  /*!
64  \brief It sets the Datasource that is being used to save TIN.
65  */
66  void setOutput(std::map<std::string, std::string> &dsinfo);
67 
68 
69  /*!
70  \brief It sets the parameters that is being used to save TIN.
71  \param resx, resy resolution X and Y.
72  \param gt interpolator
73  */
74  void setParams( const std::string &attr, double resx, double resy, Interpolator gt, double rad, int pow);
75 
76  /*! Function used to set the Spatial Reference System ID */
77  void setSRID(int srid);
78 
79  /*! Function used to set the envelope parameter */
80  void setEnvelope(te::gm::Envelope &env);
81 
82  std::auto_ptr<te::rst::Raster> Initialize(bool spline, unsigned int &nro_neighb, double &rx1, double &ry2, unsigned int &outputWidth, unsigned int &outputHeight);
83 
84  /*!
85  \brief Interpolates the z value of the pg point3d.
86  \ This method interpolates the z value of the pg point3d using the
87  \ information on the current partition, the dist double vector and
88  \param pg: points to an point3d whose z value must be calculated
89  \param points: vector that contains points from point pg to the partition points
90  \param distq: points to a double vector that contains distance values from point pg to the partition points.
91  */
92  void Interpolation(te::gm::PointZ& pg, std::vector<te::gm::PointZ>& points, std::vector<double>& distq);
93 
94  /*!
95  \brief Interpolates the z value of the pg point3d using an weighted average by quadrant.
96  \ Implements the interpolator that uses the average, weighted by the inverse
97  \ square distance, of the nearest neighbours by quadrant.*/
98  double Interpwq(te::gm::PointZ& pg, std::vector<te::gm::PointZ>& points, std::vector<double>& distq);
99 
100  /*!
101  \brief Interpolates the z value of the pg point3d using an weighted average by quadrant and by z values.
102  \ Implements the interpolator tha uses the average, weighted by the inverse
103  \ square distance, of the nearest neighbours by z values and by quadrant.
104  \ This method accepts no repeated z values in the interpolation.*/
105  double Interpwqz(te::gm::PointZ& pg, std::vector<te::gm::PointZ>& points, std::vector<double>& distq);
106 
107  /*!
108  \brief Method to calculate a grid from a vector of samples using a Spline (GRASS) fitting algorithm
109  \return true when the z grid value is succesfully evaluated
110  \return false when a z grid value could not be evaluated or some error is encountered
111  */
112  bool GenerateGridSplineGrass();
113 
114  /*!
115  \brief Method to calculate a grid from a vector of samples using a Spline (Mitasova) fitting algorithm
116  \return true when the z grid value is succesfully evaluated
117  \return false when a z grid value could not be evaluated or some error is encountered
118  */
119  bool GenerateGridSplineMitasova();
120 
121  protected:
122 
123  int m_srid; //!< Attribute with spatial reference information
124  te::gm::Envelope m_env; //!< Attribute used to restrict the area to generate the raster.
125 
127  std::string m_inDsetName; //!<
128  std::auto_ptr<te::da::DataSetType> m_inDsetType; //!<
129 
130  std::string m_attrZ; //!< Attribute used to calculate grid
131 
132  std::map<std::string, std::string> m_dsinfo; //!<
133 
134  double m_resx, m_resy; //!< grid resolution in X and Y
135  Interpolator m_inter; //!< selected interpolation method
136  double m_radius; //!< radius
137  int m_power; //!< power
138  int m_tension; //!< the tension spline factor considered in the spline fitting process
139  int m_smoothM; //!< smooth factor used
140 
142 
143  double m_tolerance; //!< tolerance used to simplify lines
144  double m_nodatavalue; //!< no data value
145 
147  std::vector<std::pair<te::gm::Coord2D, te::gm::PointZ> > m_dataset; //!<
148 
149  }; //class CalculateGrid
150 
151  } //mnt
152 } //te
153 
154 #endif
double m_nodatavalue
no data value
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
int m_smoothM
smooth factor used
#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:352
int m_srid
Attribute with spatial reference information.
te::da::DataSourcePtr m_inDsrc
Interpolator m_inter
selected interpolation method
std::string m_attrZ
Attribute used to calculate grid.
KD_ADAPTATIVE_TREE * m_adaptativeTree
Interpolator
Definition: Enums.h:54
A point with z-coordinate value.
Definition: PointZ.h:51
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.
double m_radius
radius
std::auto_ptr< te::da::DataSetType > m_inDsetType
te::gm::Envelope m_env
Attribute used to restrict the area to generate the raster.
std::vector< std::pair< te::gm::Coord2D, te::gm::PointZ > > m_dataset
int m_tension
the tension spline factor considered in the spline fitting process
std::map< std::string, std::string > m_dsinfo
te::rst::Raster * m_rst
A class that represents an Kd-tree node.
Definition: Node.h:206
double m_resy
grid resolution in X and Y
te::sam::kdtree::AdaptativeNode< te::gm::Coord2D, std::vector< te::gm::PointZ >, te::gm::PointZ > KD_ADAPTATIVE_NODE
Definition: CalculateGrid.h:25
General enumerations.
double m_tolerance
tolerance used to simplify lines